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