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