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_PLANE_H 17 #define DRM_PLANE_H 18 #include <cinttypes> 19 #include <string> 20 #include <vector> 21 #include <xf86drm.h> 22 #include <xf86drmMode.h> 23 24 namespace OHOS { 25 namespace HDI { 26 namespace DISPLAY { 27 const std::string PROP_FBID = "FB_ID"; 28 const std::string PROP_IN_FENCE_FD = "IN_FENCE_FD"; 29 const std::string PROP_CRTC_ID = "CRTC_ID"; 30 const std::string PROP_TYPE = "type"; 31 class DrmDevice; 32 33 class DrmPlane { 34 public: 35 explicit DrmPlane(drmModePlane &p); 36 virtual ~DrmPlane(); 37 int32_t Init(DrmDevice &drmDevice); GetId()38 uint32_t GetId() const 39 { 40 return mId; 41 } GetPropFbId()42 uint32_t GetPropFbId() const 43 { 44 return mPropFbId; 45 } GetPropFenceInId()46 uint32_t GetPropFenceInId() const 47 { 48 return mPropFenceInId; 49 } GetPropCrtcId()50 uint32_t GetPropCrtcId() const 51 { 52 return mPropCrtcId; 53 } GetPossibleCrtcs()54 uint32_t GetPossibleCrtcs() const 55 { 56 return mPossibleCrtcs; 57 } GetType()58 uint32_t GetType() const 59 { 60 return mType; 61 } BindToPipe(uint32_t pipe)62 void BindToPipe(uint32_t pipe) 63 { 64 mPipe = pipe; 65 } UnBindPipe()66 void UnBindPipe() 67 { 68 mPipe = 0; 69 } IsIdle()70 bool IsIdle() const 71 { 72 return (mPipe == 0); 73 } 74 75 private: 76 uint32_t mId = 0; 77 uint32_t mPossibleCrtcs = 0; 78 uint32_t mPropFbId = 0; 79 uint32_t mPropFenceInId = 0; 80 uint32_t mPropCrtcId = 0; 81 uint32_t mPipe = 0; 82 uint32_t mType = 0; 83 std::vector<uint32_t> mFormats; 84 }; 85 } // namespace OHOS 86 } // namespace HDI 87 } // namespace DISPLAY 88 89 #endif // DRM_PLANE_H