1.. Permission is granted to copy, distribute and/or modify this
2.. document under the terms of the GNU Free Documentation License,
3.. Version 1.1 or any later version published by the Free Software
4.. Foundation, with no Invariant Sections, no Front-Cover Texts
5.. and no Back-Cover Texts. A copy of the license is included at
6.. Documentation/userspace-api/media/fdl-appendix.rst.
7..
8.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
9
10.. _video:
11
12************************
13Video Inputs and Outputs
14************************
15
16Video inputs and outputs are physical connectors of a device. These can
17be for example: RF connectors (antenna/cable), CVBS a.k.a. Composite
18Video, S-Video and RGB connectors. Camera sensors are also considered to
19be a video input. Video and VBI capture devices have inputs. Video and
20VBI output devices have outputs, at least one each. Radio devices have
21no video inputs or outputs.
22
23To learn about the number and attributes of the available inputs and
24outputs applications can enumerate them with the
25:ref:`VIDIOC_ENUMINPUT` and
26:ref:`VIDIOC_ENUMOUTPUT` ioctl, respectively. The
27struct :c:type:`v4l2_input` returned by the
28:ref:`VIDIOC_ENUMINPUT` ioctl also contains signal
29status information applicable when the current video input is queried.
30
31The :ref:`VIDIOC_G_INPUT <VIDIOC_G_INPUT>` and
32:ref:`VIDIOC_G_OUTPUT <VIDIOC_G_OUTPUT>` ioctls return the index of
33the current video input or output. To select a different input or output
34applications call the :ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` and
35:ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` ioctls. Drivers must
36implement all the input ioctls when the device has one or more inputs,
37all the output ioctls when the device has one or more outputs.
38
39Example: Information about the current video input
40==================================================
41
42.. code-block:: c
43
44    struct v4l2_input input;
45    int index;
46
47    if (-1 == ioctl(fd, VIDIOC_G_INPUT, &index)) {
48	perror("VIDIOC_G_INPUT");
49	exit(EXIT_FAILURE);
50    }
51
52    memset(&input, 0, sizeof(input));
53    input.index = index;
54
55    if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &input)) {
56	perror("VIDIOC_ENUMINPUT");
57	exit(EXIT_FAILURE);
58    }
59
60    printf("Current input: %s\\n", input.name);
61
62
63Example: Switching to the first video input
64===========================================
65
66.. code-block:: c
67
68    int index;
69
70    index = 0;
71
72    if (-1 == ioctl(fd, VIDIOC_S_INPUT, &index)) {
73	perror("VIDIOC_S_INPUT");
74	exit(EXIT_FAILURE);
75    }
76