1 /* 2 * Copyright (C) 2021–2022 Beijing OSWare Technology Co., Ltd 3 * This file contains confidential and proprietary information of 4 * OSWare Technology Co., Ltd 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef DRM_DISPLAY_H 20 #define DRM_DISPLAY_H 21 #include <unordered_map> 22 #include <memory> 23 #include "drm_connector.h" 24 #include "drm_crtc.h" 25 #include "drm_device.h" 26 #include "drm_plane.h" 27 #include "hdi_composer.h" 28 #include "hdi_drm_composition.h" 29 30 namespace OHOS { 31 namespace HDI { 32 namespace DISPLAY { 33 class DrmDisplay : public HdiDisplay { 34 public: 35 DrmDisplay(std::shared_ptr<DrmConnector> &connector, std::shared_ptr<DrmCrtc> &crtc, 36 std::shared_ptr<DrmDevice> &drmDevice); 37 38 virtual ~DrmDisplay() override; 39 40 int32_t Init() override; 41 int32_t GetDisplayCapability(DisplayCapability *info) override; 42 int32_t GetDisplaySupportedModes(uint32_t *num, DisplayModeInfo *modes) override; 43 int32_t GetDisplayMode(uint32_t *modeId) override; 44 int32_t SetDisplayMode(uint32_t modeId) override; 45 int32_t GetDisplayPowerStatus(DispPowerStatus *status) override; 46 int32_t SetDisplayPowerStatus(DispPowerStatus status) override; 47 int32_t GetDisplayBacklight(uint32_t *value) override; 48 int32_t SetDisplayBacklight(uint32_t value) override; 49 int32_t ChosePreferenceMode(); 50 virtual int32_t RegDisplayVBlankCallback(VBlankCallback cb, void *data) override; 51 virtual int32_t WaitForVBlank(uint64_t *ns) override; 52 virtual bool IsConnected() override; 53 virtual int32_t SetDisplayVsyncEnabled(bool enabled) override; 54 HdiDrmComposition *GetDrmComposition(); 55 56 protected: 57 std::unique_ptr<HdiLayer> CreateHdiLayer(LayerType type) override; 58 59 private: 60 int32_t PushFirstFrame(); 61 int32_t ConvertToHdiPowerState(uint32_t drmPowerState, DispPowerStatus &hdiPowerState); 62 int32_t ConvertToDrmPowerState(DispPowerStatus hdiPowerState, uint32_t &drmPowerState); 63 std::shared_ptr<DrmDevice> mDrmDevice; 64 std::shared_ptr<DrmConnector> mConnector; 65 std::shared_ptr<DrmCrtc> mCrtc; 66 }; 67 } // namespace OHOS 68 } // namespace HDI 69 } // namespace DISPLAY 70 71 #endif // HDI_DISPLAY_H