Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > fa21ac0b5c825597d4ae80018c3f2f25 > files > 3063

kernel-doc-2.6.38.6-26.rc1.fc15.noarch.rpm

<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Raw VBI Data Interface</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API" /><link rel="up" href="devices.html" title="Chapter&#160;4.&#160;Interfaces" /><link rel="prev" href="effect.html" title="Effect Devices Interface" /><link rel="next" href="sliced.html" title="Sliced VBI Data Interface" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Raw VBI Data Interface</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="effect.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;4.&#160;Interfaces</th><td width="20%" align="right">&#160;<a accesskey="n" href="sliced.html">Next</a></td></tr></table><hr /></div><div class="section" title="Raw VBI Data Interface"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="raw-vbi"></a>Raw VBI Data Interface</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="raw-vbi.html#id3106794">Querying Capabilities</a></span></dt><dt><span class="section"><a href="raw-vbi.html#id3106835">Supplemental Functions</a></span></dt><dt><span class="section"><a href="raw-vbi.html#id3106875">Raw VBI Format Negotiation</a></span></dt><dt><span class="section"><a href="raw-vbi.html#id3107673">Reading and writing VBI images</a></span></dt></dl></div><p>VBI is an abbreviation of Vertical Blanking Interval, a gap
in the sequence of lines of an analog video signal. During VBI
no picture information is transmitted, allowing some time while the
electron beam of a cathode ray tube TV returns to the top of the
screen. Using an oscilloscope you will find here the vertical
synchronization pulses and short data packages ASK
modulated<sup>[<a id="id3105678" href="#ftn.id3105678" class="footnote">21</a>]</sup>
onto the video signal. These are transmissions of services such as
Teletext or Closed Caption.</p><p>Subject of this interface type is raw VBI data, as sampled off
a video signal, or to be added to a signal for output.
The data format is similar to uncompressed video images, a number of
lines times a number of samples per line, we call this a VBI image.</p><p>Conventionally V4L2 VBI devices are accessed through character
device special files named <code class="filename">/dev/vbi</code> and
<code class="filename">/dev/vbi0</code> to <code class="filename">/dev/vbi31</code> with
major number 81 and minor numbers 224 to 255.
<code class="filename">/dev/vbi</code> is typically a symbolic link to the
preferred VBI device. This convention applies to both input and output
devices.</p><p>To address the problems of finding related video and VBI
devices VBI capturing and output is also available as device function
under <code class="filename">/dev/video</code>. To capture or output raw VBI
data with these devices applications must call the <a class="link" href="vidioc-g-fmt.html" title="ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT"><code class="constant">VIDIOC_S_FMT</code></a>
ioctl. Accessed as <code class="filename">/dev/vbi</code>, raw VBI capturing
or output is the default device function.</p><div class="section" title="Querying Capabilities"><div class="titlepage"><div><div><h3 class="title"><a id="id3106794"></a>Querying Capabilities</h3></div></div></div><p>Devices supporting the raw VBI capturing or output API set
the <code class="constant">V4L2_CAP_VBI_CAPTURE</code> or
<code class="constant">V4L2_CAP_VBI_OUTPUT</code> flags, respectively, in the
<em class="structfield"><code>capabilities</code></em> field of struct&#160;<a class="link" href="vidioc-querycap.html#v4l2-capability" title="Table&#160;A.75.&#160;struct v4l2_capability">v4l2_capability</a>
returned by the <a class="link" href="vidioc-querycap.html" title="ioctl VIDIOC_QUERYCAP"><code class="constant">VIDIOC_QUERYCAP</code></a> ioctl. At least one of the
read/write, streaming or asynchronous I/O methods must be
supported. VBI devices may or may not have a tuner or modulator.</p></div><div class="section" title="Supplemental Functions"><div class="titlepage"><div><div><h3 class="title"><a id="id3106835"></a>Supplemental Functions</h3></div></div></div><p>VBI devices shall support <a class="link" href="video.html" title="Video Inputs and Outputs">video
input or output</a>, <a class="link" href="tuner.html" title="Tuners and Modulators">tuner or
modulator</a>, and <a class="link" href="control.html" title="User Controls">controls</a> ioctls
as needed. The <a class="link" href="standard.html" title="Video Standards">video standard</a> ioctls provide
information vital to program a VBI device, therefore must be
supported.</p></div><div class="section" title="Raw VBI Format Negotiation"><div class="titlepage"><div><div><h3 class="title"><a id="id3106875"></a>Raw VBI Format Negotiation</h3></div></div></div><p>Raw VBI sampling abilities can vary, in particular the
sampling frequency. To properly interpret the data V4L2 specifies an
ioctl to query the sampling parameters. Moreover, to allow for some
flexibility applications can also suggest different parameters.</p><p>As usual these parameters are <span class="emphasis"><em>not</em></span>
reset at <a class="link" href="func-open.html" title="V4L2 open()"><code class="function">open()</code></a> time to permit Unix tool chains, programming a
device and then reading from it as if it was a plain file. Well
written V4L2 applications should always ensure they really get what
they want, requesting reasonable parameters and then checking if the
actual parameters are suitable.</p><p>To query the current raw VBI capture parameters
applications set the <em class="structfield"><code>type</code></em> field of a
struct&#160;<a class="link" href="vidioc-g-fmt.html#v4l2-format" title="Table&#160;A.55.&#160;struct v4l2_format">v4l2_format</a> to <code class="constant">V4L2_BUF_TYPE_VBI_CAPTURE</code> or
<code class="constant">V4L2_BUF_TYPE_VBI_OUTPUT</code>, and call the
<a class="link" href="vidioc-g-fmt.html" title="ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT"><code class="constant">VIDIOC_G_FMT</code></a> ioctl with a pointer to this structure. Drivers fill
the struct&#160;<a class="link" href="raw-vbi.html#v4l2-vbi-format" title="Table&#160;4.4.&#160;struct v4l2_vbi_format">v4l2_vbi_format</a> <em class="structfield"><code>vbi</code></em> member of the
<em class="structfield"><code>fmt</code></em> union.</p><p>To request different parameters applications set the
<em class="structfield"><code>type</code></em> field of a struct&#160;<a class="link" href="vidioc-g-fmt.html#v4l2-format" title="Table&#160;A.55.&#160;struct v4l2_format">v4l2_format</a> as above and
initialize all fields of the struct&#160;<a class="link" href="raw-vbi.html#v4l2-vbi-format" title="Table&#160;4.4.&#160;struct v4l2_vbi_format">v4l2_vbi_format</a>
<em class="structfield"><code>vbi</code></em> member of the
<em class="structfield"><code>fmt</code></em> union, or better just modify the
results of <code class="constant">VIDIOC_G_FMT</code>, and call the
<a class="link" href="vidioc-g-fmt.html" title="ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT"><code class="constant">VIDIOC_S_FMT</code></a> ioctl with a pointer to this structure. Drivers return
an <span class="errorcode">EINVAL</span> error code only when the given parameters are ambiguous, otherwise
they modify the parameters according to the hardware capabilites and
return the actual parameters. When the driver allocates resources at
this point, it may return an <span class="errorcode">EBUSY</span> error code to indicate the returned
parameters are valid but the required resources are currently not
available. That may happen for instance when the video and VBI areas
to capture would overlap, or when the driver supports multiple opens
and another process already requested VBI capturing or output. Anyway,
applications must expect other resource allocation points which may
return <span class="errorcode">EBUSY</span>, at the <a class="link" href="vidioc-streamon.html" title="ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF"><code class="constant">VIDIOC_STREAMON</code></a> ioctl
and the first read(), write() and select() call.</p><p>VBI devices must implement both the
<code class="constant">VIDIOC_G_FMT</code> and
<code class="constant">VIDIOC_S_FMT</code> ioctl, even if
<code class="constant">VIDIOC_S_FMT</code> ignores all requests and always
returns default parameters as <code class="constant">VIDIOC_G_FMT</code> does.
<code class="constant">VIDIOC_TRY_FMT</code> is optional.</p><div class="table"><a id="v4l2-vbi-format"></a><p class="title"><strong>Table&#160;4.4.&#160;struct <span class="structname">v4l2_vbi_format</span></strong></p><div class="table-contents"><table summary="struct v4l2_vbi_format" width="100%" border="0"><colgroup><col class="c1" /><col class="c2" /><col class="c3" /></colgroup><tbody valign="top"><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>sampling_rate</code></em></td><td valign="top">Samples per second, i.&#160;e. unit 1 Hz.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>offset</code></em></td><td valign="top"><p>Horizontal offset of the VBI image,
relative to the leading edge of the line synchronization pulse and
counted in samples: The first sample in the VBI image will be located
<em class="structfield"><code>offset</code></em> /
<em class="structfield"><code>sampling_rate</code></em> seconds following the leading
edge. See also <a class="xref" href="raw-vbi.html#vbi-hsync" title="Figure&#160;4.1.&#160;Line synchronization">Figure&#160;4.1, &#8220;Line synchronization&#8221;</a>.</p></td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>samples_per_line</code></em></td><td valign="top">&#160;</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>sample_format</code></em></td><td valign="top"><p>Defines the sample format as in <a class="xref" href="pixfmt.html" title="Chapter&#160;2.&#160;Image Formats">Chapter&#160;2, <em>Image Formats</em></a>, a four-character-code.<sup>[<a id="id3107194" href="#ftn.id3107194" class="footnote">a</a>]</sup> Usually this is
<code class="constant">V4L2_PIX_FMT_GREY</code>, i.&#160;e. each sample
consists of 8 bits with lower values oriented towards the black level.
Do not assume any other correlation of values with the signal level.
For example, the MSB does not necessarily indicate if the signal is
'high' or 'low' because 128 may not be the mean value of the
signal. Drivers shall not convert the sample format by software.</p></td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>start</code></em>[2]</td><td valign="top">This is the scanning system line number
associated with the first line of the VBI image, of the first and the
second field respectively. See <a class="xref" href="raw-vbi.html#vbi-525" title="Figure&#160;4.2.&#160;ITU-R 525 line numbering (M/NTSC and M/PAL)">Figure&#160;4.2, &#8220;ITU-R 525 line numbering (M/NTSC and M/PAL)&#8221;</a> and
<a class="xref" href="raw-vbi.html#vbi-625" title="Figure&#160;4.3.&#160;ITU-R 625 line numbering">Figure&#160;4.3, &#8220;ITU-R 625 line numbering&#8221;</a> for valid values. VBI input drivers can
return start values 0 if the hardware cannot reliable identify
scanning lines, VBI acquisition may not require this
information.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>count</code></em>[2]</td><td valign="top">The number of lines in the first and second
field image, respectively.</td></tr><tr><td colspan="3" valign="top"><p>Drivers should be as
flexibility as possible. For example, it may be possible to extend or
move the VBI capture window down to the picture area, implementing a
'full field mode' to capture data service transmissions embedded in
the picture.</p><p>An application can set the first or second
<em class="structfield"><code>count</code></em> value to zero if no data is required
from the respective field; <em class="structfield"><code>count</code></em>[1] if the
scanning system is progressive, i.&#160;e. not interlaced. The
corresponding start value shall be ignored by the application and
driver. Anyway, drivers may not support single field capturing and
return both count values non-zero.</p><p>Both
<em class="structfield"><code>count</code></em> values set to zero, or line numbers
outside the bounds depicted in <a class="xref" href="raw-vbi.html#vbi-525" title="Figure&#160;4.2.&#160;ITU-R 525 line numbering (M/NTSC and M/PAL)">Figure&#160;4.2, &#8220;ITU-R 525 line numbering (M/NTSC and M/PAL)&#8221;</a> and <a class="xref" href="raw-vbi.html#vbi-625" title="Figure&#160;4.3.&#160;ITU-R 625 line numbering">Figure&#160;4.3, &#8220;ITU-R 625 line numbering&#8221;</a>, or a field image covering
lines of two fields, are invalid and shall not be returned by the
driver.</p><p>To initialize the <em class="structfield"><code>start</code></em>
and <em class="structfield"><code>count</code></em> fields, applications must first
determine the current video standard selection. The <a class="link" href="vidioc-enumstd.html#v4l2-std-id" title="Table&#160;A.34.&#160;typedef v4l2_std_id">v4l2_std_id</a> or
the <em class="structfield"><code>framelines</code></em> field of struct&#160;<a class="link" href="vidioc-enumstd.html#v4l2-standard" title="Table&#160;A.32.&#160;struct v4l2_standard">v4l2_standard</a> can
be evaluated for this purpose.</p></td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>flags</code></em></td><td valign="top">See <a class="xref" href="raw-vbi.html#vbifmt-flags" title="Table&#160;4.5.&#160;Raw VBI Format Flags">Table&#160;4.5, &#8220;Raw VBI Format Flags&#8221;</a> below. Currently
only drivers set flags, applications must set this field to
zero.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>reserved</code></em>[2]</td><td valign="top">This array is reserved for future extensions.
Drivers and applications must set it to zero.</td></tr></tbody><tbody class="footnotes"><tr><td colspan="3"><div class="footnote"><p><sup>[<a id="ftn.id3107194" href="#id3107194" class="para">a</a>] </sup>A few devices may be unable to
sample VBI data at all but can extend the video capture window to the
VBI region.</p></div></td></tr></tbody></table></div></div><br class="table-break" /><div class="table"><a id="vbifmt-flags"></a><p class="title"><strong>Table&#160;4.5.&#160;Raw VBI Format Flags</strong></p><div class="table-contents"><table summary="Raw VBI Format Flags" width="100%" border="0"><colgroup><col class="c1" /><col class="c2" /><col class="c3" /></colgroup><tbody valign="top"><tr><td valign="top"><code class="constant">V4L2_VBI_UNSYNC</code></td><td valign="top">0x0001</td><td valign="top"><p>This flag indicates hardware which does not
properly distinguish between fields. Normally the VBI image stores the
first field (lower scanning line numbers) first in memory. This may be
a top or bottom field depending on the video standard. When this flag
is set the first or second field may be stored first, however the
fields are still in correct temporal order with the older field first
in memory.<sup>[<a id="id3107453" href="#ftn.id3107453" class="footnote">a</a>]</sup></p></td></tr><tr><td valign="top"><code class="constant">V4L2_VBI_INTERLACED</code></td><td valign="top">0x0002</td><td valign="top">By default the two field images will be passed
sequentially; all lines of the first field followed by all lines of
the second field (compare <a class="xref" href="field-order.html" title="Field Order">the section called &#8220;Field Order&#8221;</a>
<code class="constant">V4L2_FIELD_SEQ_TB</code> and
<code class="constant">V4L2_FIELD_SEQ_BT</code>, whether the top or bottom
field is first in memory depends on the video standard). When this
flag is set, the two fields are interlaced (cf.
<code class="constant">V4L2_FIELD_INTERLACED</code>). The first line of the
first field followed by the first line of the second field, then the
two second lines, and so on. Such a layout may be necessary when the
hardware has been programmed to capture or output interlaced video
images and is unable to separate the fields for VBI capturing at
the same time. For simplicity setting this flag implies that both
<em class="structfield"><code>count</code></em> values are equal and non-zero.</td></tr></tbody><tbody class="footnotes"><tr><td colspan="3"><div class="footnote"><p><sup>[<a id="ftn.id3107453" href="#id3107453" class="para">a</a>] </sup>Most VBI services transmit on both fields, but
some have different semantics depending on the field number. These
cannot be reliable decoded or encoded when
<code class="constant">V4L2_VBI_UNSYNC</code> is set.</p></div></td></tr></tbody></table></div></div><br class="table-break" /><div class="figure"><a id="vbi-hsync"></a><p class="title"><strong>Figure&#160;4.1.&#160;Line synchronization</strong></p><div class="figure-contents"><div class="mediaobject"><img src="vbi_hsync.gif" alt="Line synchronization diagram" /></div></div></div><br class="figure-break" /><div class="figure"><a id="vbi-525"></a><p class="title"><strong>Figure&#160;4.2.&#160;ITU-R 525 line numbering (M/NTSC and M/PAL)</strong></p><div class="figure-contents"><div class="mediaobject"><img src="vbi_525.gif" alt="NTSC field synchronization diagram" /><div class="caption"><p>(1) For the purpose of this specification field 2
starts in line 264 and not 263.5 because half line capturing is not
supported.</p></div></div></div></div><br class="figure-break" /><div class="figure"><a id="vbi-625"></a><p class="title"><strong>Figure&#160;4.3.&#160;ITU-R 625 line numbering</strong></p><div class="figure-contents"><div class="mediaobject"><img src="vbi_625.gif" alt="PAL/SECAM field synchronization diagram" /><div class="caption"><p>(1) For the purpose of this specification field 2
starts in line 314 and not 313.5 because half line capturing is not
supported.</p></div></div></div></div><br class="figure-break" /><p>Remember the VBI image format depends on the selected
video standard, therefore the application must choose a new standard or
query the current standard first. Attempts to read or write data ahead
of format negotiation, or after switching the video standard which may
invalidate the negotiated VBI parameters, should be refused by the
driver. A format change during active I/O is not permitted.</p></div><div class="section" title="Reading and writing VBI images"><div class="titlepage"><div><div><h3 class="title"><a id="id3107673"></a>Reading and writing VBI images</h3></div></div></div><p>To assure synchronization with the field number and easier
implementation, the smallest unit of data passed at a time is one
frame, consisting of two fields of VBI images immediately following in
memory.</p><p>The total size of a frame computes as follows:</p><pre class="programlisting">
(<em class="structfield"><code>count</code></em>[0] + <em class="structfield"><code>count</code></em>[1]) *
<em class="structfield"><code>samples_per_line</code></em> * sample size in bytes</pre><p>The sample size is most likely always one byte,
applications must check the <em class="structfield"><code>sample_format</code></em>
field though, to function properly with other drivers.</p><p>A VBI device may support <a class="link" href="io.html#rw" title="Read/Write">read/write</a> and/or streaming (<a class="link" href="mmap.html" title="Streaming I/O (Memory Mapping)">memory mapping</a> or <a class="link" href="userp.html" title="Streaming I/O (User Pointers)">user pointer</a>) I/O. The latter bears the
possibility of synchronizing video and
VBI data by using buffer timestamps.</p><p>Remember the <a class="link" href="vidioc-streamon.html" title="ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF"><code class="constant">VIDIOC_STREAMON</code></a> ioctl and the first read(),
write() and select() call can be resource allocation points returning
an <span class="errorcode">EBUSY</span> error code if the required hardware resources are temporarily
unavailable, for example the device is already in use by another
process.</p></div><div class="footnotes"><br /><hr width="100" align="left" /><div class="footnote"><p><sup>[<a id="ftn.id3105678" href="#id3105678" class="para">21</a>] </sup>ASK: Amplitude-Shift Keying. A high signal
level represents a '1' bit, a low level a '0' bit.</p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="effect.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="devices.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="sliced.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Effect Devices Interface&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Sliced VBI Data Interface</td></tr></table></div></body></html>