1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef DRM_CRTC_H 17#define DRM_CRTC_H 18#include <string> 19#include <memory> 20#include <xf86drm.h> 21#include <xf86drmMode.h> 22#include "hdi_device_common.h" 23#include "hdi_display.h" 24 25namespace OHOS { 26namespace HDI { 27namespace DISPLAY { 28const std::string PROP_ACTIVE = "ACTIVE"; 29const std::string PROP_MODEID = "MODE_ID"; 30const std::string PROP_OUTFENCE = "OUT_FENCE_PTR"; 31 32class DrmDevice; 33 34class DrmCrtc { 35public: 36 DrmCrtc(drmModeCrtcPtr c, uint32_t pipe); 37 virtual ~DrmCrtc() {}; 38 int32_t BindToDisplay(uint32_t id); 39 void UnBindDisplay(uint32_t id); 40 bool CanBind(); 41 uint32_t GetId() const 42 { 43 return mId; 44 } 45 uint32_t GetModePropId() const 46 { 47 return mModePropId; 48 } 49 uint32_t GetOutFencePropId() const 50 { 51 return mOutFencePropId; 52 } 53 uint32_t GetActivePropId() const 54 { 55 return mActivePropId; 56 } 57 uint32_t GetPipe() const 58 { 59 return mPipe; 60 } 61 int32_t Init(DrmDevice &drmDevice); 62 int32_t SetActivieMode(int32_t id); 63 int32_t GetActiveModeId() const 64 { 65 return mActiveModeId; 66 } 67 bool NeedModeSet() 68 { 69 return mNeedModeSet; 70 } 71 void ClearModeSet() 72 { 73 mNeedModeSet = false; 74 } 75 uint32_t GetPlaneMask() 76 { 77 return mPlaneMask; 78 } 79private: 80 uint32_t mId = 0; 81 uint32_t mModePropId = 0; 82 uint32_t mOutFencePropId = 0; 83 uint32_t mActivePropId = 0; 84 uint32_t mDisplayId = INVALIDE_DISPLAY_ID; 85 uint32_t mPipe = 0; 86 int32_t mActiveModeId = INVALID_MODE_ID; 87 bool mNeedModeSet = false; 88 uint32_t mPlaneMask = 0; 89}; 90} // namespace OHOS 91} // namespace HDI 92} // namespace DISPLAY 93 94#endif // DRM_CRTC_H