[PATCH] Add wl_dmabuf protocol

Benjamin Gaignard benjamin.gaignard at linaro.org
Tue Dec 10 01:50:50 PST 2013


Hi,

For me mmap capability means that both server and client can call
mmap() on the provided file descriptor.
I have no simple way to know if the driver support mmap().
The better option I see today is to create a dumb buffer and to try to
mmap it at server initialization.
Anyway client and server should always test the result of mmap() to be
sure that the pointer is valid.

About multiple gfx device, I will re-introduce device name capability
(at it was in wl_drm), I think that could solve this issue.

Regards,
Benjamin

2013/12/9 Pekka Paalanen <ppaalanen at gmail.com>:
> On Thu,  5 Dec 2013 18:36:38 +0100
> benjamin.gaignard at linaro.org wrote:
>
>> From: Benjamin Gaignard <benjamin.gaignard at linaro.org>
>>
>> It allow to use a dmabuf file descriptor in a wayland protocol.
>> To make as generic as possible it is up to the server to call
>> wl_dmabuf_send_format() and/or wl_dmabuf_send_capabilities() to signal
>> it capabilities.
>>
>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard at linaro.org>
>> ---
>>  protocol/Makefile.am        |    6 +-
>>  protocol/wayland-dmabuf.xml |  134 +++++++++++++++++++++
>>  src/Makefile.am             |   12 +-
>>  src/wayland-dmabuf.c        |  275
>> +++++++++++++++++++++++++++++++++++++++++++
>> src/wayland-dmabuf.h        |  134 +++++++++++++++++++++ 5 files
>> changed, 557 insertions(+), 4 deletions(-) create mode 100644
>> protocol/wayland-dmabuf.xml create mode 100644 src/wayland-dmabuf.c
>>  create mode 100644 src/wayland-dmabuf.h
>>
>> diff --git a/protocol/Makefile.am b/protocol/Makefile.am
>> index e8b6290..8c9499f 100644
>> --- a/protocol/Makefile.am
>> +++ b/protocol/Makefile.am
>> @@ -1,4 +1,4 @@
>> -dist_pkgdata_DATA = wayland.xml wayland.dtd
>> +dist_pkgdata_DATA = wayland.xml wayland-dmabuf.xml wayland.dtd
>>
>>  if HAVE_XMLLINT
>>  .PHONY: validate
>> @@ -6,9 +6,9 @@ if HAVE_XMLLINT
>>  .%.xml.valid: %.xml
>>       $(AM_V_GEN)$(XMLLINT) --noout --dtdvalid
>> $(srcdir)/wayland.dtd $^ > $@
>> -validate: .wayland.xml.valid
>> +validate: .wayland.xml.valid .wayland-dmabuf.xml.valid
>>
>>  all-local: validate
>>
>> -CLEANFILES = .wayland.xml.valid
>> +CLEANFILES = .wayland.xml.valid .wayland-dmabuf.xml.valid
>>  endif
>> diff --git a/protocol/wayland-dmabuf.xml b/protocol/wayland-dmabuf.xml
>> new file mode 100644
>> index 0000000..b3b7ded
>> --- /dev/null
>> +++ b/protocol/wayland-dmabuf.xml
>> @@ -0,0 +1,134 @@
>> +<?xml version="1.0" encoding="UTF-8"?>
>> +<protocol name="dmabuf">
>> +
>> +  <copyright>
>> +    Copyright © 2008-2011 Kristian Høgsberg
>> +    Copyright © 2010-2011 Intel Corporation
>> +
>> +    Permission to use, copy, modify, distribute, and sell this
>> +    software and its documentation for any purpose is hereby granted
>> +    without fee, provided that\n 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.
>> +  </copyright>
>> +
>> +  <!-- dmabuf support. This object is created by the server and
>> published
>> +       using the display's global event. -->
>> +  <interface name="wl_dmabuf" version="1">
>> +    <enum name="error">
>> +             <entry name="invalid_format" value="1"/>
>> +             <entry name="invalid_file_descriptor" value="2"/>
>> +    </enum>
>> +
>> +    <enum name="format">
>> +      <!-- The dmabuf format codes match the #defines in
>> drm_fourcc.h.
>> +           The formats actually supported by the compositor will be
>> +           reported by the format event. -->
>> +      <entry name="c8" value="0x20203843"/>
>> +      <entry name="rgb332" value="0x38424752"/>
>> +      <entry name="bgr233" value="0x38524742"/>
>> +      <entry name="xrgb4444" value="0x32315258"/>
>> +      <entry name="xbgr4444" value="0x32314258"/>
>> +      <entry name="rgbx4444" value="0x32315852"/>
>> +      <entry name="bgrx4444" value="0x32315842"/>
>> +      <entry name="argb4444" value="0x32315241"/>
>> +      <entry name="abgr4444" value="0x32314241"/>
>> +      <entry name="rgba4444" value="0x32314152"/>
>> +      <entry name="bgra4444" value="0x32314142"/>
>> +      <entry name="xrgb1555" value="0x35315258"/>
>> +      <entry name="xbgr1555" value="0x35314258"/>
>> +      <entry name="rgbx5551" value="0x35315852"/>
>> +      <entry name="bgrx5551" value="0x35315842"/>
>> +      <entry name="argb1555" value="0x35315241"/>
>> +      <entry name="abgr1555" value="0x35314241"/>
>> +      <entry name="rgba5551" value="0x35314152"/>
>> +      <entry name="bgra5551" value="0x35314142"/>
>> +      <entry name="rgb565" value="0x36314752"/>
>> +      <entry name="bgr565" value="0x36314742"/>
>> +      <entry name="rgb888" value="0x34324752"/>
>> +      <entry name="bgr888" value="0x34324742"/>
>> +      <entry name="xrgb8888" value="0x34325258"/>
>> +      <entry name="xbgr8888" value="0x34324258"/>
>> +      <entry name="rgbx8888" value="0x34325852"/>
>> +      <entry name="bgrx8888" value="0x34325842"/>
>> +      <entry name="argb8888" value="0x34325241"/>
>> +      <entry name="abgr8888" value="0x34324241"/>
>> +      <entry name="rgba8888" value="0x34324152"/>
>> +      <entry name="bgra8888" value="0x34324142"/>
>> +      <entry name="xrgb2101010" value="0x30335258"/>
>> +      <entry name="xbgr2101010" value="0x30334258"/>
>> +      <entry name="rgbx1010102" value="0x30335852"/>
>> +      <entry name="bgrx1010102" value="0x30335842"/>
>> +      <entry name="argb2101010" value="0x30335241"/>
>> +      <entry name="abgr2101010" value="0x30334241"/>
>> +      <entry name="rgba1010102" value="0x30334152"/>
>> +      <entry name="bgra1010102" value="0x30334142"/>
>> +      <entry name="yuyv" value="0x56595559"/>
>> +      <entry name="yvyu" value="0x55595659"/>
>> +      <entry name="uyvy" value="0x59565955"/>
>> +      <entry name="vyuy" value="0x59555956"/>
>> +      <entry name="ayuv" value="0x56555941"/>
>> +      <entry name="nv12" value="0x3231564e"/>
>> +      <entry name="nv21" value="0x3132564e"/>
>> +      <entry name="nv16" value="0x3631564e"/>
>> +      <entry name="nv61" value="0x3136564e"/>
>> +      <entry name="yuv410" value="0x39565559"/>
>> +      <entry name="yvu410" value="0x39555659"/>
>> +      <entry name="yuv411" value="0x31315559"/>
>> +      <entry name="yvu411" value="0x31315659"/>
>> +      <entry name="yuv420" value="0x32315559"/>
>> +      <entry name="yvu420" value="0x32315659"/>
>> +      <entry name="yuv422" value="0x36315559"/>
>> +      <entry name="yvu422" value="0x36315659"/>
>> +      <entry name="yuv444" value="0x34325559"/>
>> +      <entry name="yvu444" value="0x34325659"/>
>> +    </enum>
>> +
>> +    <!-- Create a wayland buffer for the prime fd.  Use for regular
>> and planar
>> +         buffers.  Pass 0 for offset and stride for unused planes.
>> -->
>> +    <request name="create_prime_buffer">
>> +      <arg name="id" type="new_id" interface="wl_buffer"/>
>> +      <arg name="name" type="fd"/>
>> +      <arg name="width" type="int"/>
>> +      <arg name="height" type="int"/>
>> +      <arg name="format" type="uint"/>
>> +      <arg name="offset0" type="int"/>
>> +      <arg name="stride0" type="int"/>
>> +      <arg name="offset1" type="int"/>
>> +      <arg name="stride1" type="int"/>
>> +      <arg name="offset2" type="int"/>
>> +      <arg name="stride2" type="int"/>
>> +    </request>
>> +
>> +     <event name="format">
>> +      <arg name="format" type="uint"/>
>> +    </event>
>> +
>> +    <enum name="capability">
>> +      <description summary="wl_dmabuf capability bitmask">
>> +        Bitmask of capabilities.
>> +      </description>
>> +      <entry name="mmap" value="1" summary="wl_dmabuf mmap
>> available"/>
>> +    </enum>
>> +
>> +    <event name="capabilities">
>> +      <arg name="value" type="uint"/>
>> +    </event>
>> +  </interface>
>> +
>> +</protocol>
>
> Hi,
>
> what does the "mmap" capability bit actually mean? How is it used?
>
> I have heard that not all drivers supporting dma-buf do mmap(), but how
> does that reflect here? Is the mmap-capability dependent on the
> exporting driver only?
>
> What I mean is, if it is the Wayland client that chooses the device, and
> so the exporting driver, how could the Wayland server be telling the
> client if mmap is supported?
>
> Or does the "mmap" instead mean, that the server is able to call mmap()
> on dma-buf based wl_buffers? Or does it mean that the server will
> *always* use mmap(), and the client must provide compatible buffers?
>
> Does this protocol design work, if there are two (exporting?) gfx
> devices for clients to choose from, one mmap-capable and the other not?
>
> I think the intention for the mmap capability would need more
> documentation in the protocol.
>
>
> Thanks,
> pq



-- 
Benjamin Gaignard

Graphic Working Group

Linaro.org │ Open source software for ARM SoCs

Follow Linaro: Facebook | Twitter | Blog


More information about the wayland-devel mailing list