Path: blob/main/gpu_display/protocol/linux-dmabuf-unstable-v1.xml
5394 views
<?xml version="1.0" encoding="UTF-8"?>1<protocol name="linux_dmabuf_unstable_v1">23<copyright>4Copyright © 2014, 2015 Collabora, Ltd.56Permission is hereby granted, free of charge, to any person obtaining a7copy of this software and associated documentation files (the "Software"),8to deal in the Software without restriction, including without limitation9the rights to use, copy, modify, merge, publish, distribute, sublicense,10and/or sell copies of the Software, and to permit persons to whom the11Software is furnished to do so, subject to the following conditions:1213The above copyright notice and this permission notice (including the next14paragraph) shall be included in all copies or substantial portions of the15Software.1617THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL20THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING22FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER23DEALINGS IN THE SOFTWARE.24</copyright>2526<interface name="zwp_linux_dmabuf_v1" version="3">27<description summary="factory for creating dmabuf-based wl_buffers">28Following the interfaces from:29https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_image_dma_buf_import.txt30and the Linux DRM sub-system's AddFb2 ioctl.3132This interface offers ways to create generic dmabuf-based33wl_buffers. Immediately after a client binds to this interface,34the set of supported formats and format modifiers is sent with35'format' and 'modifier' events.3637The following are required from clients:3839- Clients must ensure that either all data in the dma-buf is40coherent for all subsequent read access or that coherency is41correctly handled by the underlying kernel-side dma-buf42implementation.4344- Don't make any more attachments after sending the buffer to the45compositor. Making more attachments later increases the risk of46the compositor not being able to use (re-import) an existing47dmabuf-based wl_buffer.4849The underlying graphics stack must ensure the following:5051- The dmabuf file descriptors relayed to the server will stay valid52for the whole lifetime of the wl_buffer. This means the server may53at any time use those fds to import the dmabuf into any kernel54sub-system that might accept it.5556To create a wl_buffer from one or more dmabufs, a client creates a57zwp_linux_dmabuf_params_v1 object with a zwp_linux_dmabuf_v1.create_params58request. All planes required by the intended format are added with59the 'add' request. Finally, a 'create' or 'create_immed' request is60issued, which has the following outcome depending on the import success.6162The 'create' request,63- on success, triggers a 'created' event which provides the final64wl_buffer to the client.65- on failure, triggers a 'failed' event to convey that the server66cannot use the dmabufs received from the client.6768For the 'create_immed' request,69- on success, the server immediately imports the added dmabufs to70create a wl_buffer. No event is sent from the server in this case.71- on failure, the server can choose to either:72- terminate the client by raising a fatal error.73- mark the wl_buffer as failed, and send a 'failed' event to the74client. If the client uses a failed wl_buffer as an argument to any75request, the behaviour is compositor implementation-defined.7677Warning! The protocol described in this file is experimental and78backward incompatible changes may be made. Backward compatible changes79may be added together with the corresponding interface version bump.80Backward incompatible changes are done by bumping the version number in81the protocol and interface names and resetting the interface version.82Once the protocol is to be declared stable, the 'z' prefix and the83version number in the protocol and interface names are removed and the84interface version number is reset.85</description>8687<request name="destroy" type="destructor">88<description summary="unbind the factory">89Objects created through this interface, especially wl_buffers, will90remain valid.91</description>92</request>9394<request name="create_params">95<description summary="create a temporary object for buffer parameters">96This temporary object is used to collect multiple dmabuf handles into97a single batch to create a wl_buffer. It can only be used once and98should be destroyed after a 'created' or 'failed' event has been99received.100</description>101<arg name="params_id" type="new_id" interface="zwp_linux_buffer_params_v1"102summary="the new temporary"/>103</request>104105<event name="format">106<description summary="supported buffer format">107This event advertises one buffer format that the server supports.108All the supported formats are advertised once when the client109binds to this interface. A roundtrip after binding guarantees110that the client has received all supported formats.111112For the definition of the format codes, see the113zwp_linux_buffer_params_v1::create request.114115Warning: the 'format' event is likely to be deprecated and replaced116with the 'modifier' event introduced in zwp_linux_dmabuf_v1117version 3, described below. Please refrain from using the information118received from this event.119</description>120<arg name="format" type="uint" summary="DRM_FORMAT code"/>121</event>122123<event name="modifier" since="3">124<description summary="supported buffer format modifier">125This event advertises the formats that the server supports, along with126the modifiers supported for each format. All the supported modifiers127for all the supported formats are advertised once when the client128binds to this interface. A roundtrip after binding guarantees that129the client has received all supported format-modifier pairs.130131For the definition of the format and modifier codes, see the132zwp_linux_buffer_params_v1::create request.133</description>134<arg name="format" type="uint" summary="DRM_FORMAT code"/>135<arg name="modifier_hi" type="uint"136summary="high 32 bits of layout modifier"/>137<arg name="modifier_lo" type="uint"138summary="low 32 bits of layout modifier"/>139</event>140</interface>141142<interface name="zwp_linux_buffer_params_v1" version="3">143<description summary="parameters for creating a dmabuf-based wl_buffer">144This temporary object is a collection of dmabufs and other145parameters that together form a single logical buffer. The temporary146object may eventually create one wl_buffer unless cancelled by147destroying it before requesting 'create'.148149Single-planar formats only require one dmabuf, however150multi-planar formats may require more than one dmabuf. For all151formats, an 'add' request must be called once per plane (even if the152underlying dmabuf fd is identical).153154You must use consecutive plane indices ('plane_idx' argument for 'add')155from zero to the number of planes used by the drm_fourcc format code.156All planes required by the format must be given exactly once, but can157be given in any order. Each plane index can be set only once.158</description>159160<enum name="error">161<entry name="already_used" value="0"162summary="the dmabuf_batch object has already been used to create a wl_buffer"/>163<entry name="plane_idx" value="1"164summary="plane index out of bounds"/>165<entry name="plane_set" value="2"166summary="the plane index was already set"/>167<entry name="incomplete" value="3"168summary="missing or too many planes to create a buffer"/>169<entry name="invalid_format" value="4"170summary="format not supported"/>171<entry name="invalid_dimensions" value="5"172summary="invalid width or height"/>173<entry name="out_of_bounds" value="6"174summary="offset + stride * height goes out of dmabuf bounds"/>175<entry name="invalid_wl_buffer" value="7"176summary="invalid wl_buffer resulted from importing dmabufs via177the create_immed request on given buffer_params"/>178</enum>179180<request name="destroy" type="destructor">181<description summary="delete this object, used or not">182Cleans up the temporary data sent to the server for dmabuf-based183wl_buffer creation.184</description>185</request>186187<request name="add">188<description summary="add a dmabuf to the temporary set">189This request adds one dmabuf to the set in this190zwp_linux_buffer_params_v1.191192The 64-bit unsigned value combined from modifier_hi and modifier_lo193is the dmabuf layout modifier. DRM AddFB2 ioctl calls this the194fb modifier, which is defined in drm_mode.h of Linux UAPI.195This is an opaque token. Drivers use this token to express tiling,196compression, etc. driver-specific modifications to the base format197defined by the DRM fourcc code.198199This request raises the PLANE_IDX error if plane_idx is too large.200The error PLANE_SET is raised if attempting to set a plane that201was already set.202</description>203<arg name="fd" type="fd" summary="dmabuf fd"/>204<arg name="plane_idx" type="uint" summary="plane index"/>205<arg name="offset" type="uint" summary="offset in bytes"/>206<arg name="stride" type="uint" summary="stride in bytes"/>207<arg name="modifier_hi" type="uint"208summary="high 32 bits of layout modifier"/>209<arg name="modifier_lo" type="uint"210summary="low 32 bits of layout modifier"/>211</request>212213<enum name="flags">214<entry name="y_invert" value="1" summary="contents are y-inverted"/>215<entry name="interlaced" value="2" summary="content is interlaced"/>216<entry name="bottom_first" value="4" summary="bottom field first"/>217</enum>218219<request name="create">220<description summary="create a wl_buffer from the given dmabufs">221This asks for creation of a wl_buffer from the added dmabuf222buffers. The wl_buffer is not created immediately but returned via223the 'created' event if the dmabuf sharing succeeds. The sharing224may fail at runtime for reasons a client cannot predict, in225which case the 'failed' event is triggered.226227The 'format' argument is a DRM_FORMAT code, as defined by the228libdrm's drm_fourcc.h. The Linux kernel's DRM sub-system is the229authoritative source on how the format codes should work.230231The 'flags' is a bitfield of the flags defined in enum "flags".232'y_invert' means the that the image needs to be y-flipped.233234Flag 'interlaced' means that the frame in the buffer is not235progressive as usual, but interlaced. An interlaced buffer as236supported here must always contain both top and bottom fields.237The top field always begins on the first pixel row. The temporal238ordering between the two fields is top field first, unless239'bottom_first' is specified. It is undefined whether 'bottom_first'240is ignored if 'interlaced' is not set.241242This protocol does not convey any information about field rate,243duration, or timing, other than the relative ordering between the244two fields in one buffer. A compositor may have to estimate the245intended field rate from the incoming buffer rate. It is undefined246whether the time of receiving wl_surface.commit with a new buffer247attached, applying the wl_surface state, wl_surface.frame callback248trigger, presentation, or any other point in the compositor cycle249is used to measure the frame or field times. There is no support250for detecting missed or late frames/fields/buffers either, and251there is no support whatsoever for cooperating with interlaced252compositor output.253254The composited image quality resulting from the use of interlaced255buffers is explicitly undefined. A compositor may use elaborate256hardware features or software to deinterlace and create progressive257output frames from a sequence of interlaced input buffers, or it258may produce substandard image quality. However, compositors that259cannot guarantee reasonable image quality in all cases are recommended260to just reject all interlaced buffers.261262Any argument errors, including non-positive width or height,263mismatch between the number of planes and the format, bad264format, bad offset or stride, may be indicated by fatal protocol265errors: INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS,266OUT_OF_BOUNDS.267268Dmabuf import errors in the server that are not obvious client269bugs are returned via the 'failed' event as non-fatal. This270allows attempting dmabuf sharing and falling back in the client271if it fails.272273This request can be sent only once in the object's lifetime, after274which the only legal request is destroy. This object should be275destroyed after issuing a 'create' request. Attempting to use this276object after issuing 'create' raises ALREADY_USED protocol error.277278It is not mandatory to issue 'create'. If a client wants to279cancel the buffer creation, it can just destroy this object.280</description>281<arg name="width" type="int" summary="base plane width in pixels"/>282<arg name="height" type="int" summary="base plane height in pixels"/>283<arg name="format" type="uint" summary="DRM_FORMAT code"/>284<arg name="flags" type="uint" summary="see enum flags"/>285</request>286287<event name="created">288<description summary="buffer creation succeeded">289This event indicates that the attempted buffer creation was290successful. It provides the new wl_buffer referencing the dmabuf(s).291292Upon receiving this event, the client should destroy the293zlinux_dmabuf_params object.294</description>295<arg name="buffer" type="new_id" interface="wl_buffer"296summary="the newly created wl_buffer"/>297</event>298299<event name="failed">300<description summary="buffer creation failed">301This event indicates that the attempted buffer creation has302failed. It usually means that one of the dmabuf constraints303has not been fulfilled.304305Upon receiving this event, the client should destroy the306zlinux_buffer_params object.307</description>308</event>309310<request name="create_immed" since="2">311<description summary="immediately create a wl_buffer from the given312dmabufs">313This asks for immediate creation of a wl_buffer by importing the314added dmabufs.315316In case of import success, no event is sent from the server, and the317wl_buffer is ready to be used by the client.318319Upon import failure, either of the following may happen, as seen fit320by the implementation:321- the client is terminated with one of the following fatal protocol322errors:323- INCOMPLETE, INVALID_FORMAT, INVALID_DIMENSIONS, OUT_OF_BOUNDS,324in case of argument errors such as mismatch between the number325of planes and the format, bad format, non-positive width or326height, or bad offset or stride.327- INVALID_WL_BUFFER, in case the cause for failure is unknown or328plaform specific.329- the server creates an invalid wl_buffer, marks it as failed and330sends a 'failed' event to the client. The result of using this331invalid wl_buffer as an argument in any request by the client is332defined by the compositor implementation.333334This takes the same arguments as a 'create' request, and obeys the335same restrictions.336</description>337<arg name="buffer_id" type="new_id" interface="wl_buffer"338summary="id for the newly created wl_buffer"/>339<arg name="width" type="int" summary="base plane width in pixels"/>340<arg name="height" type="int" summary="base plane height in pixels"/>341<arg name="format" type="uint" summary="DRM_FORMAT code"/>342<arg name="flags" type="uint" summary="see enum flags"/>343</request>344345</interface>346347</protocol>348349350