On Mon, 2009-03-09 at 08:25 +0100, Hans Verkuil wrote: > On Monday 09 March 2009 05:30:54 Mauro Carvalho Chehab wrote: > > On Sat, 7 Mar 2009 09:49:30 +0100 > > > > Hans Verkuil <hverkuil@xxxxxxxxx> wrote: > > > On Saturday 07 March 2009 02:31:41 Andy Walls wrote: > > > > On Fri, 2009-03-06 at 15:41 +0100, Hans Verkuil wrote: > > > > > On Friday 06 March 2009 04:39:34 Andy Walls wrote: > > > > > > Yes, they should be exported to userspace as well, so apps like > > > > > > MythTV don't have to keep their own copies as well. I'm going to > > > > > > work on a V4L2 spec change to add structures and defines for the > > > > > > packets indicated by V4L2_MPEG_STREAM_VBI_FMT_IVTV, and then add > > > > > > it to some API header. Maybe in linux/include/linux/videodev2.h > > > > > > with all the other VBI data formats. > > > > > > > > > > > > Unless someone really disagrees. > > > > > > > > > > These VBI defines should be moved to videodev2.h. In hindsight this > > > > > should never have been added to ivtv.h. Originally only ivtv used > > > > > this, but now cx18 does as well, and in theory any MPEG encoder > > > > > device can use it. > > > > > > > > Hans, Mauro, and whoever: > > > > > > > > Before I get too far down the road of writing the spec modifications > > > > and perhaps modifying drivers, in the diff below: > > > > > > > > 1. Are the modifications to the headers acceptable? > > > > > > > > 2. Are they correct? (I *think* they are.) > > > > > > Acked-by: Hans Verkuil <hverkuil@xxxxxxxxx> > > > > > > Very nice. I was also toying with the idea to rename 'IVTV' in these > > > defines to something different, but that makes too much of a mess. I > > > think it is sufficient to add a sentence to the spec along the lines > > > of: > > > > > > "This format was first introduced in the ivtv driver, hence the use of > > > IVTV in these defines. It is however not limited to the ivtv driver, > > > any MPEG encoder can use it." > > > > > > And I think that it also doesn't hurt if some of my explanations from > > > my earlier email are added to the spec as well. The format looks really > > > weird if you do not understand the PVR350 (cx23415) limitation. > > > > IMO, it is better to remove the IVTV from the name or to replace to > > something else, since it is meant to be used by other drivers. > > > > > +#define V4L2_MPEG_VBI_IVTV_MAGIC0 "itv0" > > > +#define V4L2_MPEG_VBI_IVTV_MAGIC1 "ITV0" > > > > Hmm... maybe we could just name it as format ITV0, as marked at the magic > > values above. What do you think? > > I don't really see much of an improvement here. I think it is better to put > a note in the spec (and perhaps in videodev2.h) that while it originated > with ivtv it is not specific to that driver. > > But I do not have a really strong opinion here. I don't have a terribly strong opinion either. I'm almost done the spec changes (see the diff inline below), but I can easily change things. I don't particularly want to purge IVTV from the V4L2_CID_MPEG_STREAM_VBI_FMT MPEG control enumeration: enum v4l2_mpeg_stream_vbi_fmt { [...] V4L2_MPEG_STREAM_VBI_FMT_IVTV = 1, }; as that would be a specification change vs. an addition. Also adding a new ...FMT_ITV0 symbol to the enumeration, that overlaps with a value of 1, creates problems for the controls code. IMO, IVTV is there to stay in that enumeration. I can change every other IVTV reference to ITV0 in a sensible way (I think). Let me know, if you really want this. I won't be finishing it and posting it for final draft review for a day or two. Regards, Andy diff -r 5361470b10f4 linux/include/linux/ivtv.h --- a/linux/include/linux/ivtv.h Sun Mar 01 21:10:07 2009 -0500 +++ b/linux/include/linux/ivtv.h Mon Mar 09 16:42:40 2009 -0400 @@ -60,10 +60,10 @@ #define IVTV_IOC_DMA_FRAME _IOW ('V', BASE_VIDIOC_PRIVATE+0, struct ivtv_dma_frame) -/* These are the VBI types as they appear in the embedded VBI private packets. */ -#define IVTV_SLICED_TYPE_TELETEXT_B (1) -#define IVTV_SLICED_TYPE_CAPTION_525 (4) -#define IVTV_SLICED_TYPE_WSS_625 (5) -#define IVTV_SLICED_TYPE_VPS (7) +/* Deprecated defines: applications should use the defines from videodev2.h */ +#define IVTV_SLICED_TYPE_TELETEXT_B V4L2_MPEG_VBI_IVTV_TELETEXT_B +#define IVTV_SLICED_TYPE_CAPTION_525 V4L2_MPEG_VBI_IVTV_CAPTION_525 +#define IVTV_SLICED_TYPE_WSS_625 V4L2_MPEG_VBI_IVTV_WSS_625 +#define IVTV_SLICED_TYPE_VPS V4L2_MPEG_VBI_IVTV_VPS #endif /* _LINUX_IVTV_H */ diff -r 5361470b10f4 linux/include/linux/videodev2.h --- a/linux/include/linux/videodev2.h Sun Mar 01 21:10:07 2009 -0500 +++ b/linux/include/linux/videodev2.h Mon Mar 09 16:42:40 2009 -0400 @@ -1348,6 +1348,53 @@ }; /* + * Sliced VBI data inserted into MPEG Streams + */ + +/* + * V4L2_MPEG_STREAM_VBI_FMT_IVTV: + * + * Structure of payload contained in an MPEG 2 Private Stream 1 PES Packet in an + * MPEG-2 Program Pack that contains V4L2_MPEG_STREAM_VBI_FMT_IVTV Sliced VBI + * data + * + * Note, the MPEG-2 Program Pack and Private Stream 1 PES packet header + * definitions are not included here. See the MPEG-2 specifications for details + * on these headers. + */ + +/* Line type IDs */ +#define V4L2_MPEG_VBI_IVTV_TELETEXT_B (1) +#define V4L2_MPEG_VBI_IVTV_CAPTION_525 (4) +#define V4L2_MPEG_VBI_IVTV_WSS_625 (5) +#define V4L2_MPEG_VBI_IVTV_VPS (7) + +struct v4l2_mpeg_vbi_itv0_line { + __u8 id; /* One of V4L2_MPEG_VBI_IVTV_* above */ + __u8 data[42]; /* Sliced VBI data for the line */ +} __attribute__ ((packed)); + +struct v4l2_mpeg_vbi_itv0 { + __u32 linemask[2]; /* Bitmasks of which VBI service lines are present */ + struct v4l2_mpeg_vbi_itv0_line line[35]; +} __attribute__ ((packed)); + +struct v4l2_mpeg_vbi_ITV0 { + struct v4l2_mpeg_vbi_itv0_line line[36]; +} __attribute__ ((packed)); + +#define V4L2_MPEG_VBI_IVTV_MAGIC0 "itv0" +#define V4L2_MPEG_VBI_IVTV_MAGIC1 "ITV0" + +struct v4l2_mpeg_vbi_fmt_ivtv { + __u8 magic[4]; + union { + struct v4l2_mpeg_vbi_itv0 itv0; + struct v4l2_mpeg_vbi_ITV0 ITV0; + }; +} __attribute__ ((packed)); + +/* * A G G R E G A T E S T R U C T U R E S */ diff -r 5361470b10f4 v4l2-spec/Makefile --- a/v4l2-spec/Makefile Sun Mar 01 21:10:07 2009 -0500 +++ b/v4l2-spec/Makefile Mon Mar 09 16:42:40 2009 -0400 @@ -274,6 +274,7 @@ v4l2_input \ v4l2_jpegcompression \ v4l2_modulator \ + v4l2_mpeg_vbi_fmt_ivtv \ v4l2_output \ v4l2_outputparm \ v4l2_pix_format \ diff -r 5361470b10f4 v4l2-spec/dev-sliced-vbi.sgml --- a/v4l2-spec/dev-sliced-vbi.sgml Sun Mar 01 21:10:07 2009 -0500 +++ b/v4l2-spec/dev-sliced-vbi.sgml Mon Mar 09 16:42:40 2009 -0400 @@ -48,7 +48,7 @@ supported.</para> </section> - <section> + <section id="sliced-vbi-format-negotitation"> <title>Sliced VBI Format Negotiation</title> <para>To find out which data services are supported by the @@ -386,6 +386,278 @@ </section> + <section> + <title>Sliced VBI Data in MPEG Streams</title> + + <para>If a device can produce an MPEG output stream, it may be +capable of providing <link +linkend="sliced-vbi-format-negotitation">negotiated sliced VBI +services</link> as data embedded in the MPEG stream. Users or +applications control this sliced VBI data insertion with the <link +linkend="v4l2-mpeg-stream-vbi-fmt">V4L2_CID_MPEG_STREAM_VBI_FMT</link> +control.</para> + + <para>If the driver does not provide the <link +linkend="v4l2-mpeg-stream-vbi-fmt">V4L2_CID_MPEG_STREAM_VBI_FMT</link> +control, or only allows that control to be set to <link +linkend="v4l2-mpeg-stream-vbi-fmt"><constant> +V4L2_MPEG_STREAM_VBI_FMT_NONE</constant></link>, then the device +cannot embed sliced VBI data in the MPEG stream.</para> + + <para>The <link linkend="v4l2-mpeg-stream-vbi-fmt"> +V4L2_CID_MPEG_STREAM_VBI_FMT</link> control does not implicitly set +the device driver to capture nor cease capturing sliced VBI data. The +control only indicates to embed sliced VBI data in the MPEG stream, if +an application has negotiated sliced VBI service be captured.</para> + + <para>It may also be the case that a device can embed sliced VBI +data in only certain types of MPEG streams: for example in an MPEG-2 +PS but not an MPEG-2 TS. In this situation, if sliced VBI data +insertion is requested, the sliced VBI data will be embedded in MPEG +stream types when supported, and silently omitted from MPEG stream +types where sliced VBI data insertion is not supported by the device. +</para> + + <para>The following subsections specify the format of the +embedded sliced VBI data.</para> + + <section> + <title>MPEG Stream Embedded, Sliced VBI Data Format: NONE</title> + <para>The <link linkend="v4l2-mpeg-stream-vbi-fmt"><constant> +V4L2_MPEG_STREAM_VBI_FMT_NONE</constant></link> embedded sliced VBI +format shall be interpreted by drivers as a control to cease +embedding sliced VBI data in MPEG streams. Neither the device nor +driver shall insert "empty" embedded sliced VBI data packets in the +MPEG stream when this format is set. No MPEG stream data structures +are specified for this format.</para> + </section> + + <section> + <title>MPEG Stream Embedded, Sliced VBI Data Format: IVTV</title> + <para>The <link linkend="v4l2-mpeg-stream-vbi-fmt"><constant> +V4L2_MPEG_STREAM_VBI_FMT_IVTV</constant></link> embedded sliced VBI +format, when supported, indicates to the driver to embed up to 36 +lines of sliced VBI data per frame in an MPEG-2 <emphasis>Private +Stream 1 PES</emphasis> packet encapsulated in an MPEG-2 <emphasis> +Program Pack</emphasis> in the MPEG stream.</para> + + <para><emphasis>Historical context</emphasis>: This format +specification originates from a custom, embedded, sliced VBI data +format used by the <filename>ivtv</filename> driver. This format +has already been informally specified in the kernel sources in the +file <filename>Documentation/video4linux/cx2341x/README.vbi</filename> +. The maximum size of the payload and other aspects of this format +are driven by the CX23415 MPEG decoder's capabilities and limitations +with respect to extracting, decoding, and displaying sliced VBI data +embedded within an MPEG stream.</para> + + <para>This format's use is <emphasis>not</emphasis> exclusive to +the <filename>ivtv</filename> driver <emphasis>nor</emphasis> +exclusive to CX2341x devices, as the sliced VBI data packet insertion +into the MPEG stream is implemented in driver software. At least the +<filename>cx18</filename> driver provides sliced VBI data insertion +into an MPEG-2 PS in this format as well.</para> + + <para>The following definitions specify the payload of the +MPEG-2 <emphasis>Private Stream 1 PES</emphasis> packets that contain +sliced VBI data when <link linkend="v4l2-mpeg-stream-vbi-fmt"> +<constant>V4L2_MPEG_STREAM_VBI_FMT_IVTV</constant></link> is set. +(The MPEG-2 <emphasis>Private Stream 1 PES</emphasis> packet header +and encapsulating MPEG-2 <emphasis>Program Pack</emphasis> header are +not detailed here. Please refer to the MPEG-2 specifications for +details on those packet headers.)</para> + + <para>The payload of the MPEG-2 <emphasis>Private Stream 1 PES +</emphasis> packets that contain sliced VBI data is specified by +&v4l2-mpeg-vbi-fmt-ivtv;. The payload is variable +length, depending on the actual number of lines of sliced VBI data +present in a video frame. The payload may be padded at the end with +unspecified fill bytes to align the end of the payload to a 4-byte +boundary. The payload shall never exceed 1552 bytes (2 fields with +18 lines/field with 43 bytes of data/line and a 4 byte magic number). +</para> + + <table frame="none" pgwide="1" id="v4l2-mpeg-vbi-fmt-ivtv"> + <title>struct <structname>v4l2_mpeg_vbi_fmt_ivtv</structname></title> + <tgroup cols="4"> + &cs-ustr; + <tbody valign="top"> + <row> + <entry>__u8</entry> + <entry><structfield>magic</structfield>[4]</entry> + <entry></entry> + <entry>A "magic" constant from <xref + linkend="v4l2-mpeg-vbi-fmt-ivtv-magic"> that indicates +this is a valid sliced VBI data payload and also indicates which +member of the anonymous union, <structfield>itv0</structfield> or +<structfield>ITV0</structfield>, to use for the payload data.</entry> + </row> + <row> + <entry>union</entry> + <entry>(anonymous)</entry> + </row> + <row> + <entry></entry> + <entry>struct <link linkend="v4l2-mpeg-vbi-itv0"> + <structname>v4l2_mpeg_vbi_itv0</structname></link> + </entry> + <entry><structfield>itv0</structfield></entry> + <entry>comment</entry> + </row> + <row> + <entry></entry> + <entry>struct <link linkend="v4l2-mpeg-vbi-ITV0-1"> + <structname>v4l2_mpeg_vbi_ITV0</structname></link> + </entry> + <entry><structfield>ITV0</structfield></entry> + <entry>comment</entry> + </row> + </tbody> + </tgroup> + </table> + + <table frame="none" pgwide="1" id="v4l2-mpeg-vbi-fmt-ivtv-magic"> + <title>Magic Constants for &v4l2-mpeg-vbi-fmt-ivtv; + <structfield>magic</structfield> field</title> + <tgroup cols="3"> + &cs-def; + <thead> + <row> + <entry align="left">Defined Symbol</entry> + <entry align="left">Value</entry> + <entry align="left">Description</entry> + </row> + </thead> + <tbody valign="top"> + <row> + <entry><constant>V4L2_MPEG_VBI_IVTV_MAGIC0</constant> + </entry> + <entry>"itv0"</entry> + <entry>Indicates the <structfield>itv0</structfield> + member of the union in &v4l2-mpeg-vbi-fmt-ivtv; is valid. Line +masks are provided in this form of the payload indicating which VBI +lines are provided.</entry> + </row> + <row> + <entry><constant>V4L2_MPEG_VBI_IVTV_MAGIC1</constant> + </entry> + <entry>"ITV0"</entry> + <entry>Indicates the <structfield>ITV0</structfield> +member of the union in &v4l2-mpeg-vbi-fmt-ivtv; is valid and +that 36 VBI lines are provided. No line masks are provided in this +form of the payload; all valid line mask bits are implcitly set. +</entry> + </row> + </tbody> + </tgroup> + </table> + + <table frame="none" pgwide="1" id="v4l2-mpeg-vbi-itv0"> + <title>struct <structname>v4l2_mpeg_vbi_itv0</structname> + </title> + <tgroup cols="3"> + &cs-str; + <tbody valign="top"> + <row> + <entry>__u32</entry> + <entry><structfield>linemask</structfield>[2]</entry> + <entry>comment</entry> + </row> + <row> + <entry>struct <link linkend="v4l2-mpeg-vbi-itv0-line"> + <structname>v4l2_mpeg_vbi_itv0_line</structname></link> + </entry> + <entry><structfield>line</structfield>[35]</entry> + <entry>comment: up to 35 lines</entry> + </row> + </tbody> + </tgroup> + </table> + + <table frame="none" pgwide="1" id="v4l2-mpeg-vbi-ITV0-1"> + <title>struct <structname>v4l2_mpeg_vbi_ITV0</structname> + </title> + <tgroup cols="3"> + &cs-str; + <tbody valign="top"> + <row> + <entry>struct <link linkend="v4l2-mpeg-vbi-itv0-line"> + <structname>v4l2_mpeg_vbi_itv0_line</structname></link> + </entry> + <entry><structfield>line</structfield>[36]</entry> + <entry>comment: all 36 lines</entry> + </row> + </tbody> + </tgroup> + </table> + + <table frame="none" pgwide="1" id="v4l2-mpeg-vbi-itv0-line"> + <title>struct <structname>v4l2_mpeg_vbi_itv0_line</structname> + </title> + <tgroup cols="3"> + &cs-str; + <tbody valign="top"> + <row> + <entry>__u8</entry> + <entry><structfield>id</structfield></entry> + <entry>comment</entry> + </row> + <row> + <entry>__u8</entry> + <entry><structfield>data</structfield>[42]</entry> + <entry>comment</entry> + </row> + </tbody> + </tgroup> + </table> + + <table frame="none" pgwide="1" id="ITV0-Line-Identifier-Constants"> + <title>Line Identifiers for struct <link + linkend="v4l2-mpeg-vbi-itv0-line"><structname> +v4l2_mpeg_vbi_itv0_line</structname></link> <structfield>id +</structfield> field</title> + <tgroup cols="3"> + &cs-def; + <thead> + <row> + <entry align="left">Defined Symbol</entry> + <entry align="left">Value</entry> + <entry align="left">Description</entry> + </row> + </thead> + <tbody valign="top"> + <row> + <entry><constant>V4L2_MPEG_VBI_IVTV_TELETEXT_B</constant> + </entry> + <entry>1</entry> + <entry></entry> + </row> + <row> + <entry><constant>V4L2_MPEG_VBI_IVTV_CAPTION_525</constant> + </entry> + <entry>4</entry> + <entry></entry> + </row> + <row> + <entry><constant>V4L2_MPEG_VBI_IVTV_WSS_625</constant> + </entry> + <entry>5</entry> + <entry></entry> + </row> + <row> + <entry><constant>V4L2_MPEG_VBI_IVTV_VPS</constant> + </entry> + <entry>7</entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </table> + + </section> + </section> + + <!-- Local Variables: mode: sgml -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html