summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/ozone/platform/drm/gpu/hardware_display_plane.cc68
-rw-r--r--ui/ozone/platform/drm/gpu/hardware_display_plane.h18
-rw-r--r--ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.cc16
-rw-r--r--ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h7
-rw-r--r--ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc13
-rw-r--r--ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc5
6 files changed, 96 insertions, 31 deletions
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane.cc b/ui/ozone/platform/drm/gpu/hardware_display_plane.cc
index 77fc7178..3f700cb 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_plane.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_plane.cc
@@ -4,11 +4,44 @@
#include "ui/ozone/platform/drm/gpu/hardware_display_plane.h"
+#include <drm_fourcc.h>
+
#include "base/logging.h"
#include "ui/ozone/platform/drm/gpu/drm_device.h"
+#ifndef DRM_PLANE_TYPE_OVERLAY
+#define DRM_PLANE_TYPE_OVERLAY 0
+#endif
+
+#ifndef DRM_PLANE_TYPE_PRIMARY
+#define DRM_PLANE_TYPE_PRIMARY 1
+#endif
+
+#ifndef DRM_PLANE_TYPE_CURSOR
+#define DRM_PLANE_TYPE_CURSOR 2
+#endif
+
namespace ui {
+namespace {
+
+const char* kTypePropName = "type";
+HardwareDisplayPlane::Type GetPlaneType(int value) {
+ switch (value) {
+ case DRM_PLANE_TYPE_CURSOR:
+ return HardwareDisplayPlane::kCursor;
+ case DRM_PLANE_TYPE_PRIMARY:
+ return HardwareDisplayPlane::kPrimary;
+ case DRM_PLANE_TYPE_OVERLAY:
+ return HardwareDisplayPlane::kOverlay;
+ default:
+ NOTREACHED();
+ return HardwareDisplayPlane::kDummy;
+ }
+}
+
+} // namespace
+
HardwareDisplayPlane::HardwareDisplayPlane(uint32_t plane_id,
uint32_t possible_crtcs)
: plane_id_(plane_id), possible_crtcs_(possible_crtcs) {
@@ -22,12 +55,43 @@ bool HardwareDisplayPlane::CanUseForCrtc(uint32_t crtc_index) {
}
bool HardwareDisplayPlane::Initialize(DrmDevice* drm,
- const std::vector<uint32_t>& formats) {
- return true;
+ const std::vector<uint32_t>& formats,
+ bool is_dummy) {
+ if (is_dummy) {
+ type_ = kDummy;
+ supported_formats_.push_back(DRM_FORMAT_XRGB8888);
+ return true;
+ }
+
+ supported_formats_ = formats;
+
+ ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties(
+ drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE));
+ if (!plane_props) {
+ PLOG(ERROR) << "Unable to get plane properties.";
+ return false;
+ }
+
+ uint32_t count_props = plane_props->count_props;
+ for (uint32_t i = 0; i < count_props; i++) {
+ ScopedDrmPropertyPtr property(
+ drmModeGetProperty(drm->get_fd(), plane_props->props[i]));
+ if (property && !strcmp(property->name, kTypePropName)) {
+ type_ = GetPlaneType(plane_props->prop_values[i]);
+ }
+ }
+
+ return InitializeProperties(drm, plane_props);
}
bool HardwareDisplayPlane::IsSupportedFormat(uint32_t format) const {
return true;
}
+bool HardwareDisplayPlane::InitializeProperties(
+ DrmDevice* drm,
+ const ScopedDrmObjectPropertyPtr& plane_props) {
+ return true;
+}
+
} // namespace ui
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane.h b/ui/ozone/platform/drm/gpu/hardware_display_plane.h
index 778f344..4eecf8d 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_plane.h
+++ b/ui/ozone/platform/drm/gpu/hardware_display_plane.h
@@ -22,11 +22,15 @@ class DrmDevice;
class OZONE_EXPORT HardwareDisplayPlane {
public:
+ enum Type { kDummy, kPrimary, kOverlay, kCursor };
+
HardwareDisplayPlane(uint32_t plane_id, uint32_t possible_crtcs);
virtual ~HardwareDisplayPlane();
- virtual bool Initialize(DrmDevice* drm, const std::vector<uint32_t>& formats);
+ bool Initialize(DrmDevice* drm,
+ const std::vector<uint32_t>& formats,
+ bool is_dummy);
virtual bool IsSupportedFormat(uint32_t format) const;
@@ -35,20 +39,24 @@ class OZONE_EXPORT HardwareDisplayPlane {
bool in_use() const { return in_use_; }
void set_in_use(bool in_use) { in_use_ = in_use; }
- bool is_dummy() const { return is_dummy_; }
- void set_is_dummy(bool is_dummy) { is_dummy_ = is_dummy; }
-
uint32_t plane_id() const { return plane_id_; }
+ Type type() const { return type_; }
+
void set_owning_crtc(uint32_t crtc) { owning_crtc_ = crtc; }
uint32_t owning_crtc() const { return owning_crtc_; }
protected:
+ virtual bool InitializeProperties(
+ DrmDevice* drm,
+ const ScopedDrmObjectPropertyPtr& plane_props);
+
uint32_t plane_id_ = 0;
uint32_t possible_crtcs_ = 0;
uint32_t owning_crtc_ = 0;
bool in_use_ = false;
- bool is_dummy_ = false;
+ Type type_ = kPrimary;
+ std::vector<uint32_t> supported_formats_;
DISALLOW_COPY_AND_ASSIGN(HardwareDisplayPlane);
};
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.cc b/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.cc
index 2477e37..e1f4bb6 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.cc
@@ -86,17 +86,9 @@ bool HardwareDisplayPlaneAtomic::SetPlaneData(drmModePropertySet* property_set,
return true;
}
-bool HardwareDisplayPlaneAtomic::Initialize(
+bool HardwareDisplayPlaneAtomic::InitializeProperties(
DrmDevice* drm,
- const std::vector<uint32_t>& formats) {
- ScopedDrmObjectPropertyPtr plane_props(drmModeObjectGetProperties(
- drm->get_fd(), plane_id_, DRM_MODE_OBJECT_PLANE));
-
- if (!plane_props) {
- PLOG(ERROR) << "Unable to get plane properties.";
- return false;
- }
-
+ const ScopedDrmObjectPropertyPtr& plane_props) {
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) &&
@@ -113,10 +105,6 @@ bool HardwareDisplayPlaneAtomic::Initialize(
return false;
}
- supported_formats_ = formats;
- if (is_dummy())
- supported_formats_.push_back(DRM_FORMAT_XRGB8888);
-
return true;
}
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h b/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h
index b8fb861..9b8d349 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h
+++ b/ui/ozone/platform/drm/gpu/hardware_display_plane_atomic.h
@@ -26,14 +26,16 @@ class HardwareDisplayPlaneAtomic : public HardwareDisplayPlane {
const gfx::Rect& src_rect);
// HardwareDisplayPlane:
- bool Initialize(DrmDevice* drm,
- const std::vector<uint32_t>& formats) override;
bool IsSupportedFormat(uint32_t format) const override;
void set_crtc(CrtcController* crtc) { crtc_ = crtc; }
CrtcController* crtc() const { return crtc_; }
private:
+ bool InitializeProperties(
+ DrmDevice* drm,
+ const ScopedDrmObjectPropertyPtr& plane_props) override;
+
struct Property {
Property();
bool Initialize(DrmDevice* drm,
@@ -53,7 +55,6 @@ class HardwareDisplayPlaneAtomic : public HardwareDisplayPlane {
Property src_w_prop_;
Property src_h_prop_;
CrtcController* crtc_ = nullptr;
- std::vector<uint32_t> supported_formats_;
};
} // namespace ui
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc
index f4b637e..7759ff9 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.cc
@@ -101,8 +101,12 @@ bool HardwareDisplayPlaneManager::Initialize(DrmDevice* drm) {
for (uint32_t j = 0; j < formats_size; j++)
supported_formats.push_back(drm_plane->formats[j]);
- if (plane->Initialize(drm, supported_formats)) {
- planes_.push_back(plane.Pass());
+ if (plane->Initialize(drm, supported_formats, false)) {
+ // CRTC controllers always assume they have a cursor plane and the cursor
+ // plane is updated via cursor specific DRM API. Hence, we dont keep
+ // track of Cursor plane here to avoid re-using it for any other purpose.
+ if (plane->type() != HardwareDisplayPlane::kCursor)
+ planes_.push_back(plane.Pass());
}
}
@@ -115,8 +119,7 @@ bool HardwareDisplayPlaneManager::Initialize(DrmDevice* drm) {
if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) {
scoped_ptr<HardwareDisplayPlane> dummy_plane(
CreatePlane(resources->crtcs[i] - 1, (1 << i)));
- dummy_plane->set_is_dummy(true);
- if (dummy_plane->Initialize(drm, std::vector<uint32_t>())) {
+ if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), true)) {
planes_.push_back(dummy_plane.Pass());
}
}
@@ -187,7 +190,7 @@ bool HardwareDisplayPlaneManager::AssignOverlayPlanes(
}
gfx::Rect fixed_point_rect;
- if (!hw_plane->is_dummy()) {
+ if (hw_plane->type() != HardwareDisplayPlane::kDummy) {
const gfx::Size& size = plane.buffer->GetSize();
gfx::RectF crop_rect = plane.crop_rect;
crop_rect.Scale(size.width(), size.height());
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
index dff9e57..5e3f0a1 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
@@ -67,7 +67,7 @@ bool HardwareDisplayPlaneManagerLegacy::Commit(
// For each element in |old_plane_list|, if it hasn't been reclaimed (by
// this or any other HDPL), clear the overlay contents.
for (HardwareDisplayPlane* plane : plane_list->old_plane_list) {
- if (!plane->in_use() && !plane->is_dummy()) {
+ if (!plane->in_use() && (plane->type() != HardwareDisplayPlane::kDummy)) {
// This plane is being released, so we need to zero it.
if (!drm_->PageFlipOverlay(plane->owning_crtc(), 0, gfx::Rect(),
gfx::Rect(), plane->plane_id())) {
@@ -91,7 +91,8 @@ bool HardwareDisplayPlaneManagerLegacy::SetPlaneData(
uint32_t crtc_id,
const gfx::Rect& src_rect,
CrtcController* crtc) {
- if (hw_plane->is_dummy() || plane_list->legacy_page_flips.empty() ||
+ if ((hw_plane->type() == HardwareDisplayPlane::kDummy) ||
+ plane_list->legacy_page_flips.empty() ||
plane_list->legacy_page_flips.back().crtc_id != crtc_id) {
plane_list->legacy_page_flips.push_back(
HardwareDisplayPlaneList::PageFlipInfo(