[weston 1/2] linux-dmabuf: implement immediate dmabuf import

Varad Gautam varadgautam at gmail.com
Fri Nov 11 11:40:45 UTC 2016


From: Varad Gautam <varad.gautam at collabora.com>

handle create_immed() dmabuf import requests and support
zwp_linux_dmabuf_v1_interface version 2.

Signed-off-by: Varad Gautam <varad.gautam at collabora.com>
---
 libweston/linux-dmabuf.c | 56 ++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 45 insertions(+), 11 deletions(-)

diff --git a/libweston/linux-dmabuf.c b/libweston/linux-dmabuf.c
index 7b29f08..2121634 100644
--- a/libweston/linux-dmabuf.c
+++ b/libweston/linux-dmabuf.c
@@ -140,12 +140,13 @@ destroy_linux_dmabuf_wl_buffer(struct wl_resource *resource)
 }
 
 static void
-params_create(struct wl_client *client,
-	      struct wl_resource *params_resource,
-	      int32_t width,
-	      int32_t height,
-	      uint32_t format,
-	      uint32_t flags)
+params_create_common(struct wl_client *client,
+		     struct wl_resource *params_resource,
+		     uint32_t buffer_id,
+		     int32_t width,
+		     int32_t height,
+		     uint32_t format,
+		     uint32_t flags)
 {
 	struct linux_dmabuf_buffer *buffer;
 	int i;
@@ -260,7 +261,7 @@ params_create(struct wl_client *client,
 
 	buffer->buffer_resource = wl_resource_create(client,
 						     &wl_buffer_interface,
-						     1, 0);
+						     1, buffer_id);
 	if (!buffer->buffer_resource) {
 		wl_resource_post_no_memory(params_resource);
 		goto err_buffer;
@@ -270,7 +271,11 @@ params_create(struct wl_client *client,
 				       &linux_dmabuf_buffer_implementation,
 				       buffer, destroy_linux_dmabuf_wl_buffer);
 
-	zwp_linux_buffer_params_v1_send_created(params_resource,
+	/* non-zero buffer_id implies we are handling a 'create_immed' request */
+	if (buffer_id)
+		zwp_linux_buffer_params_v1_send_created_immed(params_resource);
+	else
+		zwp_linux_buffer_params_v1_send_created(params_resource,
 						buffer->buffer_resource);
 
 	return;
@@ -280,17 +285,46 @@ err_buffer:
 		buffer->user_data_destroy_func(buffer);
 
 err_failed:
-	zwp_linux_buffer_params_v1_send_failed(params_resource);
+	if (buffer_id)
+		zwp_linux_buffer_params_v1_send_failed_immed(params_resource);
+	else
+		zwp_linux_buffer_params_v1_send_failed(params_resource);
 
 err_out:
 	linux_dmabuf_buffer_destroy(buffer);
 }
 
+static void
+params_create(struct wl_client *client,
+	      struct wl_resource *params_resource,
+	      int32_t width,
+	      int32_t height,
+	      uint32_t format,
+	      uint32_t flags)
+{
+	params_create_common(client, params_resource, 0, width, height, format,
+			     flags);
+}
+
+static void
+params_create_immed(struct wl_client *client,
+		    struct wl_resource *params_resource,
+		    uint32_t buffer_id,
+		    int32_t width,
+		    int32_t height,
+		    uint32_t format,
+		    uint32_t flags)
+{
+	params_create_common(client, params_resource, buffer_id, width, height,
+			     format, flags);
+}
+
 static const struct zwp_linux_buffer_params_v1_interface
 zwp_linux_buffer_params_implementation = {
 	params_destroy,
 	params_add,
-	params_create
+	params_create,
+	params_create_immed
 };
 
 static void
@@ -454,7 +488,7 @@ WL_EXPORT int
 linux_dmabuf_setup(struct weston_compositor *compositor)
 {
 	if (!wl_global_create(compositor->wl_display,
-			      &zwp_linux_dmabuf_v1_interface, 1,
+			      &zwp_linux_dmabuf_v1_interface, 2,
 			      compositor, bind_linux_dmabuf))
 		return -1;
 
-- 
2.6.2



More information about the wayland-devel mailing list