Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 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 | |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame] | 17 | #define LOG_TAG "hwc-drm-crtc" |
| 18 | |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 19 | #include "DrmCrtc.h" |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 20 | |
| 21 | #include <stdint.h> |
Roman Stratiienko | d518a05 | 2021-02-25 19:15:14 +0200 | [diff] [blame^] | 22 | #include <utils/log.h> |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 23 | #include <xf86drmMode.h> |
| 24 | |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 25 | #include "DrmDevice.h" |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame] | 26 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 27 | namespace android { |
| 28 | |
Alexandru Gheorghe | 0f5abd7 | 2018-05-01 14:37:10 +0100 | [diff] [blame] | 29 | DrmCrtc::DrmCrtc(DrmDevice *drm, drmModeCrtcPtr c, unsigned pipe) |
| 30 | : drm_(drm), id_(c->crtc_id), pipe_(pipe), display_(-1), mode_(&c->mode) { |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 31 | } |
| 32 | |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame] | 33 | int 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 Foss | ca0fbba | 2016-10-20 10:14:43 -0400 | [diff] [blame] | 45 | |
| 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 Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame] | 51 | return 0; |
| 52 | } |
| 53 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 54 | uint32_t DrmCrtc::id() const { |
| 55 | return id_; |
| 56 | } |
| 57 | |
| 58 | unsigned DrmCrtc::pipe() const { |
| 59 | return pipe_; |
| 60 | } |
| 61 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 62 | int DrmCrtc::display() const { |
| 63 | return display_; |
| 64 | } |
| 65 | |
| 66 | void DrmCrtc::set_display(int display) { |
| 67 | display_ = display; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | bool DrmCrtc::can_bind(int display) const { |
| 71 | return display_ == -1 || display_ == display; |
| 72 | } |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame] | 73 | |
| 74 | const DrmProperty &DrmCrtc::active_property() const { |
| 75 | return active_property_; |
| 76 | } |
| 77 | |
| 78 | const DrmProperty &DrmCrtc::mode_property() const { |
| 79 | return mode_property_; |
| 80 | } |
Robert Foss | ca0fbba | 2016-10-20 10:14:43 -0400 | [diff] [blame] | 81 | |
| 82 | const DrmProperty &DrmCrtc::out_fence_ptr_property() const { |
| 83 | return out_fence_ptr_property_; |
| 84 | } |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 85 | } // namespace android |