From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from smtp-vbr2.xs4all.nl ([194.109.24.22]:3168 "EHLO smtp-vbr2.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754350Ab2JEIpH (ORCPT ); Fri, 5 Oct 2012 04:45:07 -0400 From: Hans Verkuil To: Tomasz Stanislawski Subject: Re: [PATCHv9 17/25] Documentation: media: description of DMABUF exporting in V4L2 Date: Fri, 5 Oct 2012 10:44:22 +0200 Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, airlied@redhat.com, m.szyprowski@samsung.com, kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com, sumit.semwal@ti.com, daeinki@gmail.com, daniel.vetter@ffwll.ch, robdclark@gmail.com, pawel@osciak.com, linaro-mm-sig@lists.linaro.org, remi@remlab.net, subashrp@gmail.com, mchehab@redhat.com, zhangfei.gao@gmail.com, s.nawrocki@samsung.com, k.debski@samsung.com, linux-doc@vger.kernel.org References: <1349188056-4886-1-git-send-email-t.stanislaws@samsung.com> <1349188056-4886-18-git-send-email-t.stanislaws@samsung.com> In-Reply-To: <1349188056-4886-18-git-send-email-t.stanislaws@samsung.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201210051044.23099.hverkuil@xs4all.nl> Sender: linux-media-owner@vger.kernel.org List-ID: More stylistic comments and a suggestion for re-ordering the fields in the expbuf struct. On Tue October 2 2012 16:27:28 Tomasz Stanislawski wrote: > This patch adds description and usage examples for exporting > DMABUF file descriptor in V4L2. > > Signed-off-by: Tomasz Stanislawski > Signed-off-by: Kyungmin Park > CC: linux-doc@vger.kernel.org > --- > Documentation/DocBook/media/v4l/compat.xml | 3 + > Documentation/DocBook/media/v4l/io.xml | 3 + > Documentation/DocBook/media/v4l/v4l2.xml | 1 + > Documentation/DocBook/media/v4l/vidioc-expbuf.xml | 212 +++++++++++++++++++++ > 4 files changed, 219 insertions(+) > create mode 100644 Documentation/DocBook/media/v4l/vidioc-expbuf.xml > > diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml > index a46f95b..f0512aa 100644 > --- a/Documentation/DocBook/media/v4l/compat.xml > +++ b/Documentation/DocBook/media/v4l/compat.xml > @@ -2625,6 +2625,9 @@ ioctls. > Importing DMABUF file descriptors as a new IO method described > in . > > + > + Exporting DMABUF files using &VIDIOC-EXPBUF; ioctl. > + > > > > diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml > index 5b58657..476f448 100644 > --- a/Documentation/DocBook/media/v4l/io.xml > +++ b/Documentation/DocBook/media/v4l/io.xml > @@ -488,6 +488,9 @@ DMA buffer from userspace using a file descriptor previously exported for a > different or the same device (known as the importer role), or both. This > section describes the DMABUF importer role API in V4L2. > > + Refer to DMABUF exporting for > +details about exporting a V4L2 buffers as DMABUF file descriptors. "exporting a" -> "exporting" > + > Input and output devices support the streaming I/O method when the > V4L2_CAP_STREAMING flag in the > capabilities field of &v4l2-capability; returned by > diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml > index eee6908..d8c2597 100644 > --- a/Documentation/DocBook/media/v4l/v4l2.xml > +++ b/Documentation/DocBook/media/v4l/v4l2.xml > @@ -543,6 +543,7 @@ and discussions on the V4L mailing list. > &sub-enuminput; > &sub-enumoutput; > &sub-enumstd; > + &sub-expbuf; > &sub-g-audio; > &sub-g-audioout; > &sub-g-crop; > diff --git a/Documentation/DocBook/media/v4l/vidioc-expbuf.xml b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml > new file mode 100644 > index 0000000..bf28e7d > --- /dev/null > +++ b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml > @@ -0,0 +1,212 @@ > + > + > + > + ioctl VIDIOC_EXPBUF > + &manvol; > + > + > + > + VIDIOC_EXPBUF > + Export a buffer as a DMABUF file descriptor. > + > + > + > + > + > + int ioctl > + int fd > + int request > + struct v4l2_exportbuffer *argp > + > + > + > + > + > + Arguments > + > + > + > + fd > + > + &fd; > + > + > + > + request > + > + VIDIOC_EXPBUF > + > + > + > + argp > + > + > + > + > + > + > + > + > + Description > + > + > + Experimental > + This is an experimental > + interface and may change in the future. > + > + > +This ioctl is an extension to the memory > +mapping I/O method therefore it is available only for "method therefore" -> "method, therefore" > +V4L2_MEMORY_MMAP buffers. It can be used to export a > +buffer as a DMABUF file at any time after buffers have been allocated with the > +&VIDIOC-REQBUFS; ioctl. > + > + To export a buffer, applicationis fill &v4l2-exportbuffer;. The applicationis -> applications > + type field is set to the same buffer type as was > +previously used with &v4l2-requestbuffers; type . > +Applications must also set the index field. Valid > +index numbers range from zero to the number of buffers allocated with > +&VIDIOC-REQBUFS; (&v4l2-requestbuffers; count ) > +minus one. For multi plane API, applications set the plane "multi plane" -> "the multi-planar" > + field to the index of the plane to be exported. Valid planes > +range from zero to the maximal number of valid planes for currently active "for" -> "for the" > +format. For single plane API, applications must set plane "single plane" -> "the single-planar" > + to zero. Additional flags may be posted in the > +flags field. Refer to a manual for open() for details. > +Currently only O_CLOEXEC is supported. All other fields must be set to zero. > +In a case of multi-planar API, every plane is exported separately using "a case of" -> "the case of the" > +multiple VIDIOC_EXPBUF calls. > + > + After calling VIDIOC_EXPBUF the fd > + field will be set by a driver. This is a DMABUF file > +descriptor. The application may pass it to other API. Refer to "APIs" or alternatively (and I like that better): "API" -> "DMABUF-aware devices" > +linkend="dmabuf">DMABUF importing for details about importing DMABUF > +files into V4L2 nodes. A developer is encouraged to close a DMABUF file when it > +is no longer used to avoid a resource leak. I'm not sure I like that last sentence. Perhaps something like this: "It is recommended to close a DMABUF file when it is no longer used to allow the associated memory to be reclaimed." > + > + > + > +
> + Examples > + > + > + Exporting a buffer. > + > +int buffer_export(int v4lfd, &v4l2-buf-type; bt, int index, int *dmafd) > +{ > + &v4l2-exportbuffer; expbuf; > + > + memset(&expbuf, 0, sizeof expbuf); sizeof expbuf -> sizeof(expbuf) > + expbuf.type = bt; > + expbuf.index = index; > + if (ioctl(v4lfd, &VIDIOC-EXPBUF;, &expbuf) == -1) { > + perror("VIDIOC_EXPBUF"); > + return -1; > + } > + > + *dmafd = expbuf.fd; > + > + return 0; > +} > + > + > + > + > + Exporting a buffer using multi plane API. "multi plane" -> "the multi-planar" > + > +int buffer_export_mp(int v4lfd, &v4l2-buf-type; bt, int index, > + int dmafd[], int n_planes) > +{ > + int i; > + > + for (i = 0; i < n_planes; ++i) { > + &v4l2-exportbuffer; expbuf; > + > + memset(&expbuf, 0, sizeof expbuf); sizeof(expbuf) > + expbuf.type = bt; > + expbuf.index = index; > + expbuf.plane = i; > + if (ioctl(v4lfd, &VIDIOC-EXPBUF;, &expbuf) == -1) { > + perror("VIDIOC_EXPBUF"); > + while (i) > + close(dmafd[--i]); > + return -1; > + } > + dmafd[i] = expbuf.fd; > + } > + > + return 0; > +} > + > + > +
> +
> + > + > + > + struct <structname>v4l2_exportbuffer</structname> > + > + &cs-str; > + > + > + __s32 > + fd > + The DMABUF file descriptor associated with a buffer. Set by > + a driver. a -> the > + > + > + __u32 > + flags > + Flags for newly created file, currently only for -> for the > +O_CLOEXEC is supported, refer to the manual of open() for more > +details. > + > + > + __u32 > + type > + Type of the buffer, same as &v4l2-format; > +type or &v4l2-requestbuffers; > +type, set by the application. See +linkend="v4l2-buf-type" /> > + > + > + __u32 > + index > + Number of the buffer, set by the application. This field is > +only used for memory mapping I/O and can range from > +zero to the number of buffers allocated with the &VIDIOC-REQBUFS; ioctl This really also includes any buffers allocated with VIDIOC_CREATE_BUFS. > +(&v4l2-requestbuffers; count) minus one. > + > + > + __u32 > + plane > + Index of the plane to be exported when using multi plane multi plane -> the multi-planar > +API. Otherwise this value must be set to zero. > + Shouldn't type, index and plane comes first in this struct? That feels more natural. > + > + __u32 > + reserved[11] > + Reserved field for future use. Must be set to zero. > + > + > + > +
> + > +
> + > + > + &return-value; > + > + > + EINVAL > + > + A queue is not in MMAP mode or DMABUF exporting is not > +supported or flags or type > + or index or plane > + fields are invalid. > + > + > + > + > + > +
>