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