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 "drmresources.h"
21
22 #include <stdint.h>
23 #include <xf86drmMode.h>
24
25 #include <cutils/log.h>
26
27 namespace android {
28
DrmCrtc(DrmResources * drm,drmModeCrtcPtr c,unsigned pipe)29 DrmCrtc::DrmCrtc(DrmResources *drm, drmModeCrtcPtr c, unsigned pipe)
30 : drm_(drm),
31 id_(c->crtc_id),
32 pipe_(pipe),
33 display_(-1),
34 x_(c->x),
35 y_(c->y),
36 width_(c->width),
37 height_(c->height),
38 mode_(&c->mode),
39 mode_valid_(c->mode_valid) {
40 }
41
Init()42 int DrmCrtc::Init() {
43 int ret = drm_->GetCrtcProperty(*this, "ACTIVE", &active_property_);
44 if (ret) {
45 ALOGE("Failed to get ACTIVE property");
46 return ret;
47 }
48
49 ret = drm_->GetCrtcProperty(*this, "MODE_ID", &mode_property_);
50 if (ret) {
51 ALOGE("Failed to get MODE_ID property");
52 return ret;
53 }
54 return 0;
55 }
56
id() const57 uint32_t DrmCrtc::id() const {
58 return id_;
59 }
60
pipe() const61 unsigned DrmCrtc::pipe() const {
62 return pipe_;
63 }
64
display() const65 int DrmCrtc::display() const {
66 return display_;
67 }
68
set_display(int display)69 void DrmCrtc::set_display(int display) {
70 display_ = display;
71 }
72
can_bind(int display) const73 bool DrmCrtc::can_bind(int display) const {
74 return display_ == -1 || display_ == display;
75 }
76
active_property() const77 const DrmProperty &DrmCrtc::active_property() const {
78 return active_property_;
79 }
80
mode_property() const81 const DrmProperty &DrmCrtc::mode_property() const {
82 return mode_property_;
83 }
84 }
85