• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "drm_plane.h"
17 #include "drm_device.h"
18 
19 namespace OHOS {
20 namespace HDI {
21 namespace DISPLAY {
DrmPlane(drmModePlane & p)22 DrmPlane::DrmPlane(drmModePlane &p)
23     : mId(p.plane_id), mPossibleCrtcs(p.possible_crtcs), mFormats(p.formats, p.formats + p.count_formats)
24 {}
25 
~DrmPlane()26 DrmPlane::~DrmPlane()
27 {
28     DISPLAY_LOGD();
29 }
30 
Init(DrmDevice & drmDevice)31 int32_t DrmPlane::Init(DrmDevice &drmDevice)
32 {
33     DISPLAY_LOGD();
34     int32_t ret;
35     DrmProperty prop;
36     ret = drmDevice.GetPlaneProperty(*this, PROP_FBID, prop);
37     mPropFbId = prop.propId;
38     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not get plane fb id"));
39     ret = drmDevice.GetPlaneProperty(*this, PROP_IN_FENCE_FD, prop);
40     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get plane in fence prop id"));
41     mPropFenceInId = prop.propId;
42     ret = drmDevice.GetPlaneProperty(*this, PROP_CRTC_ID, prop);
43     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get pane crtc prop id"));
44     mPropCrtcId = prop.propId;
45     ret = drmDevice.GetPlaneProperty(*this, PROP_SRC_W, prop);
46     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get plane srcw prop id"));
47     mPropSrcWId = prop.propId;
48     ret = drmDevice.GetPlaneProperty(*this, PROP_SRC_H, prop);
49     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get plane srch prop id"));
50     mPropSrcHId = prop.propId;
51     ret = drmDevice.GetPlaneProperty(*this, PROP_TYPE, prop);
52     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get pane crtc prop id"));
53     switch (prop.value) {
54         case DRM_PLANE_TYPE_OVERLAY:
55         case DRM_PLANE_TYPE_PRIMARY:
56         case DRM_PLANE_TYPE_CURSOR:
57             mType = static_cast<uint32_t>(prop.value);
58             break;
59         default:
60             DISPLAY_LOGE("unknown type value %{public}" PRIu64 "", prop.value);
61             return DISPLAY_FAILURE;
62     }
63     return DISPLAY_SUCCESS;
64 }
65 } // namespace OHOS
66 } // namespace HDI
67 } // namespace DISPLAY
68