blob: 40332699cf26ff806ddbe2485e85933e488d285f [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
John Stultz9057a6f2018-04-26 12:05:55 -070025#include <log/log.h>
Sean Paul877be972015-06-03 14:08:27 -040026
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),
Rob Herring1b2685c2017-11-29 10:19:57 -060034 mode_(&c->mode) {
Sean Paul6a55e9f2015-04-30 15:31:06 -040035}
36
Sean Paul877be972015-06-03 14:08:27 -040037int DrmCrtc::Init() {
38 int ret = drm_->GetCrtcProperty(*this, "ACTIVE", &active_property_);
39 if (ret) {
40 ALOGE("Failed to get ACTIVE property");
41 return ret;
42 }
43
44 ret = drm_->GetCrtcProperty(*this, "MODE_ID", &mode_property_);
45 if (ret) {
46 ALOGE("Failed to get MODE_ID property");
47 return ret;
48 }
Robert Fossca0fbba2016-10-20 10:14:43 -040049
50 ret = drm_->GetCrtcProperty(*this, "OUT_FENCE_PTR", &out_fence_ptr_property_);
51 if (ret) {
52 ALOGE("Failed to get OUT_FENCE_PTR property");
53 return ret;
54 }
Sean Paul877be972015-06-03 14:08:27 -040055 return 0;
56}
57
Sean Paul6a55e9f2015-04-30 15:31:06 -040058uint32_t DrmCrtc::id() const {
59 return id_;
60}
61
62unsigned DrmCrtc::pipe() const {
63 return pipe_;
64}
65
Sean Paul6a55e9f2015-04-30 15:31:06 -040066int DrmCrtc::display() const {
67 return display_;
68}
69
70void DrmCrtc::set_display(int display) {
71 display_ = display;
Sean Paul6a55e9f2015-04-30 15:31:06 -040072}
73
74bool DrmCrtc::can_bind(int display) const {
75 return display_ == -1 || display_ == display;
76}
Sean Paul877be972015-06-03 14:08:27 -040077
78const DrmProperty &DrmCrtc::active_property() const {
79 return active_property_;
80}
81
82const DrmProperty &DrmCrtc::mode_property() const {
83 return mode_property_;
84}
Robert Fossca0fbba2016-10-20 10:14:43 -040085
86const DrmProperty &DrmCrtc::out_fence_ptr_property() const {
87 return out_fence_ptr_property_;
88}
Sean Paul6a55e9f2015-04-30 15:31:06 -040089}