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 const std::string PROP_SRC_W = "SRC_W"; 32 const std::string PROP_SRC_H = "SRC_H"; 33 34 class DrmDevice; 35 36 class DrmPlane { 37 public: 38 explicit DrmPlane(drmModePlane &p); 39 virtual ~DrmPlane(); 40 int32_t Init(DrmDevice &drmDevice); GetId()41 uint32_t GetId() const 42 { 43 return mId; 44 } GetPropFbId()45 uint32_t GetPropFbId() const 46 { 47 return mPropFbId; 48 } GetPropFenceInId()49 uint32_t GetPropFenceInId() const 50 { 51 return mPropFenceInId; 52 } GetPropCrtcId()53 uint32_t GetPropCrtcId() const 54 { 55 return mPropCrtcId; 56 } GetPossibleCrtcs()57 uint32_t GetPossibleCrtcs() const 58 { 59 return mPossibleCrtcs; 60 } GetType()61 uint32_t GetType() const 62 { 63 return mType; 64 } GetPropSrcWId()65 uint32_t GetPropSrcWId() const 66 { 67 return mPropSrcWId; 68 } GetPropSrcHId()69 uint32_t GetPropSrcHId() const 70 { 71 return mPropSrcHId; 72 } BindToPipe(uint32_t pipe)73 void BindToPipe(uint32_t pipe) 74 { 75 mPipe = pipe; 76 } UnBindPipe()77 void UnBindPipe() 78 { 79 mPipe = 0; 80 } IsIdle()81 bool IsIdle() const 82 { 83 return (mPipe == 0); 84 } 85 86 private: 87 uint32_t mId = 0; 88 uint32_t mPossibleCrtcs = 0; 89 uint32_t mPropFbId = 0; 90 uint32_t mPropFenceInId = 0; 91 uint32_t mPropCrtcId = 0; 92 uint32_t mPipe = 0; 93 uint32_t mType = 0; 94 uint32_t mPropSrcWId = 0; 95 uint32_t mPropSrcHId = 0; 96 std::vector<uint32_t> mFormats; 97 }; 98 } // namespace OHOS 99 } // namespace HDI 100 } // namespace DISPLAY 101 102 #endif // DRM_PLANE_H 103