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"
26 #include <cutils/log.h>
27 #include <xf86drmMode.h>
31 DrmPlane::DrmPlane(DrmResources *drm, drmModePlanePtr p)
32 : drm_(drm), id_(p->plane_id), possible_crtc_mask_(p->possible_crtcs) {
35 int DrmPlane::Init() {
38 int ret = drm_->GetPlaneProperty(*this, "type", &p);
40 ALOGE("Could not get plane type property");
47 ALOGE("Failed to get plane type property value");
51 case DRM_PLANE_TYPE_OVERLAY:
52 case DRM_PLANE_TYPE_PRIMARY:
53 case DRM_PLANE_TYPE_CURSOR:
54 type_ = (uint32_t)type;
57 ALOGE("Invalid plane type %" PRIu64, type);
61 ret = drm_->GetPlaneProperty(*this, "CRTC_ID", &crtc_property_);
63 ALOGE("Could not get CRTC_ID property");
67 ret = drm_->GetPlaneProperty(*this, "FB_ID", &fb_property_);
69 ALOGE("Could not get FB_ID property");
73 ret = drm_->GetPlaneProperty(*this, "CRTC_X", &crtc_x_property_);
75 ALOGE("Could not get CRTC_X property");
79 ret = drm_->GetPlaneProperty(*this, "CRTC_Y", &crtc_y_property_);
81 ALOGE("Could not get CRTC_Y property");
85 ret = drm_->GetPlaneProperty(*this, "CRTC_W", &crtc_w_property_);
87 ALOGE("Could not get CRTC_W property");
91 ret = drm_->GetPlaneProperty(*this, "CRTC_H", &crtc_h_property_);
93 ALOGE("Could not get CRTC_H property");
97 ret = drm_->GetPlaneProperty(*this, "SRC_X", &src_x_property_);
99 ALOGE("Could not get SRC_X property");
103 ret = drm_->GetPlaneProperty(*this, "SRC_Y", &src_y_property_);
105 ALOGE("Could not get SRC_Y property");
109 ret = drm_->GetPlaneProperty(*this, "SRC_W", &src_w_property_);
111 ALOGE("Could not get SRC_W property");
115 ret = drm_->GetPlaneProperty(*this, "SRC_H", &src_h_property_);
117 ALOGE("Could not get SRC_H property");
121 ret = drm_->GetPlaneProperty(*this, "rotation", &rotation_property_);
123 ALOGE("Could not get rotation property");
125 ret = drm_->GetPlaneProperty(*this, "alpha", &alpha_property_);
127 ALOGI("Could not get alpha property");
132 uint32_t DrmPlane::id() const {
136 bool DrmPlane::GetCrtcSupported(const DrmCrtc &crtc) const {
137 return !!((1 << crtc.pipe()) & possible_crtc_mask_);
140 uint32_t DrmPlane::type() const {
144 const DrmProperty &DrmPlane::crtc_property() const {
145 return crtc_property_;
148 const DrmProperty &DrmPlane::fb_property() const {
152 const DrmProperty &DrmPlane::crtc_x_property() const {
153 return crtc_x_property_;
156 const DrmProperty &DrmPlane::crtc_y_property() const {
157 return crtc_y_property_;
160 const DrmProperty &DrmPlane::crtc_w_property() const {
161 return crtc_w_property_;
164 const DrmProperty &DrmPlane::crtc_h_property() const {
165 return crtc_h_property_;
168 const DrmProperty &DrmPlane::src_x_property() const {
169 return src_x_property_;
172 const DrmProperty &DrmPlane::src_y_property() const {
173 return src_y_property_;
176 const DrmProperty &DrmPlane::src_w_property() const {
177 return src_w_property_;
180 const DrmProperty &DrmPlane::src_h_property() const {
181 return src_h_property_;
184 const DrmProperty &DrmPlane::rotation_property() const {
185 return rotation_property_;
188 const DrmProperty &DrmPlane::alpha_property() const {
189 return alpha_property_;