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"
7 #include "ui/ozone/platform/drm/gpu/drm_device.h"
12 const char* kCrtcPropName
= "CRTC_ID";
13 const char* kFbPropName
= "FB_ID";
14 const char* kCrtcXPropName
= "CRTC_X";
15 const char* kCrtcYPropName
= "CRTC_Y";
16 const char* kCrtcWPropName
= "CRTC_W";
17 const char* kCrtcHPropName
= "CRTC_H";
18 const char* kSrcXPropName
= "SRC_X";
19 const char* kSrcYPropName
= "SRC_Y";
20 const char* kSrcWPropName
= "SRC_W";
21 const char* kSrcHPropName
= "SRC_H";
25 HardwareDisplayPlaneAtomic::Property::Property() {
28 bool HardwareDisplayPlaneAtomic::Property::Initialize(
31 const ScopedDrmObjectPropertyPtr
& plane_props
) {
32 for (uint32_t i
= 0; i
< plane_props
->count_props
; i
++) {
33 ScopedDrmPropertyPtr
property(
34 drmModeGetProperty(drm
->get_fd(), plane_props
->props
[i
]));
35 if (property
&& !strcmp(property
->name
, name
)) {
36 id
= property
->prop_id
;
41 LOG(ERROR
) << "Could not find property " << name
;
47 HardwareDisplayPlaneAtomic::HardwareDisplayPlaneAtomic(uint32_t plane_id
,
48 uint32_t possible_crtcs
)
49 : HardwareDisplayPlane(plane_id
, possible_crtcs
) {
51 HardwareDisplayPlaneAtomic::~HardwareDisplayPlaneAtomic() {
54 bool HardwareDisplayPlaneAtomic::SetPlaneData(drmModeAtomicReq
* property_set
,
57 const gfx::Rect
& crtc_rect
,
58 const gfx::Rect
& src_rect
) {
59 int plane_set_succeeded
=
60 drmModeAtomicAddProperty(property_set
, plane_id_
, crtc_prop_
.id
,
62 drmModeAtomicAddProperty(property_set
, plane_id_
, fb_prop_
.id
,
64 drmModeAtomicAddProperty(property_set
, plane_id_
, crtc_x_prop_
.id
,
66 drmModeAtomicAddProperty(property_set
, plane_id_
, crtc_y_prop_
.id
,
68 drmModeAtomicAddProperty(property_set
, plane_id_
, crtc_w_prop_
.id
,
70 drmModeAtomicAddProperty(property_set
, plane_id_
, crtc_h_prop_
.id
,
71 crtc_rect
.height()) &&
72 drmModeAtomicAddProperty(property_set
, plane_id_
, src_x_prop_
.id
,
74 drmModeAtomicAddProperty(property_set
, plane_id_
, src_y_prop_
.id
,
76 drmModeAtomicAddProperty(property_set
, plane_id_
, src_w_prop_
.id
,
78 drmModeAtomicAddProperty(property_set
, plane_id_
, src_h_prop_
.id
,
80 if (!plane_set_succeeded
) {
81 PLOG(ERROR
) << "Failed to set plane data";
87 bool HardwareDisplayPlaneAtomic::InitializeProperties(
89 const ScopedDrmObjectPropertyPtr
& plane_props
) {
90 bool props_init
= crtc_prop_
.Initialize(drm
, kCrtcPropName
, plane_props
) &&
91 fb_prop_
.Initialize(drm
, kFbPropName
, plane_props
) &&
92 crtc_x_prop_
.Initialize(drm
, kCrtcXPropName
, plane_props
) &&
93 crtc_y_prop_
.Initialize(drm
, kCrtcYPropName
, plane_props
) &&
94 crtc_w_prop_
.Initialize(drm
, kCrtcWPropName
, plane_props
) &&
95 crtc_h_prop_
.Initialize(drm
, kCrtcHPropName
, plane_props
) &&
96 src_x_prop_
.Initialize(drm
, kSrcXPropName
, plane_props
) &&
97 src_y_prop_
.Initialize(drm
, kSrcYPropName
, plane_props
) &&
98 src_w_prop_
.Initialize(drm
, kSrcWPropName
, plane_props
) &&
99 src_h_prop_
.Initialize(drm
, kSrcHPropName
, plane_props
);
102 LOG(ERROR
) << "Unable to get plane properties.";