[PATCH] dmabuf: get supported dmabuf formats from compositor backend

Fabien Dessenne fabien.dessenne at st.com
Tue Oct 20 07:54:30 PDT 2015


Add the possibility for the compositor backend to provide with the list
of supported pixel formats for dmabuf-based buffers.
This information is used by linux_dmabuf to inform clients when binding.

Signed-off-by: Fabien Dessenne <fabien.dessenne at st.com>
---
 src/compositor.h   |  2 ++
 src/linux-dmabuf.c | 16 +++++++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/compositor.h b/src/compositor.h
index 2e2a185..f58e0cc 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -613,6 +613,8 @@ enum weston_capability {
 struct weston_backend {
 	void (*destroy)(struct weston_compositor *ec);
 	void (*restore)(struct weston_compositor *ec);
+	void (*get_dmabuf_formats)(struct weston_compositor *ec,
+				   struct wl_array *formats);
 };
 
 struct weston_compositor {
diff --git a/src/linux-dmabuf.c b/src/linux-dmabuf.c
index 90c9757..ee02ea4 100644
--- a/src/linux-dmabuf.c
+++ b/src/linux-dmabuf.c
@@ -433,9 +433,19 @@ 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 */
+	if (compositor->backend->get_dmabuf_formats) {
+		struct wl_array dmabuf_formats;
+		uint32_t *p;
+
+		wl_array_init(&dmabuf_formats);
+
+		compositor->backend->get_dmabuf_formats(compositor,
+							&dmabuf_formats);
+		wl_array_for_each(p, &dmabuf_formats)
+			zlinux_dmabuf_send_format(resource, *p);
+
+		wl_array_release(&dmabuf_formats);
+	}
 }
 
 /** Advertise linux_dmabuf support
-- 
1.9.1



More information about the wayland-devel mailing list