summaryrefslogtreecommitdiff
path: root/libhwc2.1/libdrmresource/drm/drmcrtc.cpp
blob: 55cee3cf9309750e5d49923e034777d8c564ffd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "hwc-drm-crtc"

#include "drmcrtc.h"
#include "drmdevice.h"

#include <stdint.h>
#include <xf86drmMode.h>

#include <log/log.h>

namespace android {

DrmCrtc::DrmCrtc(DrmDevice *drm, drmModeCrtcPtr c, unsigned pipe)
    : drm_(drm), id_(c->crtc_id), pipe_(pipe), mode_(&c->mode) {
        displays_.clear();
}

int DrmCrtc::Init() {
  int ret = drm_->GetCrtcProperty(*this, "ACTIVE", &active_property_);
  if (ret) {
    ALOGE("Failed to get ACTIVE property");
    return ret;
  }

  ret = drm_->GetCrtcProperty(*this, "MODE_ID", &mode_property_);
  if (ret) {
    ALOGE("Failed to get MODE_ID property");
    return ret;
  }

  ret = drm_->GetCrtcProperty(*this, "OUT_FENCE_PTR", &out_fence_ptr_property_);
  if (ret) {
    ALOGE("Failed to get OUT_FENCE_PTR property");
    return ret;
  }

  if (drm_->GetCrtcProperty(*this, "partial_region", &partial_region_property_))
    ALOGI("Failed to get &partial_region_property");

  if (drm_->GetCrtcProperty(*this, "cgc_lut", &cgc_lut_property_))
    ALOGI("Failed to get cgc_lut property");
  if (drm_->GetCrtcProperty(*this, "cgc_lut_fd", &cgc_lut_fd_property_))
    ALOGI("Failed to get cgc_lut_fd property");
  if (drm_->GetCrtcProperty(*this, "DEGAMMA_LUT", &degamma_lut_property_))
    ALOGI("Failed to get &degamma_lut property");
  if (drm_->GetCrtcProperty(*this, "DEGAMMA_LUT_SIZE", &degamma_lut_size_property_))
    ALOGI("Failed to get &degamma_lut_size property");
  if (drm_->GetCrtcProperty(*this, "GAMMA_LUT", &gamma_lut_property_))
    ALOGI("Failed to get &gamma_lut property");
  if (drm_->GetCrtcProperty(*this, "GAMMA_LUT_SIZE", &gamma_lut_size_property_))
    ALOGI("Failed to get &gamma_lut_size property");
  if (drm_->GetCrtcProperty(*this, "linear_matrix", &linear_matrix_property_))
    ALOGI("Failed to get &linear_matrix property");
  if (drm_->GetCrtcProperty(*this, "gamma_matrix", &gamma_matrix_property_))
    ALOGI("Failed to get &gamma_matrix property");
  if (drm_->GetCrtcProperty(*this, "force_bpc", &force_bpc_property_))
    ALOGI("Failed to get &force_bpc_property_");
  if (drm_->GetCrtcProperty(*this, "disp_dither", &disp_dither_property_))
    ALOGI("Failed to get &disp_dither property");
  if (drm_->GetCrtcProperty(*this, "cgc_dither", &cgc_dither_property_))
    ALOGI("Failed to get &cgc_dither property");
  if (drm_->GetCrtcProperty(*this, "adjusted_vblank", &adjusted_vblank_property_))
    ALOGI("Failed to get &adjusted_vblank property");
  if (drm_->GetCrtcProperty(*this, "ppc", &ppc_property_))
    ALOGI("Failed to get &ppc property");
  if (drm_->GetCrtcProperty(*this, "max_disp_freq", &max_disp_freq_property_))
    ALOGI("Failed to get &max_disp_freq property");
  if (drm_->GetCrtcProperty(*this, "dqe_enabled", &dqe_enabled_property_))
    ALOGI("Failed to get &dqe_enabled_property property");
  if (drm_->GetCrtcProperty(*this, "color mode", &color_mode_property_))
    ALOGI("Failed to get color mode property");
  if (drm_->GetCrtcProperty(*this, "expected_present_time", &expected_present_time_property_))
      ALOGI("Failed to get expected_present_time property");

  /* Histogram Properties */
  if (drm_->GetCrtcProperty(*this, "histogram_roi", &histogram_roi_property_))
      ALOGI("Failed to get &histogram_roi property");
  if (drm_->GetCrtcProperty(*this, "histogram_weights", &histogram_weights_property_))
      ALOGI("Failed to get &histogram_weights property");
  if (drm_->GetCrtcProperty(*this, "histogram_threshold", &histogram_threshold_property_))
      ALOGI("Failed to get &histogram_threshold property");
  if (drm_->GetCrtcProperty(*this, "histogram_pos", &histogram_position_property_))
      ALOGI("Failed to get &histogram_position property");
  if (drm_->GetCrtcProperty(*this, "rcd_plane_id", &rcd_plane_id_property_))
      ALOGI("Failed to get &rcd_plane_id property");

  properties_.push_back(&active_property_);
  properties_.push_back(&mode_property_);
  properties_.push_back(&out_fence_ptr_property_);
  properties_.push_back(&cgc_lut_property_);
  properties_.push_back(&cgc_lut_fd_property_);
  properties_.push_back(&degamma_lut_property_);
  properties_.push_back(&degamma_lut_size_property_);
  properties_.push_back(&gamma_lut_property_);
  properties_.push_back(&gamma_lut_size_property_);
  properties_.push_back(&linear_matrix_property_);
  properties_.push_back(&gamma_matrix_property_);
  properties_.push_back(&partial_region_property_);
  properties_.push_back(&force_bpc_property_);
  properties_.push_back(&disp_dither_property_);
  properties_.push_back(&cgc_dither_property_);
  properties_.push_back(&adjusted_vblank_property_);
  properties_.push_back(&ppc_property_);
  properties_.push_back(&max_disp_freq_property_);
  properties_.push_back(&dqe_enabled_property_);
  properties_.push_back(&color_mode_property_);
  properties_.push_back(&expected_present_time_property_);

  /* Histogram Properties */
  properties_.push_back(&histogram_roi_property_);
  properties_.push_back(&histogram_weights_property_);
  properties_.push_back(&histogram_threshold_property_);
  properties_.push_back(&histogram_position_property_);

  properties_.push_back(&rcd_plane_id_property_);

  return 0;
}

uint32_t DrmCrtc::id() const {
  return id_;
}

unsigned DrmCrtc::pipe() const {
  return pipe_;
}

const std::vector<int>& DrmCrtc::displays() const {
  return displays_;
}

bool DrmCrtc::has_display(int display) const {
  auto it = find_if(displays_.begin(), displays_.end(),
      [&display](auto disp) {
      return (disp == display);
      });
  if (it != displays_.end())
    return true;
  return false;
}

void DrmCrtc::set_display(int display) {
  displays_.push_back(display);
}

bool DrmCrtc::can_bind(int display) const {
  if (displays_.size() == 0)
    return true;
  return has_display(display);
}

const DrmProperty &DrmCrtc::active_property() const {
  return active_property_;
}

const DrmProperty &DrmCrtc::mode_property() const {
  return mode_property_;
}

const DrmProperty &DrmCrtc::out_fence_ptr_property() const {
  return out_fence_ptr_property_;
}

const DrmProperty &DrmCrtc::cgc_lut_property() const {
    return cgc_lut_property_;
}

const DrmProperty &DrmCrtc::cgc_lut_fd_property() const {
    return cgc_lut_fd_property_;
}

const DrmProperty &DrmCrtc::degamma_lut_property() const {
    return degamma_lut_property_;
}

const DrmProperty &DrmCrtc::degamma_lut_size_property() const {
    return degamma_lut_size_property_;
}

const DrmProperty &DrmCrtc::gamma_lut_property() const {
    return gamma_lut_property_;
}

const DrmProperty &DrmCrtc::gamma_lut_size_property() const {
    return gamma_lut_size_property_;
}

const DrmProperty &DrmCrtc::linear_matrix_property() const {
    return linear_matrix_property_;
}

const DrmProperty &DrmCrtc::gamma_matrix_property() const {
    return gamma_matrix_property_;
}

const DrmProperty &DrmCrtc::partial_region_property() const {
    return partial_region_property_;
}

const DrmProperty &DrmCrtc::force_bpc_property() const {
    return force_bpc_property_;
}

const DrmProperty &DrmCrtc::disp_dither_property() const {
    return disp_dither_property_;
}

const DrmProperty &DrmCrtc::cgc_dither_property() const {
    return cgc_dither_property_;
}

DrmProperty &DrmCrtc::adjusted_vblank_property() {
    return adjusted_vblank_property_;
}

const DrmProperty &DrmCrtc::ppc_property() const {
    return ppc_property_;
}

const DrmProperty &DrmCrtc::max_disp_freq_property() const {
    return max_disp_freq_property_;
}

const DrmProperty &DrmCrtc::dqe_enabled_property() const {
    return dqe_enabled_property_;
}

const DrmProperty &DrmCrtc::color_mode_property() const {
    return color_mode_property_;
}

const DrmProperty &DrmCrtc::expected_present_time_property() const {
    return expected_present_time_property_;
}

/* Histogram Properties */
const DrmProperty &DrmCrtc::histogram_roi_property() const {
    return histogram_roi_property_;
}

const DrmProperty &DrmCrtc::histogram_weights_property() const {
    return histogram_weights_property_;
}

const DrmProperty &DrmCrtc::histogram_threshold_property() const {
    return histogram_threshold_property_;
}

const DrmProperty &DrmCrtc::histogram_position_property() const {
    return histogram_position_property_;
}

const DrmProperty &DrmCrtc::rcd_plane_id_property() const {
    return rcd_plane_id_property_;
}

}  // namespace android