[PATCH weston v11 04/13] compositor-drm: Add universal plane awareness
Daniel Stone
daniels at collabora.com
Tue Jul 18 13:14:26 UTC 2017
From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Add awareness of, rather than support for, universal planes. Activate
the client cap when we start if possible, and if this is activated,
studiously ignore non-overlay planes. For now.
Signed-off-by: Daniel Stone <daniels at collabora.com>
Co-authored-with: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Co-authored-with: Louis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne at collabora.co.uk>
---
libweston/compositor-drm.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index e7e8e821..c680c2cf 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -67,6 +67,10 @@
#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
#endif
+#ifndef DRM_CLIENT_CAP_UNIVERSAL_PLANES
+#define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2
+#endif
+
#ifndef DRM_CAP_CURSOR_WIDTH
#define DRM_CAP_CURSOR_WIDTH 0x8
#endif
@@ -80,6 +84,24 @@
#endif
/**
+ * List of properties attached to DRM planes
+ */
+enum wdrm_plane_property {
+ WDRM_PLANE_TYPE = 0,
+ WDRM_PLANE__COUNT
+};
+
+/**
+ * Possible values for the WDRM_PLANE_TYPE property.
+ */
+enum wdrm_plane_type {
+ WDRM_PLANE_TYPE_PRIMARY = 0,
+ WDRM_PLANE_TYPE_CURSOR,
+ WDRM_PLANE_TYPE_OVERLAY,
+ WDRM_PLANE_TYPE__COUNT
+};
+
+/**
* List of properties attached to a DRM connector
*/
enum wdrm_connector_property {
@@ -150,6 +172,8 @@ struct drm_backend {
int cursors_are_broken;
+ bool universal_planes;
+
int use_pixman;
struct udev_input input;
@@ -223,10 +247,14 @@ struct drm_plane {
struct drm_output *output;
struct drm_backend *backend;
+ enum wdrm_plane_type type;
+
uint32_t possible_crtcs;
uint32_t plane_id;
uint32_t count_formats;
+ struct drm_property_info props[WDRM_PLANE__COUNT];
+
/* The last framebuffer submitted to the kernel for this plane. */
struct drm_fb *fb_current;
/* The previously-submitted framebuffer, where the hardware has not
@@ -1968,6 +1996,11 @@ init_kms_caps(struct drm_backend *b)
else
b->cursor_height = 64;
+ ret = drmSetClientCap(b->drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
+ b->universal_planes = (ret == 0);
+ weston_log("DRM: %s universal planes\n",
+ b->universal_planes ? "supports" : "does not support");
+
return 0;
}
@@ -2081,6 +2114,26 @@ static struct drm_plane *
drm_plane_create(struct drm_backend *b, const drmModePlane *kplane)
{
struct drm_plane *plane;
+ drmModeObjectProperties *props;
+
+ static struct drm_property_enum_info plane_type_enums[] = {
+ [WDRM_PLANE_TYPE_PRIMARY] = {
+ .name = "Primary",
+ },
+ [WDRM_PLANE_TYPE_OVERLAY] = {
+ .name = "Overlay",
+ },
+ [WDRM_PLANE_TYPE_CURSOR] = {
+ .name = "Cursor",
+ },
+ };
+ static const struct drm_property_info plane_props[] = {
+ [WDRM_PLANE_TYPE] = {
+ .name = "type",
+ .enum_values = plane_type_enums,
+ .num_enum_values = WDRM_PLANE_TYPE__COUNT,
+ },
+ };
plane = zalloc(sizeof(*plane) + ((sizeof(uint32_t)) *
kplane->count_formats));
@@ -2096,6 +2149,21 @@ drm_plane_create(struct drm_backend *b, const drmModePlane *kplane)
memcpy(plane->formats, kplane->formats,
kplane->count_formats * sizeof(kplane->formats[0]));
+ props = drmModeObjectGetProperties(b->drm.fd, kplane->plane_id,
+ DRM_MODE_OBJECT_PLANE);
+ if (!props) {
+ weston_log("couldn't get plane properties\n");
+ free(plane);
+ return NULL;
+ }
+ drm_property_info_update(b, plane_props, plane->props,
+ WDRM_PLANE__COUNT, props);
+ plane->type =
+ drm_property_get_value(&plane->props[WDRM_PLANE_TYPE],
+ props,
+ WDRM_PLANE_TYPE_OVERLAY);
+ drmModeFreeObjectProperties(props);
+
weston_plane_init(&plane->base, b->compositor, 0, 0);
wl_list_insert(&b->sprite_list, &plane->link);
@@ -2117,6 +2185,7 @@ drm_plane_destroy(struct drm_plane *plane)
0, 0, 0, 0, 0, 0, 0, 0);
assert(!plane->fb_last);
assert(!plane->fb_pending);
+ drm_property_info_free(plane->props, WDRM_PLANE__COUNT);
drm_fb_unref(plane->fb_current);
weston_plane_release(&plane->base);
wl_list_remove(&plane->link);
@@ -2157,6 +2226,12 @@ create_sprites(struct drm_backend *b)
if (!drm_plane)
continue;
+ /* Ignore non-overlay planes for now. */
+ if (drm_plane->type != WDRM_PLANE_TYPE_OVERLAY) {
+ drm_plane_destroy(drm_plane);
+ continue;
+ }
+
weston_compositor_stack_plane(b->compositor, &drm_plane->base,
&b->compositor->primary_plane);
}
--
2.13.3
More information about the wayland-devel
mailing list