blob: 2314c390131fd95921027d293613c4528a97b472 [file] [log] [blame]
Sean Paul6a55e9f2015-04-30 15:31:06 -04001/*
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
17#define LOG_TAG "hwc-drm-plane"
18
19#include "drmplane.h"
20#include "drmresources.h"
21
22#include <errno.h>
23#include <stdint.h>
24
25#include <cutils/log.h>
26#include <xf86drmMode.h>
27
28namespace android {
29
30DrmPlane::DrmPlane(DrmResources *drm, drmModePlanePtr p)
31 : drm_(drm), id_(p->plane_id), possible_crtc_mask_(p->possible_crtcs) {
32}
33
Sean Paul6a55e9f2015-04-30 15:31:06 -040034int DrmPlane::Init() {
35 DrmProperty p;
36
37 int ret = drm_->GetPlaneProperty(*this, "type", &p);
38 if (ret) {
39 ALOGE("Could not get plane type property");
40 return ret;
41 }
42
43 uint64_t type;
44 ret = p.value(&type);
45 if (ret) {
46 ALOGE("Failed to get plane type property value");
47 return ret;
48 }
49 switch (type) {
50 case DRM_PLANE_TYPE_OVERLAY:
51 case DRM_PLANE_TYPE_PRIMARY:
52 case DRM_PLANE_TYPE_CURSOR:
53 type_ = (uint32_t)type;
54 break;
55 default:
56 ALOGE("Invalid plane type %d", type);
57 return -EINVAL;
58 }
59
60 ret = drm_->GetPlaneProperty(*this, "CRTC_ID", &crtc_property_);
61 if (ret) {
62 ALOGE("Could not get CRTC_ID property");
63 return ret;
64 }
65
66 ret = drm_->GetPlaneProperty(*this, "FB_ID", &fb_property_);
67 if (ret) {
68 ALOGE("Could not get FB_ID property");
69 return ret;
70 }
71
72 ret = drm_->GetPlaneProperty(*this, "CRTC_X", &crtc_x_property_);
73 if (ret) {
74 ALOGE("Could not get CRTC_X property");
75 return ret;
76 }
77
78 ret = drm_->GetPlaneProperty(*this, "CRTC_Y", &crtc_y_property_);
79 if (ret) {
80 ALOGE("Could not get CRTC_Y property");
81 return ret;
82 }
83
84 ret = drm_->GetPlaneProperty(*this, "CRTC_W", &crtc_w_property_);
85 if (ret) {
86 ALOGE("Could not get CRTC_W property");
87 return ret;
88 }
89
90 ret = drm_->GetPlaneProperty(*this, "CRTC_H", &crtc_h_property_);
91 if (ret) {
92 ALOGE("Could not get CRTC_H property");
93 return ret;
94 }
95
96 ret = drm_->GetPlaneProperty(*this, "SRC_X", &src_x_property_);
97 if (ret) {
98 ALOGE("Could not get SRC_X property");
99 return ret;
100 }
101
102 ret = drm_->GetPlaneProperty(*this, "SRC_Y", &src_y_property_);
103 if (ret) {
104 ALOGE("Could not get SRC_Y property");
105 return ret;
106 }
107
108 ret = drm_->GetPlaneProperty(*this, "SRC_W", &src_w_property_);
109 if (ret) {
110 ALOGE("Could not get SRC_W property");
111 return ret;
112 }
113
114 ret = drm_->GetPlaneProperty(*this, "SRC_H", &src_h_property_);
115 if (ret) {
116 ALOGE("Could not get SRC_H property");
117 return ret;
118 }
119
Sean Paul1c4c3262015-07-14 15:51:52 -0400120 ret = drm_->GetPlaneProperty(*this, "rotation", &rotation_property_);
121 if (ret)
122 ALOGE("Could not get rotation property");
123
Sean Pauld8aefb62015-10-15 15:17:31 -0400124 ret = drm_->GetPlaneProperty(*this, "alpha", &alpha_property_);
125 if (ret)
126 ALOGI("Could not get alpha property");
127
Sean Paul6a55e9f2015-04-30 15:31:06 -0400128 return 0;
129}
130
131uint32_t DrmPlane::id() const {
132 return id_;
133}
134
135bool DrmPlane::GetCrtcSupported(const DrmCrtc &crtc) const {
136 return !!((1 << crtc.pipe()) & possible_crtc_mask_);
137}
138
139uint32_t DrmPlane::type() const {
140 return type_;
141}
142
143const DrmProperty &DrmPlane::crtc_property() const {
144 return crtc_property_;
145}
146
147const DrmProperty &DrmPlane::fb_property() const {
148 return fb_property_;
149}
150
151const DrmProperty &DrmPlane::crtc_x_property() const {
152 return crtc_x_property_;
153}
154
155const DrmProperty &DrmPlane::crtc_y_property() const {
156 return crtc_y_property_;
157}
158
159const DrmProperty &DrmPlane::crtc_w_property() const {
160 return crtc_w_property_;
161}
162
163const DrmProperty &DrmPlane::crtc_h_property() const {
164 return crtc_h_property_;
165}
166
167const DrmProperty &DrmPlane::src_x_property() const {
168 return src_x_property_;
169}
170
171const DrmProperty &DrmPlane::src_y_property() const {
172 return src_y_property_;
173}
174
175const DrmProperty &DrmPlane::src_w_property() const {
176 return src_w_property_;
177}
178
179const DrmProperty &DrmPlane::src_h_property() const {
180 return src_h_property_;
181}
Sean Paul1c4c3262015-07-14 15:51:52 -0400182
183const DrmProperty &DrmPlane::rotation_property() const {
184 return rotation_property_;
185}
Sean Pauld8aefb62015-10-15 15:17:31 -0400186
187const DrmProperty &DrmPlane::alpha_property() const {
188 return alpha_property_;
189}
Sean Paul6a55e9f2015-04-30 15:31:06 -0400190}