Debian Codegraph @

Documentation/userspace-api/media/v4l/video.rst

raw
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: V4L
3
4 .. _video:
5
6 ************************
7 Video Inputs and Outputs
8 ************************
9
10 Video inputs and outputs are physical connectors of a device. These can
11 be for example: RF connectors (antenna/cable), CVBS a.k.a. Composite
12 Video, S-Video and RGB connectors. Camera sensors are also considered to
13 be a video input. Video and VBI capture devices have inputs. Video and
14 VBI output devices have outputs, at least one each. Radio devices have
15 no video inputs or outputs.
16
17 To learn about the number and attributes of the available inputs and
18 outputs applications can enumerate them with the
19 :ref:`VIDIOC_ENUMINPUT` and
20 :ref:`VIDIOC_ENUMOUTPUT` ioctl, respectively. The
21 struct :c:type:`v4l2_input` returned by the
22 :ref:`VIDIOC_ENUMINPUT` ioctl also contains signal
23 status information applicable when the current video input is queried.
24
25 The :ref:`VIDIOC_G_INPUT <VIDIOC_G_INPUT>` and
26 :ref:`VIDIOC_G_OUTPUT <VIDIOC_G_OUTPUT>` ioctls return the index of
27 the current video input or output. To select a different input or output
28 applications call the :ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` and
29 :ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` ioctls. Drivers must
30 implement all the input ioctls when the device has one or more inputs,
31 all the output ioctls when the device has one or more outputs.
32
33 Example: Information about the current video input
34 ==================================================
35
36 .. code-block:: c
37
38 struct v4l2_input input;
39 int index;
40
41 if (-1 == ioctl(fd, VIDIOC_G_INPUT, &index)) {
42 perror("VIDIOC_G_INPUT");
43 exit(EXIT_FAILURE);
44 }
45
46 memset(&input, 0, sizeof(input));
47 input.index = index;
48
49 if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &input)) {
50 perror("VIDIOC_ENUMINPUT");
51 exit(EXIT_FAILURE);
52 }
53
54 printf("Current input: %s\\n", input.name);
55
56
57 Example: Switching to the first video input
58 ===========================================
59
60 .. code-block:: c
61
62 int index;
63
64 index = 0;
65
66 if (-1 == ioctl(fd, VIDIOC_S_INPUT, &index)) {
67 perror("VIDIOC_S_INPUT");
68 exit(EXIT_FAILURE);
69 }