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