• 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 #ifndef DRM_CRTC_H
17 #define DRM_CRTC_H
18 #include <string>
19 #include <memory>
20 #include <xf86drm.h>
21 #include <xf86drmMode.h>
22 #include "hdi_device_common.h"
23 #include "hdi_display.h"
24 
25 namespace OHOS {
26 namespace HDI {
27 namespace DISPLAY {
28 const std::string PROP_ACTIVE = "ACTIVE";
29 const std::string PROP_MODEID = "MODE_ID";
30 const std::string PROP_OUTFENCE = "OUT_FENCE_PTR";
31 
32 class DrmDevice;
33 
34 class DrmCrtc {
35 public:
36     DrmCrtc(drmModeCrtcPtr c, uint32_t pipe);
~DrmCrtc()37     virtual ~DrmCrtc() {}
38     int32_t BindToDisplay(uint32_t id);
39     void UnBindDisplay(uint32_t id);
40     bool CanBind() const;
GetId()41     uint32_t GetId() const
42     {
43         return mId;
44     }
GetModePropId()45     uint32_t GetModePropId() const
46     {
47         return mModePropId;
48     }
GetOutFencePropId()49     uint32_t GetOutFencePropId() const
50     {
51         return mOutFencePropId;
52     }
GetActivePropId()53     uint32_t GetActivePropId() const
54     {
55         return mActivePropId;
56     }
GetPipe()57     uint32_t GetPipe() const
58     {
59         return mPipe;
60     }
61     int32_t Init(DrmDevice &drmDevice);
62     int32_t SetActivieMode(int32_t id);
GetActiveModeId()63     int32_t GetActiveModeId() const
64     {
65         return mActiveModeId;
66     }
NeedModeSet()67     bool NeedModeSet() const
68     {
69         return mNeedModeSet;
70     }
71 
72 private:
73     uint32_t mId = 0;
74     uint32_t mModePropId = 0;
75     uint32_t mOutFencePropId = 0;
76     uint32_t mActivePropId = 0;
77     uint32_t mDisplayId = INVALIDE_DISPLAY_ID;
78     uint32_t mPipe = 0;
79     int32_t mActiveModeId = INVALID_MODE_ID;
80     bool mNeedModeSet = false;
81 };
82 } // namespace OHOS
83 } // namespace HDI
84 } // namespace DISPLAY
85 
86 #endif // DRM_CRTC_H