Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(579)

Side by Side Diff: ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.cc

Issue 994503004: Preliminary atomic patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h"
6
7 #include <drm.h>
8 #include <errno.h>
9 #include <xf86drm.h>
10
11 #include "ui/ozone/platform/drm/gpu/drm_device.h"
12
13 namespace ui {
14 namespace {
dnicoara 2015/03/09 20:10:40 space above
15 const char* kCrtcPropName = "CRTC_ID";
16 const char* kFbPropName = "FB_ID";
17 const char* kCrtcXPropName = "CRTC_X";
18 const char* kCrtcYPropName = "CRTC_Y";
19 const char* kCrtcWPropName = "CRTC_W";
20 const char* kCrtcHPropName = "CRTC_H";
21 const char* kSrcXPropName = "SRC_X";
22 const char* kSrcYPropName = "SRC_Y";
23 const char* kSrcWPropName = "SRC_W";
24 const char* kSrcHPropName = "SRC_H";
25 }
26
27 HardwareDisplayPlaneAtomic::Property::Property() : id_(0) {
28 }
29
30 bool HardwareDisplayPlaneAtomic::Property::Initialize(
31 DrmDevice* drm,
32 const char* name,
33 const ScopedDrmObjectPropertyPtr& plane_props) {
34 for (uint32_t i = 0; i < plane_props->count_props; i++) {
35 ScopedDrmPropertyPtr property(
dnicoara 2015/03/09 20:10:40 Check that the returned property is a valid object
achaulk 2015/03/09 20:23:48 Done.
36 drmModeGetProperty(drm->get_fd(), plane_props->props[i]));
37 if (!strcmp(property->name, name)) {
38 id_ = property->prop_id;
39 break;
40 }
41 }
42 if (!id_) {
43 LOG(ERROR) << "Could not find property " << name;
44 return false;
45 }
46 return true;
47 }
48
49 HardwareDisplayPlaneAtomic::HardwareDisplayPlaneAtomic(uint32_t plane_id,
50 uint32_t possible_crtcs)
51 : HardwareDisplayPlane(plane_id, possible_crtcs) {
52 }
53 HardwareDisplayPlaneAtomic::~HardwareDisplayPlaneAtomic() {
54 }
55
56 bool HardwareDisplayPlaneAtomic::SetPlaneData(drmModePropertySet* property_set,
57 uint32_t crtc_id,
58 uint32_t framebuffer,
59 const gfx::Rect& crtc_rect,
60 const gfx::Rect& src_rect) {
61 int plane_set_error =
62 drmModePropertySetAdd(property_set, plane_id_, crtc_prop_.id_, crtc_id) ||
63 drmModePropertySetAdd(property_set, plane_id_, fb_prop_.id_,
64 framebuffer) ||
65 drmModePropertySetAdd(property_set, plane_id_, crtc_x_prop_.id_,
66 crtc_rect.x()) ||
67 drmModePropertySetAdd(property_set, plane_id_, crtc_y_prop_.id_,
68 crtc_rect.y()) ||
69 drmModePropertySetAdd(property_set, plane_id_, crtc_w_prop_.id_,
70 crtc_rect.width()) ||
71 drmModePropertySetAdd(property_set, plane_id_, crtc_h_prop_.id_,
72 crtc_rect.height()) ||
73 drmModePropertySetAdd(property_set, plane_id_, src_x_prop_.id_,
74 src_rect.x()) ||
75 drmModePropertySetAdd(property_set, plane_id_, src_y_prop_.id_,
76 src_rect.x()) ||
77 drmModePropertySetAdd(property_set, plane_id_, src_w_prop_.id_,
78 src_rect.width()) ||
79 drmModePropertySetAdd(property_set, plane_id_, src_h_prop_.id_,
80 src_rect.height());
81 if (plane_set_error) {
82 LOG(ERROR) << "Failed to set plane data";
dnicoara 2015/03/09 20:10:40 Use PLOG since it outputs the errno value.
achaulk 2015/03/09 20:23:48 Done.
83 return false;
84 }
85 return true;
86 }
87
88 bool HardwareDisplayPlaneAtomic::Initialize(DrmDevice* drm) {
89 ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties(
90 drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE));
91
92 if (!plane_props) {
93 LOG(ERROR) << "Unable to get plane properties.";
dnicoara 2015/03/09 20:10:40 PLOG
achaulk 2015/03/09 20:23:48 Done.
94 return false;
95 }
96
97 bool props_init = crtc_prop_.Initialize(drm, kCrtcPropName, plane_props) &&
98 fb_prop_.Initialize(drm, kFbPropName, plane_props) &&
99 crtc_x_prop_.Initialize(drm, kCrtcXPropName, plane_props) &&
100 crtc_y_prop_.Initialize(drm, kCrtcYPropName, plane_props) &&
101 crtc_w_prop_.Initialize(drm, kCrtcWPropName, plane_props) &&
102 crtc_h_prop_.Initialize(drm, kCrtcHPropName, plane_props) &&
103 src_x_prop_.Initialize(drm, kSrcXPropName, plane_props) &&
104 src_y_prop_.Initialize(drm, kSrcYPropName, plane_props) &&
105 src_w_prop_.Initialize(drm, kSrcWPropName, plane_props) &&
106 src_h_prop_.Initialize(drm, kSrcHPropName, plane_props);
107
108 if (!props_init) {
109 LOG(ERROR) << "Unable to get plane properties.";
110 return false;
111 }
112 return true;
113 }
114
115 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698