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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.cc
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.cc b/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f7c95c1de6e9536dfb02b73534c44c303a5ed639
--- /dev/null
+++ b/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.cc
@@ -0,0 +1,115 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h"
+
+#include <drm.h>
+#include <errno.h>
+#include <xf86drm.h>
+
+#include "ui/ozone/platform/drm/gpu/drm_device.h"
+
+namespace ui {
+namespace {
dnicoara 2015/03/09 20:10:40 space above
+const char* kCrtcPropName = "CRTC_ID";
+const char* kFbPropName = "FB_ID";
+const char* kCrtcXPropName = "CRTC_X";
+const char* kCrtcYPropName = "CRTC_Y";
+const char* kCrtcWPropName = "CRTC_W";
+const char* kCrtcHPropName = "CRTC_H";
+const char* kSrcXPropName = "SRC_X";
+const char* kSrcYPropName = "SRC_Y";
+const char* kSrcWPropName = "SRC_W";
+const char* kSrcHPropName = "SRC_H";
+}
+
+HardwareDisplayPlaneAtomic::Property::Property() : id_(0) {
+}
+
+bool HardwareDisplayPlaneAtomic::Property::Initialize(
+ DrmDevice* drm,
+ const char* name,
+ const ScopedDrmObjectPropertyPtr& plane_props) {
+ for (uint32_t i = 0; i < plane_props->count_props; i++) {
+ 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.
+ drmModeGetProperty(drm->get_fd(), plane_props->props[i]));
+ if (!strcmp(property->name, name)) {
+ id_ = property->prop_id;
+ break;
+ }
+ }
+ if (!id_) {
+ LOG(ERROR) << "Could not find property " << name;
+ return false;
+ }
+ return true;
+}
+
+HardwareDisplayPlaneAtomic::HardwareDisplayPlaneAtomic(uint32_t plane_id,
+ uint32_t possible_crtcs)
+ : HardwareDisplayPlane(plane_id, possible_crtcs) {
+}
+HardwareDisplayPlaneAtomic::~HardwareDisplayPlaneAtomic() {
+}
+
+bool HardwareDisplayPlaneAtomic::SetPlaneData(drmModePropertySet* property_set,
+ uint32_t crtc_id,
+ uint32_t framebuffer,
+ const gfx::Rect& crtc_rect,
+ const gfx::Rect& src_rect) {
+ int plane_set_error =
+ drmModePropertySetAdd(property_set, plane_id_, crtc_prop_.id_, crtc_id) ||
+ drmModePropertySetAdd(property_set, plane_id_, fb_prop_.id_,
+ framebuffer) ||
+ drmModePropertySetAdd(property_set, plane_id_, crtc_x_prop_.id_,
+ crtc_rect.x()) ||
+ drmModePropertySetAdd(property_set, plane_id_, crtc_y_prop_.id_,
+ crtc_rect.y()) ||
+ drmModePropertySetAdd(property_set, plane_id_, crtc_w_prop_.id_,
+ crtc_rect.width()) ||
+ drmModePropertySetAdd(property_set, plane_id_, crtc_h_prop_.id_,
+ crtc_rect.height()) ||
+ drmModePropertySetAdd(property_set, plane_id_, src_x_prop_.id_,
+ src_rect.x()) ||
+ drmModePropertySetAdd(property_set, plane_id_, src_y_prop_.id_,
+ src_rect.x()) ||
+ drmModePropertySetAdd(property_set, plane_id_, src_w_prop_.id_,
+ src_rect.width()) ||
+ drmModePropertySetAdd(property_set, plane_id_, src_h_prop_.id_,
+ src_rect.height());
+ if (plane_set_error) {
+ 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.
+ return false;
+ }
+ return true;
+}
+
+bool HardwareDisplayPlaneAtomic::Initialize(DrmDevice* drm) {
+ ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties(
+ drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE));
+
+ if (!plane_props) {
+ LOG(ERROR) << "Unable to get plane properties.";
dnicoara 2015/03/09 20:10:40 PLOG
achaulk 2015/03/09 20:23:48 Done.
+ return false;
+ }
+
+ bool props_init = crtc_prop_.Initialize(drm, kCrtcPropName, plane_props) &&
+ fb_prop_.Initialize(drm, kFbPropName, plane_props) &&
+ crtc_x_prop_.Initialize(drm, kCrtcXPropName, plane_props) &&
+ crtc_y_prop_.Initialize(drm, kCrtcYPropName, plane_props) &&
+ crtc_w_prop_.Initialize(drm, kCrtcWPropName, plane_props) &&
+ crtc_h_prop_.Initialize(drm, kCrtcHPropName, plane_props) &&
+ src_x_prop_.Initialize(drm, kSrcXPropName, plane_props) &&
+ src_y_prop_.Initialize(drm, kSrcYPropName, plane_props) &&
+ src_w_prop_.Initialize(drm, kSrcWPropName, plane_props) &&
+ src_h_prop_.Initialize(drm, kSrcHPropName, plane_props);
+
+ if (!props_init) {
+ LOG(ERROR) << "Unable to get plane properties.";
+ return false;
+ }
+ return true;
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698