Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[firefly-linux-kernel-4.4.55.git] / Documentation / DocBook / media / v4l / vidioc-g-tuner.xml
1 <refentry id="vidioc-g-tuner">
2   <refmeta>
3     <refentrytitle>ioctl VIDIOC_G_TUNER, VIDIOC_S_TUNER</refentrytitle>
4     &manvol;
5   </refmeta>
6
7   <refnamediv>
8     <refname>VIDIOC_G_TUNER</refname>
9     <refname>VIDIOC_S_TUNER</refname>
10     <refpurpose>Get or set tuner attributes</refpurpose>
11   </refnamediv>
12
13   <refsynopsisdiv>
14     <funcsynopsis>
15       <funcprototype>
16         <funcdef>int <function>ioctl</function></funcdef>
17         <paramdef>int <parameter>fd</parameter></paramdef>
18         <paramdef>int <parameter>request</parameter></paramdef>
19         <paramdef>struct v4l2_tuner
20 *<parameter>argp</parameter></paramdef>
21       </funcprototype>
22     </funcsynopsis>
23     <funcsynopsis>
24       <funcprototype>
25         <funcdef>int <function>ioctl</function></funcdef>
26         <paramdef>int <parameter>fd</parameter></paramdef>
27         <paramdef>int <parameter>request</parameter></paramdef>
28         <paramdef>const struct v4l2_tuner
29 *<parameter>argp</parameter></paramdef>
30       </funcprototype>
31     </funcsynopsis>
32   </refsynopsisdiv>
33
34   <refsect1>
35     <title>Arguments</title>
36
37     <variablelist>
38       <varlistentry>
39         <term><parameter>fd</parameter></term>
40         <listitem>
41           <para>&fd;</para>
42         </listitem>
43       </varlistentry>
44       <varlistentry>
45         <term><parameter>request</parameter></term>
46         <listitem>
47           <para>VIDIOC_G_TUNER, VIDIOC_S_TUNER</para>
48         </listitem>
49       </varlistentry>
50       <varlistentry>
51         <term><parameter>argp</parameter></term>
52         <listitem>
53           <para></para>
54         </listitem>
55       </varlistentry>
56     </variablelist>
57   </refsect1>
58
59   <refsect1>
60     <title>Description</title>
61
62     <para>To query the attributes of a tuner applications initialize the
63 <structfield>index</structfield> field and zero out the
64 <structfield>reserved</structfield> array of a &v4l2-tuner; and call the
65 <constant>VIDIOC_G_TUNER</constant> ioctl with a pointer to this
66 structure. Drivers fill the rest of the structure or return an
67 &EINVAL; when the index is out of bounds. To enumerate all tuners
68 applications shall begin at index zero, incrementing by one until the
69 driver returns <errorcode>EINVAL</errorcode>.</para>
70
71     <para>Tuners have two writable properties, the audio mode and
72 the radio frequency. To change the audio mode, applications initialize
73 the <structfield>index</structfield>,
74 <structfield>audmode</structfield> and
75 <structfield>reserved</structfield> fields and call the
76 <constant>VIDIOC_S_TUNER</constant> ioctl. This will
77 <emphasis>not</emphasis> change the current tuner, which is determined
78 by the current video input. Drivers may choose a different audio mode
79 if the requested mode is invalid or unsupported. Since this is a
80 <!-- FIXME -->write-only ioctl, it does not return the actually
81 selected audio mode.</para>
82
83     <para>To change the radio frequency the &VIDIOC-S-FREQUENCY; ioctl
84 is available.</para>
85
86     <table pgwide="1" frame="none" id="v4l2-tuner">
87       <title>struct <structname>v4l2_tuner</structname></title>
88       <tgroup cols="3">
89         <colspec colname="c1" colwidth="1*" />
90         <colspec colname="c2" colwidth="1*" />
91         <colspec colname="c3" colwidth="1*" />
92         <colspec colname="c4" colwidth="1*" />
93         <spanspec spanname="hspan" namest="c3" nameend="c4" />
94         <tbody valign="top">
95           <row>
96             <entry>__u32</entry>
97             <entry><structfield>index</structfield></entry>
98             <entry spanname="hspan">Identifies the tuner, set by the
99 application.</entry>
100           </row>
101           <row>
102             <entry>__u8</entry>
103             <entry><structfield>name</structfield>[32]</entry>
104             <entry spanname="hspan"><para>Name of the tuner, a
105 NUL-terminated ASCII string. This information is intended for the
106 user.<!-- FIXME Video inputs already have a name, the purpose of this
107 field is not quite clear.--></para></entry>
108           </row>
109           <row>
110             <entry>__u32</entry>
111             <entry><structfield>type</structfield></entry>
112             <entry spanname="hspan">Type of the tuner, see <xref
113                 linkend="v4l2-tuner-type" />.</entry>
114           </row>
115           <row>
116             <entry>__u32</entry>
117             <entry><structfield>capability</structfield></entry>
118             <entry spanname="hspan"><para>Tuner capability flags, see
119 <xref linkend="tuner-capability" />. Audio flags indicate the ability
120 to decode audio subprograms. They will <emphasis>not</emphasis>
121 change, for example with the current video standard.</para><para>When
122 the structure refers to a radio tuner only the
123 <constant>V4L2_TUNER_CAP_LOW</constant>,
124 <constant>V4L2_TUNER_CAP_STEREO</constant> and
125 <constant>V4L2_TUNER_CAP_RDS</constant> flags can be set.</para></entry>
126           </row>
127           <row>
128             <entry>__u32</entry>
129             <entry><structfield>rangelow</structfield></entry>
130             <entry spanname="hspan">The lowest tunable frequency in
131 units of 62.5 kHz, or if the <structfield>capability</structfield>
132 flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
133 Hz.</entry>
134           </row>
135           <row>
136             <entry>__u32</entry>
137             <entry><structfield>rangehigh</structfield></entry>
138             <entry spanname="hspan">The highest tunable frequency in
139 units of 62.5 kHz, or if the <structfield>capability</structfield>
140 flag <constant>V4L2_TUNER_CAP_LOW</constant> is set, in units of 62.5
141 Hz.</entry>
142           </row>
143           <row>
144             <entry>__u32</entry>
145             <entry><structfield>rxsubchans</structfield></entry>
146             <entry spanname="hspan"><para>Some tuners or audio
147 decoders can determine the received audio subprograms by analyzing
148 audio carriers, pilot tones or other indicators. To pass this
149 information drivers set flags defined in <xref
150                   linkend="tuner-rxsubchans" /> in this field. For
151 example:</para></entry>
152           </row>
153           <row>
154             <entry></entry>
155             <entry></entry>
156             <entry><constant>V4L2_TUNER_SUB_MONO</constant></entry>
157             <entry>receiving mono audio</entry>
158           </row>
159           <row>
160             <entry></entry>
161             <entry></entry>
162             <entry><constant>STEREO | SAP</constant></entry>
163             <entry>receiving stereo audio and a secondary audio
164 program</entry>
165           </row>
166           <row>
167             <entry></entry>
168             <entry></entry>
169             <entry><constant>MONO | STEREO</constant></entry>
170             <entry>receiving mono or stereo audio, the hardware cannot
171 distinguish</entry>
172           </row>
173           <row>
174             <entry></entry>
175             <entry></entry>
176             <entry><constant>LANG1 | LANG2</constant></entry>
177             <entry>receiving bilingual audio</entry>
178           </row>
179           <row>
180             <entry></entry>
181             <entry></entry>
182             <entry><constant>MONO | STEREO | LANG1 | LANG2</constant></entry>
183             <entry>receiving mono, stereo or bilingual
184 audio</entry>
185           </row>
186           <row>
187             <entry></entry>
188             <entry></entry>
189             <entry spanname="hspan"><para>When the
190 <constant>V4L2_TUNER_CAP_STEREO</constant>,
191 <constant>_LANG1</constant>, <constant>_LANG2</constant> or
192 <constant>_SAP</constant> flag is cleared in the
193 <structfield>capability</structfield> field, the corresponding
194 <constant>V4L2_TUNER_SUB_</constant> flag must not be set
195 here.</para><para>This field is valid only if this is the tuner of the
196 current video input, or when the structure refers to a radio
197 tuner.</para></entry>
198           </row>
199           <row>
200             <entry>__u32</entry>
201             <entry><structfield>audmode</structfield></entry>
202             <entry spanname="hspan"><para>The selected audio mode, see
203 <xref linkend="tuner-audmode" /> for valid values. The audio mode does
204 not affect audio subprogram detection, and like a <link
205 linkend="control">control</link> it does not automatically change
206 unless the requested mode is invalid or unsupported. See <xref
207                   linkend="tuner-matrix" /> for possible results when
208 the selected and received audio programs do not
209 match.</para><para>Currently this is the only field of struct
210 <structname>v4l2_tuner</structname> applications can
211 change.</para></entry>
212           </row>
213           <row>
214             <entry>__u32</entry>
215             <entry><structfield>signal</structfield></entry>
216             <entry spanname="hspan">The signal strength if known, ranging
217 from 0 to 65535. Higher values indicate a better signal.</entry>
218           </row>
219           <row>
220             <entry>__s32</entry>
221             <entry><structfield>afc</structfield></entry>
222             <entry spanname="hspan">Automatic frequency control: When the
223 <structfield>afc</structfield> value is negative, the frequency is too
224 low, when positive too high.<!-- FIXME need example what to do when it never
225 settles at zero, &ie; range is what? --></entry>
226           </row>
227           <row>
228             <entry>__u32</entry>
229             <entry><structfield>reserved</structfield>[4]</entry>
230             <entry spanname="hspan">Reserved for future extensions. Drivers and
231 applications must set the array to zero.</entry>
232           </row>
233         </tbody>
234       </tgroup>
235     </table>
236
237     <table pgwide="1" frame="none" id="v4l2-tuner-type">
238       <title>enum v4l2_tuner_type</title>
239       <tgroup cols="3">
240         &cs-def;
241         <tbody valign="top">
242           <row>
243             <entry><constant>V4L2_TUNER_RADIO</constant></entry>
244             <entry>1</entry>
245             <entry></entry>
246           </row>
247           <row>
248             <entry><constant>V4L2_TUNER_ANALOG_TV</constant></entry>
249             <entry>2</entry>
250             <entry></entry>
251           </row>
252         </tbody>
253       </tgroup>
254     </table>
255
256     <table pgwide="1" frame="none" id="tuner-capability">
257       <title>Tuner and Modulator Capability Flags</title>
258       <tgroup cols="3">
259         &cs-def;
260         <tbody valign="top">
261           <row>
262             <entry><constant>V4L2_TUNER_CAP_LOW</constant></entry>
263             <entry>0x0001</entry>
264             <entry>When set, tuning frequencies are expressed in units of
265 62.5&nbsp;Hz, otherwise in units of 62.5&nbsp;kHz.</entry>
266           </row>
267           <row>
268             <entry><constant>V4L2_TUNER_CAP_NORM</constant></entry>
269             <entry>0x0002</entry>
270             <entry>This is a multi-standard tuner; the video standard
271 can or must be switched. (B/G PAL tuners for example are typically not
272       considered multi-standard because the video standard is automatically
273       determined from the frequency band.) The set of supported video
274       standards is available from the &v4l2-input; pointing to this tuner,
275       see the description of ioctl &VIDIOC-ENUMINPUT; for details. Only
276       <constant>V4L2_TUNER_ANALOG_TV</constant> tuners can have this capability.</entry>
277           </row>
278           <row>
279             <entry><constant>V4L2_TUNER_CAP_HWSEEK_BOUNDED</constant></entry>
280             <entry>0x0004</entry>
281             <entry>If set, then this tuner supports the hardware seek functionality
282             where the seek stops when it reaches the end of the frequency range.</entry>
283           </row>
284           <row>
285             <entry><constant>V4L2_TUNER_CAP_HWSEEK_WRAP</constant></entry>
286             <entry>0x0008</entry>
287             <entry>If set, then this tuner supports the hardware seek functionality
288             where the seek wraps around when it reaches the end of the frequency range.</entry>
289           </row>
290           <row>
291         <entry><constant>V4L2_TUNER_CAP_STEREO</constant></entry>
292         <entry>0x0010</entry>
293         <entry>Stereo audio reception is supported.</entry>
294           </row>
295           <row>
296             <entry><constant>V4L2_TUNER_CAP_LANG1</constant></entry>
297             <entry>0x0040</entry>
298             <entry>Reception of the primary language of a bilingual
299 audio program is supported. Bilingual audio is a feature of
300 two-channel systems, transmitting the primary language monaural on the
301 main audio carrier and a secondary language monaural on a second
302 carrier. Only
303       <constant>V4L2_TUNER_ANALOG_TV</constant> tuners can have this capability.</entry>
304           </row>
305           <row>
306             <entry><constant>V4L2_TUNER_CAP_LANG2</constant></entry>
307             <entry>0x0020</entry>
308             <entry>Reception of the secondary language of a bilingual
309 audio program is supported. Only
310       <constant>V4L2_TUNER_ANALOG_TV</constant> tuners can have this capability.</entry>
311           </row>
312           <row>
313             <entry><constant>V4L2_TUNER_CAP_SAP</constant></entry>
314             <entry>0x0020</entry>
315             <entry><para>Reception of a secondary audio program is
316 supported. This is a feature of the BTSC system which accompanies the
317 NTSC video standard. Two audio carriers are available for mono or
318 stereo transmissions of a primary language, and an independent third
319 carrier for a monaural secondary language. Only
320       <constant>V4L2_TUNER_ANALOG_TV</constant> tuners can have this capability.</para><para>Note the
321 <constant>V4L2_TUNER_CAP_LANG2</constant> and
322 <constant>V4L2_TUNER_CAP_SAP</constant> flags are synonyms.
323 <constant>V4L2_TUNER_CAP_SAP</constant> applies when the tuner
324 supports the <constant>V4L2_STD_NTSC_M</constant> video
325 standard.</para><!-- FIXME what if PAL+NTSC and Bi but not SAP? --></entry>
326           </row>
327           <row>
328         <entry><constant>V4L2_TUNER_CAP_RDS</constant></entry>
329         <entry>0x0080</entry>
330         <entry>RDS capture is supported. This capability is only valid for
331 radio tuners.</entry>
332           </row>
333           <row>
334         <entry><constant>V4L2_TUNER_CAP_RDS_BLOCK_IO</constant></entry>
335         <entry>0x0100</entry>
336         <entry>The RDS data is passed as unparsed RDS blocks.</entry>
337           </row>
338           <row>
339         <entry><constant>V4L2_TUNER_CAP_RDS_CONTROLS</constant></entry>
340         <entry>0x0200</entry>
341         <entry>The RDS data is parsed by the hardware and set via controls.</entry>
342           </row>
343         </tbody>
344       </tgroup>
345     </table>
346
347     <table pgwide="1" frame="none" id="tuner-rxsubchans">
348       <title>Tuner Audio Reception Flags</title>
349       <tgroup cols="3">
350         &cs-def;
351         <tbody valign="top">
352           <row>
353             <entry><constant>V4L2_TUNER_SUB_MONO</constant></entry>
354             <entry>0x0001</entry>
355             <entry>The tuner receives a mono audio signal.</entry>
356           </row>
357           <row>
358             <entry><constant>V4L2_TUNER_SUB_STEREO</constant></entry>
359             <entry>0x0002</entry>
360             <entry>The tuner receives a stereo audio signal.</entry>
361           </row>
362           <row>
363             <entry><constant>V4L2_TUNER_SUB_LANG1</constant></entry>
364             <entry>0x0008</entry>
365             <entry>The tuner receives the primary language of a
366 bilingual audio signal. Drivers must clear this flag when the current
367 video standard is <constant>V4L2_STD_NTSC_M</constant>.</entry>
368           </row>
369           <row>
370             <entry><constant>V4L2_TUNER_SUB_LANG2</constant></entry>
371             <entry>0x0004</entry>
372             <entry>The tuner receives the secondary language of a
373 bilingual audio signal (or a second audio program).</entry>
374           </row>
375           <row>
376             <entry><constant>V4L2_TUNER_SUB_SAP</constant></entry>
377             <entry>0x0004</entry>
378             <entry>The tuner receives a Second Audio Program. Note the
379 <constant>V4L2_TUNER_SUB_LANG2</constant> and
380 <constant>V4L2_TUNER_SUB_SAP</constant> flags are synonyms. The
381 <constant>V4L2_TUNER_SUB_SAP</constant> flag applies when the
382 current video standard is <constant>V4L2_STD_NTSC_M</constant>.</entry>
383           </row>
384           <row>
385             <entry><constant>V4L2_TUNER_SUB_RDS</constant></entry>
386             <entry>0x0010</entry>
387             <entry>The tuner receives an RDS channel.</entry>
388           </row>
389         </tbody>
390       </tgroup>
391     </table>
392
393     <table pgwide="1" frame="none" id="tuner-audmode">
394       <title>Tuner Audio Modes</title>
395       <tgroup cols="3">
396         &cs-def;
397         <tbody valign="top">
398           <row>
399             <entry><constant>V4L2_TUNER_MODE_MONO</constant></entry>
400             <entry>0</entry>
401             <entry>Play mono audio. When the tuner receives a stereo
402 signal this a down-mix of the left and right channel. When the tuner
403 receives a bilingual or SAP signal this mode selects the primary
404 language.</entry>
405           </row>
406           <row>
407             <entry><constant>V4L2_TUNER_MODE_STEREO</constant></entry>
408             <entry>1</entry>
409             <entry><para>Play stereo audio. When the tuner receives
410 bilingual audio it may play different languages on the left and right
411 channel or the primary language is played on both channels.</para><para>Playing
412 different languages in this mode is
413 deprecated. New drivers should do this only in
414 <constant>MODE_LANG1_LANG2</constant>.</para><para>When the tuner
415 receives no stereo signal or does not support stereo reception the
416 driver shall fall back to <constant>MODE_MONO</constant>.</para></entry>
417           </row>
418           <row>
419             <entry><constant>V4L2_TUNER_MODE_LANG1</constant></entry>
420             <entry>3</entry>
421             <entry>Play the primary language, mono or stereo. Only
422 <constant>V4L2_TUNER_ANALOG_TV</constant> tuners support this
423 mode.</entry>
424           </row>
425           <row>
426             <entry><constant>V4L2_TUNER_MODE_LANG2</constant></entry>
427             <entry>2</entry>
428             <entry>Play the secondary language, mono. When the tuner
429 receives no bilingual audio or SAP, or their reception is not
430 supported the driver shall fall back to mono or stereo mode. Only
431 <constant>V4L2_TUNER_ANALOG_TV</constant> tuners support this
432 mode.</entry>
433           </row>
434           <row>
435             <entry><constant>V4L2_TUNER_MODE_SAP</constant></entry>
436             <entry>2</entry>
437             <entry>Play the Second Audio Program. When the tuner
438 receives no bilingual audio or SAP, or their reception is not
439 supported the driver shall fall back to mono or stereo mode. Only
440 <constant>V4L2_TUNER_ANALOG_TV</constant> tuners support this mode.
441 Note the <constant>V4L2_TUNER_MODE_LANG2</constant> and
442 <constant>V4L2_TUNER_MODE_SAP</constant> are synonyms.</entry>
443           </row>
444           <row>
445             <entry><constant>V4L2_TUNER_MODE_LANG1_LANG2</constant></entry>
446             <entry>4</entry>
447             <entry>Play the primary language on the left channel, the
448 secondary language on the right channel. When the tuner receives no
449 bilingual audio or SAP, it shall fall back to
450 <constant>MODE_LANG1</constant> or <constant>MODE_MONO</constant>.
451 Only <constant>V4L2_TUNER_ANALOG_TV</constant> tuners support this
452 mode.</entry>
453           </row>
454         </tbody>
455       </tgroup>
456     </table>
457
458     <table pgwide="1" frame="all" id="tuner-matrix">
459       <title>Tuner Audio Matrix</title>
460       <tgroup cols="6" align="center">
461         <colspec align="left" />
462         <colspec colname="c2" colwidth="1*" />
463         <colspec colwidth="1*" />
464         <colspec colwidth="1*" />
465         <colspec colnum="6" colname="c6" colwidth="1*" />
466         <spanspec namest="c2" nameend="c6" spanname="hspan" align="center" />
467         <thead>
468           <row>
469             <entry></entry>
470             <entry spanname="hspan">Selected
471 <constant>V4L2_TUNER_MODE_</constant></entry>
472           </row>
473           <row>
474             <entry>Received <constant>V4L2_TUNER_SUB_</constant></entry>
475             <entry><constant>MONO</constant></entry>
476             <entry><constant>STEREO</constant></entry>
477             <entry><constant>LANG1</constant></entry>
478             <entry><constant>LANG2 = SAP</constant></entry>
479             <entry><constant>LANG1_LANG2</constant><footnote><para>This
480 mode has been added in Linux 2.6.17 and may not be supported by older
481 drivers.</para></footnote></entry>
482           </row>
483         </thead>
484         <tbody valign="top">
485           <row>
486             <entry><constant>MONO</constant></entry>
487             <entry>Mono</entry>
488             <entry>Mono/Mono</entry>
489             <entry>Mono</entry>
490             <entry>Mono</entry>
491             <entry>Mono/Mono</entry>
492           </row>
493           <row>
494             <entry><constant>MONO | SAP</constant></entry>
495             <entry>Mono</entry>
496             <entry>Mono/Mono</entry>
497             <entry>Mono</entry>
498             <entry>SAP</entry>
499             <entry>Mono/SAP (preferred) or Mono/Mono</entry>
500           </row>
501           <row>
502             <entry><constant>STEREO</constant></entry>
503             <entry>L+R</entry>
504             <entry>L/R</entry>
505             <entry>Stereo L/R (preferred) or Mono L+R</entry>
506             <entry>Stereo L/R (preferred) or Mono L+R</entry>
507             <entry>L/R (preferred) or L+R/L+R</entry>
508           </row>
509           <row>
510             <entry><constant>STEREO | SAP</constant></entry>
511             <entry>L+R</entry>
512             <entry>L/R</entry>
513             <entry>Stereo L/R (preferred) or Mono L+R</entry>
514             <entry>SAP</entry>
515             <entry>L+R/SAP (preferred) or L/R or L+R/L+R</entry>
516           </row>
517           <row>
518             <entry><constant>LANG1 | LANG2</constant></entry>
519             <entry>Language&nbsp;1</entry>
520             <entry>Lang1/Lang2 (deprecated<footnote><para>Playback of
521 both languages in <constant>MODE_STEREO</constant> is deprecated. In
522 the future drivers should produce only the primary language in this
523 mode. Applications should request
524 <constant>MODE_LANG1_LANG2</constant> to record both languages or a
525 stereo signal.</para></footnote>) or
526 Lang1/Lang1</entry>
527             <entry>Language&nbsp;1</entry>
528             <entry>Language&nbsp;2</entry>
529             <entry>Lang1/Lang2 (preferred) or Lang1/Lang1</entry>
530           </row>
531         </tbody>
532       </tgroup>
533     </table>
534   </refsect1>
535
536   <refsect1>
537     &return-value;
538
539     <variablelist>
540       <varlistentry>
541         <term><errorcode>EINVAL</errorcode></term>
542         <listitem>
543           <para>The &v4l2-tuner; <structfield>index</structfield> is
544 out of bounds.</para>
545         </listitem>
546       </varlistentry>
547     </variablelist>
548   </refsect1>
549 </refentry>