[PATCH weston 2/9] linux-dmabuf: advertise supported formats and modifiers
Varad Gautam
varadgautam at gmail.com
Thu Nov 17 11:55:56 UTC 2016
From: Varad Gautam <varad.gautam at collabora.com>
implement 'format' and 'modifier' events to communicate available
formats and modifiers to the client and support zwp_linux_dmabuf_v1
interface version 3.
Signed-off-by: Varad Gautam <varad.gautam at collabora.com>
---
libweston/linux-dmabuf.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/libweston/linux-dmabuf.c b/libweston/linux-dmabuf.c
index 2121634..bc021e1 100644
--- a/libweston/linux-dmabuf.c
+++ b/libweston/linux-dmabuf.c
@@ -457,6 +457,10 @@ bind_linux_dmabuf(struct wl_client *client,
{
struct weston_compositor *compositor = data;
struct wl_resource *resource;
+ int *formats = NULL;
+ uint64_t *modifiers = NULL;
+ int num_formats, num_modifiers;
+ int i, j;
resource = wl_resource_create(client, &zwp_linux_dmabuf_v1_interface,
version, id);
@@ -468,9 +472,30 @@ bind_linux_dmabuf(struct wl_client *client,
wl_resource_set_implementation(resource, &linux_dmabuf_implementation,
compositor, NULL);
- /* EGL_EXT_image_dma_buf_import does not provide a way to query the
- * supported pixel formats. */
- /* XXX: send formats */
+ /*
+ * Use EGL_EXT_image_dma_buf_import_modifiers to query and advertise
+ * format/modifier codes.
+ */
+ compositor->renderer->query_dmabuf_formats(compositor, &formats,
+ &num_formats);
+
+ for (i = 0; i < num_formats; i++) {
+ zwp_linux_dmabuf_v1_send_format(resource, formats[i]);
+
+ compositor->renderer->query_dmabuf_modifiers(compositor,
+ formats[i],
+ &modifiers,
+ &num_modifiers);
+ for (j = 0; j < num_modifiers; j++) {
+ uint32_t modifier_lo = modifiers[j] & 0xFFFFFFFF;
+ uint32_t modifier_hi = modifiers[j] >> 32;
+ zwp_linux_dmabuf_v1_send_modifier(resource, formats[i],
+ modifier_hi,
+ modifier_lo);
+ }
+ free(modifiers);
+ }
+ free(formats);
}
/** Advertise linux_dmabuf support
@@ -488,7 +513,7 @@ WL_EXPORT int
linux_dmabuf_setup(struct weston_compositor *compositor)
{
if (!wl_global_create(compositor->wl_display,
- &zwp_linux_dmabuf_v1_interface, 2,
+ &zwp_linux_dmabuf_v1_interface, 3,
compositor, bind_linux_dmabuf))
return -1;
--
2.6.2
More information about the wayland-devel
mailing list