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
21 #include <log/log.h>
22 #include <stdint.h>
23 #include <xf86drmMode.h>
24
25 #include "DrmDevice.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), display_(-1), mode_(&c->mode) {
31 }
32
Init()33 int DrmCrtc::Init() {
34 int ret = drm_->GetCrtcProperty(*this, "ACTIVE", &active_property_);
35 if (ret) {
36 ALOGE("Failed to get ACTIVE property");
37 return ret;
38 }
39
40 ret = drm_->GetCrtcProperty(*this, "MODE_ID", &mode_property_);
41 if (ret) {
42 ALOGE("Failed to get MODE_ID property");
43 return ret;
44 }
45
46 ret = drm_->GetCrtcProperty(*this, "OUT_FENCE_PTR", &out_fence_ptr_property_);
47 if (ret) {
48 ALOGE("Failed to get OUT_FENCE_PTR property");
49 return ret;
50 }
51 return 0;
52 }
53
id() const54 uint32_t DrmCrtc::id() const {
55 return id_;
56 }
57
pipe() const58 unsigned DrmCrtc::pipe() const {
59 return pipe_;
60 }
61
display() const62 int DrmCrtc::display() const {
63 return display_;
64 }
65
set_display(int display)66 void DrmCrtc::set_display(int display) {
67 display_ = display;
68 }
69
can_bind(int display) const70 bool DrmCrtc::can_bind(int display) const {
71 return display_ == -1 || display_ == display;
72 }
73
active_property() const74 const DrmProperty &DrmCrtc::active_property() const {
75 return active_property_;
76 }
77
mode_property() const78 const DrmProperty &DrmCrtc::mode_property() const {
79 return mode_property_;
80 }
81
out_fence_ptr_property() const82 const DrmProperty &DrmCrtc::out_fence_ptr_property() const {
83 return out_fence_ptr_property_;
84 }
85 } // namespace android
86