• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define LOG_TAG "hwc-drm-crtc"
18 
19 #include "drmcrtc.h"
20 #include "drmdevice.h"
21 
22 #include <stdint.h>
23 #include <xf86drmMode.h>
24 
25 #include <log/log.h>
26 
27 namespace android {
28 
DrmCrtc(DrmDevice * drm,drmModeCrtcPtr c,unsigned pipe)29 DrmCrtc::DrmCrtc(DrmDevice *drm, drmModeCrtcPtr c, unsigned pipe)
30     : drm_(drm), id_(c->crtc_id), pipe_(pipe), mode_(&c->mode) {
31         displays_.clear();
32 }
33 
Init()34 int DrmCrtc::Init() {
35   int ret = drm_->GetCrtcProperty(*this, "ACTIVE", &active_property_);
36   if (ret) {
37     ALOGE("Failed to get ACTIVE property");
38     return ret;
39   }
40 
41   ret = drm_->GetCrtcProperty(*this, "MODE_ID", &mode_property_);
42   if (ret) {
43     ALOGE("Failed to get MODE_ID property");
44     return ret;
45   }
46 
47   ret = drm_->GetCrtcProperty(*this, "OUT_FENCE_PTR", &out_fence_ptr_property_);
48   if (ret) {
49     ALOGE("Failed to get OUT_FENCE_PTR property");
50     return ret;
51   }
52 
53   if (drm_->GetCrtcProperty(*this, "partial_region", &partial_region_property_))
54     ALOGI("Failed to get &partial_region_property");
55 
56   if (drm_->GetCrtcProperty(*this, "cgc_lut", &cgc_lut_property_))
57     ALOGI("Failed to get cgc_lut property");
58   if (drm_->GetCrtcProperty(*this, "cgc_lut_fd", &cgc_lut_fd_property_))
59     ALOGI("Failed to get cgc_lut_fd property");
60   if (drm_->GetCrtcProperty(*this, "DEGAMMA_LUT", &degamma_lut_property_))
61     ALOGI("Failed to get &degamma_lut property");
62   if (drm_->GetCrtcProperty(*this, "DEGAMMA_LUT_SIZE", &degamma_lut_size_property_))
63     ALOGI("Failed to get &degamma_lut_size property");
64   if (drm_->GetCrtcProperty(*this, "GAMMA_LUT", &gamma_lut_property_))
65     ALOGI("Failed to get &gamma_lut property");
66   if (drm_->GetCrtcProperty(*this, "GAMMA_LUT_SIZE", &gamma_lut_size_property_))
67     ALOGI("Failed to get &gamma_lut_size property");
68   if (drm_->GetCrtcProperty(*this, "linear_matrix", &linear_matrix_property_))
69     ALOGI("Failed to get &linear_matrix property");
70   if (drm_->GetCrtcProperty(*this, "gamma_matrix", &gamma_matrix_property_))
71     ALOGI("Failed to get &gamma_matrix property");
72   if (drm_->GetCrtcProperty(*this, "force_bpc", &force_bpc_property_))
73     ALOGI("Failed to get &force_bpc_property_");
74   if (drm_->GetCrtcProperty(*this, "disp_dither", &disp_dither_property_))
75     ALOGI("Failed to get &disp_dither property");
76   if (drm_->GetCrtcProperty(*this, "cgc_dither", &cgc_dither_property_))
77     ALOGI("Failed to get &cgc_dither property");
78   if (drm_->GetCrtcProperty(*this, "adjusted_vblank", &adjusted_vblank_property_))
79     ALOGI("Failed to get &adjusted_vblank property");
80   if (drm_->GetCrtcProperty(*this, "ppc", &ppc_property_))
81     ALOGI("Failed to get &ppc property");
82   if (drm_->GetCrtcProperty(*this, "max_disp_freq", &max_disp_freq_property_))
83     ALOGI("Failed to get &max_disp_freq property");
84   if (drm_->GetCrtcProperty(*this, "dqe_enabled", &dqe_enabled_property_))
85     ALOGI("Failed to get &dqe_enabled_property property");
86   if (drm_->GetCrtcProperty(*this, "color mode", &color_mode_property_))
87     ALOGI("Failed to get color mode property");
88   if (drm_->GetCrtcProperty(*this, "expected_present_time", &expected_present_time_property_))
89       ALOGI("Failed to get expected_present_time property");
90 
91   /* Histogram Properties */
92   if (drm_->GetCrtcProperty(*this, "histogram_roi", &histogram_roi_property_))
93       ALOGI("Failed to get &histogram_roi property");
94   if (drm_->GetCrtcProperty(*this, "histogram_weights", &histogram_weights_property_))
95       ALOGI("Failed to get &histogram_weights property");
96   if (drm_->GetCrtcProperty(*this, "histogram_threshold", &histogram_threshold_property_))
97       ALOGI("Failed to get &histogram_threshold property");
98   if (drm_->GetCrtcProperty(*this, "histogram_pos", &histogram_position_property_))
99       ALOGI("Failed to get &histogram_position property");
100 
101   properties_.push_back(&active_property_);
102   properties_.push_back(&mode_property_);
103   properties_.push_back(&out_fence_ptr_property_);
104   properties_.push_back(&cgc_lut_property_);
105   properties_.push_back(&cgc_lut_fd_property_);
106   properties_.push_back(&degamma_lut_property_);
107   properties_.push_back(&degamma_lut_size_property_);
108   properties_.push_back(&gamma_lut_property_);
109   properties_.push_back(&gamma_lut_size_property_);
110   properties_.push_back(&linear_matrix_property_);
111   properties_.push_back(&gamma_matrix_property_);
112   properties_.push_back(&partial_region_property_);
113   properties_.push_back(&force_bpc_property_);
114   properties_.push_back(&disp_dither_property_);
115   properties_.push_back(&cgc_dither_property_);
116   properties_.push_back(&adjusted_vblank_property_);
117   properties_.push_back(&ppc_property_);
118   properties_.push_back(&max_disp_freq_property_);
119   properties_.push_back(&dqe_enabled_property_);
120   properties_.push_back(&color_mode_property_);
121   properties_.push_back(&expected_present_time_property_);
122 
123   /* Histogram Properties */
124   properties_.push_back(&histogram_roi_property_);
125   properties_.push_back(&histogram_weights_property_);
126   properties_.push_back(&histogram_threshold_property_);
127   properties_.push_back(&histogram_position_property_);
128 
129   return 0;
130 }
131 
id() const132 uint32_t DrmCrtc::id() const {
133   return id_;
134 }
135 
pipe() const136 unsigned DrmCrtc::pipe() const {
137   return pipe_;
138 }
139 
displays() const140 const std::vector<int>& DrmCrtc::displays() const {
141   return displays_;
142 }
143 
has_display(int display) const144 bool DrmCrtc::has_display(int display) const {
145   auto it = find_if(displays_.begin(), displays_.end(),
146       [&display](auto disp) {
147       return (disp == display);
148       });
149   if (it != displays_.end())
150     return true;
151   return false;
152 }
153 
set_display(int display)154 void DrmCrtc::set_display(int display) {
155   displays_.push_back(display);
156 }
157 
can_bind(int display) const158 bool DrmCrtc::can_bind(int display) const {
159   if (displays_.size() == 0)
160     return true;
161   return has_display(display);
162 }
163 
active_property() const164 const DrmProperty &DrmCrtc::active_property() const {
165   return active_property_;
166 }
167 
mode_property() const168 const DrmProperty &DrmCrtc::mode_property() const {
169   return mode_property_;
170 }
171 
out_fence_ptr_property() const172 const DrmProperty &DrmCrtc::out_fence_ptr_property() const {
173   return out_fence_ptr_property_;
174 }
175 
cgc_lut_property() const176 const DrmProperty &DrmCrtc::cgc_lut_property() const {
177     return cgc_lut_property_;
178 }
179 
cgc_lut_fd_property() const180 const DrmProperty &DrmCrtc::cgc_lut_fd_property() const {
181     return cgc_lut_fd_property_;
182 }
183 
degamma_lut_property() const184 const DrmProperty &DrmCrtc::degamma_lut_property() const {
185     return degamma_lut_property_;
186 }
187 
degamma_lut_size_property() const188 const DrmProperty &DrmCrtc::degamma_lut_size_property() const {
189     return degamma_lut_size_property_;
190 }
191 
gamma_lut_property() const192 const DrmProperty &DrmCrtc::gamma_lut_property() const {
193     return gamma_lut_property_;
194 }
195 
gamma_lut_size_property() const196 const DrmProperty &DrmCrtc::gamma_lut_size_property() const {
197     return gamma_lut_size_property_;
198 }
199 
linear_matrix_property() const200 const DrmProperty &DrmCrtc::linear_matrix_property() const {
201     return linear_matrix_property_;
202 }
203 
gamma_matrix_property() const204 const DrmProperty &DrmCrtc::gamma_matrix_property() const {
205     return gamma_matrix_property_;
206 }
207 
partial_region_property() const208 const DrmProperty &DrmCrtc::partial_region_property() const {
209     return partial_region_property_;
210 }
211 
force_bpc_property() const212 const DrmProperty &DrmCrtc::force_bpc_property() const {
213     return force_bpc_property_;
214 }
215 
disp_dither_property() const216 const DrmProperty &DrmCrtc::disp_dither_property() const {
217     return disp_dither_property_;
218 }
219 
cgc_dither_property() const220 const DrmProperty &DrmCrtc::cgc_dither_property() const {
221     return cgc_dither_property_;
222 }
223 
adjusted_vblank_property()224 DrmProperty &DrmCrtc::adjusted_vblank_property() {
225     return adjusted_vblank_property_;
226 }
227 
ppc_property() const228 const DrmProperty &DrmCrtc::ppc_property() const {
229     return ppc_property_;
230 }
231 
max_disp_freq_property() const232 const DrmProperty &DrmCrtc::max_disp_freq_property() const {
233     return max_disp_freq_property_;
234 }
235 
dqe_enabled_property() const236 const DrmProperty &DrmCrtc::dqe_enabled_property() const {
237     return dqe_enabled_property_;
238 }
239 
color_mode_property() const240 const DrmProperty &DrmCrtc::color_mode_property() const {
241     return color_mode_property_;
242 }
243 
expected_present_time_property() const244 const DrmProperty &DrmCrtc::expected_present_time_property() const {
245     return expected_present_time_property_;
246 }
247 
248 /* Histogram Properties */
histogram_roi_property() const249 const DrmProperty &DrmCrtc::histogram_roi_property() const {
250     return histogram_roi_property_;
251 }
252 
histogram_weights_property() const253 const DrmProperty &DrmCrtc::histogram_weights_property() const {
254     return histogram_weights_property_;
255 }
256 
histogram_threshold_property() const257 const DrmProperty &DrmCrtc::histogram_threshold_property() const {
258     return histogram_threshold_property_;
259 }
260 
histogram_position_property() const261 const DrmProperty &DrmCrtc::histogram_position_property() const {
262     return histogram_position_property_;
263 }
264 
265 }  // namespace android
266