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