blob: b627291cf8bb7bda47622171beef1a737b041309 [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"
Alexandru Gheorghe0f5abd72018-05-01 14:37:10 +010020#include "drmdevice.h"
Sean Paul6a55e9f2015-04-30 15:31:06 -040021
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
Alexandru Gheorghe0f5abd72018-05-01 14:37:10 +010029DrmCrtc::DrmCrtc(DrmDevice *drm, drmModeCrtcPtr c, unsigned pipe)
30 : drm_(drm), id_(c->crtc_id), pipe_(pipe), display_(-1), mode_(&c->mode) {
Sean Paul6a55e9f2015-04-30 15:31:06 -040031}
32
Sean Paul877be972015-06-03 14:08:27 -040033int 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 }
Robert Fossca0fbba2016-10-20 10:14:43 -040045
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 }
Sean Paul877be972015-06-03 14:08:27 -040051 return 0;
52}
53
Sean Paul6a55e9f2015-04-30 15:31:06 -040054uint32_t DrmCrtc::id() const {
55 return id_;
56}
57
58unsigned DrmCrtc::pipe() const {
59 return pipe_;
60}
61
Sean Paul6a55e9f2015-04-30 15:31:06 -040062int DrmCrtc::display() const {
63 return display_;
64}
65
66void DrmCrtc::set_display(int display) {
67 display_ = display;
Sean Paul6a55e9f2015-04-30 15:31:06 -040068}
69
70bool DrmCrtc::can_bind(int display) const {
71 return display_ == -1 || display_ == display;
72}
Sean Paul877be972015-06-03 14:08:27 -040073
74const DrmProperty &DrmCrtc::active_property() const {
75 return active_property_;
76}
77
78const DrmProperty &DrmCrtc::mode_property() const {
79 return mode_property_;
80}
Robert Fossca0fbba2016-10-20 10:14:43 -040081
82const DrmProperty &DrmCrtc::out_fence_ptr_property() const {
83 return out_fence_ptr_property_;
84}
Sean Paulf72cccd2018-08-27 13:59:08 -040085} // namespace android