~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/userspace-api/media/v4l/audio.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
  2 
  3 .. _audio:
  4 
  5 ************************
  6 Audio Inputs and Outputs
  7 ************************
  8 
  9 Audio inputs and outputs are physical connectors of a device. Video
 10 capture devices have inputs, output devices have outputs, zero or more
 11 each. Radio devices have no audio inputs or outputs. They have exactly
 12 one tuner which in fact *is* an audio source, but this API associates
 13 tuners with video inputs or outputs only, and radio devices have none of
 14 these. [#f1]_ A connector on a TV card to loop back the received audio
 15 signal to a sound card is not considered an audio output.
 16 
 17 Audio and video inputs and outputs are associated. Selecting a video
 18 source also selects an audio source. This is most evident when the video
 19 and audio source is a tuner. Further audio connectors can combine with
 20 more than one video input or output. Assumed two composite video inputs
 21 and two audio inputs exist, there may be up to four valid combinations.
 22 The relation of video and audio connectors is defined in the
 23 ``audioset`` field of the respective struct
 24 :c:type:`v4l2_input` or struct
 25 :c:type:`v4l2_output`, where each bit represents the index
 26 number, starting at zero, of one audio input or output.
 27 
 28 To learn about the number and attributes of the available inputs and
 29 outputs applications can enumerate them with the
 30 :ref:`VIDIOC_ENUMAUDIO` and
 31 :ref:`VIDIOC_ENUMAUDOUT <VIDIOC_ENUMAUDOUT>` ioctl, respectively.
 32 The struct :c:type:`v4l2_audio` returned by the
 33 :ref:`VIDIOC_ENUMAUDIO` ioctl also contains signal
 34 status information applicable when the current audio input is queried.
 35 
 36 The :ref:`VIDIOC_G_AUDIO <VIDIOC_G_AUDIO>` and
 37 :ref:`VIDIOC_G_AUDOUT <VIDIOC_G_AUDOUT>` ioctls report the current
 38 audio input and output, respectively.
 39 
 40 .. note::
 41 
 42    Note that, unlike :ref:`VIDIOC_G_INPUT <VIDIOC_G_INPUT>` and
 43    :ref:`VIDIOC_G_OUTPUT <VIDIOC_G_OUTPUT>` these ioctls return a
 44    structure as :ref:`VIDIOC_ENUMAUDIO` and
 45    :ref:`VIDIOC_ENUMAUDOUT <VIDIOC_ENUMAUDOUT>` do, not just an index.
 46 
 47 To select an audio input and change its properties applications call the
 48 :ref:`VIDIOC_S_AUDIO <VIDIOC_G_AUDIO>` ioctl. To select an audio
 49 output (which presently has no changeable properties) applications call
 50 the :ref:`VIDIOC_S_AUDOUT <VIDIOC_G_AUDOUT>` ioctl.
 51 
 52 Drivers must implement all audio input ioctls when the device has
 53 multiple selectable audio inputs, all audio output ioctls when the
 54 device has multiple selectable audio outputs. When the device has any
 55 audio inputs or outputs the driver must set the ``V4L2_CAP_AUDIO`` flag
 56 in the struct :c:type:`v4l2_capability` returned by
 57 the :ref:`VIDIOC_QUERYCAP` ioctl.
 58 
 59 
 60 Example: Information about the current audio input
 61 ==================================================
 62 
 63 .. code-block:: c
 64 
 65     struct v4l2_audio audio;
 66 
 67     memset(&audio, 0, sizeof(audio));
 68 
 69     if (-1 == ioctl(fd, VIDIOC_G_AUDIO, &audio)) {
 70         perror("VIDIOC_G_AUDIO");
 71         exit(EXIT_FAILURE);
 72     }
 73 
 74     printf("Current input: %s\\n", audio.name);
 75 
 76 
 77 Example: Switching to the first audio input
 78 ===========================================
 79 
 80 .. code-block:: c
 81 
 82     struct v4l2_audio audio;
 83 
 84     memset(&audio, 0, sizeof(audio)); /* clear audio.mode, audio.reserved */
 85 
 86     audio.index = 0;
 87 
 88     if (-1 == ioctl(fd, VIDIOC_S_AUDIO, &audio)) {
 89         perror("VIDIOC_S_AUDIO");
 90         exit(EXIT_FAILURE);
 91     }
 92 
 93 .. [#f1]
 94    Actually struct :c:type:`v4l2_audio` ought to have a
 95    ``tuner`` field like struct :c:type:`v4l2_input`, not
 96    only making the API more consistent but also permitting radio devices
 97    with multiple tuners.

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php