xref: /linux/Documentation/userspace-api/media/v4l/video.rst (revision a5844227e0f030d2af2d85d4aed10c5eca6ca176)
1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2.. c:namespace:: V4L
3
4.. _video:
5
6************************
7Video Inputs and Outputs
8************************
9
10Video inputs and outputs are physical connectors of a device. These can
11be for example: RF connectors (antenna/cable), CVBS a.k.a. Composite
12Video, S-Video and RGB connectors. Camera sensors are also considered to
13be a video input. Video and VBI capture devices have inputs. Video and
14VBI output devices have outputs, at least one each. Radio devices have
15no video inputs or outputs.
16
17To learn about the number and attributes of the available inputs and
18outputs applications can enumerate them with the
19:ref:`VIDIOC_ENUMINPUT` and
20:ref:`VIDIOC_ENUMOUTPUT` ioctl, respectively. The
21struct :c:type:`v4l2_input` returned by the
22:ref:`VIDIOC_ENUMINPUT` ioctl also contains signal
23status information applicable when the current video input is queried.
24
25The :ref:`VIDIOC_G_INPUT <VIDIOC_G_INPUT>` and
26:ref:`VIDIOC_G_OUTPUT <VIDIOC_G_OUTPUT>` ioctls return the index of
27the current video input or output. To select a different input or output
28applications call the :ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` and
29:ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` ioctls. Drivers must
30implement all the input ioctls when the device has one or more inputs,
31all the output ioctls when the device has one or more outputs.
32
33Example: 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
57Example: 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    }
70