blob: 4da08fe48c12bfeafb7fe4e0a4863064ae050afb [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
Roman Stratiienko13cc3662020-08-29 21:35:39 +030019#include "DrmCrtc.h"
Sean Paul6a55e9f2015-04-30 15:31:06 -040020
Roman Stratiienkod518a052021-02-25 19:15:14 +020021#include <utils/log.h>
Sean Paul6a55e9f2015-04-30 15:31:06 -040022#include <xf86drmMode.h>
23
Roman Stratiienkoe2f2c922021-02-13 10:57:47 +020024#include <cstdint>
25
Roman Stratiienko13cc3662020-08-29 21:35:39 +030026#include "DrmDevice.h"
Sean Paul877be972015-06-03 14:08:27 -040027
Sean Paul6a55e9f2015-04-30 15:31:06 -040028namespace android {
29
Alexandru Gheorghe0f5abd72018-05-01 14:37:10 +010030DrmCrtc::DrmCrtc(DrmDevice *drm, drmModeCrtcPtr c, unsigned pipe)
31 : drm_(drm), id_(c->crtc_id), pipe_(pipe), display_(-1), mode_(&c->mode) {
Sean Paul6a55e9f2015-04-30 15:31:06 -040032}
33
Sean Paul877be972015-06-03 14:08:27 -040034int DrmCrtc::Init() {
35 int ret = drm_->GetCrtcProperty(*this, "ACTIVE", &active_property_);
36 if (ret) {
37 ALOGE("Failed to get ACTIVE property");
38 return ret;
39 }
40
41 ret = drm_->GetCrtcProperty(*this, "MODE_ID", &mode_property_);
42 if (ret) {
43 ALOGE("Failed to get MODE_ID property");
44 return ret;
45 }
Robert Fossca0fbba2016-10-20 10:14:43 -040046
47 ret = drm_->GetCrtcProperty(*this, "OUT_FENCE_PTR", &out_fence_ptr_property_);
48 if (ret) {
49 ALOGE("Failed to get OUT_FENCE_PTR property");
50 return ret;
51 }
Sean Paul877be972015-06-03 14:08:27 -040052 return 0;
53}
54
Sean Paul6a55e9f2015-04-30 15:31:06 -040055uint32_t DrmCrtc::id() const {
56 return id_;
57}
58
59unsigned DrmCrtc::pipe() const {
60 return pipe_;
61}
62
Sean Paul6a55e9f2015-04-30 15:31:06 -040063int DrmCrtc::display() const {
64 return display_;
65}
66
67void DrmCrtc::set_display(int display) {
68 display_ = display;
Sean Paul6a55e9f2015-04-30 15:31:06 -040069}
70
71bool DrmCrtc::can_bind(int display) const {
72 return display_ == -1 || display_ == display;
73}
Sean Paul877be972015-06-03 14:08:27 -040074
75const DrmProperty &DrmCrtc::active_property() const {
76 return active_property_;
77}
78
79const DrmProperty &DrmCrtc::mode_property() const {
80 return mode_property_;
81}
Robert Fossca0fbba2016-10-20 10:14:43 -040082
83const DrmProperty &DrmCrtc::out_fence_ptr_property() const {
84 return out_fence_ptr_property_;
85}
Sean Paulf72cccd2018-08-27 13:59:08 -040086} // namespace android