blob: c1398699d40d8780601e326ba46462826d94a62f [file] [log] [blame]
Sean Paul6a55e9f2015-04-30 15:31:06 -04001/*
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
Sean Paul877be972015-06-03 14:08:27 -040017#define LOG_TAG "hwc-drm-crtc"
18
Sean Paul6a55e9f2015-04-30 15:31:06 -040019#include "drmcrtc.h"
20#include "drmresources.h"
21
22#include <stdint.h>
23#include <xf86drmMode.h>
24
Sean Paul877be972015-06-03 14:08:27 -040025#include <cutils/log.h>
26
Sean Paul6a55e9f2015-04-30 15:31:06 -040027namespace android {
28
Sean Paul877be972015-06-03 14:08:27 -040029DrmCrtc::DrmCrtc(DrmResources *drm, drmModeCrtcPtr c, unsigned pipe)
30 : drm_(drm),
31 id_(c->crtc_id),
Sean Paul6a55e9f2015-04-30 15:31:06 -040032 pipe_(pipe),
33 display_(-1),
Sean Paul6a55e9f2015-04-30 15:31:06 -040034 x_(c->x),
35 y_(c->y),
36 width_(c->width),
37 height_(c->height),
38 mode_(&c->mode),
Sean Paul5f9339c2015-05-18 08:31:06 -070039 mode_valid_(c->mode_valid) {
Sean Paul6a55e9f2015-04-30 15:31:06 -040040}
41
Sean Paul877be972015-06-03 14:08:27 -040042int 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 }
Robert Fossca0fbba2016-10-20 10:14:43 -040054
55 ret = drm_->GetCrtcProperty(*this, "OUT_FENCE_PTR", &out_fence_ptr_property_);
56 if (ret) {
57 ALOGE("Failed to get OUT_FENCE_PTR property");
58 return ret;
59 }
Sean Paul877be972015-06-03 14:08:27 -040060 return 0;
61}
62
Sean Paul6a55e9f2015-04-30 15:31:06 -040063uint32_t DrmCrtc::id() const {
64 return id_;
65}
66
67unsigned DrmCrtc::pipe() const {
68 return pipe_;
69}
70
Sean Paul6a55e9f2015-04-30 15:31:06 -040071int DrmCrtc::display() const {
72 return display_;
73}
74
75void DrmCrtc::set_display(int display) {
76 display_ = display;
Sean Paul6a55e9f2015-04-30 15:31:06 -040077}
78
79bool DrmCrtc::can_bind(int display) const {
80 return display_ == -1 || display_ == display;
81}
Sean Paul877be972015-06-03 14:08:27 -040082
83const DrmProperty &DrmCrtc::active_property() const {
84 return active_property_;
85}
86
87const DrmProperty &DrmCrtc::mode_property() const {
88 return mode_property_;
89}
Robert Fossca0fbba2016-10-20 10:14:43 -040090
91const DrmProperty &DrmCrtc::out_fence_ptr_property() const {
92 return out_fence_ptr_property_;
93}
Sean Paul6a55e9f2015-04-30 15:31:06 -040094}