Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > 2c51d8eb79f8810ada971ee8c30ce1e5 > files > 2617

kernel-doc-2.6.32-71.14.1.el6.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>Video Standards</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API" /><link rel="up" href="ch01.html" title="Chapter&#160;1.&#160;Common API Elements" /><link rel="prev" href="ch01s06.html" title="Tuners and Modulators" /><link rel="next" href="ch01s08.html" title="User Controls" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Video Standards</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01s06.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;1.&#160;Common API Elements</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch01s08.html">Next</a></td></tr></table><hr /></div><div class="section" title="Video Standards"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="standard"></a>Video Standards</h2></div></div></div><p>Video devices typically support one or more different video
standards or variations of standards. Each video input and output may
support another set of standards. This set is reported by the
<em class="structfield"><code>std</code></em> field of struct&#160;<a class="link" href="re31.html#v4l2-input" title="Table&#160;A.22.&#160;struct v4l2_input">v4l2_input</a> and
struct&#160;<a class="link" href="re32.html#v4l2-output" title="Table&#160;A.25.&#160;struct v4l2_output">v4l2_output</a> returned by the <a class="link" href="re31.html" title="ioctl VIDIOC_ENUMINPUT"><code class="constant">VIDIOC_ENUMINPUT</code></a> and
<a class="link" href="re32.html" title="ioctl VIDIOC_ENUMOUTPUT"><code class="constant">VIDIOC_ENUMOUTPUT</code></a> ioctl, respectively.</p><p>V4L2 defines one bit for each analog video standard
currently in use worldwide, and sets aside bits for driver defined
standards, e.&#160;g. hybrid standards to watch NTSC video tapes on PAL TVs
and vice versa. Applications can use the predefined bits to select a
particular standard, although presenting the user a menu of supported
standards is preferred. To enumerate and query the attributes of the
supported standards applications use the <a class="link" href="re33.html" title="ioctl VIDIOC_ENUMSTD"><code class="constant">VIDIOC_ENUMSTD</code></a> ioctl.</p><p>Many of the defined standards are actually just variations
of a few major standards. The hardware may in fact not distinguish
between them, or do so internal and switch automatically. Therefore
enumerated standards also contain sets of one or more standard
bits.</p><p>Assume a hypothetic tuner capable of demodulating B/PAL,
G/PAL and I/PAL signals. The first enumerated standard is a set of B
and G/PAL, switched automatically depending on the selected radio
frequency in UHF or VHF band. Enumeration gives a "PAL-B/G" or "PAL-I"
choice. Similar a Composite input may collapse standards, enumerating
"PAL-B/G/H/I", "NTSC-M" and "SECAM-D/K".<sup>[<a id="id2578015" href="#ftn.id2578015" class="footnote">6</a>]</sup></p><p>To query and select the standard used by the current video
input or output applications call the <a class="link" href="re50.html" title="ioctl VIDIOC_G_STD, VIDIOC_S_STD"><code class="constant">VIDIOC_G_STD</code></a> and
<a class="link" href="re50.html" title="ioctl VIDIOC_G_STD, VIDIOC_S_STD"><code class="constant">VIDIOC_S_STD</code></a> ioctl, respectively. The <span class="emphasis"><em>received</em></span>
standard can be sensed with the <a class="link" href="re58.html" title="ioctl VIDIOC_QUERYSTD"><code class="constant">VIDIOC_QUERYSTD</code></a> ioctl. Note parameter of all these ioctls is a pointer to a <a class="link" href="re33.html#v4l2-std-id" title="Table&#160;A.29.&#160;typedef v4l2_std_id">v4l2_std_id</a> type (a standard set), <span class="emphasis"><em>not</em></span> an index into the standard enumeration.<sup>[<a id="id2578058" href="#ftn.id2578058" class="footnote">7</a>]</sup> Drivers must implement all video standard ioctls
when the device has one or more video inputs or outputs.</p><p>Special rules apply to USB cameras where the notion of video
standards makes little sense. More generally any capture device,
output devices accordingly, which is </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>incapable of capturing fields or frames at the nominal
rate of the video standard, or</p></li><li class="listitem"><p>where <a class="link" href="ch03s05.html" title="Buffers">timestamps</a> refer
to the instant the field or frame was received by the driver, not the
capture time, or</p></li><li class="listitem"><p>where <a class="link" href="ch03s05.html" title="Buffers">sequence numbers</a>
refer to the frames received by the driver, not the captured
frames.</p></li></ul></div><p> Here the driver shall set the
<em class="structfield"><code>std</code></em> field of struct&#160;<a class="link" href="re31.html#v4l2-input" title="Table&#160;A.22.&#160;struct v4l2_input">v4l2_input</a> and struct&#160;<a class="link" href="re32.html#v4l2-output" title="Table&#160;A.25.&#160;struct v4l2_output">v4l2_output</a>
to zero, the <code class="constant">VIDIOC_G_STD</code>,
<code class="constant">VIDIOC_S_STD</code>,
<code class="constant">VIDIOC_QUERYSTD</code> and
<code class="constant">VIDIOC_ENUMSTD</code> ioctls shall return the
<span class="errorcode">EINVAL</span> error code.<sup>[<a id="id2578225" href="#ftn.id2578225" class="footnote">8</a>]</sup></p><div class="example"><a id="id2578242"></a><p class="title"><b>Example&#160;1.5.&#160;Information about the current video standard</b></p><div class="example-contents"><pre class="programlisting">
<a class="link" href="re33.html#v4l2-std-id" title="Table&#160;A.29.&#160;typedef v4l2_std_id">v4l2_std_id</a> std_id;
struct&#160;<a class="link" href="re33.html#v4l2-standard" title="Table&#160;A.27.&#160;struct v4l2_standard">v4l2_standard</a> standard;

if (-1 == ioctl (fd, <a class="link" href="re50.html" title="ioctl VIDIOC_G_STD, VIDIOC_S_STD"><code class="constant">VIDIOC_G_STD</code></a>, &amp;std_id)) {
	/* Note when VIDIOC_ENUMSTD always returns EINVAL this
	   is no video device or it falls under the USB exception,
	   and VIDIOC_G_STD returning EINVAL is no error. */

	perror ("VIDIOC_G_STD");
	exit (EXIT_FAILURE);
}

memset (&amp;standard, 0, sizeof (standard));
standard.index = 0;

while (0 == ioctl (fd, <a class="link" href="re33.html" title="ioctl VIDIOC_ENUMSTD"><code class="constant">VIDIOC_ENUMSTD</code></a>, &amp;standard)) {
	if (standard.id &amp; std_id) {
	       printf ("Current video standard: %s\n", standard.name);
	       exit (EXIT_SUCCESS);
	}

	standard.index++;
}

/* EINVAL indicates the end of the enumeration, which cannot be
   empty unless this device falls under the USB exception. */

if (errno == EINVAL || standard.index == 0) {
	perror ("VIDIOC_ENUMSTD");
	exit (EXIT_FAILURE);
}
      </pre></div></div><br class="example-break" /><div class="example"><a id="id2578260"></a><p class="title"><b>Example&#160;1.6.&#160;Listing the video standards supported by the current
input</b></p><div class="example-contents"><pre class="programlisting">
struct&#160;<a class="link" href="re31.html#v4l2-input" title="Table&#160;A.22.&#160;struct v4l2_input">v4l2_input</a> input;
struct&#160;<a class="link" href="re33.html#v4l2-standard" title="Table&#160;A.27.&#160;struct v4l2_standard">v4l2_standard</a> standard;

memset (&amp;input, 0, sizeof (input));

if (-1 == ioctl (fd, <a class="link" href="re43.html" title="ioctl VIDIOC_G_INPUT, VIDIOC_S_INPUT"><code class="constant">VIDIOC_G_INPUT</code></a>, &amp;input.index)) {
	perror ("VIDIOC_G_INPUT");
	exit (EXIT_FAILURE);
}

if (-1 == ioctl (fd, <a class="link" href="re31.html" title="ioctl VIDIOC_ENUMINPUT"><code class="constant">VIDIOC_ENUMINPUT</code></a>, &amp;input)) {
	perror ("VIDIOC_ENUM_INPUT");
	exit (EXIT_FAILURE);
}

printf ("Current input %s supports:\n", input.name);

memset (&amp;standard, 0, sizeof (standard));
standard.index = 0;

while (0 == ioctl (fd, <a class="link" href="re33.html" title="ioctl VIDIOC_ENUMSTD"><code class="constant">VIDIOC_ENUMSTD</code></a>, &amp;standard)) {
	if (standard.id &amp; input.std)
		printf ("%s\n", standard.name);

	standard.index++;
}

/* EINVAL indicates the end of the enumeration, which cannot be
   empty unless this device falls under the USB exception. */

if (errno != EINVAL || standard.index == 0) {
	perror ("VIDIOC_ENUMSTD");
	exit (EXIT_FAILURE);
}
      </pre></div></div><br class="example-break" /><div class="example"><a id="id2578376"></a><p class="title"><b>Example&#160;1.7.&#160;Selecting a new video standard</b></p><div class="example-contents"><pre class="programlisting">
struct&#160;<a class="link" href="re31.html#v4l2-input" title="Table&#160;A.22.&#160;struct v4l2_input">v4l2_input</a> input;
<a class="link" href="re33.html#v4l2-std-id" title="Table&#160;A.29.&#160;typedef v4l2_std_id">v4l2_std_id</a> std_id;

memset (&amp;input, 0, sizeof (input));

if (-1 == ioctl (fd, <a class="link" href="re43.html" title="ioctl VIDIOC_G_INPUT, VIDIOC_S_INPUT"><code class="constant">VIDIOC_G_INPUT</code></a>, &amp;input.index)) {
	perror ("VIDIOC_G_INPUT");
	exit (EXIT_FAILURE);
}

if (-1 == ioctl (fd, <a class="link" href="re31.html" title="ioctl VIDIOC_ENUMINPUT"><code class="constant">VIDIOC_ENUMINPUT</code></a>, &amp;input)) {
	perror ("VIDIOC_ENUM_INPUT");
	exit (EXIT_FAILURE);
}

if (0 == (input.std &amp; V4L2_STD_PAL_BG)) {
	fprintf (stderr, "Oops. B/G PAL is not supported.\n");
	exit (EXIT_FAILURE);
}

/* Note this is also supposed to work when only B
   <span class="emphasis"><em>or</em></span> G/PAL is supported. */

std_id = V4L2_STD_PAL_BG;

if (-1 == ioctl (fd, <a class="link" href="re50.html" title="ioctl VIDIOC_G_STD, VIDIOC_S_STD"><code class="constant">VIDIOC_S_STD</code></a>, &amp;std_id)) {
	perror ("VIDIOC_S_STD");
	exit (EXIT_FAILURE);
}
      </pre></div></div><br class="example-break" /><div class="footnotes"><br /><hr width="100" align="left" /><div class="footnote"><p><sup>[<a id="ftn.id2578015" href="#id2578015" class="para">6</a>] </sup>Some users are already confused by technical terms PAL,
NTSC and SECAM. There is no point asking them to distinguish between
B, G, D, or K when the software or hardware can do that
automatically.</p></div><div class="footnote"><p><sup>[<a id="ftn.id2578058" href="#id2578058" class="para">7</a>] </sup>An alternative to the current scheme is to use pointers
to indices as arguments of <code class="constant">VIDIOC_G_STD</code> and
<code class="constant">VIDIOC_S_STD</code>, the struct&#160;<a class="link" href="re31.html#v4l2-input" title="Table&#160;A.22.&#160;struct v4l2_input">v4l2_input</a> and
struct&#160;<a class="link" href="re32.html#v4l2-output" title="Table&#160;A.25.&#160;struct v4l2_output">v4l2_output</a> <em class="structfield"><code>std</code></em> field would be a set of
indices like <em class="structfield"><code>audioset</code></em>.</p><p>Indices are consistent with the rest of the API
and identify the standard unambiguously. In the present scheme of
things an enumerated standard is looked up by <a class="link" href="re33.html#v4l2-std-id" title="Table&#160;A.29.&#160;typedef v4l2_std_id">v4l2_std_id</a>. Now the
standards supported by the inputs of a device can overlap. Just
assume the tuner and composite input in the example above both
exist on a device. An enumeration of "PAL-B/G", "PAL-H/I" suggests
a choice which does not exist. We cannot merge or omit sets, because
applications would be unable to find the standards reported by
<code class="constant">VIDIOC_G_STD</code>. That leaves separate enumerations
for each input. Also selecting a standard by <a class="link" href="re33.html#v4l2-std-id" title="Table&#160;A.29.&#160;typedef v4l2_std_id">v4l2_std_id</a> can be
ambiguous. Advantage of this method is that applications need not
identify the standard indirectly, after enumerating.</p><p>So in
summary, the lookup itself is unavoidable. The difference is only
whether the lookup is necessary to find an enumerated standard or to
switch to a standard by <a class="link" href="re33.html#v4l2-std-id" title="Table&#160;A.29.&#160;typedef v4l2_std_id">v4l2_std_id</a>.</p></div><div class="footnote"><p><sup>[<a id="ftn.id2578225" href="#id2578225" class="para">8</a>] </sup>See <a class="xref" href="ch03s05.html" title="Buffers">the section called &#8220;Buffers&#8221;</a> for a rationale. Probably
even USB cameras follow some well known video standard. It might have
been better to explicitly indicate elsewhere if a device cannot live
up to normal expectations, instead of this exception.</p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01s06.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch01.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch01s08.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Tuners and Modulators&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;User Controls</td></tr></table></div></body></html>