1<html><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.78.1"><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API"><link rel="up" href="common.html" title="Chapter 1. Common API Elements"><link rel="prev" href="tuner.html" title="Tuners and Modulators"><link rel="next" href="dv-timings.html" title="Digital Video (DV) Timings"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><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="tuner.html">Prev</a> </td><th width="60%" align="center">Chapter 1. Common API Elements</th><td width="20%" align="right"> <a accesskey="n" href="dv-timings.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="standard"></a>Video Standards</h2></div></div></div><p>Video devices typically support one or more different video 2standards or variations of standards. Each video input and output may 3support another set of standards. This set is reported by the 4<em class="structfield"><code>std</code></em> field of struct <a class="link" href="vidioc-enuminput.html#v4l2-input" title="Table A.39. struct v4l2_input">v4l2_input</a> and 5struct <a class="link" href="vidioc-enumoutput.html#v4l2-output" title="Table A.43. struct v4l2_output">v4l2_output</a> returned by the <a class="link" href="vidioc-enuminput.html" title="ioctl VIDIOC_ENUMINPUT"><code class="constant">VIDIOC_ENUMINPUT</code></a> and 6<a class="link" href="vidioc-enumoutput.html" title="ioctl VIDIOC_ENUMOUTPUT"><code class="constant">VIDIOC_ENUMOUTPUT</code></a> ioctls, respectively.</p><p>V4L2 defines one bit for each analog video standard 7currently in use worldwide, and sets aside bits for driver defined 8standards, e. g. hybrid standards to watch NTSC video tapes on PAL TVs 9and vice versa. Applications can use the predefined bits to select a 10particular standard, although presenting the user a menu of supported 11standards is preferred. To enumerate and query the attributes of the 12supported standards applications use the <a class="link" href="vidioc-enumstd.html" title="ioctl VIDIOC_ENUMSTD"><code class="constant">VIDIOC_ENUMSTD</code></a> ioctl.</p><p>Many of the defined standards are actually just variations 13of a few major standards. The hardware may in fact not distinguish 14between them, or do so internal and switch automatically. Therefore 15enumerated standards also contain sets of one or more standard 16bits.</p><p>Assume a hypothetic tuner capable of demodulating B/PAL, 17G/PAL and I/PAL signals. The first enumerated standard is a set of B 18and G/PAL, switched automatically depending on the selected radio 19frequency in UHF or VHF band. Enumeration gives a "PAL-B/G" or "PAL-I" 20choice. Similar a Composite input may collapse standards, enumerating 21"PAL-B/G/H/I", "NTSC-M" and "SECAM-D/K".<a href="#ftn.idp1096857284" class="footnote" name="idp1096857284"><sup class="footnote">[5]</sup></a></p><p>To query and select the standard used by the current video 22input or output applications call the <a class="link" href="vidioc-g-std.html" title="ioctl VIDIOC_G_STD, VIDIOC_S_STD"><code class="constant">VIDIOC_G_STD</code></a> and 23<a class="link" href="vidioc-g-std.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> 24standard can be sensed with the <a class="link" href="vidioc-querystd.html" title="ioctl VIDIOC_QUERYSTD"><code class="constant">VIDIOC_QUERYSTD</code></a> ioctl. Note that the 25parameter of all these ioctls is a pointer to a <a class="link" href="vidioc-enumstd.html#v4l2-std-id" title="Table A.48. typedef v4l2_std_id">v4l2_std_id</a> type 26(a standard set), <span class="emphasis"><em>not</em></span> an index into the standard 27enumeration. Drivers must implement all video standard ioctls 28when the device has one or more video inputs or outputs.</p><p>Special rules apply to devices such as USB cameras where the notion of video 29standards makes little sense. More generally for any capture or output device 30which is: </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>incapable of capturing fields or frames at the nominal 31rate of the video standard, or</p></li><li class="listitem"><p>that does not support the video standard formats at all.</p></li></ul></div><p> Here the driver shall set the 32<em class="structfield"><code>std</code></em> field of struct <a class="link" href="vidioc-enuminput.html#v4l2-input" title="Table A.39. struct v4l2_input">v4l2_input</a> and struct <a class="link" href="vidioc-enumoutput.html#v4l2-output" title="Table A.43. struct v4l2_output">v4l2_output</a> 33to zero and the <code class="constant">VIDIOC_G_STD</code>, 34<code class="constant">VIDIOC_S_STD</code>, 35<code class="constant">VIDIOC_QUERYSTD</code> and 36<code class="constant">VIDIOC_ENUMSTD</code> ioctls shall return the 37<span class="errorcode">ENOTTY</span> error code or the <span class="errorcode">EINVAL</span> error code.</p><p>Applications can make use of the <a class="xref" href="vidioc-enuminput.html#input-capabilities" title="Table A.42. Input capabilities">Table A.42, “Input capabilities”</a> and 38<a class="xref" href="vidioc-enumoutput.html#output-capabilities" title="Table A.45. Output capabilities">Table A.45, “Output capabilities”</a> flags to determine whether the video standard ioctls 39can be used with the given input or output.</p><div class="example"><a name="idp1096867468"></a><p class="title"><b>Example 1.5. Information about the current video standard</b></p><div class="example-contents"><pre class="programlisting"> 40<a class="link" href="vidioc-enumstd.html#v4l2-std-id" title="Table A.48. typedef v4l2_std_id">v4l2_std_id</a> std_id; 41struct <a class="link" href="vidioc-enumstd.html#v4l2-standard" title="Table A.46. struct v4l2_standard">v4l2_standard</a> standard; 42 43if (-1 == ioctl(fd, <a class="link" href="vidioc-g-std.html" title="ioctl VIDIOC_G_STD, VIDIOC_S_STD"><code class="constant">VIDIOC_G_STD</code></a>, &std_id)) { 44 /* Note when VIDIOC_ENUMSTD always returns ENOTTY this 45 is no video device or it falls under the USB exception, 46 and VIDIOC_G_STD returning ENOTTY is no error. */ 47 48 perror("VIDIOC_G_STD"); 49 exit(EXIT_FAILURE); 50} 51 52memset(&standard, 0, sizeof(standard)); 53standard.index = 0; 54 55while (0 == ioctl(fd, <a class="link" href="vidioc-enumstd.html" title="ioctl VIDIOC_ENUMSTD"><code class="constant">VIDIOC_ENUMSTD</code></a>, &standard)) { 56 if (standard.id & std_id) { 57 printf("Current video standard: %s\n", standard.name); 58 exit(EXIT_SUCCESS); 59 } 60 61 standard.index++; 62} 63 64/* EINVAL indicates the end of the enumeration, which cannot be 65 empty unless this device falls under the USB exception. */ 66 67if (errno == EINVAL || standard.index == 0) { 68 perror("VIDIOC_ENUMSTD"); 69 exit(EXIT_FAILURE); 70} 71 </pre></div></div><br class="example-break"><div class="example"><a name="idp1096871812"></a><p class="title"><b>Example 1.6. Listing the video standards supported by the current 72input</b></p><div class="example-contents"><pre class="programlisting"> 73struct <a class="link" href="vidioc-enuminput.html#v4l2-input" title="Table A.39. struct v4l2_input">v4l2_input</a> input; 74struct <a class="link" href="vidioc-enumstd.html#v4l2-standard" title="Table A.46. struct v4l2_standard">v4l2_standard</a> standard; 75 76memset(&input, 0, sizeof(input)); 77 78if (-1 == ioctl(fd, <a class="link" href="vidioc-g-input.html" title="ioctl VIDIOC_G_INPUT, VIDIOC_S_INPUT"><code class="constant">VIDIOC_G_INPUT</code></a>, &input.index)) { 79 perror("VIDIOC_G_INPUT"); 80 exit(EXIT_FAILURE); 81} 82 83if (-1 == ioctl(fd, <a class="link" href="vidioc-enuminput.html" title="ioctl VIDIOC_ENUMINPUT"><code class="constant">VIDIOC_ENUMINPUT</code></a>, &input)) { 84 perror("VIDIOC_ENUM_INPUT"); 85 exit(EXIT_FAILURE); 86} 87 88printf("Current input %s supports:\n", input.name); 89 90memset(&standard, 0, sizeof(standard)); 91standard.index = 0; 92 93while (0 == ioctl(fd, <a class="link" href="vidioc-enumstd.html" title="ioctl VIDIOC_ENUMSTD"><code class="constant">VIDIOC_ENUMSTD</code></a>, &standard)) { 94 if (standard.id & input.std) 95 printf("%s\n", standard.name); 96 97 standard.index++; 98} 99 100/* EINVAL indicates the end of the enumeration, which cannot be 101 empty unless this device falls under the USB exception. */ 102 103if (errno != EINVAL || standard.index == 0) { 104 perror("VIDIOC_ENUMSTD"); 105 exit(EXIT_FAILURE); 106} 107 </pre></div></div><br class="example-break"><div class="example"><a name="idp1096876036"></a><p class="title"><b>Example 1.7. Selecting a new video standard</b></p><div class="example-contents"><pre class="programlisting"> 108struct <a class="link" href="vidioc-enuminput.html#v4l2-input" title="Table A.39. struct v4l2_input">v4l2_input</a> input; 109<a class="link" href="vidioc-enumstd.html#v4l2-std-id" title="Table A.48. typedef v4l2_std_id">v4l2_std_id</a> std_id; 110 111memset(&input, 0, sizeof(input)); 112 113if (-1 == ioctl(fd, <a class="link" href="vidioc-g-input.html" title="ioctl VIDIOC_G_INPUT, VIDIOC_S_INPUT"><code class="constant">VIDIOC_G_INPUT</code></a>, &input.index)) { 114 perror("VIDIOC_G_INPUT"); 115 exit(EXIT_FAILURE); 116} 117 118if (-1 == ioctl(fd, <a class="link" href="vidioc-enuminput.html" title="ioctl VIDIOC_ENUMINPUT"><code class="constant">VIDIOC_ENUMINPUT</code></a>, &input)) { 119 perror("VIDIOC_ENUM_INPUT"); 120 exit(EXIT_FAILURE); 121} 122 123if (0 == (input.std & V4L2_STD_PAL_BG)) { 124 fprintf(stderr, "Oops. B/G PAL is not supported.\n"); 125 exit(EXIT_FAILURE); 126} 127 128/* Note this is also supposed to work when only B 129 <span class="emphasis"><em>or</em></span> G/PAL is supported. */ 130 131std_id = V4L2_STD_PAL_BG; 132 133if (-1 == ioctl(fd, <a class="link" href="vidioc-g-std.html" title="ioctl VIDIOC_G_STD, VIDIOC_S_STD"><code class="constant">VIDIOC_S_STD</code></a>, &std_id)) { 134 perror("VIDIOC_S_STD"); 135 exit(EXIT_FAILURE); 136} 137 </pre></div></div><br class="example-break"><div class="footnotes"><br><hr style="width:100; text-align:left;margin-left: 0"><div id="ftn.idp1096857284" class="footnote"><p><a href="#idp1096857284" class="para"><sup class="para">[5] </sup></a>Some users are already confused by technical terms PAL, 138NTSC and SECAM. There is no point asking them to distinguish between 139B, G, D, or K when the software or hardware can do that 140automatically.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="tuner.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="common.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="dv-timings.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Tuners and Modulators </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Digital Video (DV) Timings</td></tr></table></div></body></html> 141