diff options
author | alexst@chromium.org <alexst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-12 04:58:30 +0000 |
---|---|---|
committer | alexst@chromium.org <alexst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-12 04:58:30 +0000 |
commit | dbd38e814d2a0168eb218942313ded234c1e76df (patch) | |
tree | ba19313ad99b4954890676ce7a5e7c5de69f24a8 /ui/ozone | |
parent | 3b6761d5dddb058e0a2fcc17828731d6b2c8fb35 (diff) | |
download | chromium_src-dbd38e814d2a0168eb218942313ded234c1e76df.zip chromium_src-dbd38e814d2a0168eb218942313ded234c1e76df.tar.gz chromium_src-dbd38e814d2a0168eb218942313ded234c1e76df.tar.bz2 |
Start plumbing drm atomic swap.
This creates an atomic plane to be updated during page flip.
BUG=none
Review URL: https://codereview.chromium.org/383193002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282803 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/ozone')
-rw-r--r-- | ui/ozone/platform/dri/dri.gypi | 9 | ||||
-rw-r--r-- | ui/ozone/platform/dri/hardware_display_plane.cc | 126 | ||||
-rw-r--r-- | ui/ozone/platform/dri/hardware_display_plane.h | 72 | ||||
-rw-r--r-- | ui/ozone/platform/dri/scoped_drm_types.cc | 9 | ||||
-rw-r--r-- | ui/ozone/platform/dri/scoped_drm_types.h | 11 |
5 files changed, 227 insertions, 0 deletions
diff --git a/ui/ozone/platform/dri/dri.gypi b/ui/ozone/platform/dri/dri.gypi index 2dcb782..e26cb20 100644 --- a/ui/ozone/platform/dri/dri.gypi +++ b/ui/ozone/platform/dri/dri.gypi @@ -13,6 +13,7 @@ 'internal_ozone_platforms': [ 'dri', ], + 'use_drm_atomic_flip%': 0, }, 'targets': [ { @@ -68,6 +69,14 @@ 'virtual_terminal_manager.cc', 'virtual_terminal_manager.h', ], + 'conditions': [ + ['use_drm_atomic_flip==1', { + 'sources': [ + 'hardware_display_plane.cc', + 'hardware_display_plane.h', + ], + }], + ], }, { 'target_name': 'ozone_platform_dri_unittests', diff --git a/ui/ozone/platform/dri/hardware_display_plane.cc b/ui/ozone/platform/dri/hardware_display_plane.cc new file mode 100644 index 0000000..dff58fe --- /dev/null +++ b/ui/ozone/platform/dri/hardware_display_plane.cc @@ -0,0 +1,126 @@ +// Copyright 2014 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/dri/hardware_display_plane.h" + +#include <drm.h> +#include <errno.h> +#include <xf86drm.h> + +#include "base/logging.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/ozone/platform/dri/dri_wrapper.h" + +namespace ui { + +namespace { +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"; +} + +HardwareDisplayPlane::Property::Property() : id_(0) { +} + +bool HardwareDisplayPlane::Property::Initialize( + DriWrapper* drm, + const char* name, + const ScopedDrmObjectPropertyPtr& plane_props) { + for (uint32_t i = 0; i < plane_props->count_props; i++) { + ScopedDrmPropertyPtr property( + 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; +} + +HardwareDisplayPlane::HardwareDisplayPlane( + DriWrapper* drm, + drmModePropertySetPtr atomic_property_set, + ScopedDrmPlanePtr plane) + : drm_(drm), + property_set_(atomic_property_set), + plane_(plane.Pass()), + plane_id_(plane_->plane_id) { +} + +HardwareDisplayPlane::~HardwareDisplayPlane() { +} + +bool HardwareDisplayPlane::SetPlaneData(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"; + return false; + } + return true; +} + +bool HardwareDisplayPlane::Initialize() { + ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties( + drm_->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE)); + + if (!plane_props) { + LOG(ERROR) << "Unable to get plane properties."; + 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 diff --git a/ui/ozone/platform/dri/hardware_display_plane.h b/ui/ozone/platform/dri/hardware_display_plane.h new file mode 100644 index 0000000..1a37b48 --- /dev/null +++ b/ui/ozone/platform/dri/hardware_display_plane.h @@ -0,0 +1,72 @@ +// Copyright 2014 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. + +#ifndef UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_PLANE_H_ +#define UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_PLANE_H_ + +#include <stddef.h> +#include <stdint.h> +#include <xf86drmMode.h> + +#include "base/basictypes.h" +#include "ui/ozone/platform/dri/scoped_drm_types.h" + +namespace gfx { +class Rect; +} + +namespace ui { + +class DriWrapper; + +class HardwareDisplayPlane { + public: + HardwareDisplayPlane(DriWrapper* drm, + drmModePropertySetPtr atomic_property_set, + ScopedDrmPlanePtr plane); + + ~HardwareDisplayPlane(); + + bool Initialize(); + + bool SetPlaneData(uint32_t crtc_id, + uint32_t framebuffer, + const gfx::Rect& crtc_rect, + const gfx::Rect& src_rect); + + private: + struct Property { + Property(); + bool Initialize(DriWrapper* drm, + const char* name, + const ScopedDrmObjectPropertyPtr& plane_properties); + uint32_t id_; + }; + // Object containing the connection to the graphics device and wraps the API + // calls to control it. + DriWrapper* drm_; + + // Not owned. + drmModePropertySetPtr property_set_; + + ScopedDrmPlanePtr plane_; + uint32_t plane_id_; + + Property crtc_prop_; + Property fb_prop_; + Property crtc_x_prop_; + Property crtc_y_prop_; + Property crtc_w_prop_; + Property crtc_h_prop_; + Property src_x_prop_; + Property src_y_prop_; + Property src_w_prop_; + Property src_h_prop_; + + DISALLOW_COPY_AND_ASSIGN(HardwareDisplayPlane); +}; + +} // namespace ui + +#endif // UI_OZONE_PLATFORM_DRI_HARDWARE_DISPLAY_PLANE_H_ diff --git a/ui/ozone/platform/dri/scoped_drm_types.cc b/ui/ozone/platform/dri/scoped_drm_types.cc index 4f68f80..7bba802 100644 --- a/ui/ozone/platform/dri/scoped_drm_types.cc +++ b/ui/ozone/platform/dri/scoped_drm_types.cc @@ -24,6 +24,15 @@ void DrmEncoderDeleter::operator()(drmModeEncoder* encoder) const { drmModeFreeEncoder(encoder); } +void DrmObjectPropertiesDeleter::operator()( + drmModeObjectProperties* properties) const { + drmModeFreeObjectProperties(properties); +} + +void DrmPlaneDeleter::operator()(drmModePlane* plane) const { + drmModeFreePlane(plane); +} + void DrmPropertyDeleter::operator()(drmModePropertyRes* property) const { drmModeFreeProperty(property); } diff --git a/ui/ozone/platform/dri/scoped_drm_types.h b/ui/ozone/platform/dri/scoped_drm_types.h index 7c4eb1b..f8a893a 100644 --- a/ui/ozone/platform/dri/scoped_drm_types.h +++ b/ui/ozone/platform/dri/scoped_drm_types.h @@ -11,6 +11,8 @@ typedef struct _drmModeConnector drmModeConnector; typedef struct _drmModeCrtc drmModeCrtc; typedef struct _drmModeEncoder drmModeEncoder; typedef struct _drmModeFB drmModeFB; +typedef struct _drmModeObjectProperties drmModeObjectProperties; +typedef struct _drmModePlane drmModePlane; typedef struct _drmModeProperty drmModePropertyRes; typedef struct _drmModePropertyBlob drmModePropertyBlobRes; typedef struct _drmModeRes drmModeRes; @@ -29,6 +31,12 @@ struct DrmCrtcDeleter { struct DrmEncoderDeleter { void operator()(drmModeEncoder* encoder) const; }; +struct DrmObjectPropertiesDeleter { + void operator()(drmModeObjectProperties* properties) const; +}; +struct DrmPlaneDeleter { + void operator()(drmModePlane* plane) const; +}; struct DrmPropertyDeleter { void operator()(drmModePropertyRes* property) const; }; @@ -43,6 +51,9 @@ typedef scoped_ptr<drmModeRes, DrmResourcesDeleter> ScopedDrmResourcesPtr; typedef scoped_ptr<drmModeConnector, DrmConnectorDeleter> ScopedDrmConnectorPtr; typedef scoped_ptr<drmModeCrtc, DrmCrtcDeleter> ScopedDrmCrtcPtr; typedef scoped_ptr<drmModeEncoder, DrmEncoderDeleter> ScopedDrmEncoderPtr; +typedef scoped_ptr<drmModeObjectProperties, DrmObjectPropertiesDeleter> + ScopedDrmObjectPropertyPtr; +typedef scoped_ptr<drmModePlane, DrmPlaneDeleter> ScopedDrmPlanePtr; typedef scoped_ptr<drmModePropertyRes, DrmPropertyDeleter> ScopedDrmPropertyPtr; typedef scoped_ptr<drmModePropertyBlobRes, DrmPropertyBlobDeleter> ScopedDrmPropertyBlobPtr; |