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 int DrmPlane::Init() {
37 int ret = drm_->GetPlaneProperty(*this, "type", &p);
39 ALOGE("Could not get plane type property");
46 ALOGE("Failed to get plane type property value");
50 case DRM_PLANE_TYPE_OVERLAY:
51 case DRM_PLANE_TYPE_PRIMARY:
52 case DRM_PLANE_TYPE_CURSOR:
53 type_ = (uint32_t)type;
56 ALOGE("Invalid plane type %d", type);
60 ret = drm_->GetPlaneProperty(*this, "CRTC_ID", &crtc_property_);
62 ALOGE("Could not get CRTC_ID property");
66 ret = drm_->GetPlaneProperty(*this, "FB_ID", &fb_property_);
68 ALOGE("Could not get FB_ID property");
72 ret = drm_->GetPlaneProperty(*this, "CRTC_X", &crtc_x_property_);
74 ALOGE("Could not get CRTC_X property");
78 ret = drm_->GetPlaneProperty(*this, "CRTC_Y", &crtc_y_property_);
80 ALOGE("Could not get CRTC_Y property");
84 ret = drm_->GetPlaneProperty(*this, "CRTC_W", &crtc_w_property_);
86 ALOGE("Could not get CRTC_W property");
90 ret = drm_->GetPlaneProperty(*this, "CRTC_H", &crtc_h_property_);
92 ALOGE("Could not get CRTC_H property");
96 ret = drm_->GetPlaneProperty(*this, "SRC_X", &src_x_property_);
98 ALOGE("Could not get SRC_X property");
102 ret = drm_->GetPlaneProperty(*this, "SRC_Y", &src_y_property_);
104 ALOGE("Could not get SRC_Y property");
108 ret = drm_->GetPlaneProperty(*this, "SRC_W", &src_w_property_);
110 ALOGE("Could not get SRC_W property");
114 ret = drm_->GetPlaneProperty(*this, "SRC_H", &src_h_property_);
116 ALOGE("Could not get SRC_H property");
120 ret = drm_->GetPlaneProperty(*this, "rotation", &rotation_property_);
122 ALOGE("Could not get rotation property");
124 ret = drm_->GetPlaneProperty(*this, "alpha", &alpha_property_);
126 ALOGI("Could not get alpha property");
131 uint32_t DrmPlane::id() const {
135 bool DrmPlane::GetCrtcSupported(const DrmCrtc &crtc) const {
136 return !!((1 << crtc.pipe()) & possible_crtc_mask_);
139 uint32_t DrmPlane::type() const {
143 const DrmProperty &DrmPlane::crtc_property() const {
144 return crtc_property_;
147 const DrmProperty &DrmPlane::fb_property() const {
151 const DrmProperty &DrmPlane::crtc_x_property() const {
152 return crtc_x_property_;
155 const DrmProperty &DrmPlane::crtc_y_property() const {
156 return crtc_y_property_;
159 const DrmProperty &DrmPlane::crtc_w_property() const {
160 return crtc_w_property_;
163 const DrmProperty &DrmPlane::crtc_h_property() const {
164 return crtc_h_property_;
167 const DrmProperty &DrmPlane::src_x_property() const {
168 return src_x_property_;
171 const DrmProperty &DrmPlane::src_y_property() const {
172 return src_y_property_;
175 const DrmProperty &DrmPlane::src_w_property() const {
176 return src_w_property_;
179 const DrmProperty &DrmPlane::src_h_property() const {
180 return src_h_property_;
183 const DrmProperty &DrmPlane::rotation_property() const {
184 return rotation_property_;
187 const DrmProperty &DrmPlane::alpha_property() const {
188 return alpha_property_;