linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFCv1 PATCH 0/5] DocBook media updates
@ 2014-03-07 14:26 Hans Verkuil
  2014-03-07 14:26 ` [RFCv1 PATCH 1/5] DocBook media: update STREAMON/OFF documentation Hans Verkuil
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Hans Verkuil @ 2014-03-07 14:26 UTC (permalink / raw)
  To: linux-media

After doing a lot of work on v4l2-compliance I found some wrong and some
missing information in the spec. This patch series fixes and clarifies
them.

The first clarifies two corner cases: what happens with queued buffers is
STREAMON fails, and what happens if buffers are queued, STREAMON was never
called, and STREAMOFF is called.

The second fixed a bug in a code example.

The third clarifies the use of several v4l2_buffer/plane fields. In particular
who is responsible for setting them, the application or the driver.

The fourth fixes the FIELD_ALTERNATE description: sizeimage is really
that of the field, not of the frame. It makes no sense to do it the way
that the spec describes, and all the drivers implementing FIELD_ALTERNATE
set sizeimage to the field height times bytesperline.

The last patch does the same as the third but for v4l2_pix_format(_mplane).

Regards,

	Hans


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFCv1 PATCH 1/5] DocBook media: update STREAMON/OFF documentation.
  2014-03-07 14:26 [RFCv1 PATCH 0/5] DocBook media updates Hans Verkuil
@ 2014-03-07 14:26 ` Hans Verkuil
  2014-03-07 14:26 ` [RFCv1 PATCH 2/5] DocBook: fix incorrect code example Hans Verkuil
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2014-03-07 14:26 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 .../DocBook/media/v4l/vidioc-streamon.xml          | 28 +++++++++++++++++-----
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/vidioc-streamon.xml b/Documentation/DocBook/media/v4l/vidioc-streamon.xml
index 65dff55..df2c63d 100644
--- a/Documentation/DocBook/media/v4l/vidioc-streamon.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-streamon.xml
@@ -52,16 +52,24 @@
     <para>The <constant>VIDIOC_STREAMON</constant> and
 <constant>VIDIOC_STREAMOFF</constant> ioctl start and stop the capture
 or output process during streaming (<link linkend="mmap">memory
-mapping</link> or <link linkend="userp">user pointer</link>) I/O.</para>
+mapping</link>, <link linkend="userp">user pointer</link> or
+<link linkend="dmabuf">DMABUF</link>) I/O.</para>
 
-    <para>Specifically the capture hardware is disabled and no input
+    <para>Capture hardware is disabled and no input
 buffers are filled (if there are any empty buffers in the incoming
 queue) until <constant>VIDIOC_STREAMON</constant> has been called.
-Accordingly the output hardware is disabled, no video signal is
+Output hardware is disabled and no video signal is
 produced until <constant>VIDIOC_STREAMON</constant> has been called.
 The ioctl will succeed when at least one output buffer is in the
 incoming queue.</para>
 
+    <para>Memory-to-memory devices will not start until
+<constant>VIDIOC_STREAMON</constant> has been called for both the capture
+and output stream types.</para>
+
+    <para>If <constant>VIDIOC_STREAMON</constant> fails then any already
+queued buffers will remain queued.</para>
+
     <para>The <constant>VIDIOC_STREAMOFF</constant> ioctl, apart of
 aborting or finishing any DMA in progress, unlocks any user pointer
 buffers locked in physical memory, and it removes all buffers from the
@@ -70,14 +78,22 @@ dequeued yet will be lost, likewise all images enqueued for output but
 not transmitted yet. I/O returns to the same state as after calling
 &VIDIOC-REQBUFS; and can be restarted accordingly.</para>
 
+    <para>If buffers have been queued with &VIDIOC-QBUF; and
+<constant>VIDIOC_STREAMOFF</constant> is called without ever having
+called <constant>VIDIOC_STREAMON</constant>, then those queued buffers
+will also be removed from the incoming queue and all are returned to the
+same state as after calling &VIDIOC-REQBUFS; and can be restarted
+accordingly.</para>
+
     <para>Both ioctls take a pointer to an integer, the desired buffer or
 stream type. This is the same as &v4l2-requestbuffers;
 <structfield>type</structfield>.</para>
 
     <para>If <constant>VIDIOC_STREAMON</constant> is called when streaming
 is already in progress, or if <constant>VIDIOC_STREAMOFF</constant> is called
-when streaming is already stopped, then the ioctl does nothing and 0 is
-returned.</para>
+when streaming is already stopped, then 0 is returned. Nothing happens in the
+case of <constant>VIDIOC_STREAMON</constant>, but <constant>VIDIOC_STREAMOFF</constant>
+will return queued buffers to their starting state as mentioned above.</para>
 
     <para>Note that applications can be preempted for unknown periods right
 before or after the <constant>VIDIOC_STREAMON</constant> or
@@ -93,7 +109,7 @@ synchronize with other events.</para>
       <varlistentry>
 	<term><errorcode>EINVAL</errorcode></term>
 	<listitem>
-	  <para>The buffer<structfield>type</structfield> is not supported,
+	  <para>The buffer <structfield>type</structfield> is not supported,
 	  or no buffers have been allocated (memory mapping) or enqueued
 	  (output) yet.</para>
 	</listitem>
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFCv1 PATCH 2/5] DocBook: fix incorrect code example
  2014-03-07 14:26 [RFCv1 PATCH 0/5] DocBook media updates Hans Verkuil
  2014-03-07 14:26 ` [RFCv1 PATCH 1/5] DocBook media: update STREAMON/OFF documentation Hans Verkuil
@ 2014-03-07 14:26 ` Hans Verkuil
  2014-03-07 14:26 ` [RFCv1 PATCH 3/5] DocBook media: clarify v4l2_buffer/plane fields Hans Verkuil
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2014-03-07 14:26 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

The code said for (i = 0; i > 30; ++i) instead of i < 30.

Fix this and clean it up a bit at the same time.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 Documentation/DocBook/media/v4l/dev-osd.xml | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/dev-osd.xml b/Documentation/DocBook/media/v4l/dev-osd.xml
index dd91d61..5485332 100644
--- a/Documentation/DocBook/media/v4l/dev-osd.xml
+++ b/Documentation/DocBook/media/v4l/dev-osd.xml
@@ -56,18 +56,18 @@ framebuffer device.</para>
 unsigned int i;
 int fb_fd;
 
-if (-1 == ioctl (fd, VIDIOC_G_FBUF, &amp;fbuf)) {
-	perror ("VIDIOC_G_FBUF");
-	exit (EXIT_FAILURE);
+if (-1 == ioctl(fd, VIDIOC_G_FBUF, &amp;fbuf)) {
+	perror("VIDIOC_G_FBUF");
+	exit(EXIT_FAILURE);
 }
 
-for (i = 0; i &gt; 30; ++i) {
+for (i = 0; i &lt; 30; i++) {
 	char dev_name[16];
 	struct fb_fix_screeninfo si;
 
-	snprintf (dev_name, sizeof (dev_name), "/dev/fb%u", i);
+	snprintf(dev_name, sizeof(dev_name), "/dev/fb%u", i);
 
-	fb_fd = open (dev_name, O_RDWR);
+	fb_fd = open(dev_name, O_RDWR);
 	if (-1 == fb_fd) {
 		switch (errno) {
 		case ENOENT: /* no such file */
@@ -75,19 +75,19 @@ for (i = 0; i &gt; 30; ++i) {
 			continue;
 
 		default:
-			perror ("open");
-			exit (EXIT_FAILURE);
+			perror("open");
+			exit(EXIT_FAILURE);
 		}
 	}
 
-	if (0 == ioctl (fb_fd, FBIOGET_FSCREENINFO, &amp;si)) {
-		if (si.smem_start == (unsigned long) fbuf.base)
+	if (0 == ioctl(fb_fd, FBIOGET_FSCREENINFO, &amp;si)) {
+		if (si.smem_start == (unsigned long)fbuf.base)
 			break;
 	} else {
 		/* Apparently not a framebuffer device. */
 	}
 
-	close (fb_fd);
+	close(fb_fd);
 	fb_fd = -1;
 }
 
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFCv1 PATCH 3/5] DocBook media: clarify v4l2_buffer/plane fields.
  2014-03-07 14:26 [RFCv1 PATCH 0/5] DocBook media updates Hans Verkuil
  2014-03-07 14:26 ` [RFCv1 PATCH 1/5] DocBook media: update STREAMON/OFF documentation Hans Verkuil
  2014-03-07 14:26 ` [RFCv1 PATCH 2/5] DocBook: fix incorrect code example Hans Verkuil
@ 2014-03-07 14:26 ` Hans Verkuil
  2014-03-07 14:26 ` [RFCv1 PATCH 4/5] DocBook media: fix broken FIELD_ALTERNATE description Hans Verkuil
  2014-03-07 14:26 ` [RFCv1 PATCH 5/5] DocBook media: clarify v4l2_pix_format and v4l2_pix_format_mplane fields Hans Verkuil
  4 siblings, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2014-03-07 14:26 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Be more specific as to who has to fill in each field/flag: the driver
or the application.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 Documentation/DocBook/media/v4l/io.xml | 54 ++++++++++++++++++++++------------
 1 file changed, 36 insertions(+), 18 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index 49e48be..0a5d8c6 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -676,10 +676,11 @@ plane structures.</para>
 	    <entry>__u32</entry>
 	    <entry><structfield>index</structfield></entry>
 	    <entry></entry>
-	    <entry>Number of the buffer, set by the application. This
-field is only used for <link linkend="mmap">memory mapping</link> I/O
-and can range from zero to the number of buffers allocated
-with the &VIDIOC-REQBUFS; ioctl (&v4l2-requestbuffers; <structfield>count</structfield>) minus one.</entry>
+	    <entry>Number of the buffer, set by the application except
+when calling &VIDIOC-DQBUF;, then it is set by the driver.
+This field can range from zero to the number of buffers allocated
+with the &VIDIOC-REQBUFS; ioctl (&v4l2-requestbuffers; <structfield>count</structfield>),
+plus any buffers allocated with &VIDIOC-CREATE-BUFS; minus one.</entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
@@ -698,7 +699,7 @@ linkend="v4l2-buf-type" /></entry>
 buffer. It depends on the negotiated data format and may change with
 each buffer for compressed variable size data like JPEG images.
 Drivers must set this field when <structfield>type</structfield>
-refers to an input stream, applications when an output stream.</entry>
+refers to an input stream, applications when it refers to an output stream.</entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
@@ -715,7 +716,7 @@ linkend="buffer-flags" />.</entry>
 buffer, see <xref linkend="v4l2-field" />. This field is not used when
 the buffer contains VBI data. Drivers must set it when
 <structfield>type</structfield> refers to an input stream,
-applications when an output stream.</entry>
+applications when it refers to an output stream.</entry>
 	  </row>
 	  <row>
 	    <entry>struct timeval</entry>
@@ -729,7 +730,9 @@ applications when an output stream.</entry>
 	    stores the time at which the last data byte was actually sent out
 	    in the  <structfield>timestamp</structfield> field. This permits
 	    applications to monitor the drift between the video and system
-	    clock.</para></entry>
+	    clock. For output streams that use <constant>V4L2_BUF_FLAG_TIMESTAMP_COPY</constant>
+	    the application has to fill in the timestamp which will be copied
+	    by the driver to the capture stream.</para></entry>
 	  </row>
 	  <row>
 	    <entry>&v4l2-timecode;</entry>
@@ -822,7 +825,8 @@ is the file descriptor associated with a DMABUF buffer.</entry>
 	    <entry><structfield>length</structfield></entry>
 	    <entry></entry>
 	    <entry>Size of the buffer (not the payload) in bytes for the
-	    single-planar API. For the multi-planar API the application sets
+	    single-planar API. This is set by the driver based on the calls to
+	    &VIDIOC-REQBUFS; and/or &VIDIOC-CREATE-BUFS;. For the multi-planar API the application sets
 	    this to the number of elements in the <structfield>planes</structfield>
 	    array. The driver will fill in the actual number of valid elements in
 	    that array.
@@ -856,13 +860,15 @@ should set this to 0.</entry>
 	    <entry><structfield>bytesused</structfield></entry>
 	    <entry></entry>
 	    <entry>The number of bytes occupied by data in the plane
-	    (its payload).</entry>
+	      (its payload). Drivers must set this field when <structfield>type</structfield>
+	      refers to an input stream, applications when it refers to an output stream.</entry>
 	  </row>
 	  <row>
 	    <entry>__u32</entry>
 	    <entry><structfield>length</structfield></entry>
 	    <entry></entry>
-	    <entry>Size in bytes of the plane (not its payload).</entry>
+	    <entry>Size in bytes of the plane (not its payload). This is set by the driver
+	    based on the calls to &VIDIOC-REQBUFS; and/or &VIDIOC-CREATE-BUFS;.</entry>
 	  </row>
 	  <row>
 	    <entry>union</entry>
@@ -901,7 +907,9 @@ should set this to 0.</entry>
 	    <entry>__u32</entry>
 	    <entry><structfield>data_offset</structfield></entry>
 	    <entry></entry>
-	    <entry>Offset in bytes to video data in the plane, if applicable.
+	    <entry>Offset in bytes to video data in the plane.
+	      Drivers must set this field when <structfield>type</structfield>
+	      refers to an input stream, applications when it refers to an output stream.
 	    </entry>
 	  </row>
 	  <row>
@@ -1031,7 +1039,7 @@ buffer cannot be on both queues at the same time, the
 <constant>V4L2_BUF_FLAG_QUEUED</constant> and
 <constant>V4L2_BUF_FLAG_DONE</constant> flag are mutually exclusive.
 They can be both cleared however, then the buffer is in "dequeued"
-state, in the application domain to say so.</entry>
+state, in the application domain so to say.</entry>
 	  </row>
 	  <row>
 	    <entry><constant>V4L2_BUF_FLAG_ERROR</constant></entry>
@@ -1049,27 +1057,35 @@ state, in the application domain to say so.</entry>
 	  <entry>Drivers set or clear this flag when calling the
 <constant>VIDIOC_DQBUF</constant> ioctl. It may be set by video
 capture devices when the buffer contains a compressed image which is a
-key frame (or field), &ie; can be decompressed on its own.</entry>
+key frame (or field), &ie; can be decompressed on its own. Also know as
+an I-frame.  Applications can set this bit when <structfield>type</structfield>
+refers to an output stream.</entry>
 	  </row>
 	  <row>
 	    <entry><constant>V4L2_BUF_FLAG_PFRAME</constant></entry>
 	    <entry>0x00000010</entry>
 	    <entry>Similar to <constant>V4L2_BUF_FLAG_KEYFRAME</constant>
 this flags predicted frames or fields which contain only differences to a
-previous key frame.</entry>
+previous key frame. Applications can set this bit when <structfield>type</structfield>
+refers to an output stream.</entry>
 	  </row>
 	  <row>
 	    <entry><constant>V4L2_BUF_FLAG_BFRAME</constant></entry>
 	    <entry>0x00000020</entry>
-	    <entry>Similar to <constant>V4L2_BUF_FLAG_PFRAME</constant>
-	this is a bidirectional predicted frame or field. [ooc tbd]</entry>
+	    <entry>Similar to <constant>V4L2_BUF_FLAG_KEYFRAME</constant>
+this flags a bi-directional predicted frame or field which contains only
+the differences between the current frame and both the preceding and following
+key frames to specify its content. Applications can set this bit when
+<structfield>type</structfield> refers to an output stream.</entry>
 	  </row>
 	  <row>
 	    <entry><constant>V4L2_BUF_FLAG_TIMECODE</constant></entry>
 	    <entry>0x00000100</entry>
 	    <entry>The <structfield>timecode</structfield> field is valid.
 Drivers set or clear this flag when the <constant>VIDIOC_DQBUF</constant>
-ioctl is called.</entry>
+ioctl is called.  Applications can set this bit and the corresponding
+<structfield>timecode</structfield> structure when <structfield>type</structfield>
+refers to an output stream.</entry>
 	  </row>
 	  <row>
 	    <entry><constant>V4L2_BUF_FLAG_PREPARED</constant></entry>
@@ -1141,7 +1157,9 @@ in which case caches have not been used.</entry>
 	    the frame. Logical 'and' operation between the
 	    <structfield>flags</structfield> field and
 	    <constant>V4L2_BUF_FLAG_TSTAMP_SRC_MASK</constant> produces the
-	    value of the timestamp source.</entry>
+	    value of the timestamp source. Applications must set the timestamp
+	    source when <structfield>type</structfield> refers to an output stream
+	    and <constant>V4L2_BUF_FLAG_TIMESTAMP_COPY</constant> is set.</entry>
 	  </row>
 	  <row>
 	    <entry><constant>V4L2_BUF_FLAG_TSTAMP_SRC_EOF</constant></entry>
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFCv1 PATCH 4/5] DocBook media: fix broken FIELD_ALTERNATE description.
  2014-03-07 14:26 [RFCv1 PATCH 0/5] DocBook media updates Hans Verkuil
                   ` (2 preceding siblings ...)
  2014-03-07 14:26 ` [RFCv1 PATCH 3/5] DocBook media: clarify v4l2_buffer/plane fields Hans Verkuil
@ 2014-03-07 14:26 ` Hans Verkuil
  2014-03-07 14:26 ` [RFCv1 PATCH 5/5] DocBook media: clarify v4l2_pix_format and v4l2_pix_format_mplane fields Hans Verkuil
  4 siblings, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2014-03-07 14:26 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

The sizeimage is that of a single field, not that of a full frame.
That makes no sense, and in fact all drivers supporting ALTERNATE will
set sizeimage to that of a field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 Documentation/DocBook/media/v4l/io.xml | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml
index 0a5d8c6..97a69bf 100644
--- a/Documentation/DocBook/media/v4l/io.xml
+++ b/Documentation/DocBook/media/v4l/io.xml
@@ -1470,10 +1470,9 @@ or application, depending on data direction, must set &v4l2-buffer;
 <constant>V4L2_FIELD_BOTTOM</constant>. Any two successive fields pair
 to build a frame. If fields are successive, without any dropped fields
 between them (fields can drop individually), can be determined from
-the &v4l2-buffer; <structfield>sequence</structfield> field. Image
-sizes refer to the frame, not fields. This format cannot be selected
-when using the read/write I/O method.<!-- Where it's indistinguishable
-from V4L2_FIELD_SEQ_*. --></entry>
+the &v4l2-buffer; <structfield>sequence</structfield> field. This format
+cannot be selected when using the read/write I/O method since there
+is no way to communicate if a field was a top or bottom field.</entry>
 	  </row>
 	  <row>
 	    <entry><constant>V4L2_FIELD_INTERLACED_TB</constant></entry>
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFCv1 PATCH 5/5] DocBook media: clarify v4l2_pix_format and v4l2_pix_format_mplane fields
  2014-03-07 14:26 [RFCv1 PATCH 0/5] DocBook media updates Hans Verkuil
                   ` (3 preceding siblings ...)
  2014-03-07 14:26 ` [RFCv1 PATCH 4/5] DocBook media: fix broken FIELD_ALTERNATE description Hans Verkuil
@ 2014-03-07 14:26 ` Hans Verkuil
  2014-03-13 14:31   ` Mauro Carvalho Chehab
  4 siblings, 1 reply; 7+ messages in thread
From: Hans Verkuil @ 2014-03-07 14:26 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Be more specific with regards to how some of these fields are interpreted.
In particular height vs field and which fields can be set by the application.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 Documentation/DocBook/media/v4l/pixfmt.xml | 33 +++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml b/Documentation/DocBook/media/v4l/pixfmt.xml
index f586d34..7b0b098 100644
--- a/Documentation/DocBook/media/v4l/pixfmt.xml
+++ b/Documentation/DocBook/media/v4l/pixfmt.xml
@@ -25,7 +25,18 @@ capturing and output, for overlay frame buffer formats see also
 	<row>
 	  <entry>__u32</entry>
 	  <entry><structfield>height</structfield></entry>
-	  <entry>Image height in pixels.</entry>
+	  <entry>Image height in pixels. If <structfield>field</structfield> is
+	  one of <constant>V4L2_FIELD_TOP</constant>, <constant>V4L2_FIELD_BOTTOM</constant>
+	  or <constant>V4L2_FIELD_ALTERNATE</constant> then height refers to the
+	  number of lines in the field, otherwise it refers to the number of
+	  lines in the frame (which is twice the field height for interlaced
+	  formats). In case of conflicts between the <structfield>height</structfield>
+	  value and the <structfield>field</structfield> value, the
+	  <structfield>height</structfield> shall be the deciding factor.
+	  So if <structfield>height</structfield> is set to 480 for an NTSC-M
+	  standard, and <structfield>field</structfield> is set to
+	  <constant>V4L2_FIELD_TOP</constant>, then <structfield>field</structfield>
+	  shall be adjusted to &eg; <constant>V4L2_FIELD_INTERLACED</constant>.</entry>
 	</row>
 	<row>
 	  <entry spanname="hspan">Applications set these fields to
@@ -54,7 +65,11 @@ linkend="reserved-formats" /></entry>
 can request to capture or output only the top or bottom field, or both
 fields interlaced or sequentially stored in one buffer or alternating
 in separate buffers. Drivers return the actual field order selected.
-For details see <xref linkend="field-order" />.</entry>
+In case of conflicts between the <structfield>height</structfield> and
+<structfield>field</structfield> values, the <structfield>height</structfield>
+value will be the deciding factor. See also the description of
+<structfield>height</structfield> above.
+For more details on fields see <xref linkend="field-order" />.</entry>
 	</row>
 	<row>
 	  <entry>__u32</entry>
@@ -81,7 +96,10 @@ plane and is divided by the same factor as the
 example the Cb and Cr planes of a YUV 4:2:0 image have half as many
 padding bytes following each line as the Y plane. To avoid ambiguities
 drivers must return a <structfield>bytesperline</structfield> value
-rounded up to a multiple of the scale factor.</para></entry>
+rounded up to a multiple of the scale factor.</para>
+<para>For compressed formats the <structfield>bytesperline</structfield>
+value makes no sense. Applications and drivers must set this to 0 in
+that case.</para></entry>
 	</row>
 	<row>
 	  <entry>__u32</entry>
@@ -97,7 +115,8 @@ hold an image.</entry>
 	  <entry>&v4l2-colorspace;</entry>
 	  <entry><structfield>colorspace</structfield></entry>
 	  <entry>This information supplements the
-<structfield>pixelformat</structfield> and must be set by the driver,
+<structfield>pixelformat</structfield> and must be set by the driver for
+capture streams and by the application for output streams,
 see <xref linkend="colorspaces" />.</entry>
 	</row>
 	<row>
@@ -135,7 +154,7 @@ set this field to zero.</entry>
           <entry>__u16</entry>
           <entry><structfield>bytesperline</structfield></entry>
           <entry>Distance in bytes between the leftmost pixels in two adjacent
-            lines.</entry>
+            lines. See &v4l2-pix-format;.</entry>
         </row>
         <row>
           <entry>__u16</entry>
@@ -154,12 +173,12 @@ set this field to zero.</entry>
         <row>
           <entry>__u32</entry>
           <entry><structfield>width</structfield></entry>
-          <entry>Image width in pixels.</entry>
+          <entry>Image width in pixels. See &v4l2-pix-format;.</entry>
         </row>
         <row>
           <entry>__u32</entry>
           <entry><structfield>height</structfield></entry>
-          <entry>Image height in pixels.</entry>
+          <entry>Image height in pixels. See &v4l2-pix-format;.</entry>
         </row>
         <row>
           <entry>__u32</entry>
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RFCv1 PATCH 5/5] DocBook media: clarify v4l2_pix_format and v4l2_pix_format_mplane fields
  2014-03-07 14:26 ` [RFCv1 PATCH 5/5] DocBook media: clarify v4l2_pix_format and v4l2_pix_format_mplane fields Hans Verkuil
@ 2014-03-13 14:31   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 7+ messages in thread
From: Mauro Carvalho Chehab @ 2014-03-13 14:31 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

Em Fri,  7 Mar 2014 15:26:24 +0100
Hans Verkuil <hverkuil@xs4all.nl> escreveu:

> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> Be more specific with regards to how some of these fields are interpreted.
> In particular height vs field and which fields can be set by the application.
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  Documentation/DocBook/media/v4l/pixfmt.xml | 33 +++++++++++++++++++++++-------
>  1 file changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/DocBook/media/v4l/pixfmt.xml b/Documentation/DocBook/media/v4l/pixfmt.xml
> index f586d34..7b0b098 100644
> --- a/Documentation/DocBook/media/v4l/pixfmt.xml
> +++ b/Documentation/DocBook/media/v4l/pixfmt.xml
> @@ -25,7 +25,18 @@ capturing and output, for overlay frame buffer formats see also
>  	<row>
>  	  <entry>__u32</entry>
>  	  <entry><structfield>height</structfield></entry>
> -	  <entry>Image height in pixels.</entry>
> +	  <entry>Image height in pixels. If <structfield>field</structfield> is
> +	  one of <constant>V4L2_FIELD_TOP</constant>, <constant>V4L2_FIELD_BOTTOM</constant>
> +	  or <constant>V4L2_FIELD_ALTERNATE</constant> then height refers to the
> +	  number of lines in the field, otherwise it refers to the number of
> +	  lines in the frame (which is twice the field height for interlaced
> +	  formats). In case of conflicts between the <structfield>height</structfield>
> +	  value and the <structfield>field</structfield> value, the
> +	  <structfield>height</structfield> shall be the deciding factor.
> +	  So if <structfield>height</structfield> is set to 480 for an NTSC-M
> +	  standard, and <structfield>field</structfield> is set to
> +	  <constant>V4L2_FIELD_TOP</constant>, then <structfield>field</structfield>
> +	  shall be adjusted to &eg; <constant>V4L2_FIELD_INTERLACED</constant>.</entry>

This seems to be a description of a hack. I think we should better discuss
the meanings for V4L2_FIELD on some next mini-summit, as this seem to be
very confusing. I'm not even sure if applications use it properly, as
some drivers never implemented it right.

>  	</row>
>  	<row>
>  	  <entry spanname="hspan">Applications set these fields to
> @@ -54,7 +65,11 @@ linkend="reserved-formats" /></entry>
>  can request to capture or output only the top or bottom field, or both
>  fields interlaced or sequentially stored in one buffer or alternating
>  in separate buffers. Drivers return the actual field order selected.
> -For details see <xref linkend="field-order" />.</entry>
> +In case of conflicts between the <structfield>height</structfield> and
> +<structfield>field</structfield> values, the <structfield>height</structfield>
> +value will be the deciding factor. See also the description of
> +<structfield>height</structfield> above.
> +For more details on fields see <xref linkend="field-order" />.</entry>
>  	</row>
>  	<row>
>  	  <entry>__u32</entry>
> @@ -81,7 +96,10 @@ plane and is divided by the same factor as the
>  example the Cb and Cr planes of a YUV 4:2:0 image have half as many
>  padding bytes following each line as the Y plane. To avoid ambiguities
>  drivers must return a <structfield>bytesperline</structfield> value
> -rounded up to a multiple of the scale factor.</para></entry>
> +rounded up to a multiple of the scale factor.</para>
> +<para>For compressed formats the <structfield>bytesperline</structfield>
> +value makes no sense. Applications and drivers must set this to 0 in
> +that case.</para></entry>
>  	</row>
>  	<row>
>  	  <entry>__u32</entry>
> @@ -97,7 +115,8 @@ hold an image.</entry>
>  	  <entry>&v4l2-colorspace;</entry>
>  	  <entry><structfield>colorspace</structfield></entry>
>  	  <entry>This information supplements the
> -<structfield>pixelformat</structfield> and must be set by the driver,
> +<structfield>pixelformat</structfield> and must be set by the driver for
> +capture streams and by the application for output streams,
>  see <xref linkend="colorspaces" />.</entry>
>  	</row>
>  	<row>
> @@ -135,7 +154,7 @@ set this field to zero.</entry>
>            <entry>__u16</entry>
>            <entry><structfield>bytesperline</structfield></entry>
>            <entry>Distance in bytes between the leftmost pixels in two adjacent
> -            lines.</entry>
> +            lines. See &v4l2-pix-format;.</entry>
>          </row>
>          <row>
>            <entry>__u16</entry>
> @@ -154,12 +173,12 @@ set this field to zero.</entry>
>          <row>
>            <entry>__u32</entry>
>            <entry><structfield>width</structfield></entry>
> -          <entry>Image width in pixels.</entry>
> +          <entry>Image width in pixels. See &v4l2-pix-format;.</entry>
>          </row>
>          <row>
>            <entry>__u32</entry>
>            <entry><structfield>height</structfield></entry>
> -          <entry>Image height in pixels.</entry>
> +          <entry>Image height in pixels. See &v4l2-pix-format;.</entry>
>          </row>
>          <row>
>            <entry>__u32</entry>


-- 

Regards,
Mauro

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-03-13 14:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-07 14:26 [RFCv1 PATCH 0/5] DocBook media updates Hans Verkuil
2014-03-07 14:26 ` [RFCv1 PATCH 1/5] DocBook media: update STREAMON/OFF documentation Hans Verkuil
2014-03-07 14:26 ` [RFCv1 PATCH 2/5] DocBook: fix incorrect code example Hans Verkuil
2014-03-07 14:26 ` [RFCv1 PATCH 3/5] DocBook media: clarify v4l2_buffer/plane fields Hans Verkuil
2014-03-07 14:26 ` [RFCv1 PATCH 4/5] DocBook media: fix broken FIELD_ALTERNATE description Hans Verkuil
2014-03-07 14:26 ` [RFCv1 PATCH 5/5] DocBook media: clarify v4l2_pix_format and v4l2_pix_format_mplane fields Hans Verkuil
2014-03-13 14:31   ` Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).