All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Tomasz Stanislawski <t.stanislaws@samsung.com>
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, g.liakhovetski@gmx.de,
	dmitriyz@google.com, s.nawrocki@samsung.com,
	k.debski@samsung.com, linux-doc@vger.kernel.org
Subject: Re: [PATCHv8 02/26] Documentation: media: description of DMABUF importing in V4L2
Date: Tue, 25 Sep 2012 12:48:08 +0200	[thread overview]
Message-ID: <201209251248.08951.hverkuil@xs4all.nl> (raw)
In-Reply-To: <50604F3C.2060006@samsung.com>

On Mon 24 September 2012 14:17:00 Tomasz Stanislawski wrote:
> Hi Hans,
> Thank you for review.
> 
> On 08/22/2012 12:47 PM, Hans Verkuil wrote:
> > On Tue August 14 2012 17:34:32 Tomasz Stanislawski wrote:
> >> This patch adds description and usage examples for importing
> >> DMABUF file descriptor in V4L2.
> >>
> >> Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
> >> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> >> CC: linux-doc@vger.kernel.org
> >> ---
> >>  Documentation/DocBook/media/v4l/compat.xml         |    4 +
> >>  Documentation/DocBook/media/v4l/io.xml             |  180 ++++++++++++++++++++
> >>  .../DocBook/media/v4l/vidioc-create-bufs.xml       |    3 +-
> >>  Documentation/DocBook/media/v4l/vidioc-qbuf.xml    |   15 ++
> >>  Documentation/DocBook/media/v4l/vidioc-reqbufs.xml |   47 ++---
> >>  5 files changed, 226 insertions(+), 23 deletions(-)
> >>
> 
> [snip]
> 
> >> +&v4l2-plane; in the multi-planar API case).  The driver must be switched into
> >> +DMABUF I/O mode by calling the &VIDIOC-REQBUFS; with the desired buffer type.
> >> +No buffers (planes) are allocated beforehand, consequently they are not indexed
> >> +and cannot be queried like mapped buffers with the
> >> +<constant>VIDIOC_QUERYBUF</constant> ioctl.</para>
> > 
> > I disagree with that. Userptr buffers can use QUERYBUF just fine. Even for the
> > userptr you still have to fill in the buffer index when calling QBUF.
> > 
> > So I see no reason why you couldn't use QUERYBUF in the DMABUF case. The only
> > difference is that the fd field is undefined (set to -1 perhaps?) if the bufffer
> > isn't queued.
> > 
> > QUERYBUF can be very useful for debugging, for example to see what the status
> > is of each buffer and how many are queued.
> > 
> 
> Ok. I agree that QUERYBUF can be useful for debugging. The value of fd field
> should be the last value passed using QBUF. It would simplify streaming
> because an application would not have to keep the file descriptor around.

If a buffer isn't queued, then fd really is undefined. I don't see any advantage
of remembering the last value used there (and after a REQBUFS there isn't a 'last
value' anyway).

> >> +
> >> +    <example>
> >> +      <title>Initiating streaming I/O with DMABUF file descriptors</title>
> >> +
> >> +      <programlisting>
> >> +&v4l2-requestbuffers; reqbuf;
> >> +
> >> +memset (&amp;reqbuf, 0, sizeof (reqbuf));
> >> +reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
> >> +reqbuf.memory = V4L2_MEMORY_DMABUF;
> >> +reqbuf.count = 1;
> >> +
> >> +if (ioctl (fd, &VIDIOC-REQBUFS;, &amp;reqbuf) == -1) {
> >> +	if (errno == EINVAL)
> >> +		printf ("Video capturing or DMABUF streaming is not supported\n");
> >> +	else
> >> +		perror ("VIDIOC_REQBUFS");
> >> +
> >> +	exit (EXIT_FAILURE);
> > 
> > Let's stick to the kernel coding style, so no ' ' before '(' in function calls.
> > Same for the other program examples below.
> > 
> 
> The ' ' before function was used for userptr and mmap usage examples.
> These examples should be fixed too.
> 
> >> +}
> >> +      </programlisting>
> >> +    </example>
> >> +
> >> +    <para>Buffer (plane) file descriptor is passed on the fly with the
> > 
> > s/Buffer/The buffer/
> > 
> >> +&VIDIOC-QBUF; ioctl. In case of multiplanar buffers, every plane can be
> > 
> > 'Can be', 'should be' or 'must be'? Does it ever make sense to have the same
> > fd for different planes? Do we have restrictions on this in the userptr case?
> > 
> 
> I think that we should keep to 'can be'. I see no good reason to
> prevent the same dmabuf to be used for different planes.
> Allowing reusing of dmabufs with assistance of data_offset field
> would allow to pass a 2-planar YUV420 from V4L2-single-plane API
> to a driver with V4L2-multi-plane API.

That's true.

> 
> [snip]
> 
> >> diff --git a/Documentation/DocBook/media/v4l/vidioc-qbuf.xml b/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
> >> index 77ff5be..436d21c 100644
> >> --- a/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
> >> +++ b/Documentation/DocBook/media/v4l/vidioc-qbuf.xml
> >> @@ -109,6 +109,21 @@ they cannot be swapped out to disk. Buffers remain locked until
> >>  dequeued, until the &VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl is
> >>  called, or until the device is closed.</para>
> >>  
> >> +    <para>To enqueue a <link linkend="dmabuf">DMABUF</link> buffer applications
> >> +set the <structfield>memory</structfield> field to
> >> +<constant>V4L2_MEMORY_DMABUF</constant> and the <structfield>m.fd</structfield>
> >> +field to a file descriptor associated with a DMABUF buffer. When the
> >> +multi-planar API is used <structfield>m.fd</structfield> of the passed array of
> > 
> > multi-planar API is used the <structfield>m.fd</structfield> fields of the passed array of
> > 
> >> +&v4l2-plane; have to be used instead. When <constant>VIDIOC_QBUF</constant> is
> >> +called with a pointer to this structure the driver sets the
> >> +<constant>V4L2_BUF_FLAG_QUEUED</constant> flag and clears the
> >> +<constant>V4L2_BUF_FLAG_MAPPED</constant> and
> >> +<constant>V4L2_BUF_FLAG_DONE</constant> flags in the

What does it do to the PREPARED flag I wonder?

> >> +<structfield>flags</structfield> field, or it returns an error code.  This
> >> +ioctl locks the buffer. Buffers remain locked until dequeued, until the
> >> +&VIDIOC-STREAMOFF; or &VIDIOC-REQBUFS; ioctl is called, or until the device is
> >> +closed.</para>
> > 
> > You need to explain what a 'locked buffer' means.
> 
> I propose following definition:
> "Locking a buffer means passing it to a driver for an access by hardware.
> "If an application accesses (reads/writes) a locked buffer then the result
> is undefined."
> 
> What is your opinion about proposed definition?

Sounds good.

> 
> > 
> >> +
> >>      <para>Applications call the <constant>VIDIOC_DQBUF</constant>
> >>  ioctl to dequeue a filled (capturing) or displayed (output) buffer
> >>  from the driver's outgoing queue. They just set the
> >> diff --git a/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml b/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml
> >> index d7c9505..20f4323 100644
> >> --- a/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml
> >> +++ b/Documentation/DocBook/media/v4l/vidioc-reqbufs.xml
> >> @@ -48,28 +48,30 @@
> >>    <refsect1>
> >>      <title>Description</title>
> >>  
> >> -    <para>This ioctl is used to initiate <link linkend="mmap">memory
> >> -mapped</link> or <link linkend="userp">user pointer</link>
> >> -I/O. Memory mapped buffers are located in device memory and must be
> >> -allocated with this ioctl before they can be mapped into the
> >> -application's address space. User buffers are allocated by
> >> -applications themselves, and this ioctl is merely used to switch the
> >> -driver into user pointer I/O mode and to setup some internal structures.</para>
> >> +<para>This ioctl is used to initiate <link linkend="mmap">memory mapped</link>,
> >> +<link linkend="userp">user pointer</link> or <link
> >> +linkend="dmabuf">DMABUF</link> based I/O.  Memory mapped buffers are located in
> >> +device memory and must be allocated with this ioctl before they can be mapped
> >> +into the application's address space. User buffers are allocated by
> >> +applications themselves, and this ioctl is merely used to switch the driver
> >> +into user pointer I/O mode and to setup some internal structures.
> >> +Similarly, DMABUF buffers are allocated by applications through a device
> >> +driver, and this ioctl only configures the driver into DMABUF I/O mode without
> >> +performing any direct allocation.</para>
> >>  
> >> -    <para>To allocate device buffers applications initialize all
> >> -fields of the <structname>v4l2_requestbuffers</structname> structure.
> >> -They set the <structfield>type</structfield> field to the respective
> >> -stream or buffer type, the <structfield>count</structfield> field to
> >> -the desired number of buffers, <structfield>memory</structfield>
> >> -must be set to the requested I/O method and the <structfield>reserved</structfield> array
> >> -must be zeroed. When the ioctl
> >> -is called with a pointer to this structure the driver will attempt to allocate
> >> -the requested number of buffers and it stores the actual number
> >> -allocated in the <structfield>count</structfield> field. It can be
> >> -smaller than the number requested, even zero, when the driver runs out
> >> -of free memory. A larger number is also possible when the driver requires
> >> -more buffers to function correctly. For example video output requires at least two buffers,
> >> -one displayed and one filled by the application.</para>
> >> +    <para>To allocate device buffers applications initialize all fields of the
> >> +<structname>v4l2_requestbuffers</structname> structure.  They set the
> >> +<structfield>type</structfield> field to the respective stream or buffer type,
> >> +the <structfield>count</structfield> field to the desired number of buffers,
> >> +<structfield>memory</structfield> must be set to the requested I/O method and
> >> +the <structfield>reserved</structfield> array must be zeroed. When the ioctl is
> >> +called with a pointer to this structure the driver will attempt to allocate the
> >> +requested number of buffers and it stores the actual number allocated in the
> >> +<structfield>count</structfield> field. It can be smaller than the number
> >> +requested, even zero, when the driver runs out of free memory. A larger number
> >> +is also possible when the driver requires more buffers to function correctly.
> >> +For example video output requires at least two buffers, one displayed and one
> >> +filled by the application.</para>
> >>      <para>When the I/O method is not supported the ioctl
> >>  returns an &EINVAL;.</para>
> >>  
> >> @@ -102,7 +104,8 @@ as the &v4l2-format; <structfield>type</structfield> field. See <xref
> >>  	    <entry>__u32</entry>
> >>  	    <entry><structfield>memory</structfield></entry>
> >>  	    <entry>Applications set this field to
> >> -<constant>V4L2_MEMORY_MMAP</constant> or
> >> +<constant>V4L2_MEMORY_MMAP</constant>,
> >> +<constant>V4L2_MEMORY_DMABUF</constant> or
> >>  <constant>V4L2_MEMORY_USERPTR</constant>. See <xref linkend="v4l2-memory"
> >>  />.</entry>
> >>  	  </row>
> >>
> > 
> > You also have to update the VIDIOC_CREATE_BUFS ioctl documentation!
> > 
> > I think the VIDIOC_PREPARE_BUF ioctl documentation is OK, but you might want to
> > check that yourself, just in case.
> > 
> 
> Ok.
> Regards,
> Tomasz Stanislawski
> 
> > Regards,
> > 
> > 	Hans
> > 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  reply	other threads:[~2012-09-25 10:48 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-14 15:34 [PATCHv8 00/26] Integration of videobuf2 with DMABUF Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 01/26] v4l: Add DMABUF as a memory type Tomasz Stanislawski
2012-08-22 10:27   ` Hans Verkuil
2012-08-22 12:09     ` Tomasz Stanislawski
2012-08-22 12:21       ` Hans Verkuil
2012-08-14 15:34 ` [PATCHv8 02/26] Documentation: media: description of DMABUF importing in V4L2 Tomasz Stanislawski
2012-08-22 10:47   ` Hans Verkuil
2012-09-24 12:17     ` Tomasz Stanislawski
2012-09-25 10:48       ` Hans Verkuil [this message]
2012-08-14 15:34 ` [PATCHv8 03/26] v4l: vb2: add support for shared buffer (dma_buf) Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 04/26] v4l: vb: remove warnings about MEMORY_DMABUF Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 05/26] v4l: vb2-dma-contig: Shorten vb2_dma_contig prefix to vb2_dc Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 06/26] v4l: vb2-dma-contig: remove reference of alloc_ctx from a buffer Tomasz Stanislawski
2012-08-15 18:24   ` Laurent Pinchart
2012-08-14 15:34 ` [PATCHv8 07/26] v4l: vb2-dma-contig: Reorder functions Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 08/26] v4l: vb2-dma-contig: add support for scatterlist in userptr mode Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 09/26] v4l: vb2: add prepare/finish callbacks to allocators Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 10/26] v4l: vb2-dma-contig: add prepare/finish to dma-contig allocator Tomasz Stanislawski
2012-08-15 18:35   ` Laurent Pinchart
2012-08-15 18:39     ` [Linaro-mm-sig] " Laurent Pinchart
2012-08-14 15:34 ` [PATCHv8 11/26] v4l: vb2-dma-contig: add support for dma_buf importing Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 12/26] v4l: vb2-vmalloc: add support for dmabuf importing Tomasz Stanislawski
2012-08-15 18:39   ` Laurent Pinchart
2012-08-14 15:34 ` [PATCHv8 13/26] v4l: vivi: " Tomasz Stanislawski
2012-08-22 10:56   ` Hans Verkuil
2012-08-22 11:03     ` Laurent Pinchart
2012-08-22 11:47     ` Hans Verkuil
2012-09-25 14:41       ` Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 14/26] v4l: s5p-tv: mixer: " Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 15/26] v4l: s5p-fimc: " Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 16/26] v4l: vb2-dma-contig: let mmap method to use dma_mmap_coherent call Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 17/26] Documentation: media: description of DMABUF exporting in V4L2 Tomasz Stanislawski
2012-08-22 11:23   ` Hans Verkuil
2012-08-14 15:34 ` [PATCHv8 18/26] v4l: add buffer exporting via dmabuf Tomasz Stanislawski
2012-08-15 19:08   ` Laurent Pinchart
2012-08-22 11:41   ` Hans Verkuil
2012-08-22 23:39     ` Laurent Pinchart
2012-08-23  6:50       ` Hans Verkuil
2012-09-25 16:30     ` Tomasz Stanislawski
2012-09-26  6:39       ` Hans Verkuil
2012-09-26  9:55         ` Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 19/26] v4l: vb2: " Tomasz Stanislawski
2012-08-22 11:43   ` Hans Verkuil
2012-08-14 15:34 ` [PATCHv8 20/26] v4l: vb2-dma-contig: add support for DMABUF exporting Tomasz Stanislawski
2012-08-21 10:03   ` Laurent Pinchart
2012-08-21 13:47     ` Tomasz Stanislawski
2012-08-21 14:07       ` Laurent Pinchart
2012-08-14 15:34 ` [PATCHv8 21/26] v4l: vb2-dma-contig: add reference counting for a device from allocator context Tomasz Stanislawski
2012-08-15 20:04   ` Laurent Pinchart
2012-09-27 15:19     ` Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 22/26] media: vb2: fail if user ptr buffer is not correctly aligned Tomasz Stanislawski
2012-08-15 20:20   ` Laurent Pinchart
2012-08-14 15:34 ` [PATCHv8 23/26] v4l: vb2: add support for DMA_ATTR_NO_KERNEL_MAPPING Tomasz Stanislawski
2012-08-15 20:44   ` Laurent Pinchart
2012-08-22 11:46   ` Hans Verkuil
2012-08-14 15:34 ` [PATCHv8 24/26] v4l: s5p-fimc: support for dmabuf exporting Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 25/26] v4l: s5p-tv: mixer: " Tomasz Stanislawski
2012-08-14 15:34 ` [PATCHv8 26/26] v4l: s5p-mfc: " Tomasz Stanislawski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201209251248.08951.hverkuil@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=airlied@redhat.com \
    --cc=daeinki@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dmitriyz@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=g.liakhovetski@gmx.de \
    --cc=k.debski@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@redhat.com \
    --cc=pawel@osciak.com \
    --cc=remi@remlab.net \
    --cc=robdclark@gmail.com \
    --cc=s.nawrocki@samsung.com \
    --cc=subashrp@gmail.com \
    --cc=sumit.semwal@ti.com \
    --cc=t.stanislaws@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.