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_CRTC_H 20 #define DRM_CRTC_H 21 #include <string> 22 #include <memory> 23 #include <xf86drm.h> 24 #include <xf86drmMode.h> 25 #include "hdi_device_common.h" 26 #include "hdi_display.h" 27 28 namespace OHOS { 29 namespace HDI { 30 namespace DISPLAY { 31 const std::string PROP_ACTIVE = "ACTIVE"; 32 const std::string PROP_MODEID = "MODE_ID"; 33 const std::string PROP_OUTFENCE = "OUT_FENCE_PTR"; 34 35 class DrmDevice; 36 37 class DrmCrtc { 38 public: 39 DrmCrtc(drmModeCrtcPtr c, uint32_t pipe); ~DrmCrtc()40 virtual ~DrmCrtc() {} 41 int32_t BindToDisplay(uint32_t id); 42 void UnBindDisplay(uint32_t id); 43 bool CanBind(); GetId()44 uint32_t GetId() const 45 { 46 return mId; 47 } GetModePropId()48 uint32_t GetModePropId() const 49 { 50 return mModePropId; 51 } GetOutFencePropId()52 uint32_t GetOutFencePropId() const 53 { 54 return mOutFencePropId; 55 } GetActivePropId()56 uint32_t GetActivePropId() const 57 { 58 return mActivePropId; 59 } GetPipe()60 uint32_t GetPipe() const 61 { 62 return mPipe; 63 } 64 int32_t Init(DrmDevice &drmDevice); 65 int32_t SetActivieMode(int32_t id); GetActiveModeId()66 int32_t GetActiveModeId() const 67 { 68 return mActiveModeId; 69 } NeedModeSet()70 bool NeedModeSet() 71 { 72 return mNeedModeSet; 73 } 74 75 private: 76 uint32_t mId = 0; 77 uint32_t mModePropId = 0; 78 uint32_t mOutFencePropId = 0; 79 uint32_t mActivePropId = 0; 80 uint32_t mDisplayId = INVALIDE_DISPLAY_ID; 81 uint32_t mPipe = 0; 82 int32_t mActiveModeId = INVALID_MODE_ID; 83 bool mNeedModeSet = false; 84 }; 85 } // namespace OHOS 86 } // namespace HDI 87 } // namespace DISPLAY 88 89 #endif // DRM_CRTC_H