1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h"
11 #include "ui/ozone/platform/drm/gpu/drm_device.h"
16 const char* kCrtcPropName
= "CRTC_ID";
17 const char* kFbPropName
= "FB_ID";
18 const char* kCrtcXPropName
= "CRTC_X";
19 const char* kCrtcYPropName
= "CRTC_Y";
20 const char* kCrtcWPropName
= "CRTC_W";
21 const char* kCrtcHPropName
= "CRTC_H";
22 const char* kSrcXPropName
= "SRC_X";
23 const char* kSrcYPropName
= "SRC_Y";
24 const char* kSrcWPropName
= "SRC_W";
25 const char* kSrcHPropName
= "SRC_H";
29 HardwareDisplayPlaneAtomic::Property::Property() {
32 bool HardwareDisplayPlaneAtomic::Property::Initialize(
35 const ScopedDrmObjectPropertyPtr
& plane_props
) {
36 for (uint32_t i
= 0; i
< plane_props
->count_props
; i
++) {
37 ScopedDrmPropertyPtr
property(
38 drmModeGetProperty(drm
->get_fd(), plane_props
->props
[i
]));
39 if (property
&& !strcmp(property
->name
, name
)) {
40 id
= property
->prop_id
;
45 LOG(ERROR
) << "Could not find property " << name
;
51 HardwareDisplayPlaneAtomic::HardwareDisplayPlaneAtomic(uint32_t plane_id
,
52 uint32_t possible_crtcs
)
53 : HardwareDisplayPlane(plane_id
, possible_crtcs
) {
55 HardwareDisplayPlaneAtomic::~HardwareDisplayPlaneAtomic() {
58 bool HardwareDisplayPlaneAtomic::SetPlaneData(drmModePropertySet
* property_set
,
61 const gfx::Rect
& crtc_rect
,
62 const gfx::Rect
& src_rect
) {
64 drmModePropertySetAdd(property_set
, plane_id_
, crtc_prop_
.id
, crtc_id
) ||
65 drmModePropertySetAdd(property_set
, plane_id_
, fb_prop_
.id
,
67 drmModePropertySetAdd(property_set
, plane_id_
, crtc_x_prop_
.id
,
69 drmModePropertySetAdd(property_set
, plane_id_
, crtc_y_prop_
.id
,
71 drmModePropertySetAdd(property_set
, plane_id_
, crtc_w_prop_
.id
,
73 drmModePropertySetAdd(property_set
, plane_id_
, crtc_h_prop_
.id
,
74 crtc_rect
.height()) ||
75 drmModePropertySetAdd(property_set
, plane_id_
, src_x_prop_
.id
,
77 drmModePropertySetAdd(property_set
, plane_id_
, src_y_prop_
.id
,
79 drmModePropertySetAdd(property_set
, plane_id_
, src_w_prop_
.id
,
81 drmModePropertySetAdd(property_set
, plane_id_
, src_h_prop_
.id
,
83 if (plane_set_error
) {
84 PLOG(ERROR
) << "Failed to set plane data";
90 bool HardwareDisplayPlaneAtomic::Initialize(DrmDevice
* drm
) {
91 ScopedDrmObjectPropertyPtr
plane_props(drmModeObjectGetProperties(
92 drm
->get_fd(), plane_id_
, DRM_MODE_OBJECT_PLANE
));
95 PLOG(ERROR
) << "Unable to get plane properties.";
99 bool props_init
= crtc_prop_
.Initialize(drm
, kCrtcPropName
, plane_props
) &&
100 fb_prop_
.Initialize(drm
, kFbPropName
, plane_props
) &&
101 crtc_x_prop_
.Initialize(drm
, kCrtcXPropName
, plane_props
) &&
102 crtc_y_prop_
.Initialize(drm
, kCrtcYPropName
, plane_props
) &&
103 crtc_w_prop_
.Initialize(drm
, kCrtcWPropName
, plane_props
) &&
104 crtc_h_prop_
.Initialize(drm
, kCrtcHPropName
, plane_props
) &&
105 src_x_prop_
.Initialize(drm
, kSrcXPropName
, plane_props
) &&
106 src_y_prop_
.Initialize(drm
, kSrcYPropName
, plane_props
) &&
107 src_w_prop_
.Initialize(drm
, kSrcWPropName
, plane_props
) &&
108 src_h_prop_
.Initialize(drm
, kSrcHPropName
, plane_props
);
111 LOG(ERROR
) << "Unable to get plane properties.";