2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #define LOG_TAG "hwc-drm-plane"
20 #include "drmresources.h"
25 #include <cutils/log.h>
26 #include <xf86drmMode.h>
30 DrmPlane::DrmPlane(DrmResources *drm, drmModePlanePtr p)
31 : drm_(drm), id_(p->plane_id), possible_crtc_mask_(p->possible_crtcs) {
34 DrmPlane::~DrmPlane() {
37 int DrmPlane::Init() {
40 int ret = drm_->GetPlaneProperty(*this, "type", &p);
42 ALOGE("Could not get plane type property");
49 ALOGE("Failed to get plane type property value");
53 case DRM_PLANE_TYPE_OVERLAY:
54 case DRM_PLANE_TYPE_PRIMARY:
55 case DRM_PLANE_TYPE_CURSOR:
56 type_ = (uint32_t)type;
59 ALOGE("Invalid plane type %d", type);
63 ret = drm_->GetPlaneProperty(*this, "CRTC_ID", &crtc_property_);
65 ALOGE("Could not get CRTC_ID property");
69 ret = drm_->GetPlaneProperty(*this, "FB_ID", &fb_property_);
71 ALOGE("Could not get FB_ID property");
75 ret = drm_->GetPlaneProperty(*this, "CRTC_X", &crtc_x_property_);
77 ALOGE("Could not get CRTC_X property");
81 ret = drm_->GetPlaneProperty(*this, "CRTC_Y", &crtc_y_property_);
83 ALOGE("Could not get CRTC_Y property");
87 ret = drm_->GetPlaneProperty(*this, "CRTC_W", &crtc_w_property_);
89 ALOGE("Could not get CRTC_W property");
93 ret = drm_->GetPlaneProperty(*this, "CRTC_H", &crtc_h_property_);
95 ALOGE("Could not get CRTC_H property");
99 ret = drm_->GetPlaneProperty(*this, "SRC_X", &src_x_property_);
101 ALOGE("Could not get SRC_X property");
105 ret = drm_->GetPlaneProperty(*this, "SRC_Y", &src_y_property_);
107 ALOGE("Could not get SRC_Y property");
111 ret = drm_->GetPlaneProperty(*this, "SRC_W", &src_w_property_);
113 ALOGE("Could not get SRC_W property");
117 ret = drm_->GetPlaneProperty(*this, "SRC_H", &src_h_property_);
119 ALOGE("Could not get SRC_H property");
123 ret = drm_->GetPlaneProperty(*this, "rotation", &rotation_property_);
125 ALOGE("Could not get rotation property");
130 uint32_t DrmPlane::id() const {
134 bool DrmPlane::GetCrtcSupported(const DrmCrtc &crtc) const {
135 return !!((1 << crtc.pipe()) & possible_crtc_mask_);
138 uint32_t DrmPlane::type() const {
142 const DrmProperty &DrmPlane::crtc_property() const {
143 return crtc_property_;
146 const DrmProperty &DrmPlane::fb_property() const {
150 const DrmProperty &DrmPlane::crtc_x_property() const {
151 return crtc_x_property_;
154 const DrmProperty &DrmPlane::crtc_y_property() const {
155 return crtc_y_property_;
158 const DrmProperty &DrmPlane::crtc_w_property() const {
159 return crtc_w_property_;
162 const DrmProperty &DrmPlane::crtc_h_property() const {
163 return crtc_h_property_;
166 const DrmProperty &DrmPlane::src_x_property() const {
167 return src_x_property_;
170 const DrmProperty &DrmPlane::src_y_property() const {
171 return src_y_property_;
174 const DrmProperty &DrmPlane::src_w_property() const {
175 return src_w_property_;
178 const DrmProperty &DrmPlane::src_h_property() const {
179 return src_h_property_;
182 const DrmProperty &DrmPlane::rotation_property() const {
183 return rotation_property_;