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 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 19 | #include "drmcrtc.h" |
| 20 | #include "drmresources.h" |
| 21 | |
| 22 | #include <stdint.h> |
| 23 | #include <xf86drmMode.h> |
| 24 | |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame^] | 25 | #include <cutils/log.h> |
| 26 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 27 | namespace android { |
| 28 | |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame^] | 29 | DrmCrtc::DrmCrtc(DrmResources *drm, drmModeCrtcPtr c, unsigned pipe) |
| 30 | : drm_(drm), |
| 31 | id_(c->crtc_id), |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 32 | pipe_(pipe), |
| 33 | display_(-1), |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 34 | x_(c->x), |
| 35 | y_(c->y), |
| 36 | width_(c->width), |
| 37 | height_(c->height), |
| 38 | mode_(&c->mode), |
Sean Paul | 5f9339c | 2015-05-18 08:31:06 -0700 | [diff] [blame] | 39 | mode_valid_(c->mode_valid) { |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | DrmCrtc::~DrmCrtc() { |
| 43 | } |
| 44 | |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame^] | 45 | int DrmCrtc::Init() { |
| 46 | int ret = drm_->GetCrtcProperty(*this, "ACTIVE", &active_property_); |
| 47 | if (ret) { |
| 48 | ALOGE("Failed to get ACTIVE property"); |
| 49 | return ret; |
| 50 | } |
| 51 | |
| 52 | ret = drm_->GetCrtcProperty(*this, "MODE_ID", &mode_property_); |
| 53 | if (ret) { |
| 54 | ALOGE("Failed to get MODE_ID property"); |
| 55 | return ret; |
| 56 | } |
| 57 | return 0; |
| 58 | } |
| 59 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 60 | uint32_t DrmCrtc::id() const { |
| 61 | return id_; |
| 62 | } |
| 63 | |
| 64 | unsigned DrmCrtc::pipe() const { |
| 65 | return pipe_; |
| 66 | } |
| 67 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 68 | int DrmCrtc::display() const { |
| 69 | return display_; |
| 70 | } |
| 71 | |
| 72 | void DrmCrtc::set_display(int display) { |
| 73 | display_ = display; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | bool DrmCrtc::can_bind(int display) const { |
| 77 | return display_ == -1 || display_ == display; |
| 78 | } |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame^] | 79 | |
| 80 | const DrmProperty &DrmCrtc::active_property() const { |
| 81 | return active_property_; |
| 82 | } |
| 83 | |
| 84 | const DrmProperty &DrmCrtc::mode_property() const { |
| 85 | return mode_property_; |
| 86 | } |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 87 | } |