[PATCH] doc: be explicit about requests not returning a value

2017-05-15 Thread Varad Gautam
From: Varad Gautam 

document how the asynchronous model works for requests and events to avoid
any confusion.

Signed-off-by: Varad Gautam 
Suggested-by: Pekka Paalanen 
---
 doc/publican/sources/Protocol.xml | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/doc/publican/sources/Protocol.xml 
b/doc/publican/sources/Protocol.xml
index ba6b5f1..b8c30fe 100644
--- a/doc/publican/sources/Protocol.xml
+++ b/doc/publican/sources/Protocol.xml
@@ -52,7 +52,12 @@
   object ID and the event opcode, from which the client can determine
   the type of event.  Events are generated both in response to requests
   (in which case the request and the event constitutes a round trip) or
-  spontaneously when the server state changes.
+  spontaneously when the server state changes.  As the Wayland protocol
+  follows an asynchronous request model, there is no concept of
+  'return value' for requests.  A client can only receive information from
+  the server in the form of events.  Hence, if a client cannot proceed
+  without getting some information from the server, it must invoke a
+  round trip by issuing a wl_display_roundtrip call.
 
 
   
-- 
2.10.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland-protocols v4] linux-dmabuf: advertise format modifiers with modifier event

2017-05-11 Thread Varad Gautam
Hello,

On Thu, Jan 19, 2017 at 1:48 PM, Varad Gautam  wrote:
> From: Varad Gautam 
>
> advertise the supported fourcc format modifiers along with supported
> formats to the client. the 'modifier' event introduced here is
> intended to replace the 'format' event from zwp_linux_dmabuf_v1
> version 1.
>
> bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
> versions to 3.
>
> v2: specify request name in event description for clarity (Yong Bakos)
> v3: grammar fixup (Yong Bakos)
> v4: add deprecation warning against 'format' event usage (pq)
>
> Signed-off-by: Varad Gautam 
> Acked-by: Pekka Paalanen 
> Reviewed-by: Yong Bakos 
> ---

The same for this, applies over 'linux-dmabuf: add immediate dmabuf
import path' [1].

[1] https://patchwork.freedesktop.org/patch/138175/

Thanks,
Varad


>  unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 30 
> +++---
>  1 file changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
> b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
> index 22e7af9..1d83268 100644
> --- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
> +++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
> @@ -26,7 +26,7 @@
>  THIS SOFTWARE.
>
>
> -  
> +  
>  
>Following the interfaces from:
>
> https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
> @@ -34,7 +34,8 @@
>
>This interface offers ways to create generic dmabuf-based
>wl_buffers. Immediately after a client binds to this interface,
> -  the set of supported formats is sent with 'format' events.
> +  the set of supported formats and format modifiers is sent with
> +  'format' and 'modifier' events.
>
>The following are required from clients:
>
> @@ -107,12 +108,35 @@
>  zwp_linux_buffer_params_v1::create request.
>
>  XXX: Can a compositor ever enumerate them?
> +
> +Warning: the 'format' event is likely to be deprecated and replaced
> +with the 'modifier' event introduced in zwp_linux_dmabuf_v1 version 
> 3,
> +described below. Please refrain from using the information received
> +from this event.
>
>
>  
> +
> +
> +  
> +This event advertises the formats that the server supports, along 
> with
> +the modifiers supported for each format. All the supported modifiers
> +for all the supported formats are advertised once when the client
> +binds to this interface. A roundtrip after binding guarantees that
> +the client has received all supported format-modifier pairs.
> +
> +For the definition of the format and modifier codes, see the
> +zwp_linux_buffer_params_v1::create request.
> +  
> +  
> +   +   summary="high 32 bits of layout modifier"/>
> +   +   summary="low 32 bits of layout modifier"/>
> +
>
>
> -  
> +  
>  
>This temporary object is a collection of dmabufs and other
>parameters that together form a single logical buffer. The temporary
> --
> 2.6.2
>
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland-protocols v4] linux-dmabuf: add immediate dmabuf import path

2017-05-11 Thread Varad Gautam
Hi all,

On Fri, Feb 10, 2017 at 1:28 PM, Varad Gautam  wrote:
> From: Varad Gautam 
>
> provide a mechanism that allows clients to import the added dmabufs
> and immediately use the newly created wl_buffers without waiting on
> an event. this is useful to clients that are sure of their import
> request succeeding, and wish to avoid the wl_buffer communication
> roundtrip.
>
> bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
> versions.
>
> v2: specify using incorrectly imported dmabufs as undefined behavior
> instead of sending success/failure events. (pq, daniels)
> v3: preserve the optional protocol error added in v2 and explicitly
> state the outcome of import success or failure (pq)
> v4: clarify create_immed failure cases and error codes (pq)
>
> Signed-off-by: Varad Gautam 
> Reviewed-by: Pekka Paalanen 
> ---

Could we get this merged into wayland-protocols, if there are no
objections on the v4?

Thanks,
Varad

>  unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 66 
> +++---
>  1 file changed, 59 insertions(+), 7 deletions(-)
>
> diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
> b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
> index ed2c4bb..63fbb2d 100644
> --- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
> +++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
> @@ -24,13 +24,13 @@
>  DEALINGS IN THE SOFTWARE.
>
>
> -  
> +  
>  
>Following the interfaces from:
>
> https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
>and the Linux DRM sub-system's AddFb2 ioctl.
>
> -  This interface offers a way to create generic dmabuf-based
> +  This interface offers ways to create generic dmabuf-based
>wl_buffers. Immediately after a client binds to this interface,
>the set of supported formats is sent with 'format' events.
>
> @@ -56,10 +56,23 @@
>To create a wl_buffer from one or more dmabufs, a client creates a
>zwp_linux_dmabuf_params_v1 object with a 
> zwp_linux_dmabuf_v1.create_params
>request. All planes required by the intended format are added with
> -  the 'add' request. Finally, a 'create' request is issued. The server
> -  will reply with either a 'created' event which provides the final
> -  wl_buffer or a 'failed' event saying that it cannot use the dmabufs
> -  provided.
> +  the 'add' request. Finally, a 'create' or 'create_immed' request is
> +  issued, which has the following outcome depending on the import 
> success.
> +
> +  The 'create' request,
> +  - on success, triggers a 'created' event which provides the final
> +wl_buffer to the client.
> +  - on failure, triggers a 'failed' event to convey that the server
> +cannot use the dmabufs received from the client.
> +
> +  For the 'create_immed' request,
> +  - on success, the server immediately imports the added dmabufs to
> +create a wl_buffer. No event is sent from the server in this case.
> +  - on failure, the server can choose to either:
> +- terminate the client by raising a fatal error.
> +- mark the wl_buffer as failed, and send a 'failed' event to the
> +  client. If the client uses a failed wl_buffer as an argument to any
> +  request, the behaviour is compositor implementation-defined.
>
>Warning! The protocol described in this file is experimental and
>backward incompatible changes may be made. Backward compatible changes
> @@ -105,7 +118,7 @@
>  
>
>
> -  
> +  
>  
>This temporary object is a collection of dmabufs and other
>parameters that together form a single logical buffer. The temporary
> @@ -138,6 +151,9 @@
>   summary="invalid width or height"/>
>   summary="offset + stride * height goes out of dmabuf bounds"/>
> +   + summary="invalid wl_buffer resulted from importing dmabufs via
> +   the create_immed request on given buffer_params"/>
>  
>
>  
> @@ -269,6 +285,42 @@
>  zlinux_buffer_params object.
>
>  
> +
> +
> +  
> +This asks for immediate creation of a wl_buffer by importing the
> +added dmabufs.
> +
> +In case of import success, no event is sent from the server, and the
> +wl_buffer is ready to be used by the client.
> +
> +Upon import failure, either of the fol

[PATCH v2] linux-dmabuf: advertise supported formats and modifiers

2017-04-26 Thread Varad Gautam
From: Varad Gautam 

implement 'modifier' event to communicate available formats and modifiers
to the client and support zwp_linux_dmabuf_v1 interface version 3.

v2: handle zero modifiers case, deprecate 'format' event.

Signed-off-by: Varad Gautam 
---

Although DRM_FORMAT_MOD_NONE better articulates the no-modifier case, since
it is shared with DRM_FORMAT_MOD_LINEAR, we end up using
DRM_FORMAT_MOD_INVALID here.

protocol: https://patchwork.freedesktop.org/patch/133970/
tree: git://git.collabora.com/git/user/varad/weston.git dmabuf-modifiers-v2

 libweston/linux-dmabuf.c | 39 +++
 libweston/linux-dmabuf.h |  3 +++
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/libweston/linux-dmabuf.c b/libweston/linux-dmabuf.c
index 9121e59..4f153b1 100644
--- a/libweston/linux-dmabuf.c
+++ b/libweston/linux-dmabuf.c
@@ -467,6 +467,11 @@ 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;
+   uint64_t modifier_invalid = DRM_FORMAT_MOD_INVALID;
+   int i, j;
 
resource = wl_resource_create(client, &zwp_linux_dmabuf_v1_interface,
  version, id);
@@ -478,9 +483,35 @@ 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++) {
+   compositor->renderer->query_dmabuf_modifiers(compositor,
+formats[i],
+&modifiers,
+&num_modifiers);
+
+   /* send DRM_FORMAT_MOD_INVALID token when no modifiers are 
supported
+* for this format */
+   if (num_modifiers == 0) {
+   num_modifiers = 1;
+   modifiers = &modifier_invalid;
+   }
+   for (j = 0; j < num_modifiers; j++) {
+   uint32_t modifier_lo = modifiers[j] & 0x;
+   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
@@ -498,7 +529,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;
 
diff --git a/libweston/linux-dmabuf.h b/libweston/linux-dmabuf.h
index 64f43e5..f4ab52c 100644
--- a/libweston/linux-dmabuf.h
+++ b/libweston/linux-dmabuf.h
@@ -29,6 +29,9 @@
 #include 
 
 #define MAX_DMABUF_PLANES 4
+#ifndef DRM_FORMAT_MOD_INVALID
+#define DRM_FORMAT_MOD_INVALID ((1ULL<<56) - 1)
+#endif
 
 struct linux_dmabuf_buffer;
 typedef void (*dmabuf_user_data_destroy_func)(
-- 
2.10.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v2] clients/simple-dmabuf-drm: add freedreno support alongside intel

2017-04-26 Thread Varad Gautam
abstract drm specific bits to struct drm_device and support running on
freedreno. introduce 'modifier' event.

v2: rebase to master, deprecate 'format' event.

Signed-off-by: Varad Gautam 
---

protocol: https://patchwork.freedesktop.org/patch/133970/
tree: git://git.collabora.com/git/user/varad/weston.git dmabuf-modifiers-v2

 Makefile.am |   2 +-
 clients/simple-dmabuf-drm.c | 218 
 configure.ac|  19 +++-
 3 files changed, 197 insertions(+), 42 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 79bd744..2a28548 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -634,7 +634,7 @@ nodist_weston_simple_dmabuf_drm_SOURCES =   \
protocol/linux-dmabuf-unstable-v1-protocol.c \
protocol/linux-dmabuf-unstable-v1-client-protocol.h
 weston_simple_dmabuf_drm_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_DRM_CLIENT_CFLAGS)
-weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) libshared.la
+weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) 
$(LIBDRM_PLATFORM_LIBS) libshared.la
 BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
 endif
 
diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c
index 0cd0d2f..0acb30f 100644
--- a/clients/simple-dmabuf-drm.c
+++ b/clients/simple-dmabuf-drm.c
@@ -39,8 +39,13 @@
 #include 
 
 #include 
+
+#ifdef HAVE_LIBDRM_INTEL
 #include 
 #include 
+#elif HAVE_LIBDRM_FREEDRENO
+#include 
+#endif
 #include 
 
 #include 
@@ -49,6 +54,8 @@
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 #include "linux-dmabuf-unstable-v1-client-protocol.h"
 
+struct buffer;
+
 struct display {
struct wl_display *display;
struct wl_registry *registry;
@@ -60,14 +67,31 @@ struct display {
int req_dmabuf_immediate;
 };
 
+struct drm_device {
+   int fd;
+   char *name;
+
+   int (*alloc_bo)(struct buffer *buf);
+   void (*free_bo)(struct buffer *buf);
+   int (*export_bo_to_prime)(struct buffer *buf);
+   int (*map_bo)(struct buffer *buf);
+   void (*unmap_bo)(struct buffer *buf);
+};
+
 struct buffer {
struct wl_buffer *buffer;
int busy;
 
+   struct drm_device *dev;
int drm_fd;
 
+#ifdef HAVE_LIBDRM_INTEL
drm_intel_bufmgr *bufmgr;
drm_intel_bo *bo;
+#elif HAVE_LIBDRM_FREEDRENO
+   struct fd_device *fd_dev;
+   struct fd_bo *bo;
+#endif /* HAVE_LIBDRM_FREEDRENO */
 
uint32_t gem_handle;
int dmabuf_fd;
@@ -111,31 +135,10 @@ static const struct wl_buffer_listener buffer_listener = {
buffer_release
 };
 
-static int
-drm_connect(struct buffer *my_buf)
-{
-   /* This won't work with card0 as we need to be authenticated; instead,
-* boot with drm.rnodes=1 and use that. */
-   my_buf->drm_fd = open("/dev/dri/renderD128", O_RDWR);
-   if (my_buf->drm_fd < 0)
-   return 0;
-
-   my_buf->bufmgr = drm_intel_bufmgr_gem_init(my_buf->drm_fd, 32);
-   if (!my_buf->bufmgr)
-   return 0;
-
-   return 1;
-}
-
-static void
-drm_shutdown(struct buffer *my_buf)
-{
-   drm_intel_bufmgr_destroy(my_buf->bufmgr);
-   close(my_buf->drm_fd);
-}
 
+#ifdef HAVE_LIBDRM_INTEL
 static int
-alloc_bo(struct buffer *my_buf)
+intel_alloc_bo(struct buffer *my_buf)
 {
/* XXX: try different tiling modes for testing FB modifiers. */
uint32_t tiling = I915_TILING_NONE;
@@ -160,13 +163,13 @@ alloc_bo(struct buffer *my_buf)
 }
 
 static void
-free_bo(struct buffer *my_buf)
+intel_free_bo(struct buffer *my_buf)
 {
drm_intel_bo_unreference(my_buf->bo);
 }
 
 static int
-map_bo(struct buffer *my_buf)
+intel_map_bo(struct buffer *my_buf)
 {
if (drm_intel_gem_bo_map_gtt(my_buf->bo) != 0)
return 0;
@@ -176,6 +179,68 @@ map_bo(struct buffer *my_buf)
return 1;
 }
 
+static int
+intel_bo_export_to_prime(struct buffer *buffer)
+{
+   return drm_intel_bo_gem_export_to_prime(buffer->bo, &buffer->dmabuf_fd);
+}
+
+static void
+intel_unmap_bo(struct buffer *my_buf)
+{
+   drm_intel_gem_bo_unmap_gtt(my_buf->bo);
+}
+#elif HAVE_LIBDRM_FREEDRENO
+#define ALIGN(v, a) ((v + a - 1) & ~(a - 1))
+
+static
+int fd_alloc_bo(struct buffer *buf)
+{
+   int flags = DRM_FREEDRENO_GEM_CACHE_WCOMBINE;
+   int size = buf->width * buf->height * buf->bpp / 8;
+   buf->fd_dev = fd_device_new(buf->drm_fd);
+
+   buf->bo = fd_bo_new(buf->fd_dev, size, flags);
+
+   if (!buf->bo)
+   return 0;
+   buf->stride = ALIGN(buf->width, 32) * buf->bpp / 8;
+   return 1;
+}
+
+static
+void fd_free_bo(struct buffer *buf)
+{
+   fd_bo_del(buf->bo);
+}
+
+static
+int fd_bo_export_to_prime(struct buffer *buf)
+{
+   buf->dmabuf_fd = fd_bo_dmabuf(buf->bo);
+   if (buf->dmabuf_fd > 0)

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

2017-04-26 Thread Varad Gautam
From: Varad Gautam 

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

v2: terminate client with INVALID_WL_BUFFER when reason
for create_immed failure is unknown.

Signed-off-by: Varad Gautam 
---

protocol: https://patchwork.freedesktop.org/patch/138175/
tree: git://git.collabora.com/git/user/varad/weston.git dmabuf-immediate-v2

 libweston/linux-dmabuf.c | 63 +++-
 1 file changed, 52 insertions(+), 11 deletions(-)

diff --git a/libweston/linux-dmabuf.c b/libweston/linux-dmabuf.c
index c1627d6..9121e59 100644
--- a/libweston/linux-dmabuf.c
+++ b/libweston/linux-dmabuf.c
@@ -143,12 +143,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;
@@ -263,7 +264,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;
@@ -273,7 +274,10 @@ 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,
+   /* send 'created' event when the request is not for an immediate
+* import, ie buffer_id is zero */
+   if (buffer_id == 0)
+   zwp_linux_buffer_params_v1_send_created(params_resource,
buffer->buffer_resource);
 
return;
@@ -283,17 +287,54 @@ err_buffer:
buffer->user_data_destroy_func(buffer);
 
 err_failed:
-   zwp_linux_buffer_params_v1_send_failed(params_resource);
+   if (buffer_id == 0)
+   zwp_linux_buffer_params_v1_send_failed(params_resource);
+   else
+   /* since the behavior is left implementation defined by the
+* protocol in case of create_immed failure due to an unknown 
cause,
+* we choose to treat it as a fatal error and immediately kill 
the
+* client instead of creating an invalid handle and waiting for 
it
+* to be used.
+*/
+   wl_resource_post_error(params_resource,
+   ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_WL_BUFFER,
+   "importing the supplied dmabufs failed");
 
 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
@@ -457,7 +498,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.10.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[RESEND][weston v2 2/2] clients/simple-dmabuf-intel: request no-roundtrip dmabuf import

2017-04-26 Thread Varad Gautam
From: Varad Gautam 

request immediate dmabuf import when run with "immed" arg.

Signed-off-by: Varad Gautam 
---

protocol: https://patchwork.freedesktop.org/patch/138175/
tree: git://git.collabora.com/git/user/varad/weston.git dmabuf-immediate-v2

 clients/simple-dmabuf-intel.c | 36 +++-
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
index 67850b0..0cd0d2f 100644
--- a/clients/simple-dmabuf-intel.c
+++ b/clients/simple-dmabuf-intel.c
@@ -57,6 +57,7 @@ struct display {
struct zwp_fullscreen_shell_v1 *fshell;
struct zwp_linux_dmabuf_v1 *dmabuf;
int xrgb_format_found;
+   int req_dmabuf_immediate;
 };
 
 struct buffer {
@@ -282,7 +283,16 @@ create_dmabuf_buffer(struct display *display, struct 
buffer *buffer,
   modifier >> 32,
   modifier & 0x);
zwp_linux_buffer_params_v1_add_listener(params, ¶ms_listener, 
buffer);
-   zwp_linux_buffer_params_v1_create(params,
+   if (display->req_dmabuf_immediate) {
+   buffer->buffer = zwp_linux_buffer_params_v1_create_immed(params,
+ buffer->width,
+ buffer->height,
+ DRM_FORMAT_XRGB,
+ flags);
+   wl_buffer_add_listener(buffer->buffer, &buffer_listener, 
buffer);
+   }
+   else
+   zwp_linux_buffer_params_v1_create(params,
  buffer->width,
  buffer->height,
  DRM_FORMAT_XRGB,
@@ -506,7 +516,8 @@ registry_handle_global(void *data, struct wl_registry 
*registry,
 id, 
&zwp_fullscreen_shell_v1_interface, 1);
} else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0) {
d->dmabuf = wl_registry_bind(registry,
-id, 
&zwp_linux_dmabuf_v1_interface, 1);
+id, &zwp_linux_dmabuf_v1_interface,
+d->req_dmabuf_immediate ? 2 : 1);
zwp_linux_dmabuf_v1_add_listener(d->dmabuf, &dmabuf_listener, 
d);
}
 }
@@ -523,7 +534,7 @@ static const struct wl_registry_listener registry_listener 
= {
 };
 
 static struct display *
-create_display(void)
+create_display(int is_immediate)
 {
struct display *display;
 
@@ -537,6 +548,7 @@ create_display(void)
 
/* XXX: fake, because the compositor does not yet advertise anything */
display->xrgb_format_found = 1;
+   display->req_dmabuf_immediate = is_immediate;
 
display->registry = wl_display_get_registry(display->display);
wl_registry_add_listener(display->registry,
@@ -590,9 +602,22 @@ main(int argc, char **argv)
struct sigaction sigint;
struct display *display;
struct window *window;
+   int is_immediate = 0;
int ret = 0;
 
-   display = create_display();
+   if (argc > 1) {
+   if (!strcmp(argv[1], "immed")) {
+   is_immediate = 1;
+   }
+   else {
+   fprintf(stderr, "usage:\n\tsimple-dmabuf-intel 
[options]\n"
+   "available options:\n\timmed: avoid dmabuf "
+   "creation roundtrip and import immediately\n");
+   return 1;
+   }
+   }
+
+   display = create_display(is_immediate);
window = create_window(display, 250, 250);
if (!window)
return 1;
@@ -602,7 +627,8 @@ main(int argc, char **argv)
sigint.sa_flags = SA_RESETHAND;
sigaction(SIGINT, &sigint, NULL);
 
-   /* Here we retrieve the linux-dmabuf objects, or error */
+   /* Here we retrieve the linux-dmabuf objects if executed without immed,
+* or error */
wl_display_roundtrip(display->display);
 
if (!running)
-- 
2.10.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH wayland-protocols v4] linux-dmabuf: add immediate dmabuf import path

2017-02-10 Thread Varad Gautam
From: Varad Gautam 

provide a mechanism that allows clients to import the added dmabufs
and immediately use the newly created wl_buffers without waiting on
an event. this is useful to clients that are sure of their import
request succeeding, and wish to avoid the wl_buffer communication
roundtrip.

bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
versions.

v2: specify using incorrectly imported dmabufs as undefined behavior
instead of sending success/failure events. (pq, daniels)
v3: preserve the optional protocol error added in v2 and explicitly
state the outcome of import success or failure (pq)
v4: clarify create_immed failure cases and error codes (pq)

Signed-off-by: Varad Gautam 
Reviewed-by: Pekka Paalanen 
---
 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 66 +++---
 1 file changed, 59 insertions(+), 7 deletions(-)

diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index ed2c4bb..63fbb2d 100644
--- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -24,13 +24,13 @@
 DEALINGS IN THE SOFTWARE.
   
 
-  
+  
 
   Following the interfaces from:
   
https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
   and the Linux DRM sub-system's AddFb2 ioctl.
 
-  This interface offers a way to create generic dmabuf-based
+  This interface offers ways to create generic dmabuf-based
   wl_buffers. Immediately after a client binds to this interface,
   the set of supported formats is sent with 'format' events.
 
@@ -56,10 +56,23 @@
   To create a wl_buffer from one or more dmabufs, a client creates a
   zwp_linux_dmabuf_params_v1 object with a 
zwp_linux_dmabuf_v1.create_params
   request. All planes required by the intended format are added with
-  the 'add' request. Finally, a 'create' request is issued. The server
-  will reply with either a 'created' event which provides the final
-  wl_buffer or a 'failed' event saying that it cannot use the dmabufs
-  provided.
+  the 'add' request. Finally, a 'create' or 'create_immed' request is
+  issued, which has the following outcome depending on the import success.
+
+  The 'create' request,
+  - on success, triggers a 'created' event which provides the final
+wl_buffer to the client.
+  - on failure, triggers a 'failed' event to convey that the server
+cannot use the dmabufs received from the client.
+
+  For the 'create_immed' request,
+  - on success, the server immediately imports the added dmabufs to
+create a wl_buffer. No event is sent from the server in this case.
+  - on failure, the server can choose to either:
+- terminate the client by raising a fatal error.
+- mark the wl_buffer as failed, and send a 'failed' event to the
+  client. If the client uses a failed wl_buffer as an argument to any
+  request, the behaviour is compositor implementation-defined.
 
   Warning! The protocol described in this file is experimental and
   backward incompatible changes may be made. Backward compatible changes
@@ -105,7 +118,7 @@
 
   
 
-  
+  
 
   This temporary object is a collection of dmabufs and other
   parameters that together form a single logical buffer. The temporary
@@ -138,6 +151,9 @@
  summary="invalid width or height"/>
   
+  
 
 
 
@@ -269,6 +285,42 @@
 zlinux_buffer_params object.
   
 
+
+
+  
+This asks for immediate creation of a wl_buffer by importing the
+added dmabufs.
+
+In case of import success, no event is sent from the server, and the
+wl_buffer is ready to be used by the client.
+
+Upon import failure, either of the following may happen, as seen fit
+by the implementation:
+- the client is terminated with one of the following fatal protocol
+  errors:
+  - INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS, OUT_OF_BOUNDS,
+in case of argument errors such as mismatch between the number
+of planes and the format, bad format, non-positive width or
+height, or bad offset or stride.
+  - INVALID_WL_BUFFER, in case the cause for failure is unknown or
+plaform specific.
+- the server creates an invalid wl_buffer, marks it as failed and
+  sends a 'failed' event to the client. The result of using this
+  invalid wl_buffer as an argument in any request by the client is
+  defined by the compositor implementation.
+
+This takes the same arguments as a 'create' request, and obeys the
+same res

Re: [PATCH wayland-protocols v3] linux-dmabuf: add immediate dmabuf import path

2017-02-06 Thread Varad Gautam
Hi Pekka,

On Fri, Feb 3, 2017 at 8:39 PM, Pekka Paalanen
 wrote:
> On Tue, 31 Jan 2017 18:41:52 +0530
> Varad Gautam  wrote:
>
>> From: Varad Gautam 
>>
>> provide a mechanism that allows clients to import the added dmabufs
>> and immediately use the newly created wl_buffers without waiting on
>> an event. this is useful to clients that are sure of their import
>> request succeeding, and wish to avoid the wl_buffer communication
>> roundtrip.
>>
>> bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
>> versions.
>>
>> v2: specify using incorrectly imported dmabufs as undefined behavior
>> instead of sending success/failure events. (pq, daniels)
>> v3: preserve the optional protocol error added in v2 and explicitly
>> state the outcome of import success or failure (pq)
>>
>> Signed-off-by: Varad Gautam 
>> ---
>>  unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 58 
>> +++---
>>  1 file changed, 51 insertions(+), 7 deletions(-)
>>
>> diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
>> b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
>> index ed2c4bb..ddb49cc 100644
>> --- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
>> +++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
>> @@ -24,13 +24,13 @@
>>  DEALINGS IN THE SOFTWARE.
>>
>>
>> -  
>> +  
>>  
>>Following the interfaces from:
>>
>> https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
>>and the Linux DRM sub-system's AddFb2 ioctl.
>>
>> -  This interface offers a way to create generic dmabuf-based
>> +  This interface offers ways to create generic dmabuf-based
>>wl_buffers. Immediately after a client binds to this interface,
>>the set of supported formats is sent with 'format' events.
>>
>> @@ -56,10 +56,23 @@
>>To create a wl_buffer from one or more dmabufs, a client creates a
>>zwp_linux_dmabuf_params_v1 object with a 
>> zwp_linux_dmabuf_v1.create_params
>>request. All planes required by the intended format are added with
>> -  the 'add' request. Finally, a 'create' request is issued. The server
>> -  will reply with either a 'created' event which provides the final
>> -  wl_buffer or a 'failed' event saying that it cannot use the dmabufs
>> -  provided.
>> +  the 'add' request. Finally, a 'create' or 'create_immed' request is
>> +  issued, which has the following outcome depending on the import 
>> success.
>> +
>> +  The 'create' request,
>> +  - on success, triggers a 'created' event which provides the final
>> +wl_buffer to the client.
>> +  - on failure, triggers a 'failed' event to convey that the server
>> +cannot use the dmabufs received from the client.
>> +
>> +  For the 'create_immed' request,
>> +  - on success, the server immediately imports the added dmabufs to
>> +create a wl_buffer. No event is sent from the server in this case.
>> +  - on failure, the server can choose to either:
>> +- terminate the client by raising a fatal error.
>> +- create an invalid wl_buffer handle and send a 'failed' event to
>> +  the client. The result of using this invalid wl_buffer in the
>> +  client is left implementation-defined by the protocol.
>
> Hi,
>
> I would phrase the latter as:
>
> - Mark the wl_buffer as failed and send a 'failed' event to the
>   client. If the client uses a failed wl_buffer as an argument
>   to any request, the behaviour is compositor
>   implementation-defined.
>

ack, will fix.

>>
>>Warning! The protocol described in this file is experimental and
>>backward incompatible changes may be made. Backward compatible changes
>> @@ -105,7 +118,7 @@
>>  
>>
>>
>> -  
>> +  
>>  
>>This temporary object is a collection of dmabufs and other
>>parameters that together form a single logical buffer. The temporary
>> @@ -138,6 +151,9 @@
>>   summary="invalid width or height"/>
>>>   summary="offset + stride * height goes out of dmabuf bounds"/>
>> +  > + summary="invalid wl_buffer resulted from importing d

[PATCH wayland-protocols v3] linux-dmabuf: add immediate dmabuf import path

2017-01-31 Thread Varad Gautam
From: Varad Gautam 

provide a mechanism that allows clients to import the added dmabufs
and immediately use the newly created wl_buffers without waiting on
an event. this is useful to clients that are sure of their import
request succeeding, and wish to avoid the wl_buffer communication
roundtrip.

bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
versions.

v2: specify using incorrectly imported dmabufs as undefined behavior
instead of sending success/failure events. (pq, daniels)
v3: preserve the optional protocol error added in v2 and explicitly
state the outcome of import success or failure (pq)

Signed-off-by: Varad Gautam 
---
 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 58 +++---
 1 file changed, 51 insertions(+), 7 deletions(-)

diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index ed2c4bb..ddb49cc 100644
--- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -24,13 +24,13 @@
 DEALINGS IN THE SOFTWARE.
   
 
-  
+  
 
   Following the interfaces from:
   
https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
   and the Linux DRM sub-system's AddFb2 ioctl.
 
-  This interface offers a way to create generic dmabuf-based
+  This interface offers ways to create generic dmabuf-based
   wl_buffers. Immediately after a client binds to this interface,
   the set of supported formats is sent with 'format' events.
 
@@ -56,10 +56,23 @@
   To create a wl_buffer from one or more dmabufs, a client creates a
   zwp_linux_dmabuf_params_v1 object with a 
zwp_linux_dmabuf_v1.create_params
   request. All planes required by the intended format are added with
-  the 'add' request. Finally, a 'create' request is issued. The server
-  will reply with either a 'created' event which provides the final
-  wl_buffer or a 'failed' event saying that it cannot use the dmabufs
-  provided.
+  the 'add' request. Finally, a 'create' or 'create_immed' request is
+  issued, which has the following outcome depending on the import success.
+
+  The 'create' request,
+  - on success, triggers a 'created' event which provides the final
+wl_buffer to the client.
+  - on failure, triggers a 'failed' event to convey that the server
+cannot use the dmabufs received from the client.
+
+  For the 'create_immed' request,
+  - on success, the server immediately imports the added dmabufs to
+create a wl_buffer. No event is sent from the server in this case.
+  - on failure, the server can choose to either:
+- terminate the client by raising a fatal error.
+- create an invalid wl_buffer handle and send a 'failed' event to
+  the client. The result of using this invalid wl_buffer in the
+  client is left implementation-defined by the protocol.
 
   Warning! The protocol described in this file is experimental and
   backward incompatible changes may be made. Backward compatible changes
@@ -105,7 +118,7 @@
 
   
 
-  
+  
 
   This temporary object is a collection of dmabufs and other
   parameters that together form a single logical buffer. The temporary
@@ -138,6 +151,9 @@
  summary="invalid width or height"/>
   
+  
 
 
 
@@ -269,6 +285,34 @@
 zlinux_buffer_params object.
   
 
+
+
+  
+This asks for immediate creation of a wl_buffer by importing the
+added dmabufs.
+
+In case of import success, no event is sent from the server, and the
+wl_buffer is ready to be used by the client.
+
+Upon import failure, either of the following may happen, as seen fit
+by the implementation:
+- the client is terminated with a fatal protocol error.
+- the server creates an invalid wl_buffer and sends a 'failed' event
+  to the client. The result of using this invalid wl_buffer created
+  by the server is implementation defined.
+
+This takes the same arguments as a 'create' request, and obeys the
+same restrictions.
+  
+  
+  
+  
+  
+  
+
+
   
 
 
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


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

2017-01-30 Thread Varad Gautam
Hi Pekka,

On Fri, Jan 27, 2017 at 6:32 PM, Pekka Paalanen
 wrote:
> On Mon, 21 Nov 2016 21:27:03 +
> Daniel Stone  wrote:
>
>> Hi Varad,
>>
>> On 11 November 2016 at 11:40, Varad Gautam  wrote:
>> > handle create_immed() dmabuf import requests and support
>> > zwp_linux_dmabuf_v1_interface version 2.
>>
>> Same caveat about holding off on merging applies, but these two patches are:
>> Reviewed-by: Daniel Stone 
>
> Hi,
>
> yeah, the Weston patch v1 is probably good, considering my review on
> the protocol patch v2 essentially asking to go back to the v1 with just
> some wording added.
>
> However, it would be good to check and ensure what happens in Weston
> when a client uses a wl_buffer that has failed the dmabuf import. I
> suspect you would need to add some checks somewhere depending on what
> Weston will do.
>
> I think we pretty much agreed that Weston will just send a fatal error
> to the client if it commits a failed wl_buffer.
>
> How to recognize a failed wl_buffer then... maybe NULL user data on the
> wl_resource? Then there will be places that need to check for NULL: the
> commit machinery and destructor come to mind.
>
> Whatever Weston does, it cannot avoid creating the wl_resource. It must
> be created, if the protocol XML says a new object is created. And for
> 'create_immed' request, a new object is created. This is probably
> overlooked in patch v1.

Instead of always always creating a wl_resource and identifying an invalid
wl_buffer on commit in weston, how about treating an invalid import just as
any other cause for failure in linux-dmabuf, and letting the
compositor error-out
at import itself?

So, upon failed import the implementation can choose to either:
1. raise an error and never create an invalid resource; or,
2. create an invalid resource and have its own checks in the commit path
(or elsewhere) to decide how to handle the situation.

Option 1 allows us to have a 'semi-defined' behavior for existing compositors
{weston} that expect a commit guarantee on wl_buffers. The protocol v2 [1]
added an optional invalid_wl_buffer error, to be preventively used by
compositors
that mandate the committed wl_buffers to be valid to handle the failed import
case.

[1] https://patchwork.freedesktop.org/patch/133966/

Thanks,
Varad

>
>
> Thanks,
> pq
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH wayland-protocols v4] linux-dmabuf: advertise format modifiers with modifier event

2017-01-19 Thread Varad Gautam
From: Varad Gautam 

advertise the supported fourcc format modifiers along with supported
formats to the client. the 'modifier' event introduced here is
intended to replace the 'format' event from zwp_linux_dmabuf_v1
version 1.

bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
versions to 3.

v2: specify request name in event description for clarity (Yong Bakos)
v3: grammar fixup (Yong Bakos)
v4: add deprecation warning against 'format' event usage (pq)

Signed-off-by: Varad Gautam 
Acked-by: Pekka Paalanen 
Reviewed-by: Yong Bakos 
---
 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 30 +++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index 22e7af9..1d83268 100644
--- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -26,7 +26,7 @@
 THIS SOFTWARE.
   
 
-  
+  
 
   Following the interfaces from:
   
https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
@@ -34,7 +34,8 @@
 
   This interface offers ways to create generic dmabuf-based
   wl_buffers. Immediately after a client binds to this interface,
-  the set of supported formats is sent with 'format' events.
+  the set of supported formats and format modifiers is sent with
+  'format' and 'modifier' events.
 
   The following are required from clients:
 
@@ -107,12 +108,35 @@
 zwp_linux_buffer_params_v1::create request.
 
 XXX: Can a compositor ever enumerate them?
+
+Warning: the 'format' event is likely to be deprecated and replaced
+with the 'modifier' event introduced in zwp_linux_dmabuf_v1 version 3,
+described below. Please refrain from using the information received
+from this event.
   
   
 
+
+
+  
+This event advertises the formats that the server supports, along with
+the modifiers supported for each format. All the supported modifiers
+for all the supported formats are advertised once when the client
+binds to this interface. A roundtrip after binding guarantees that
+the client has received all supported format-modifier pairs.
+
+For the definition of the format and modifier codes, see the
+zwp_linux_buffer_params_v1::create request.
+  
+  
+  
+  
+
   
 
-  
+  
 
   This temporary object is a collection of dmabufs and other
   parameters that together form a single logical buffer. The temporary
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


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

2017-01-18 Thread Varad Gautam
From: Varad Gautam 

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

Signed-off-by: Varad Gautam 
---
 libweston/linux-dmabuf.c | 62 +++-
 1 file changed, 51 insertions(+), 11 deletions(-)

diff --git a/libweston/linux-dmabuf.c b/libweston/linux-dmabuf.c
index 7b29f08..d70e906 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,10 @@ 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,
+   /* send 'created' event when the request is not for an immediate
+* import, ie buffer_id is zero */
+   if (buffer_id == 0)
+   zwp_linux_buffer_params_v1_send_created(params_resource,
buffer->buffer_resource);
 
return;
@@ -280,17 +284,53 @@ err_buffer:
buffer->user_data_destroy_func(buffer);
 
 err_failed:
-   zwp_linux_buffer_params_v1_send_failed(params_resource);
+   if (buffer_id == 0)
+   zwp_linux_buffer_params_v1_send_failed(params_resource);
+   else
+   /* since the behavior is undefined by the protocol in this
+* case, we choose to treat it as an error and immediately
+* kill the client instead of returning an invalid handle and
+* waiting for it to be used.
+*/
+   wl_resource_post_error(params_resource,
+   ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_WL_BUFFER,
+   "importing the supplied dmabufs failed");
 
 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 +494,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

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2 2/2] clients/simple-dmabuf-intel: request no-roundtrip dmabuf import

2017-01-18 Thread Varad Gautam
From: Varad Gautam 

request immediate dmabuf import when run with "immed" arg.

Signed-off-by: Varad Gautam 
---
 clients/simple-dmabuf-intel.c | 36 +++-
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
index ec5f1cb..9917a74 100644
--- a/clients/simple-dmabuf-intel.c
+++ b/clients/simple-dmabuf-intel.c
@@ -54,6 +54,7 @@ struct display {
struct zwp_fullscreen_shell_v1 *fshell;
struct zwp_linux_dmabuf_v1 *dmabuf;
int xrgb_format_found;
+   int req_dmabuf_immediate;
 };
 
 struct buffer {
@@ -279,7 +280,16 @@ create_dmabuf_buffer(struct display *display, struct 
buffer *buffer,
   modifier >> 32,
   modifier & 0x);
zwp_linux_buffer_params_v1_add_listener(params, ¶ms_listener, 
buffer);
-   zwp_linux_buffer_params_v1_create(params,
+   if (display->req_dmabuf_immediate) {
+   buffer->buffer = zwp_linux_buffer_params_v1_create_immed(params,
+ buffer->width,
+ buffer->height,
+ DRM_FORMAT_XRGB,
+ flags);
+   wl_buffer_add_listener(buffer->buffer, &buffer_listener, 
buffer);
+   }
+   else
+   zwp_linux_buffer_params_v1_create(params,
  buffer->width,
  buffer->height,
  DRM_FORMAT_XRGB,
@@ -503,7 +513,8 @@ registry_handle_global(void *data, struct wl_registry 
*registry,
 id, 
&zwp_fullscreen_shell_v1_interface, 1);
} else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0) {
d->dmabuf = wl_registry_bind(registry,
-id, 
&zwp_linux_dmabuf_v1_interface, 1);
+id, &zwp_linux_dmabuf_v1_interface,
+d->req_dmabuf_immediate ? 2 : 1);
zwp_linux_dmabuf_v1_add_listener(d->dmabuf, &dmabuf_listener, 
d);
}
 }
@@ -520,7 +531,7 @@ static const struct wl_registry_listener registry_listener 
= {
 };
 
 static struct display *
-create_display(void)
+create_display(int is_immediate)
 {
struct display *display;
 
@@ -534,6 +545,7 @@ create_display(void)
 
/* XXX: fake, because the compositor does not yet advertise anything */
display->xrgb_format_found = 1;
+   display->req_dmabuf_immediate = is_immediate;
 
display->registry = wl_display_get_registry(display->display);
wl_registry_add_listener(display->registry,
@@ -587,9 +599,22 @@ main(int argc, char **argv)
struct sigaction sigint;
struct display *display;
struct window *window;
+   int is_immediate = 0;
int ret = 0;
 
-   display = create_display();
+   if (argc > 1) {
+   if (!strcmp(argv[1], "immed")) {
+   is_immediate = 1;
+   }
+   else {
+   fprintf(stderr, "usage:\n\tsimple-dmabuf-intel 
[options]\n"
+   "available options:\n\timmed: avoid dmabuf "
+   "creation roundtrip and import immediately\n");
+   return 1;
+   }
+   }
+
+   display = create_display(is_immediate);
window = create_window(display, 250, 250);
if (!window)
return 1;
@@ -599,7 +624,8 @@ main(int argc, char **argv)
sigint.sa_flags = SA_RESETHAND;
sigaction(SIGINT, &sigint, NULL);
 
-   /* Here we retrieve the linux-dmabuf objects, or error */
+   /* Here we retrieve the linux-dmabuf objects if executed without immed,
+* or error */
wl_display_roundtrip(display->display);
 
if (!running)
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH wayland-protocols v2] linux-dmabuf: add immediate dmabuf import path

2017-01-18 Thread Varad Gautam
From: Varad Gautam 

provide a mechanism that allows clients to import the added dmabufs
and immediately receive the newly created wl_buffer handle. this is
useful to clients that are sure of their import request succeeding,
and wish to avoid the wl_buffer communication roundtrip.

bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
versions.

v2: specify using incorrectly imported dmabufs as undefined behavior
instead of sending success/failure events. (pq, daniels)

Signed-off-by: Varad Gautam 
---
 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 39 ++
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index 60240f9..22e7af9 100644
--- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -26,13 +26,13 @@
 THIS SOFTWARE.
   
 
-  
+  
 
   Following the interfaces from:
   
https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
   and the Linux DRM sub-system's AddFb2 ioctl.
 
-  This interface offers a way to create generic dmabuf-based
+  This interface offers ways to create generic dmabuf-based
   wl_buffers. Immediately after a client binds to this interface,
   the set of supported formats is sent with 'format' events.
 
@@ -58,10 +58,15 @@
   To create a wl_buffer from one or more dmabufs, a client creates a
   zwp_linux_dmabuf_params_v1 object with a 
zwp_linux_dmabuf_v1.create_params
   request. All planes required by the intended format are added with
-  the 'add' request. Finally, a 'create' request is issued. The server
-  will reply with either a 'created' event which provides the final
+  the 'add' request. Finally, a 'create' or 'create_immed' request is
+  issued. Depending on the request, the server will:
+
+  - reply with either a 'created' event which provides the final
   wl_buffer or a 'failed' event saying that it cannot use the dmabufs
-  provided.
+  provided, in case of a 'create' request.
+
+  - return a newly created wl_buffer from the imported dmabufs, in case
+  of a 'create_immed' request.
 
   Warning! The protocol described in this file is experimental and
   backward incompatible changes may be made. Backward compatible changes
@@ -107,7 +112,7 @@
 
   
 
-  
+  
 
   This temporary object is a collection of dmabufs and other
   parameters that together form a single logical buffer. The temporary
@@ -140,6 +145,8 @@
  summary="invalid width or height"/>
   
+  
 
 
 
@@ -271,6 +278,26 @@
 zlinux_buffer_params object.
   
 
+
+
+  
+This asks for immediate creation of a wl_buffer from the added dmabufs
+and returns the newly created wl_buffer. The result of using a
+wl_buffer handle returned by this request is undefined in the case
+when the server fails to import the supplied dmabufs, and the server
+may raise an optional fatal invalid_wl_buffer error.
+
+This takes the same arguments as a 'create' request, and obeys the
+same restrictions.
+  
+  
+  
+  
+  
+  
+
+
   
 
 
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [wayland-protocols v3] linux-dmabuf: advertise format modifiers with modifier event

2017-01-17 Thread Varad Gautam
Hi,

On Tue, Jan 17, 2017 at 7:40 PM, Pekka Paalanen  wrote:
> On Mon, 21 Nov 2016 15:47:39 +0530
> Varad Gautam  wrote:
>
>> From: Varad Gautam 
>>
>> advertise the supported fourcc format modifiers along with supported
>> formats to the client.
>>
>> bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
>> versions to 3.
>>
>> v2: specify request name in event description for clarity (Yong Bakos)
>> v3: grammar fixup (Yong Bakos)
>>
>> Signed-off-by: Varad Gautam 
>> Reviewed-by: Yong Bakos 
>> ---
>>  unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 25 
>> +++---
>>  1 file changed, 22 insertions(+), 3 deletions(-)
>>
>> diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
>> b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
>> index a0aa42e..cc5d604 100644
>> --- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
>> +++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
>> @@ -26,7 +26,7 @@
>>  THIS SOFTWARE.
>>
>>
>> -  
>> +  
>>  
>>Following the interfaces from:
>>
>> https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
>> @@ -34,7 +34,8 @@
>>
>>This interface offers ways to create generic dmabuf-based
>>wl_buffers. Immediately after a client binds to this interface,
>> -  the set of supported formats is sent with 'format' events.
>> +  the set of supported formats and format modifiers is sent with
>> +  'format' and 'modifier' events.
>
> Hi,
>
> so does this mean that when v3 is bound, the client will receive *both*
> 'format' and 'modifier' events?
>
> What does it mean if a format comes via 'format' event but not via
> 'modifiers' event?
>
> Can a format come only via 'modifiers' event?

Bind triggers both `format` and `modifier` events. - the `format` event carries
only the DRM_FORMAT_* code, (preserved from v1), whereas `modifier`
sends a supported  pair. So, for each supported format,
there would be one `format` event, and as many `modifier` events as the
number of modifiers supported for that format.

Thanks,
Varad

>
> Otherwise looks fine to me. With those clarifications it's at least:
> Acked-by: Pekka Paalanen 
>
> The event size is 5 words which is 20 bytes. One wire buffer can hold
> around 200 such events. If we ever need to send more format/modifier
> combinations than that, well, I suppose we'll cross that bridge then.
>
>
> Thanks,
> pq
>
>>
>>The following are required from clients:
>>
>> @@ -110,9 +111,27 @@
>>
>>
>>  
>> +
>> +
>> +  
>> +This event advertises the formats that the server supports, along 
>> with
>> +the modifiers supported for each format. All the supported 
>> modifiers for
>> +all the supported formats are advertised once when the client binds 
>> to
>> +this interface. A roundtrip after binding guarantees that the client
>> +has received all supported format-modifier pairs.
>> +
>> +For the definition of the format and modifier codes, see the
>> +zwp_linux_buffer_params_v1::create request.
>> +  
>> +  
>> +  > +   summary="high 32 bits of layout modifier"/>
>> +  > +   summary="low 32 bits of layout modifier"/>
>> +
>>
>>
>> -  
>> +  
>>  
>>This temporary object is a collection of dmabufs and other
>>parameters that together form a single logical buffer. The temporary
>
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland-protocols, weston 0/10] format modifier support for linux-dmabuf

2017-01-11 Thread Varad Gautam
Hi Daniel,

Since the v2 appears to be botched up in patchwork, I've put a rebase
onto current master at [1][2]. Do you think we can merge the series yet?

The patches are on top of the roundtrip elimination bits at [3].

[1] 
https://git.collabora.com/cgit/user/varad/wayland-protocols.git/log/?h=dmabuf-modifiers
[2] https://git.collabora.com/cgit/user/varad/weston.git/log/?h=dmabuf-modifiers
[3] 
https://lists.freedesktop.org/archives/wayland-devel/2016-November/031537.html

Thanks,
Varad

On Thu, Nov 17, 2016 at 5:25 PM, Varad Gautam  wrote:
> Hello,
>
> This series amends the linux-dmabuf protocol to advertise supported dmabuf
> fourcc format modifiers on a platform, and implements format/modifier
> advertising and dmabuf import with modifiers in weston using
> EGL_EXT_image_dma_buf_import_modifiers. I have extended the 
> simple-dmabuf-intel
> client to work with freedreno to demonstrate the import path with modifiers
> using the DRM_FORMAT_NV12 + DRM_FORMAT_MOD_SAMSUNG_64_32_TILE format/modifier
> combination supported by the driver.
>
> The series is based upon the linux-dmabuf interface v2 patches at
> https://lists.freedesktop.org/archives/wayland-devel/2016-November/031537.html
> to keep the protocol versioning consistent. The complete series is available 
> at:
> git://git.collabora.com/git/user/varad/wayland-protocols.git dmabuf-modifiers
> git://git.collabora.com/git/user/varad/weston.git dmabuf-modifiers
>
> mesa with EGL_EXT_image_dma_buf_import_modifiers and modifier support in
> freedreno is located at:
> git://git.collabora.com/git/user/varad/mesa.git a3xx-nv12mt-sampling
>
> Thanks,
> Varad
>
> wayland-protocols:
> Varad Gautam (1):
>   linux-dmabuf: advertise format modifiers with modifier event
>
>  unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 24 
> +++---
>  1 file changed, 21 insertions(+), 3 deletions(-)
>
> weston:
> Varad Gautam (9):
>   gl-renderer: support format and modifier queries
>   linux-dmabuf: advertise supported formats and modifiers
>   gl-renderer: allow importing dmabufs with format modifiers
>   gl-renderer: allow importing fourth dmabuf plane
>   clients/simple-dmabuf-intel: rename to simple-dmabuf-drm
>   clients/simple-dmabuf-drm: add freedreno support alongside intel
>   clients/simple-dmabuf-drm: import with dmabuf modifiers
>   clients/simple-dmabuf-drm: add valid frame data to use with modifiers
>   clients/simple-dmabuf-drm: use tiled frame data with modifiers
>
>  Makefile.am  |   12 +-
>  clients/simple-dmabuf-drm-data.h | 3074 
> ++
>  clients/simple-dmabuf-drm.c  |  914 
>  clients/simple-dmabuf-intel.c|  668 -
>  configure.ac |   31 +-
>  libweston/compositor.h   |7 +
>  libweston/gl-renderer.c  |  125 +-
>  libweston/linux-dmabuf.c |   33 +-
>  libweston/weston-egl-ext.h   |   18 +
>  9 files changed, 4188 insertions(+), 694 deletions(-)
>  create mode 100644 clients/simple-dmabuf-drm-data.h
>  create mode 100644 clients/simple-dmabuf-drm.c
>  delete mode 100644 clients/simple-dmabuf-intel.c
>
> --
> 2.6.2
>
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v2] gl-renderer: support format and modifier queries

2016-11-23 Thread Varad Gautam
From: Varad Gautam 

EGL_EXT_image_dma_buf_import_modifiers allows querying the formats
and modifiers supported by the platform. expose these to the compositor.

v2:
 - change calloc args (Daniel Stone)
 - check for modifier support before querying formats (Daniel Stone)

Signed-off-by: Varad Gautam 
Reviewed-by: Daniel Stone 
---
 libweston/compositor.h |  7 
 libweston/gl-renderer.c| 85 +-
 libweston/weston-egl-ext.h |  7 
 3 files changed, 98 insertions(+), 1 deletion(-)

diff --git a/libweston/compositor.h b/libweston/compositor.h
index e00d285..a2848fb 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -675,6 +675,13 @@ struct weston_renderer {
/** See weston_compositor_import_dmabuf() */
bool (*import_dmabuf)(struct weston_compositor *ec,
  struct linux_dmabuf_buffer *buffer);
+
+   bool (*query_dmabuf_formats)(struct weston_compositor *ec,
+   int **formats, int *num_formats);
+
+   bool (*query_dmabuf_modifiers)(struct weston_compositor *ec,
+   int format, uint64_t **modifiers,
+   int *num_modifiers);
 };
 
 enum weston_capability {
diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 2f46373..77ae1a1 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -226,6 +226,10 @@ struct gl_renderer {
struct wl_signal destroy_signal;
 
struct wl_listener output_destroy_listener;
+
+   int has_dmabuf_import_modifiers;
+   PFNEGLQUERYDMABUFFORMATSEXTPROC query_dmabuf_formats;
+   PFNEGLQUERYDMABUFMODIFIERSEXTPROC query_dmabuf_modifiers;
 };
 
 static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
@@ -1847,6 +1851,70 @@ import_dmabuf(struct gl_renderer *gr,
 }
 
 static bool
+gl_renderer_query_dmabuf_formats(struct weston_compositor *wc,
+   int **formats, int *num_formats)
+{
+   struct gl_renderer *gr = get_renderer(wc);
+   EGLint num;
+
+   assert(gr->has_dmabuf_import);
+
+   if (!gr->has_dmabuf_import_modifiers ||
+   !gr->query_dmabuf_formats(gr->egl_display, 0, NULL, &num)) {
+   *num_formats = 0;
+   return false;
+   }
+
+   *formats = calloc(num, sizeof(int));
+   if (*formats == NULL) {
+   *num_formats = 0;
+   return false;
+   }
+   if (!gr->query_dmabuf_formats(gr->egl_display, num, *formats,
+   (EGLint*) &num)) {
+   *num_formats = 0;
+   free(*formats);
+   return false;
+   }
+
+   *num_formats = num;
+   return true;
+}
+
+static bool
+gl_renderer_query_dmabuf_modifiers(struct weston_compositor *wc, int format,
+   uint64_t **modifiers,
+   int *num_modifiers)
+{
+   struct gl_renderer *gr = get_renderer(wc);
+   int num;
+
+   assert(gr->has_dmabuf_import);
+
+   if (!gr->has_dmabuf_import_modifiers ||
+   !gr->query_dmabuf_modifiers(gr->egl_display, format, 0, NULL,
+   NULL, &num)) {
+   *num_modifiers = 0;
+   return false;
+   }
+
+   *modifiers = calloc(num, sizeof(uint64_t));
+   if (*modifiers == NULL) {
+   *num_modifiers = 0;
+   return false;
+   }
+   if (!gr->query_dmabuf_modifiers(gr->egl_display, format,
+   num, *modifiers, NULL, &num)) {
+   *num_modifiers = 0;
+   free(*modifiers);
+   return false;
+   }
+
+   *num_modifiers = num;
+   return true;
+}
+
+static bool
 gl_renderer_import_dmabuf(struct weston_compositor *ec,
  struct linux_dmabuf_buffer *dmabuf)
 {
@@ -2818,6 +2886,7 @@ gl_renderer_setup_egl_extensions(struct weston_compositor 
*ec)
 
gr->create_image = (void *) eglGetProcAddress("eglCreateImageKHR");
gr->destroy_image = (void *) eglGetProcAddress("eglDestroyImageKHR");
+
gr->bind_display =
(void *) eglGetProcAddress("eglBindWaylandDisplayWL");
gr->unbind_display =
@@ -2863,6 +2932,15 @@ gl_renderer_setup_egl_extensions(struct 
weston_compositor *ec)
if (weston_check_egl_extension(extensions, 
"EGL_EXT_image_dma_buf_import"))
gr->has_dmabuf_import = 1;
 
+   if (weston_check_egl_extension(extensions,
+   "EGL_EXT_image_dma_buf_import_modifiers")) {
+   gr->query_dmabuf_formats =
+   (void *) eglGetProcAddress("eglQueryDmaBufFormatsEXT");
+   gr->query_dmabuf_modifiers =
+   (

[PATCH v2] gl-renderer: allow importing fourth dmabuf plane

2016-11-23 Thread Varad Gautam
From: Varad Gautam 

EGL_EXT_image_dma_buf_import_modifiers supports importing upto four dmabuf
planes into an EGLImage.

v2: correct PLANE3_PITCH token (Daniel Stone)

Signed-off-by: Varad Gautam 
Reviewed-by: Daniel Stone 
---
 libweston/gl-renderer.c| 17 -
 libweston/weston-egl-ext.h |  5 +
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index a70f73c..98442f1 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -1558,7 +1558,7 @@ import_simple_dmabuf(struct gl_renderer *gr,
  struct dmabuf_attributes *attributes)
 {
struct egl_image *image;
-   EGLint attribs[40];
+   EGLint attribs[50];
int atti = 0;
 
/* This requires the Mesa commit in
@@ -1621,6 +1621,21 @@ import_simple_dmabuf(struct gl_renderer *gr,
}
}
 
+   if (gr->has_dmabuf_import_modifiers) {
+   if (attributes->n_planes > 3) {
+   attribs[atti++] = EGL_DMA_BUF_PLANE3_FD_EXT;
+   attribs[atti++] = attributes->fd[3];
+   attribs[atti++] = EGL_DMA_BUF_PLANE3_OFFSET_EXT;
+   attribs[atti++] = attributes->offset[3];
+   attribs[atti++] = EGL_DMA_BUF_PLANE3_PITCH_EXT;
+   attribs[atti++] = attributes->stride[3];
+   attribs[atti++] = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT;
+   attribs[atti++] = attributes->modifier[3] & 0x;
+   attribs[atti++] = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT;
+   attribs[atti++] = attributes->modifier[3] >> 32;
+   }
+   }
+
attribs[atti++] = EGL_NONE;
 
image = egl_image_create(gr, EGL_LINUX_DMA_BUF_EXT, NULL,
diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
index 05eca31..ffea438 100644
--- a/libweston/weston-egl-ext.h
+++ b/libweston/weston-egl-ext.h
@@ -128,12 +128,17 @@ typedef struct wl_buffer * (EGLAPIENTRYP 
PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) (
 /* Define tokens from EGL_EXT_image_dma_buf_import_modifiers */
 #ifndef EGL_EXT_image_dma_buf_import_modifiers
 #define EGL_EXT_image_dma_buf_import_modifiers 1
+#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440
+#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441
+#define EGL_DMA_BUF_PLANE3_PITCH_EXT  0x3442
 #define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443
 #define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444
 #define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445
 #define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446
 #define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447
 #define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448
+#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449
+#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLDisplay 
dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) 
(EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, 
EGLBoolean *external_only, EGLint *num_modifiers);
 #endif
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v2] clients/simple-dmabuf-drm: import with dmabuf modifiers

2016-11-23 Thread Varad Gautam
From: Varad Gautam 

mesa's freedreno driver supports importing dmabufs with format
DRM_FORMAT_NV12 and DRM_FORMAT_MOD_SAMSUNG_64_32_TILE modifier.
demonstrate weston modifier advertising and import path using this
combination when run with --import-format=NV12.

v2:
 - hard code format if platform doesn't implement
   EGL_EXT_image_dma_buf_import_modifiers and cannot advertise
   format/modifier support.
 - squash using valid frame data to fill dmabuf planes

Signed-off-by: Varad Gautam 
---
 Makefile.am |   4 +-
 clients/simple-dmabuf-drm.c | 185 +++-
 configure.ac|   2 +-
 3 files changed, 153 insertions(+), 38 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 3b58e29..7d4fad9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -584,7 +584,9 @@ endif
 
 if BUILD_SIMPLE_DMABUF_DRM_CLIENT
 demo_clients += weston-simple-dmabuf-drm
-weston_simple_dmabuf_drm_SOURCES = clients/simple-dmabuf-drm.c
+weston_simple_dmabuf_drm_SOURCES = \
+   clients/simple-dmabuf-drm.c \
+   clients/simple-dmabuf-drm-data.h
 nodist_weston_simple_dmabuf_drm_SOURCES =  \
protocol/xdg-shell-unstable-v6-protocol.c   \
protocol/xdg-shell-unstable-v6-client-protocol.h\
diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c
index 7cf0208..4934af2 100644
--- a/clients/simple-dmabuf-drm.c
+++ b/clients/simple-dmabuf-drm.c
@@ -23,6 +23,7 @@
  */
 
 #include "config.h"
+#include "simple-dmabuf-drm-data.h"
 
 #include 
 #include 
@@ -47,10 +48,12 @@
 
 #include 
 #include "shared/zalloc.h"
+#include "shared/platform.h"
 #include "xdg-shell-unstable-v6-client-protocol.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 #include "linux-dmabuf-unstable-v1-client-protocol.h"
 
+extern const unsigned nv12_tiled[];
 struct buffer;
 
 struct display {
@@ -61,7 +64,10 @@ struct display {
struct zwp_fullscreen_shell_v1 *fshell;
struct zwp_linux_dmabuf_v1 *dmabuf;
int xrgb_format_found;
+   int nv12_format_found;
+   int nv12_modifier_found;
int req_dmabuf_immediate;
+   int req_dmabuf_modifiers;
 };
 
 struct drm_device {
@@ -98,6 +104,7 @@ struct buffer {
int height;
int bpp;
unsigned long stride;
+   int format;
 };
 
 #define NUM_BUFFERS 3
@@ -246,11 +253,19 @@ fill_content(struct buffer *my_buf)
 
assert(my_buf->mmap);
 
-   for (y = 0; y < my_buf->height; y++) {
-   pix = (uint32_t *)(my_buf->mmap + y * my_buf->stride);
-   for (x = 0; x < my_buf->width; x++) {
-   *pix++ = (0xff << 24) | ((x % 256) << 16) |
-((y % 256) << 8) | 0xf0;
+   if (my_buf->format == DRM_FORMAT_NV12) {
+   pix = (uint32_t *) my_buf->mmap;
+   for (y = 0; y < my_buf->height; y++)
+   memcpy(&pix[y * my_buf->width / 4],
+  &nv12_tiled[my_buf->width * y / 4],
+  my_buf->width);
+   }
+   else {
+   for (y = 0; y < my_buf->height; y++) {
+   pix = (uint32_t *)(my_buf->mmap + y * my_buf->stride);
+   for (x = 0; x < my_buf->width; x++)
+   *pix++ = (0xff << 24) | ((x % 256) << 16) |
+((y % 256) << 8) | 0xf0;
}
}
 }
@@ -382,10 +397,10 @@ static const struct zwp_linux_buffer_params_v1_listener 
params_listener = {
 
 static int
 create_dmabuf_buffer(struct display *display, struct buffer *buffer,
-int width, int height)
+int width, int height, int format)
 {
struct zwp_linux_buffer_params_v1 *params;
-   uint64_t modifier;
+   uint64_t modifier = 0;
uint32_t flags;
struct drm_device *drm_dev;
 
@@ -396,8 +411,18 @@ create_dmabuf_buffer(struct display *display, struct 
buffer *buffer,
drm_dev = buffer->dev;
 
buffer->width = width;
-   buffer->height = height;
-   buffer->bpp = 32; /* hardcoded XRGB format */
+   switch (format) {
+   case DRM_FORMAT_NV12:
+   /* adjust height for allocation of NV12 Y and UV planes */
+   buffer->height = height * 3 / 2;
+   buffer->bpp = 8;
+   modifier = DRM_FORMAT_MOD_SAMSUNG_64_32_TILE;
+   break;
+   default:
+   buffer->height = height;
+   buffer->bpp = 32;
+   }
+   buffer->format = format;
 
if (!drm_dev->alloc_bo(buffer)) {
fprintf(stderr, "alloc_bo failed\n");
@@ -420,10 +445,

[PATCH v2] gl-renderer: allow importing dmabufs with format modifiers

2016-11-23 Thread Varad Gautam
From: Varad Gautam 

pass over the modifier attributes to EGL.

v2: ensure same modifier is passed for all planes (Daniel Stone)

Signed-off-by: Varad Gautam 
---
 libweston/gl-renderer.c| 29 ++---
 libweston/weston-egl-ext.h |  6 ++
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 77ae1a1..a70f73c 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -1558,7 +1558,7 @@ import_simple_dmabuf(struct gl_renderer *gr,
  struct dmabuf_attributes *attributes)
 {
struct egl_image *image;
-   EGLint attribs[30];
+   EGLint attribs[40];
int atti = 0;
 
/* This requires the Mesa commit in
@@ -1575,7 +1575,6 @@ import_simple_dmabuf(struct gl_renderer *gr,
attribs[atti++] = attributes->height;
attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
attribs[atti++] = attributes->format;
-   /* XXX: Add modifier here when supported */
 
if (attributes->n_planes > 0) {
attribs[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT;
@@ -1584,6 +1583,12 @@ import_simple_dmabuf(struct gl_renderer *gr,
attribs[atti++] = attributes->offset[0];
attribs[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
attribs[atti++] = attributes->stride[0];
+   if (gr->has_dmabuf_import_modifiers) {
+   attribs[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
+   attribs[atti++] = attributes->modifier[0] & 0x;
+   attribs[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
+   attribs[atti++] = attributes->modifier[0] >> 32;
+   }
}
 
if (attributes->n_planes > 1) {
@@ -1593,6 +1598,12 @@ import_simple_dmabuf(struct gl_renderer *gr,
attribs[atti++] = attributes->offset[1];
attribs[atti++] = EGL_DMA_BUF_PLANE1_PITCH_EXT;
attribs[atti++] = attributes->stride[1];
+   if (gr->has_dmabuf_import_modifiers) {
+   attribs[atti++] = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT;
+   attribs[atti++] = attributes->modifier[1] & 0x;
+   attribs[atti++] = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT;
+   attribs[atti++] = attributes->modifier[1] >> 32;
+   }
}
 
if (attributes->n_planes > 2) {
@@ -1602,6 +1613,12 @@ import_simple_dmabuf(struct gl_renderer *gr,
attribs[atti++] = attributes->offset[2];
attribs[atti++] = EGL_DMA_BUF_PLANE2_PITCH_EXT;
attribs[atti++] = attributes->stride[2];
+   if (gr->has_dmabuf_import_modifiers) {
+   attribs[atti++] = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT;
+   attribs[atti++] = attributes->modifier[2] & 0x;
+   attribs[atti++] = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT;
+   attribs[atti++] = attributes->modifier[2] >> 32;
+   }
}
 
attribs[atti++] = EGL_NONE;
@@ -1925,8 +1942,14 @@ gl_renderer_import_dmabuf(struct weston_compositor *ec,
assert(gr->has_dmabuf_import);
 
for (i = 0; i < dmabuf->attributes.n_planes; i++) {
-   /* EGL import does not have modifiers */
+   /* return if EGL doesn't support import modifiers */
if (dmabuf->attributes.modifier[i] != 0)
+   if (!gr->has_dmabuf_import_modifiers)
+   return false;
+
+   /* return if modifiers passed are unequal */
+   if (dmabuf->attributes.modifier[i] !=
+   dmabuf->attributes.modifier[0])
return false;
}
 
diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
index c7a3430..05eca31 100644
--- a/libweston/weston-egl-ext.h
+++ b/libweston/weston-egl-ext.h
@@ -128,6 +128,12 @@ typedef struct wl_buffer * (EGLAPIENTRYP 
PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) (
 /* Define tokens from EGL_EXT_image_dma_buf_import_modifiers */
 #ifndef EGL_EXT_image_dma_buf_import_modifiers
 #define EGL_EXT_image_dma_buf_import_modifiers 1
+#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443
+#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444
+#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445
+#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446
+#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447
+#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLDisplay 
dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) 
(EGLDisplay dpy, EGLint

[wayland-protocols v3] linux-dmabuf: advertise format modifiers with modifier event

2016-11-21 Thread Varad Gautam
From: Varad Gautam 

advertise the supported fourcc format modifiers along with supported
formats to the client.

bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
versions to 3.

v2: specify request name in event description for clarity (Yong Bakos)
v3: grammar fixup (Yong Bakos)

Signed-off-by: Varad Gautam 
Reviewed-by: Yong Bakos 
---
 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 25 +++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index a0aa42e..cc5d604 100644
--- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -26,7 +26,7 @@
 THIS SOFTWARE.
   
 
-  
+  
 
   Following the interfaces from:
   
https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
@@ -34,7 +34,8 @@
 
   This interface offers ways to create generic dmabuf-based
   wl_buffers. Immediately after a client binds to this interface,
-  the set of supported formats is sent with 'format' events.
+  the set of supported formats and format modifiers is sent with
+  'format' and 'modifier' events.
 
   The following are required from clients:
 
@@ -110,9 +111,27 @@
   
   
 
+
+
+  
+This event advertises the formats that the server supports, along with
+the modifiers supported for each format. All the supported modifiers 
for
+all the supported formats are advertised once when the client binds to
+this interface. A roundtrip after binding guarantees that the client
+has received all supported format-modifier pairs.
+
+For the definition of the format and modifier codes, see the
+zwp_linux_buffer_params_v1::create request.
+  
+  
+  
+  
+
   
 
-  
+  
 
   This temporary object is a collection of dmabufs and other
   parameters that together form a single logical buffer. The temporary
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[wayland-protocols v2] linux-dmabuf: clarify format event description

2016-11-21 Thread Varad Gautam
From: Varad Gautam 

clearly state the request name in format event to avoid abmiguous
interpretation between 'zwp_linux_buffer_params_v1::create' and
'zwp_linux_dmabuf_v1::create_params' requests.

v2: grammar fixup (Yong Bakos)

Suggested-by: Yong Bakos 
Signed-off-by: Varad Gautam 
Reviewed-by: Yong Bakos 
---
 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index cc5d604..0b22721 100644
--- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -105,7 +105,8 @@
 binds to this interface. A roundtrip after binding guarantees
 that the client has received all supported formats.
 
-For the definition of the format codes, see create request.
+For the definition of the format codes, see the
+zwp_linux_buffer_params_v1::create request.
 
 XXX: Can a compositor ever enumerate them?
   
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[wayland-protocols] linux-dmabuf: clarify format event description

2016-11-17 Thread Varad Gautam
From: Varad Gautam 

clearly state the request name in format event to avoid abmiguous
interpretation between 'zwp_linux_buffer_params_v1::create' and
'zwp_linux_dmabuf_v1::create_params' requests.

Suggested-by: Yong Bakos 
Signed-off-by: Varad Gautam 
---
 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index 3b008ee..c6aa2cd 100644
--- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -105,7 +105,8 @@
 binds to this interface. A roundtrip after binding guarantees
 that the client has received all supported formats.
 
-For the definition of the format codes, see create request.
+For the definition of the format codes, see
+zwp_linux_buffer_params_v1::create request.
 
 XXX: Can a compositor ever enumerate them?
   
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[wayland-protocols v2] linux-dmabuf: advertise format modifiers with modifier event

2016-11-17 Thread Varad Gautam
From: Varad Gautam 

advertise the supported fourcc format modifiers along with supported
formats to the client.

bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
versions to 3.

v2: specify request name in event description for clarity (Yong Bakos)

Signed-off-by: Varad Gautam 
---
 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 25 +++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index a0aa42e..3b008ee 100644
--- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -26,7 +26,7 @@
 THIS SOFTWARE.
   
 
-  
+  
 
   Following the interfaces from:
   
https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
@@ -34,7 +34,8 @@
 
   This interface offers ways to create generic dmabuf-based
   wl_buffers. Immediately after a client binds to this interface,
-  the set of supported formats is sent with 'format' events.
+  the set of supported formats and format modifiers is sent with
+  'format' and 'modifier' events.
 
   The following are required from clients:
 
@@ -110,9 +111,27 @@
   
   
 
+
+
+  
+This event advertises the formats that the server supports, along with
+the modifiers supported for each format. All the supported modifiers 
for
+all the supported formats are advertised once when the client binds to
+this interface. A roundtrip after binding guarantees that the client
+has received all supported format-modifier pairs.
+
+For the definition of the format and modifier codes, see
+zwp_linux_buffer_params_v1::create request.
+  
+  
+  
+  
+
   
 
-  
+  
 
   This temporary object is a collection of dmabufs and other
   parameters that together form a single logical buffer. The temporary
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 7/9] clients/simple-dmabuf-drm: import with dmabuf modifiers

2016-11-17 Thread Varad Gautam
From: Varad Gautam 

mesa's freedreno driver supports importing dmabufs with format
DRM_FORMAT_NV12 and DRM_FORMAT_MOD_SAMSUNG_64_32_TILE modifier.
demonstrate weston modifier advertising and import path using this
combination when run with --import-format=NV12.

Signed-off-by: Varad Gautam 
---
 clients/simple-dmabuf-drm.c | 157 +++-
 1 file changed, 125 insertions(+), 32 deletions(-)

diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c
index 7cf0208..9205138 100644
--- a/clients/simple-dmabuf-drm.c
+++ b/clients/simple-dmabuf-drm.c
@@ -61,7 +61,10 @@ struct display {
struct zwp_fullscreen_shell_v1 *fshell;
struct zwp_linux_dmabuf_v1 *dmabuf;
int xrgb_format_found;
+   int nv12_format_found;
+   int nv12_modifier_found;
int req_dmabuf_immediate;
+   int req_dmabuf_modifiers;
 };
 
 struct drm_device {
@@ -98,6 +101,7 @@ struct buffer {
int height;
int bpp;
unsigned long stride;
+   int format;
 };
 
 #define NUM_BUFFERS 3
@@ -243,12 +247,13 @@ fill_content(struct buffer *my_buf)
 {
int x = 0, y = 0;
uint32_t *pix;
+   int scale_w = my_buf->format == DRM_FORMAT_NV12 ? 4 : 1;
 
assert(my_buf->mmap);
 
for (y = 0; y < my_buf->height; y++) {
pix = (uint32_t *)(my_buf->mmap + y * my_buf->stride);
-   for (x = 0; x < my_buf->width; x++) {
+   for (x = 0; x < my_buf->width / scale_w; x++) {
*pix++ = (0xff << 24) | ((x % 256) << 16) |
 ((y % 256) << 8) | 0xf0;
}
@@ -382,10 +387,10 @@ static const struct zwp_linux_buffer_params_v1_listener 
params_listener = {
 
 static int
 create_dmabuf_buffer(struct display *display, struct buffer *buffer,
-int width, int height)
+int width, int height, int format)
 {
struct zwp_linux_buffer_params_v1 *params;
-   uint64_t modifier;
+   uint64_t modifier = 0;
uint32_t flags;
struct drm_device *drm_dev;
 
@@ -396,8 +401,18 @@ create_dmabuf_buffer(struct display *display, struct 
buffer *buffer,
drm_dev = buffer->dev;
 
buffer->width = width;
-   buffer->height = height;
-   buffer->bpp = 32; /* hardcoded XRGB format */
+   switch (format) {
+   case DRM_FORMAT_NV12:
+   /* adjust height for allocation of NV12 Y and UV planes */
+   buffer->height = height * 3 / 2;
+   buffer->bpp = 8;
+   modifier = DRM_FORMAT_MOD_SAMSUNG_64_32_TILE;
+   break;
+   default:
+   buffer->height = height;
+   buffer->bpp = 32;
+   }
+   buffer->format = format;
 
if (!drm_dev->alloc_bo(buffer)) {
fprintf(stderr, "alloc_bo failed\n");
@@ -420,10 +435,13 @@ create_dmabuf_buffer(struct display *display, struct 
buffer *buffer,
goto error2;
}
 
-   /* We now have a dmabuf! It should contain 2x2 tiles (i.e. each tile
-* is 256x256) of misc colours, and be mappable, either as ARGB, or
-* XRGB. */
-   modifier = 0;
+   /* We now have a dmabuf! For format XRGB, it should contain 2x2
+* tiles (i.e. each tile is 256x256) of misc colours, and be mappable,
+* either as ARGB, or XRGB. For format NV12, it should contain
+* the Y and UV components, and needs to be re-adjusted for passing the
+* correct height to the compositor.
+*/
+   buffer->height = height;
flags = 0;
 
params = zwp_linux_dmabuf_v1_create_params(display->dmabuf);
@@ -434,12 +452,23 @@ create_dmabuf_buffer(struct display *display, struct 
buffer *buffer,
   buffer->stride,
   modifier >> 32,
   modifier & 0x);
+
+   if (format == DRM_FORMAT_NV12) {
+   /* add the second plane params */
+   zwp_linux_buffer_params_v1_add(params,
+  buffer->dmabuf_fd,
+  1,
+  buffer->width * buffer->height,
+  buffer->stride,
+  modifier >> 32,
+  modifier & 0x);
+   }
zwp_linux_buffer_params_v1_add_listener(params, ¶ms_listener, 
buffer);
if (display->req_dmabuf_immediate) {
buffer->buffer = zwp_linux_buffer_params_v1_create_immed(params,
  buffer->width,
  

[PATCH weston 9/9] clients/simple-dmabuf-drm: use tiled frame data with modifiers

2016-11-17 Thread Varad Gautam
From: Varad Gautam 

fill the dmabuf with valid DRM_FORMAT_NV12 +
DRM_FORMAT_MOD_SAMSUNG_64_32_TILE frame data before importing to display
a non-gibberish pattern when importing with modifiers.

Signed-off-by: Varad Gautam 
---
 clients/simple-dmabuf-drm.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c
index 9205138..c2b9ad0 100644
--- a/clients/simple-dmabuf-drm.c
+++ b/clients/simple-dmabuf-drm.c
@@ -23,6 +23,7 @@
  */
 
 #include "config.h"
+#include "simple-dmabuf-drm-data.h"
 
 #include 
 #include 
@@ -51,6 +52,7 @@
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 #include "linux-dmabuf-unstable-v1-client-protocol.h"
 
+extern const unsigned nv12_tiled[];
 struct buffer;
 
 struct display {
@@ -247,15 +249,22 @@ fill_content(struct buffer *my_buf)
 {
int x = 0, y = 0;
uint32_t *pix;
-   int scale_w = my_buf->format == DRM_FORMAT_NV12 ? 4 : 1;
 
assert(my_buf->mmap);
 
-   for (y = 0; y < my_buf->height; y++) {
-   pix = (uint32_t *)(my_buf->mmap + y * my_buf->stride);
-   for (x = 0; x < my_buf->width / scale_w; x++) {
-   *pix++ = (0xff << 24) | ((x % 256) << 16) |
-((y % 256) << 8) | 0xf0;
+   if (my_buf->format == DRM_FORMAT_NV12) {
+   pix = (uint32_t *) my_buf->mmap;
+   for (y = 0; y < my_buf->height; y++)
+   memcpy(&pix[y * my_buf->width / 4],
+  &nv12_tiled[my_buf->width * y / 4],
+  my_buf->width);
+   }
+   else {
+   for (y = 0; y < my_buf->height; y++) {
+   pix = (uint32_t *)(my_buf->mmap + y * my_buf->stride);
+   for (x = 0; x < my_buf->width; x++)
+   *pix++ = (0xff << 24) | ((x % 256) << 16) |
+((y % 256) << 8) | 0xf0;
}
}
 }
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 3/9] gl-renderer: allow importing dmabufs with format modifiers

2016-11-17 Thread Varad Gautam
From: Varad Gautam 

pass over the modifier attributes to EGL.

Signed-off-by: Varad Gautam 
---
 libweston/gl-renderer.c| 26 ++
 libweston/weston-egl-ext.h |  6 ++
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 444b07a..31caf33 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -1558,7 +1558,7 @@ import_simple_dmabuf(struct gl_renderer *gr,
  struct dmabuf_attributes *attributes)
 {
struct egl_image *image;
-   EGLint attribs[30];
+   EGLint attribs[40];
int atti = 0;
 
/* This requires the Mesa commit in
@@ -1575,7 +1575,6 @@ import_simple_dmabuf(struct gl_renderer *gr,
attribs[atti++] = attributes->height;
attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
attribs[atti++] = attributes->format;
-   /* XXX: Add modifier here when supported */
 
if (attributes->n_planes > 0) {
attribs[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT;
@@ -1584,6 +1583,12 @@ import_simple_dmabuf(struct gl_renderer *gr,
attribs[atti++] = attributes->offset[0];
attribs[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT;
attribs[atti++] = attributes->stride[0];
+   if (gr->has_dmabuf_import_modifiers) {
+   attribs[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
+   attribs[atti++] = attributes->modifier[0] & 0x;
+   attribs[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
+   attribs[atti++] = attributes->modifier[0] >> 32;
+   }
}
 
if (attributes->n_planes > 1) {
@@ -1593,6 +1598,12 @@ import_simple_dmabuf(struct gl_renderer *gr,
attribs[atti++] = attributes->offset[1];
attribs[atti++] = EGL_DMA_BUF_PLANE1_PITCH_EXT;
attribs[atti++] = attributes->stride[1];
+   if (gr->has_dmabuf_import_modifiers) {
+   attribs[atti++] = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT;
+   attribs[atti++] = attributes->modifier[1] & 0x;
+   attribs[atti++] = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT;
+   attribs[atti++] = attributes->modifier[1] >> 32;
+   }
}
 
if (attributes->n_planes > 2) {
@@ -1602,6 +1613,12 @@ import_simple_dmabuf(struct gl_renderer *gr,
attribs[atti++] = attributes->offset[2];
attribs[atti++] = EGL_DMA_BUF_PLANE2_PITCH_EXT;
attribs[atti++] = attributes->stride[2];
+   if (gr->has_dmabuf_import_modifiers) {
+   attribs[atti++] = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT;
+   attribs[atti++] = attributes->modifier[2] & 0x;
+   attribs[atti++] = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT;
+   attribs[atti++] = attributes->modifier[2] >> 32;
+   }
}
 
attribs[atti++] = EGL_NONE;
@@ -1924,9 +1941,10 @@ gl_renderer_import_dmabuf(struct weston_compositor *ec,
assert(gr->has_dmabuf_import);
 
for (i = 0; i < dmabuf->attributes.n_planes; i++) {
-   /* EGL import does not have modifiers */
+   /* return if EGL doesn't support import modifiers */
if (dmabuf->attributes.modifier[i] != 0)
-   return false;
+   if (!gr->has_dmabuf_import_modifiers)
+   return false;
}
 
/* reject all flags we do not recognize or handle */
diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
index c7a3430..05eca31 100644
--- a/libweston/weston-egl-ext.h
+++ b/libweston/weston-egl-ext.h
@@ -128,6 +128,12 @@ typedef struct wl_buffer * (EGLAPIENTRYP 
PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) (
 /* Define tokens from EGL_EXT_image_dma_buf_import_modifiers */
 #ifndef EGL_EXT_image_dma_buf_import_modifiers
 #define EGL_EXT_image_dma_buf_import_modifiers 1
+#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443
+#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444
+#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445
+#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446
+#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447
+#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLDisplay 
dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) 
(EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, 
EGLBoolean *external_only, EGLint *num_modifiers);
 #endif
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 5/9] clients/simple-dmabuf-intel: rename to simple-dmabuf-drm

2016-11-17 Thread Varad Gautam
From: Varad Gautam 

this will allow adding other drm backends later.

Signed-off-by: Varad Gautam 
---
 Makefile.am   |  12 +-
 clients/simple-dmabuf-drm.c   | 668 ++
 clients/simple-dmabuf-intel.c | 668 --
 configure.ac  |  22 +-
 4 files changed, 685 insertions(+), 685 deletions(-)
 create mode 100644 clients/simple-dmabuf-drm.c
 delete mode 100644 clients/simple-dmabuf-intel.c

diff --git a/Makefile.am b/Makefile.am
index b08ce71..5a7fadb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -582,18 +582,18 @@ weston_simple_egl_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_EGL_CLIENT_CFLAGS)
 weston_simple_egl_LDADD = $(SIMPLE_EGL_CLIENT_LIBS) -lm
 endif
 
-if BUILD_SIMPLE_DMABUF_INTEL_CLIENT
-demo_clients += weston-simple-dmabuf-intel
-weston_simple_dmabuf_intel_SOURCES = clients/simple-dmabuf-intel.c
-nodist_weston_simple_dmabuf_intel_SOURCES =\
+if BUILD_SIMPLE_DMABUF_DRM_CLIENT
+demo_clients += weston-simple-dmabuf-drm
+weston_simple_dmabuf_drm_SOURCES = clients/simple-dmabuf-drm.c
+nodist_weston_simple_dmabuf_drm_SOURCES =  \
protocol/xdg-shell-unstable-v6-protocol.c   \
protocol/xdg-shell-unstable-v6-client-protocol.h\
protocol/fullscreen-shell-unstable-v1-protocol.c\
protocol/fullscreen-shell-unstable-v1-client-protocol.h \
protocol/linux-dmabuf-unstable-v1-protocol.c \
protocol/linux-dmabuf-unstable-v1-client-protocol.h
-weston_simple_dmabuf_intel_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_INTEL_CLIENT_CFLAGS)
-weston_simple_dmabuf_intel_LDADD = $(SIMPLE_DMABUF_INTEL_CLIENT_LIBS) 
libshared.la
+weston_simple_dmabuf_drm_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_DRM_CLIENT_CFLAGS)
+weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) libshared.la
 BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
 endif
 
diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c
new file mode 100644
index 000..fad420a
--- /dev/null
+++ b/clients/simple-dmabuf-drm.c
@@ -0,0 +1,668 @@
+/*
+ * Copyright © 2011 Benjamin Franzke
+ * Copyright © 2010 Intel Corporation
+ * Copyright © 2014 Collabora Ltd.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include "config.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "shared/zalloc.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
+#include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "linux-dmabuf-unstable-v1-client-protocol.h"
+
+struct display {
+   struct wl_display *display;
+   struct wl_registry *registry;
+   struct wl_compositor *compositor;
+   struct zxdg_shell_v6 *shell;
+   struct zwp_fullscreen_shell_v1 *fshell;
+   struct zwp_linux_dmabuf_v1 *dmabuf;
+   int xrgb_format_found;
+   int req_dmabuf_immediate;
+};
+
+struct buffer {
+   struct wl_buffer *buffer;
+   int busy;
+
+   int drm_fd;
+
+   drm_intel_bufmgr *bufmgr;
+   drm_intel_bo *bo;
+
+   uint32_t gem_handle;
+   int dmabuf_fd;
+   uint8_t *mmap;
+
+   int width;
+   int height;
+   int bpp;
+   unsigned long stride;
+};
+
+#define NUM_BUFFERS 3
+
+struct window {
+   struct display *display;
+   int width, height;
+   struct wl_surface *surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
+   struct buffer buffers[NUM_BUFFERS];
+   struct buffer *prev_buffer;
+   struct wl_callback *callback;
+   bool initialized;
+   bool wait_for_configure;
+};
+
+static int running = 1;
+
+static void
+re

[PATCH weston 6/9] clients/simple-dmabuf-drm: add freedreno support alongside intel

2016-11-17 Thread Varad Gautam
From: Varad Gautam 

abstract drm specific bits to struct drm_device and support running on
freedreno.

Signed-off-by: Varad Gautam 
---
 Makefile.am |   2 +-
 clients/simple-dmabuf-drm.c | 214 
 configure.ac|  19 ++--
 3 files changed, 194 insertions(+), 41 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 5a7fadb..3b58e29 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -593,7 +593,7 @@ nodist_weston_simple_dmabuf_drm_SOURCES =   \
protocol/linux-dmabuf-unstable-v1-protocol.c \
protocol/linux-dmabuf-unstable-v1-client-protocol.h
 weston_simple_dmabuf_drm_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_DRM_CLIENT_CFLAGS)
-weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) libshared.la
+weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) 
$(LIBDRM_PLATFORM_LIBS) libshared.la
 BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
 endif
 
diff --git a/clients/simple-dmabuf-drm.c b/clients/simple-dmabuf-drm.c
index fad420a..7cf0208 100644
--- a/clients/simple-dmabuf-drm.c
+++ b/clients/simple-dmabuf-drm.c
@@ -36,8 +36,13 @@
 #include 
 
 #include 
+
+#ifdef HAVE_LIBDRM_INTEL
 #include 
 #include 
+#elif HAVE_LIBDRM_FREEDRENO
+#include 
+#endif
 #include 
 
 #include 
@@ -46,6 +51,8 @@
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 #include "linux-dmabuf-unstable-v1-client-protocol.h"
 
+struct buffer;
+
 struct display {
struct wl_display *display;
struct wl_registry *registry;
@@ -57,14 +64,31 @@ struct display {
int req_dmabuf_immediate;
 };
 
+struct drm_device {
+   int fd;
+   char *name;
+
+   int (*alloc_bo)(struct buffer *buf);
+   void (*free_bo)(struct buffer *buf);
+   int (*export_bo_to_prime)(struct buffer *buf);
+   int (*map_bo)(struct buffer *buf);
+   void (*unmap_bo)(struct buffer *buf);
+};
+
 struct buffer {
struct wl_buffer *buffer;
int busy;
 
+   struct drm_device *dev;
int drm_fd;
 
+#ifdef HAVE_LIBDRM_INTEL
drm_intel_bufmgr *bufmgr;
drm_intel_bo *bo;
+#elif HAVE_LIBDRM_FREEDRENO
+   struct fd_device *fd_dev;
+   struct fd_bo *bo;
+#endif /* HAVE_LIBDRM_FREEDRENO */
 
uint32_t gem_handle;
int dmabuf_fd;
@@ -108,31 +132,10 @@ static const struct wl_buffer_listener buffer_listener = {
buffer_release
 };
 
-static int
-drm_connect(struct buffer *my_buf)
-{
-   /* This won't work with card0 as we need to be authenticated; instead,
-* boot with drm.rnodes=1 and use that. */
-   my_buf->drm_fd = open("/dev/dri/renderD128", O_RDWR);
-   if (my_buf->drm_fd < 0)
-   return 0;
-
-   my_buf->bufmgr = drm_intel_bufmgr_gem_init(my_buf->drm_fd, 32);
-   if (!my_buf->bufmgr)
-   return 0;
-
-   return 1;
-}
-
-static void
-drm_shutdown(struct buffer *my_buf)
-{
-   drm_intel_bufmgr_destroy(my_buf->bufmgr);
-   close(my_buf->drm_fd);
-}
 
+#ifdef HAVE_LIBDRM_INTEL
 static int
-alloc_bo(struct buffer *my_buf)
+intel_alloc_bo(struct buffer *my_buf)
 {
/* XXX: try different tiling modes for testing FB modifiers. */
uint32_t tiling = I915_TILING_NONE;
@@ -157,13 +160,13 @@ alloc_bo(struct buffer *my_buf)
 }
 
 static void
-free_bo(struct buffer *my_buf)
+intel_free_bo(struct buffer *my_buf)
 {
drm_intel_bo_unreference(my_buf->bo);
 }
 
 static int
-map_bo(struct buffer *my_buf)
+intel_map_bo(struct buffer *my_buf)
 {
if (drm_intel_gem_bo_map_gtt(my_buf->bo) != 0)
return 0;
@@ -173,6 +176,68 @@ map_bo(struct buffer *my_buf)
return 1;
 }
 
+static int
+intel_bo_export_to_prime(struct buffer *buffer)
+{
+   return drm_intel_bo_gem_export_to_prime(buffer->bo, &buffer->dmabuf_fd);
+}
+
+static void
+intel_unmap_bo(struct buffer *my_buf)
+{
+   drm_intel_gem_bo_unmap_gtt(my_buf->bo);
+}
+#elif HAVE_LIBDRM_FREEDRENO
+#define ALIGN(v, a) ((v + a - 1) & ~(a - 1))
+
+static
+int fd_alloc_bo(struct buffer *buf)
+{
+   int flags = DRM_FREEDRENO_GEM_CACHE_WCOMBINE;
+   int size = buf->width * buf->height * buf->bpp / 8;
+   buf->fd_dev = fd_device_new(buf->drm_fd);
+
+   buf->bo = fd_bo_new(buf->fd_dev, size, flags);
+
+   if (!buf->bo)
+   return 0;
+   buf->stride = ALIGN(buf->width, 32) * buf->bpp / 8;
+   return 1;
+}
+
+static
+void fd_free_bo(struct buffer *buf)
+{
+   fd_bo_del(buf->bo);
+}
+
+static
+int fd_bo_export_to_prime(struct buffer *buf)
+{
+   buf->dmabuf_fd = fd_bo_dmabuf(buf->bo);
+   if (buf->dmabuf_fd > 0)
+   return 0;
+
+   return 1;
+}
+
+static
+int fd_map_bo(struct buffer *buf)
+{
+   buf->mmap = fd_bo_map(buf->bo);
+
+   if (buf->mmap != NULL)
+   return

[PATCH weston 2/9] linux-dmabuf: advertise supported formats and modifiers

2016-11-17 Thread Varad Gautam
From: Varad Gautam 

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 
---
 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] & 0x;
+   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

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 4/9] gl-renderer: allow importing fourth dmabuf plane

2016-11-17 Thread Varad Gautam
From: Varad Gautam 

EGL_EXT_image_dma_buf_import_modifiers supports importing upto four dmabuf
planes into an EGLImage.

Signed-off-by: Varad Gautam 
---
 libweston/gl-renderer.c| 17 -
 libweston/weston-egl-ext.h |  5 +
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 31caf33..de03f51 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -1558,7 +1558,7 @@ import_simple_dmabuf(struct gl_renderer *gr,
  struct dmabuf_attributes *attributes)
 {
struct egl_image *image;
-   EGLint attribs[40];
+   EGLint attribs[50];
int atti = 0;
 
/* This requires the Mesa commit in
@@ -1621,6 +1621,21 @@ import_simple_dmabuf(struct gl_renderer *gr,
}
}
 
+   if (gr->has_dmabuf_import_modifiers) {
+   if (attributes->n_planes > 3) {
+   attribs[atti++] = EGL_DMA_BUF_PLANE3_FD_EXT;
+   attribs[atti++] = attributes->fd[3];
+   attribs[atti++] = EGL_DMA_BUF_PLANE3_OFFSET_EXT;
+   attribs[atti++] = attributes->offset[3];
+   attribs[atti++] = EGL_DMA_BUF_PLANE2_PITCH_EXT;
+   attribs[atti++] = attributes->stride[3];
+   attribs[atti++] = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT;
+   attribs[atti++] = attributes->modifier[3] & 0x;
+   attribs[atti++] = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT;
+   attribs[atti++] = attributes->modifier[3] >> 32;
+   }
+   }
+
attribs[atti++] = EGL_NONE;
 
image = egl_image_create(gr, EGL_LINUX_DMA_BUF_EXT, NULL,
diff --git a/libweston/weston-egl-ext.h b/libweston/weston-egl-ext.h
index 05eca31..ffea438 100644
--- a/libweston/weston-egl-ext.h
+++ b/libweston/weston-egl-ext.h
@@ -128,12 +128,17 @@ typedef struct wl_buffer * (EGLAPIENTRYP 
PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL) (
 /* Define tokens from EGL_EXT_image_dma_buf_import_modifiers */
 #ifndef EGL_EXT_image_dma_buf_import_modifiers
 #define EGL_EXT_image_dma_buf_import_modifiers 1
+#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440
+#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441
+#define EGL_DMA_BUF_PLANE3_PITCH_EXT  0x3442
 #define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443
 #define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444
 #define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445
 #define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446
 #define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447
 #define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448
+#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449
+#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLDisplay 
dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats);
 typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) 
(EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, 
EGLBoolean *external_only, EGLint *num_modifiers);
 #endif
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH wayland-protocols, weston 0/10] format modifier support for linux-dmabuf

2016-11-17 Thread Varad Gautam
Hello,

This series amends the linux-dmabuf protocol to advertise supported dmabuf
fourcc format modifiers on a platform, and implements format/modifier
advertising and dmabuf import with modifiers in weston using
EGL_EXT_image_dma_buf_import_modifiers. I have extended the simple-dmabuf-intel
client to work with freedreno to demonstrate the import path with modifiers
using the DRM_FORMAT_NV12 + DRM_FORMAT_MOD_SAMSUNG_64_32_TILE format/modifier
combination supported by the driver.

The series is based upon the linux-dmabuf interface v2 patches at
https://lists.freedesktop.org/archives/wayland-devel/2016-November/031537.html
to keep the protocol versioning consistent. The complete series is available at:
git://git.collabora.com/git/user/varad/wayland-protocols.git dmabuf-modifiers
git://git.collabora.com/git/user/varad/weston.git dmabuf-modifiers

mesa with EGL_EXT_image_dma_buf_import_modifiers and modifier support in
freedreno is located at:
git://git.collabora.com/git/user/varad/mesa.git a3xx-nv12mt-sampling

Thanks,
Varad

wayland-protocols:
Varad Gautam (1):
  linux-dmabuf: advertise format modifiers with modifier event

 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 24 +++---
 1 file changed, 21 insertions(+), 3 deletions(-)

weston:
Varad Gautam (9):
  gl-renderer: support format and modifier queries
  linux-dmabuf: advertise supported formats and modifiers
  gl-renderer: allow importing dmabufs with format modifiers
  gl-renderer: allow importing fourth dmabuf plane
  clients/simple-dmabuf-intel: rename to simple-dmabuf-drm
  clients/simple-dmabuf-drm: add freedreno support alongside intel
  clients/simple-dmabuf-drm: import with dmabuf modifiers
  clients/simple-dmabuf-drm: add valid frame data to use with modifiers
  clients/simple-dmabuf-drm: use tiled frame data with modifiers

 Makefile.am  |   12 +-
 clients/simple-dmabuf-drm-data.h | 3074 ++
 clients/simple-dmabuf-drm.c  |  914 
 clients/simple-dmabuf-intel.c|  668 -
 configure.ac |   31 +-
 libweston/compositor.h   |7 +
 libweston/gl-renderer.c  |  125 +-
 libweston/linux-dmabuf.c |   33 +-
 libweston/weston-egl-ext.h   |   18 +
 9 files changed, 4188 insertions(+), 694 deletions(-)
 create mode 100644 clients/simple-dmabuf-drm-data.h
 create mode 100644 clients/simple-dmabuf-drm.c
 delete mode 100644 clients/simple-dmabuf-intel.c

-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/9] gl-renderer: support format and modifier queries

2016-11-17 Thread Varad Gautam
From: Varad Gautam 

EGL_EXT_image_dma_buf_import_modifiers allows querying the formats
and modifiers supported by the platform. expose these to the compositor.

Signed-off-by: Varad Gautam 
---
 libweston/compositor.h |  7 
 libweston/gl-renderer.c| 84 +-
 libweston/weston-egl-ext.h |  7 
 3 files changed, 97 insertions(+), 1 deletion(-)

diff --git a/libweston/compositor.h b/libweston/compositor.h
index e00d285..a2848fb 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -675,6 +675,13 @@ struct weston_renderer {
/** See weston_compositor_import_dmabuf() */
bool (*import_dmabuf)(struct weston_compositor *ec,
  struct linux_dmabuf_buffer *buffer);
+
+   bool (*query_dmabuf_formats)(struct weston_compositor *ec,
+   int **formats, int *num_formats);
+
+   bool (*query_dmabuf_modifiers)(struct weston_compositor *ec,
+   int format, uint64_t **modifiers,
+   int *num_modifiers);
 };
 
 enum weston_capability {
diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 2f46373..444b07a 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -226,6 +226,10 @@ struct gl_renderer {
struct wl_signal destroy_signal;
 
struct wl_listener output_destroy_listener;
+
+   int has_dmabuf_import_modifiers;
+   PFNEGLQUERYDMABUFFORMATSEXTPROC query_dmabuf_formats;
+   PFNEGLQUERYDMABUFMODIFIERSEXTPROC query_dmabuf_modifiers;
 };
 
 static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
@@ -1847,6 +1851,69 @@ import_dmabuf(struct gl_renderer *gr,
 }
 
 static bool
+gl_renderer_query_dmabuf_formats(struct weston_compositor *wc,
+   int **formats, int *num_formats)
+{
+   struct gl_renderer *gr = get_renderer(wc);
+   EGLint num;
+
+   assert(gr->has_dmabuf_import);
+
+   if (!gr->query_dmabuf_formats(gr->egl_display, 0, NULL, &num)) {
+   *num_formats = 0;
+   return false;
+   }
+
+   *formats = calloc(1, num * sizeof(int));
+   if (*formats == NULL) {
+   *num_formats = 0;
+   return false;
+   }
+   if (!gr->query_dmabuf_formats(gr->egl_display, num, *formats,
+   (EGLint*) &num)) {
+   *num_formats = 0;
+   free(*formats);
+   return false;
+   }
+
+   *num_formats = num;
+   return true;
+}
+
+static bool
+gl_renderer_query_dmabuf_modifiers(struct weston_compositor *wc, int format,
+   uint64_t **modifiers,
+   int *num_modifiers)
+{
+   struct gl_renderer *gr = get_renderer(wc);
+   int num;
+
+   assert(gr->has_dmabuf_import);
+
+   if (!gr->has_dmabuf_import_modifiers ||
+   !gr->query_dmabuf_modifiers(gr->egl_display, format, 0, NULL,
+   NULL, &num)) {
+   *num_modifiers = 0;
+   return false;
+   }
+
+   *modifiers = calloc(1, num * sizeof(uint64_t));
+   if (*modifiers == NULL) {
+   *num_modifiers = 0;
+   return false;
+   }
+   if (!gr->query_dmabuf_modifiers(gr->egl_display, format,
+   num, *modifiers, NULL, &num)) {
+   *num_modifiers = 0;
+   free(*modifiers);
+   return false;
+   }
+
+   *num_modifiers = num;
+   return true;
+}
+
+static bool
 gl_renderer_import_dmabuf(struct weston_compositor *ec,
  struct linux_dmabuf_buffer *dmabuf)
 {
@@ -2818,6 +2885,9 @@ gl_renderer_setup_egl_extensions(struct weston_compositor 
*ec)
 
gr->create_image = (void *) eglGetProcAddress("eglCreateImageKHR");
gr->destroy_image = (void *) eglGetProcAddress("eglDestroyImageKHR");
+   gr->query_dmabuf_formats =
+   (void *) eglGetProcAddress("eglQueryDmaBufFormatsEXT");
+
gr->bind_display =
(void *) eglGetProcAddress("eglBindWaylandDisplayWL");
gr->unbind_display =
@@ -2863,6 +2933,13 @@ gl_renderer_setup_egl_extensions(struct 
weston_compositor *ec)
if (weston_check_egl_extension(extensions, 
"EGL_EXT_image_dma_buf_import"))
gr->has_dmabuf_import = 1;
 
+   if (weston_check_egl_extension(extensions,
+   "EGL_EXT_image_dma_buf_import_modifiers")) {
+   gr->query_dmabuf_modifiers =
+   (void *) 
eglGetProcAddress("eglQueryDmaBufModifiersEXT");
+   gr->has_dmabuf_import_modifiers = 1;
+   }
+
if (weston_check_egl_extension(extensions, "GL_EXT_texture_

[wayland-protocols] linux-dmabuf: advertise format modifiers with modifier event

2016-11-17 Thread Varad Gautam
From: Varad Gautam 

advertise the supported fourcc format modifiers along with supported
formats to the client.

bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
versions to 3.

Signed-off-by: Varad Gautam 
---
 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 24 +++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index a0aa42e..b60483b 100644
--- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -26,7 +26,7 @@
 THIS SOFTWARE.
   
 
-  
+  
 
   Following the interfaces from:
   
https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
@@ -34,7 +34,8 @@
 
   This interface offers ways to create generic dmabuf-based
   wl_buffers. Immediately after a client binds to this interface,
-  the set of supported formats is sent with 'format' events.
+  the set of supported formats and format modifiers is sent with
+  'format' and 'modifier' events.
 
   The following are required from clients:
 
@@ -110,9 +111,26 @@
   
   
 
+
+
+  
+This event advertises the formats that the server supports, along with
+the modifiers supported for each format. All the supported modifiers 
for
+all the supported formats are advertised once when the client binds to
+this interface. A roundtrip after binding guarantees that the client
+has received all supported format-modifier pairs.
+
+For the definition of the format and modifier codes, see create 
request.
+  
+  
+  
+  
+
   
 
-  
+  
 
   This temporary object is a collection of dmabufs and other
   parameters that together form a single logical buffer. The temporary
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH wayland-protocols, weston] Extend linux-dmabuf to bypass roundtrip during dmabuf import

2016-11-11 Thread Varad Gautam
Hello,

This patchset provides an immediate path to import dmabufs into a
wl_buffer to avoid the round-trip wait a client must face to receive
the buffer handle.

Previous discussion: https://phabricator.freedesktop.org/T7570

Varad

wayland-protocols:

Varad Gautam (1):
  linux-dmabuf: add immediate dmabuf import path

 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 58 +++---
 1 file changed, 52 insertions(+), 6 deletions(-)
  
weston:

Varad Gautam (2):
  linux-dmabuf: implement immediate dmabuf import
  clients/simple-dmabuf-intel: request no-roundtrip dmabuf import
 
 clients/simple-dmabuf-intel.c | 59 ++-
 libweston/linux-dmabuf.c  | 56 
 2 files changed, 98 insertions(+), 17 deletions(-)

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[wayland-protocols] linux-dmabuf: add immediate dmabuf import path

2016-11-11 Thread Varad Gautam
From: Varad Gautam 

provide a mechanism that allows clients to import the added dmabufs
and immediately receive the newly created wl_buffer handle. this is
useful to clients that are sure of their import request succeeding,
and wish to avoid the wl_buffer communication roundtrip.

bump zwp_linux_dmabuf_v1, zwp_linux_buffer_params_v1 interface
versions.

Signed-off-by: Varad Gautam 
---
 unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 58 +++---
 1 file changed, 52 insertions(+), 6 deletions(-)

diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml 
b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index 3b4861f..a0aa42e 100644
--- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -26,13 +26,13 @@
 THIS SOFTWARE.
   
 
-  
+  
 
   Following the interfaces from:
   
https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt
   and the Linux DRM sub-system's AddFb2 ioctl.
 
-  This interface offers a way to create generic dmabuf-based
+  This interface offers ways to create generic dmabuf-based
   wl_buffers. Immediately after a client binds to this interface,
   the set of supported formats is sent with 'format' events.
 
@@ -58,10 +58,16 @@
   To create a wl_buffer from one or more dmabufs, a client creates a
   zwp_linux_dmabuf_params_v1 object with a 
zwp_linux_dmabuf_v1.create_params
   request. All planes required by the intended format are added with
-  the 'add' request. Finally, a 'create' request is issued. The server
-  will reply with either a 'created' event which provides the final
+  the 'add' request. Finally, a 'create' or 'create_immed' request is
+  issued. Depending on the request, the server will:
+
+  - reply with either a 'created' event which provides the final
   wl_buffer or a 'failed' event saying that it cannot use the dmabufs
-  provided.
+  provided, in case of a 'create' request.
+
+  - reply with either a 'created_immed' event or a 'failed_immed' event to
+  notify successful wl_buffer creation, in case of a 'create_immed'
+  request. The created wl_buffer is returned to the client by the request.
 
   Warning! The protocol described in this file is experimental and
   backward incompatible changes may be made. Backward compatible changes
@@ -106,7 +112,7 @@
 
   
 
-  
+  
 
   This temporary object is a collection of dmabufs and other
   parameters that together form a single logical buffer. The temporary
@@ -255,6 +261,25 @@
   
 
 
+
+  
+This asks for immediate creation of a wl_buffer from added dmabufs and
+returns the newly created wl_buffer. On successful creation, a
+'created_immed' event is triggered that can be used to verify that the
+wl_buffer received from this request is a valid handle. A 
'failed_immed'
+event notifies unsuccessful dmabuf import.
+
+This takes the same arguments as a 'create' request, and obeys the
+same restrictions.
+  
+  
+  
+  
+  
+  
+
+
 
   
 This event indicates that the attempted buffer creation was
@@ -277,6 +302,27 @@
 zlinux_buffer_params object.
   
 
+
+
+  
+This event notifies the success of 'create_immed' request.
+
+Upon receiving this event, the client should destroy the
+zlinux_dmabuf_params object.
+  
+
+
+
+  
+This event indicates that the attempted immediate buffer creation has
+failed. It usually means that one of the dmabuf constraints has not
+been fulfilled.
+
+Upon receiving this event, the client should destroy the
+zlinux_buffer_params object.
+  
+
+
   
 
 
-- 
2.6.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[weston 2/2] clients/simple-dmabuf-intel: request no-roundtrip dmabuf import

2016-11-11 Thread Varad Gautam
From: Varad Gautam 

request immediate dmabuf import when run with "immed" arg.

Signed-off-by: Varad Gautam 
---
 clients/simple-dmabuf-intel.c | 59 ++-
 1 file changed, 53 insertions(+), 6 deletions(-)

diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
index ec5f1cb..fad420a 100644
--- a/clients/simple-dmabuf-intel.c
+++ b/clients/simple-dmabuf-intel.c
@@ -54,6 +54,7 @@ struct display {
struct zwp_fullscreen_shell_v1 *fshell;
struct zwp_linux_dmabuf_v1 *dmabuf;
int xrgb_format_found;
+   int req_dmabuf_immediate;
 };
 
 struct buffer {
@@ -221,9 +222,30 @@ create_failed(void *data, struct 
zwp_linux_buffer_params_v1 *params)
fprintf(stderr, "Error: zwp_linux_buffer_params.create failed.\n");
 }
 
+static void
+create_immed_succeeded(void *data,
+  struct zwp_linux_buffer_params_v1 *params)
+{
+   /* XXX: keep track of successfully created wl_buffers*/
+
+   zwp_linux_buffer_params_v1_destroy(params);
+}
+
+static void
+create_immed_failed(void *data,
+   struct zwp_linux_buffer_params_v1 *params)
+{
+   /* XXX: sad trombone sound */
+
+   zwp_linux_buffer_params_v1_destroy(params);
+   fprintf(stderr, "Error: zwp_linux_buffer_params.create_immed 
failed.\n");
+}
+
 static const struct zwp_linux_buffer_params_v1_listener params_listener = {
create_succeeded,
-   create_failed
+   create_failed,
+   create_immed_succeeded,
+   create_immed_failed
 };
 
 static int
@@ -279,7 +301,16 @@ create_dmabuf_buffer(struct display *display, struct 
buffer *buffer,
   modifier >> 32,
   modifier & 0x);
zwp_linux_buffer_params_v1_add_listener(params, ¶ms_listener, 
buffer);
-   zwp_linux_buffer_params_v1_create(params,
+   if (display->req_dmabuf_immediate) {
+   buffer->buffer = zwp_linux_buffer_params_v1_create_immed(params,
+ buffer->width,
+ buffer->height,
+ DRM_FORMAT_XRGB,
+ flags);
+   wl_buffer_add_listener(buffer->buffer, &buffer_listener, 
buffer);
+   }
+   else
+   zwp_linux_buffer_params_v1_create(params,
  buffer->width,
  buffer->height,
  DRM_FORMAT_XRGB,
@@ -503,7 +534,8 @@ registry_handle_global(void *data, struct wl_registry 
*registry,
 id, 
&zwp_fullscreen_shell_v1_interface, 1);
} else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0) {
d->dmabuf = wl_registry_bind(registry,
-id, 
&zwp_linux_dmabuf_v1_interface, 1);
+id, &zwp_linux_dmabuf_v1_interface,
+d->req_dmabuf_immediate ? 2 : 1);
zwp_linux_dmabuf_v1_add_listener(d->dmabuf, &dmabuf_listener, 
d);
}
 }
@@ -520,7 +552,7 @@ static const struct wl_registry_listener registry_listener 
= {
 };
 
 static struct display *
-create_display(void)
+create_display(int is_immediate)
 {
struct display *display;
 
@@ -534,6 +566,7 @@ create_display(void)
 
/* XXX: fake, because the compositor does not yet advertise anything */
display->xrgb_format_found = 1;
+   display->req_dmabuf_immediate = is_immediate;
 
display->registry = wl_display_get_registry(display->display);
wl_registry_add_listener(display->registry,
@@ -587,9 +620,22 @@ main(int argc, char **argv)
struct sigaction sigint;
struct display *display;
struct window *window;
+   int is_immediate = 0;
int ret = 0;
 
-   display = create_display();
+   if (argc > 1) {
+   if (!strcmp(argv[1], "immed")) {
+   is_immediate = 1;
+   }
+   else {
+   fprintf(stderr, "usage:\n\tsimple-dmabuf-intel 
[options]\n"
+   "available options:\n\timmed: avoid dmabuf "
+   "creation roundtrip and import immediately\n");
+   return 1;
+   }
+   }
+
+   display = create_display(is_immediate);
window = create_window(display, 250, 250);
if (!window)
return 1;
@@ -599,7 +645,8 @@ main(int argc, char **argv)
sigint.sa_flags = SA_RESETHAND;
sigaction(SIGINT, &sigint, NULL);
 
-   /* Here we retrieve the linux-dmabuf objects

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

2016-11-11 Thread Varad Gautam
From: Varad Gautam 

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

Signed-off-by: Varad Gautam 
---
 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

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel