[media] vidioc-g-tuner.rst: Fix tables to fit at LaTeX output
[cascardo/linux.git] / Documentation / media / uapi / v4l / vidioc-g-tuner.rst
1 .. -*- coding: utf-8; mode: rst -*-
2
3 .. _VIDIOC_G_TUNER:
4
5 ************************************
6 ioctl VIDIOC_G_TUNER, VIDIOC_S_TUNER
7 ************************************
8
9 Name
10 ====
11
12 VIDIOC_G_TUNER - VIDIOC_S_TUNER - Get or set tuner attributes
13
14
15 Synopsis
16 ========
17
18 .. cpp:function:: int ioctl( int fd, int request, struct v4l2_tuner *argp )
19
20 .. cpp:function:: int ioctl( int fd, int request, const struct v4l2_tuner *argp )
21
22
23 Arguments
24 =========
25
26 ``fd``
27     File descriptor returned by :ref:`open() <func-open>`.
28
29 ``request``
30     VIDIOC_G_TUNER, VIDIOC_S_TUNER
31
32 ``argp``
33
34
35 Description
36 ===========
37
38 To query the attributes of a tuner applications initialize the ``index``
39 field and zero out the ``reserved`` array of a struct
40 :ref:`v4l2_tuner <v4l2-tuner>` and call the ``VIDIOC_G_TUNER`` ioctl
41 with a pointer to this structure. Drivers fill the rest of the structure
42 or return an ``EINVAL`` error code when the index is out of bounds. To
43 enumerate all tuners applications shall begin at index zero,
44 incrementing by one until the driver returns ``EINVAL``.
45
46 Tuners have two writable properties, the audio mode and the radio
47 frequency. To change the audio mode, applications initialize the
48 ``index``, ``audmode`` and ``reserved`` fields and call the
49 ``VIDIOC_S_TUNER`` ioctl. This will *not* change the current tuner,
50 which is determined by the current video input. Drivers may choose a
51 different audio mode if the requested mode is invalid or unsupported.
52 Since this is a write-only ioctl, it does not return the actually
53 selected audio mode.
54
55 :ref:`SDR <sdr>` specific tuner types are ``V4L2_TUNER_SDR`` and
56 ``V4L2_TUNER_RF``. For SDR devices ``audmode`` field must be initialized
57 to zero. The term 'tuner' means SDR receiver in this context.
58
59 To change the radio frequency the
60 :ref:`VIDIOC_S_FREQUENCY <VIDIOC_G_FREQUENCY>` ioctl is available.
61
62
63  .. tabularcolumns:: |p{1.3cm}|p{3.0cm}|p{6.6cm}|p{6.6cm}|
64
65 .. _v4l2-tuner:
66
67 .. cssclass:: longtable
68
69 .. flat-table:: struct v4l2_tuner
70     :header-rows:  0
71     :stub-columns: 0
72
73
74     -  .. row 1
75
76        -  __u32
77
78        -  ``index``
79
80        -  :cspan:`1` Identifies the tuner, set by the application.
81
82     -  .. row 2
83
84        -  __u8
85
86        -  ``name``\ [32]
87
88        -  :cspan:`1`
89
90           Name of the tuner, a NUL-terminated ASCII string.
91
92           This information is intended for the user.
93
94     -  .. row 3
95
96        -  __u32
97
98        -  ``type``
99
100        -  :cspan:`1` Type of the tuner, see :ref:`v4l2-tuner-type`.
101
102     -  .. row 4
103
104        -  __u32
105
106        -  ``capability``
107
108        -  :cspan:`1`
109
110           Tuner capability flags, see :ref:`tuner-capability`. Audio flags
111           indicate the ability to decode audio subprograms. They will *not*
112           change, for example with the current video standard.
113
114           When the structure refers to a radio tuner the
115           ``V4L2_TUNER_CAP_LANG1``, ``V4L2_TUNER_CAP_LANG2`` and
116           ``V4L2_TUNER_CAP_NORM`` flags can't be used.
117
118           If multiple frequency bands are supported, then ``capability`` is
119           the union of all ``capability`` fields of each struct
120           :ref:`v4l2_frequency_band <v4l2-frequency-band>`.
121
122     -  .. row 5
123
124        -  __u32
125
126        -  ``rangelow``
127
128        -  :cspan:`1` The lowest tunable frequency in units of 62.5 kHz, or
129           if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in units
130           of 62.5 Hz, or if the ``capability`` flag ``V4L2_TUNER_CAP_1HZ``
131           is set, in units of 1 Hz. If multiple frequency bands are
132           supported, then ``rangelow`` is the lowest frequency of all the
133           frequency bands.
134
135     -  .. row 6
136
137        -  __u32
138
139        -  ``rangehigh``
140
141        -  :cspan:`1` The highest tunable frequency in units of 62.5 kHz,
142           or if the ``capability`` flag ``V4L2_TUNER_CAP_LOW`` is set, in
143           units of 62.5 Hz, or if the ``capability`` flag
144           ``V4L2_TUNER_CAP_1HZ`` is set, in units of 1 Hz. If multiple
145           frequency bands are supported, then ``rangehigh`` is the highest
146           frequency of all the frequency bands.
147
148     -  .. row 7
149
150        -  __u32
151
152        -  ``rxsubchans``
153
154        -  :cspan:`1`
155
156           Some tuners or audio decoders can determine the received audio
157           subprograms by analyzing audio carriers, pilot tones or other
158           indicators. To pass this information drivers set flags defined in
159           :ref:`tuner-rxsubchans` in this field. For example:
160
161     -  .. row 8
162
163        -
164        -
165        -  ``V4L2_TUNER_SUB_MONO``
166
167        -  receiving mono audio
168
169     -  .. row 9
170
171        -
172        -
173        -  ``STEREO | SAP``
174
175        -  receiving stereo audio and a secondary audio program
176
177     -  .. row 10
178
179        -
180        -
181        -  ``MONO | STEREO``
182
183        -  receiving mono or stereo audio, the hardware cannot distinguish
184
185     -  .. row 11
186
187        -
188        -
189        -  ``LANG1 | LANG2``
190
191        -  receiving bilingual audio
192
193     -  .. row 12
194
195        -
196        -
197        -  ``MONO | STEREO | LANG1 | LANG2``
198
199        -  receiving mono, stereo or bilingual audio
200
201     -  .. row 13
202
203        -
204        -
205        -  :cspan:`1`
206
207           When the ``V4L2_TUNER_CAP_STEREO``, ``_LANG1``, ``_LANG2`` or
208           ``_SAP`` flag is cleared in the ``capability`` field, the
209           corresponding ``V4L2_TUNER_SUB_`` flag must not be set here.
210
211           This field is valid only if this is the tuner of the current video
212           input, or when the structure refers to a radio tuner.
213
214     -  .. row 14
215
216        -  __u32
217
218        -  ``audmode``
219
220        -  :cspan:`1`
221
222           The selected audio mode, see :ref:`tuner-audmode` for valid
223           values. The audio mode does not affect audio subprogram detection,
224           and like a :ref:`control` it does not automatically
225           change unless the requested mode is invalid or unsupported. See
226           :ref:`tuner-matrix` for possible results when the selected and
227           received audio programs do not match.
228
229           Currently this is the only field of struct
230           :ref:`struct v4l2_tuner <v4l2-tuner>` applications can change.
231
232     -  .. row 15
233
234        -  __u32
235
236        -  ``signal``
237
238        -  :cspan:`1` The signal strength if known.
239
240           Ranging from 0 to 65535. Higher values indicate a better signal.
241
242     -  .. row 16
243
244        -  __s32
245
246        -  ``afc``
247
248        -  :cspan:`1` Automatic frequency control.
249
250           When the ``afc`` value is negative, the frequency is too
251           low, when positive too high.
252
253     -  .. row 17
254
255        -  __u32
256
257        -  ``reserved``\ [4]
258
259        -  :cspan:`1` Reserved for future extensions.
260
261            Drivers and applications must set the array to zero.
262
263
264
265 .. _v4l2-tuner-type:
266
267 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
268
269 .. flat-table:: enum v4l2_tuner_type
270     :header-rows:  0
271     :stub-columns: 0
272     :widths:       3 1 6
273
274
275     -  .. row 1
276
277        -  ``V4L2_TUNER_RADIO``
278
279        -  1
280
281        - Tuner supports radio
282
283     -  .. row 2
284
285        -  ``V4L2_TUNER_ANALOG_TV``
286
287        -  2
288
289        - Tuner supports analog TV
290
291     -  .. row 3
292
293        -  ``V4L2_TUNER_SDR``
294
295        -  4
296
297        - Tuner controls the A/D and/or D/A block of a
298          Sofware Digital Radio (SDR)
299
300     -  .. row 4
301
302        -  ``V4L2_TUNER_RF``
303
304        -  5
305
306        - Tuner controls the RF part of a Sofware Digital Radio (SDR)
307
308
309 .. _tuner-capability:
310
311 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
312
313 .. cssclass:: longtable
314
315 .. flat-table:: Tuner and Modulator Capability Flags
316     :header-rows:  0
317     :stub-columns: 0
318     :widths:       3 1 4
319
320
321     -  .. row 1
322
323        -  ``V4L2_TUNER_CAP_LOW``
324
325        -  0x0001
326
327        -  When set, tuning frequencies are expressed in units of 62.5 Hz
328           instead of 62.5 kHz.
329
330     -  .. row 2
331
332        -  ``V4L2_TUNER_CAP_NORM``
333
334        -  0x0002
335
336        -  This is a multi-standard tuner; the video standard can or must be
337           switched. (B/G PAL tuners for example are typically not considered
338           multi-standard because the video standard is automatically
339           determined from the frequency band.) The set of supported video
340           standards is available from the struct
341           :ref:`v4l2_input <v4l2-input>` pointing to this tuner, see the
342           description of ioctl :ref:`VIDIOC_ENUMINPUT`
343           for details. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
344           capability.
345
346     -  .. row 3
347
348        -  ``V4L2_TUNER_CAP_HWSEEK_BOUNDED``
349
350        -  0x0004
351
352        -  If set, then this tuner supports the hardware seek functionality
353           where the seek stops when it reaches the end of the frequency
354           range.
355
356     -  .. row 4
357
358        -  ``V4L2_TUNER_CAP_HWSEEK_WRAP``
359
360        -  0x0008
361
362        -  If set, then this tuner supports the hardware seek functionality
363           where the seek wraps around when it reaches the end of the
364           frequency range.
365
366     -  .. row 5
367
368        -  ``V4L2_TUNER_CAP_STEREO``
369
370        -  0x0010
371
372        -  Stereo audio reception is supported.
373
374     -  .. row 6
375
376        -  ``V4L2_TUNER_CAP_LANG1``
377
378        -  0x0040
379
380        -  Reception of the primary language of a bilingual audio program is
381           supported. Bilingual audio is a feature of two-channel systems,
382           transmitting the primary language monaural on the main audio
383           carrier and a secondary language monaural on a second carrier.
384           Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
385
386     -  .. row 7
387
388        -  ``V4L2_TUNER_CAP_LANG2``
389
390        -  0x0020
391
392        -  Reception of the secondary language of a bilingual audio program
393           is supported. Only ``V4L2_TUNER_ANALOG_TV`` tuners can have this
394           capability.
395
396     -  .. row 8
397
398        -  ``V4L2_TUNER_CAP_SAP``
399
400        -  0x0020
401
402        -  Reception of a secondary audio program is supported. This is a
403           feature of the BTSC system which accompanies the NTSC video
404           standard. Two audio carriers are available for mono or stereo
405           transmissions of a primary language, and an independent third
406           carrier for a monaural secondary language. Only
407           ``V4L2_TUNER_ANALOG_TV`` tuners can have this capability.
408
409           .. note::
410
411              The ``V4L2_TUNER_CAP_LANG2`` and ``V4L2_TUNER_CAP_SAP``
412              flags are synonyms. ``V4L2_TUNER_CAP_SAP`` applies when the tuner
413              supports the ``V4L2_STD_NTSC_M`` video standard.
414
415     -  .. row 9
416
417        -  ``V4L2_TUNER_CAP_RDS``
418
419        -  0x0080
420
421        -  RDS capture is supported. This capability is only valid for radio
422           tuners.
423
424     -  .. row 10
425
426        -  ``V4L2_TUNER_CAP_RDS_BLOCK_IO``
427
428        -  0x0100
429
430        -  The RDS data is passed as unparsed RDS blocks.
431
432     -  .. row 11
433
434        -  ``V4L2_TUNER_CAP_RDS_CONTROLS``
435
436        -  0x0200
437
438        -  The RDS data is parsed by the hardware and set via controls.
439
440     -  .. row 12
441
442        -  ``V4L2_TUNER_CAP_FREQ_BANDS``
443
444        -  0x0400
445
446        -  The :ref:`VIDIOC_ENUM_FREQ_BANDS`
447           ioctl can be used to enumerate the available frequency bands.
448
449     -  .. row 13
450
451        -  ``V4L2_TUNER_CAP_HWSEEK_PROG_LIM``
452
453        -  0x0800
454
455        -  The range to search when using the hardware seek functionality is
456           programmable, see
457           :ref:`VIDIOC_S_HW_FREQ_SEEK` for
458           details.
459
460     -  .. row 14
461
462        -  ``V4L2_TUNER_CAP_1HZ``
463
464        -  0x1000
465
466        -  When set, tuning frequencies are expressed in units of 1 Hz
467           instead of 62.5 kHz.
468
469
470
471 .. _tuner-rxsubchans:
472
473 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
474
475 .. flat-table:: Tuner Audio Reception Flags
476     :header-rows:  0
477     :stub-columns: 0
478     :widths:       3 1 4
479
480
481     -  .. row 1
482
483        -  ``V4L2_TUNER_SUB_MONO``
484
485        -  0x0001
486
487        -  The tuner receives a mono audio signal.
488
489     -  .. row 2
490
491        -  ``V4L2_TUNER_SUB_STEREO``
492
493        -  0x0002
494
495        -  The tuner receives a stereo audio signal.
496
497     -  .. row 3
498
499        -  ``V4L2_TUNER_SUB_LANG1``
500
501        -  0x0008
502
503        -  The tuner receives the primary language of a bilingual audio
504           signal. Drivers must clear this flag when the current video
505           standard is ``V4L2_STD_NTSC_M``.
506
507     -  .. row 4
508
509        -  ``V4L2_TUNER_SUB_LANG2``
510
511        -  0x0004
512
513        -  The tuner receives the secondary language of a bilingual audio
514           signal (or a second audio program).
515
516     -  .. row 5
517
518        -  ``V4L2_TUNER_SUB_SAP``
519
520        -  0x0004
521
522        -  The tuner receives a Second Audio Program.
523
524           .. note::
525
526              The ``V4L2_TUNER_SUB_LANG2`` and ``V4L2_TUNER_SUB_SAP``
527              flags are synonyms. The ``V4L2_TUNER_SUB_SAP`` flag applies
528              when the current video standard is ``V4L2_STD_NTSC_M``.
529
530     -  .. row 6
531
532        -  ``V4L2_TUNER_SUB_RDS``
533
534        -  0x0010
535
536        -  The tuner receives an RDS channel.
537
538
539
540 .. _tuner-audmode:
541
542 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
543
544 .. flat-table:: Tuner Audio Modes
545     :header-rows:  0
546     :stub-columns: 0
547     :widths:       3 1 4
548
549
550     -  .. row 1
551
552        -  ``V4L2_TUNER_MODE_MONO``
553
554        -  0
555
556        -  Play mono audio. When the tuner receives a stereo signal this a
557           down-mix of the left and right channel. When the tuner receives a
558           bilingual or SAP signal this mode selects the primary language.
559
560     -  .. row 2
561
562        -  ``V4L2_TUNER_MODE_STEREO``
563
564        -  1
565
566        -  Play stereo audio. When the tuner receives bilingual audio it may
567           play different languages on the left and right channel or the
568           primary language is played on both channels.
569
570           Playing different languages in this mode is deprecated. New
571           drivers should do this only in ``MODE_LANG1_LANG2``.
572
573           When the tuner receives no stereo signal or does not support
574           stereo reception the driver shall fall back to ``MODE_MONO``.
575
576     -  .. row 3
577
578        -  ``V4L2_TUNER_MODE_LANG1``
579
580        -  3
581
582        -  Play the primary language, mono or stereo. Only
583           ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
584
585     -  .. row 4
586
587        -  ``V4L2_TUNER_MODE_LANG2``
588
589        -  2
590
591        -  Play the secondary language, mono. When the tuner receives no
592           bilingual audio or SAP, or their reception is not supported the
593           driver shall fall back to mono or stereo mode. Only
594           ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
595
596     -  .. row 5
597
598        -  ``V4L2_TUNER_MODE_SAP``
599
600        -  2
601
602        -  Play the Second Audio Program. When the tuner receives no
603           bilingual audio or SAP, or their reception is not supported the
604           driver shall fall back to mono or stereo mode. Only
605           ``V4L2_TUNER_ANALOG_TV`` tuners support this mode.
606
607           .. note:: The ``V4L2_TUNER_MODE_LANG2`` and ``V4L2_TUNER_MODE_SAP``
608              are synonyms.
609
610     -  .. row 6
611
612        -  ``V4L2_TUNER_MODE_LANG1_LANG2``
613
614        -  4
615
616        -  Play the primary language on the left channel, the secondary
617           language on the right channel. When the tuner receives no
618           bilingual audio or SAP, it shall fall back to ``MODE_LANG1`` or
619           ``MODE_MONO``. Only ``V4L2_TUNER_ANALOG_TV`` tuners support this
620           mode.
621
622 .. raw:: latex
623
624     \newline\newline\begin{adjustbox}{width=\columnwidth}
625
626 .. _tuner-matrix:
627
628 .. flat-table:: Tuner Audio Matrix
629     :header-rows:  2
630     :stub-columns: 0
631
632
633     -  .. row 1
634
635        -
636        -  :cspan:`5` Selected ``V4L2_TUNER_MODE_``
637
638     -  .. row 2
639
640        -  Received ``V4L2_TUNER_SUB_``
641
642        -  ``MONO``
643
644        -  ``STEREO``
645
646        -  ``LANG1``
647
648        -  ``LANG2 = SAP``
649
650        -  ``LANG1_LANG2``\  [#f1]_
651
652     -  .. row 3
653
654        -  ``MONO``
655
656        -  Mono
657
658        -  Mono/Mono
659
660        -  Mono
661
662        -  Mono
663
664        -  Mono/Mono
665
666     -  .. row 4
667
668        -  ``MONO | SAP``
669
670        -  Mono
671
672        -  Mono/Mono
673
674        -  Mono
675
676        -  SAP
677
678        -  Mono/SAP (preferred) or Mono/Mono
679
680     -  .. row 5
681
682        -  ``STEREO``
683
684        -  L+R
685
686        -  L/R
687
688        -  Stereo L/R (preferred) or Mono L+R
689
690        -  Stereo L/R (preferred) or Mono L+R
691
692        -  L/R (preferred) or L+R/L+R
693
694     -  .. row 6
695
696        -  ``STEREO | SAP``
697
698        -  L+R
699
700        -  L/R
701
702        -  Stereo L/R (preferred) or Mono L+R
703
704        -  SAP
705
706        -  L+R/SAP (preferred) or L/R or L+R/L+R
707
708     -  .. row 7
709
710        -  ``LANG1 | LANG2``
711
712        -  Language 1
713
714        -  Lang1/Lang2 (deprecated [#f2]_) or Lang1/Lang1
715
716        -  Language 1
717
718        -  Language 2
719
720        -  Lang1/Lang2 (preferred) or Lang1/Lang1
721
722 .. raw:: latex
723
724     \end{adjustbox}\newline\newline
725
726 Return Value
727 ============
728
729 On success 0 is returned, on error -1 and the ``errno`` variable is set
730 appropriately. The generic error codes are described at the
731 :ref:`Generic Error Codes <gen-errors>` chapter.
732
733 EINVAL
734     The struct :ref:`v4l2_tuner <v4l2-tuner>` ``index`` is out of
735     bounds.
736
737 .. [#f1]
738    This mode has been added in Linux 2.6.17 and may not be supported by
739    older drivers.
740
741 .. [#f2]
742    Playback of both languages in ``MODE_STEREO`` is deprecated. In the
743    future drivers should produce only the primary language in this mode.
744    Applications should request ``MODE_LANG1_LANG2`` to record both
745    languages or a stereo signal.