• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_crtc.h"
20 #include "display_common.h"
21 #include "drm_device.h"
22 
23 namespace OHOS {
24 namespace HDI {
25 namespace DISPLAY {
DrmCrtc(drmModeCrtcPtr c,uint32_t pipe)26 DrmCrtc::DrmCrtc(drmModeCrtcPtr c, uint32_t pipe) : mId(c->crtc_id), mPipe(pipe) {}
27 
Init(DrmDevice & drmDevice)28 int32_t DrmCrtc::Init(DrmDevice &drmDevice)
29 {
30     DISPLAY_LOGD();
31     int32_t ret;
32     DrmProperty prop;
33     ret = drmDevice.GetCrtcProperty(*this, PROP_MODEID, prop);
34     mModePropId = prop.propId;
35     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("can not get mode prop id"));
36 
37     ret = drmDevice.GetCrtcProperty(*this, PROP_OUTFENCE, prop);
38     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get out fence prop id"));
39     mOutFencePropId = prop.propId;
40 
41     ret = drmDevice.GetCrtcProperty(*this, PROP_ACTIVE, prop);
42     DISPLAY_CHK_RETURN((ret != DISPLAY_SUCCESS), DISPLAY_FAILURE, DISPLAY_LOGE("cat not get out fence prop id"));
43     mActivePropId = prop.propId;
44 
45     return DISPLAY_SUCCESS;
46 }
47 
BindToDisplay(uint32_t id)48 int32_t DrmCrtc::BindToDisplay(uint32_t id)
49 {
50     DISPLAY_CHK_RETURN((mDisplayId != INVALIDE_DISPLAY_ID), DISPLAY_FAILURE,
51         DISPLAY_LOGE("the crtc has bind to %{public}d", mDisplayId));
52     mDisplayId = id;
53     return DISPLAY_SUCCESS;
54 }
55 
UnBindDisplay(uint32_t id)56 void DrmCrtc::UnBindDisplay(uint32_t id)
57 {
58     DISPLAY_LOGD();
59     if (mDisplayId == id) {
60         mDisplayId = INVALIDE_DISPLAY_ID;
61     } else {
62         DISPLAY_LOGE("can not unbind");
63     }
64 }
65 
CanBind()66 bool DrmCrtc::CanBind()
67 {
68     return (mDisplayId == INVALIDE_DISPLAY_ID);
69 }
70 
SetActivieMode(int32_t id)71 int32_t DrmCrtc::SetActivieMode(int32_t id)
72 {
73     DISPLAY_LOGD("set activie modeid to %{public}d", id);
74     DISPLAY_CHK_RETURN((id > 0), DISPLAY_PARAM_ERR, DISPLAY_LOGE("id %{public}d is invalid ", id));
75     if (mActiveModeId != id) {
76         mNeedModeSet = true;
77     }
78     mActiveModeId = id;
79     return DISPLAY_SUCCESS;
80 }
81 } // namespace OHOS
82 } // namespace HDI
83 } // namespace DISPLAY
84