Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
0002 
0003 .. _video:
0004 
0005 ************************
0006 Video Inputs and Outputs
0007 ************************
0008 
0009 Video inputs and outputs are physical connectors of a device. These can
0010 be for example: RF connectors (antenna/cable), CVBS a.k.a. Composite
0011 Video, S-Video and RGB connectors. Camera sensors are also considered to
0012 be a video input. Video and VBI capture devices have inputs. Video and
0013 VBI output devices have outputs, at least one each. Radio devices have
0014 no video inputs or outputs.
0015 
0016 To learn about the number and attributes of the available inputs and
0017 outputs applications can enumerate them with the
0018 :ref:`VIDIOC_ENUMINPUT` and
0019 :ref:`VIDIOC_ENUMOUTPUT` ioctl, respectively. The
0020 struct :c:type:`v4l2_input` returned by the
0021 :ref:`VIDIOC_ENUMINPUT` ioctl also contains signal
0022 status information applicable when the current video input is queried.
0023 
0024 The :ref:`VIDIOC_G_INPUT <VIDIOC_G_INPUT>` and
0025 :ref:`VIDIOC_G_OUTPUT <VIDIOC_G_OUTPUT>` ioctls return the index of
0026 the current video input or output. To select a different input or output
0027 applications call the :ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` and
0028 :ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` ioctls. Drivers must
0029 implement all the input ioctls when the device has one or more inputs,
0030 all the output ioctls when the device has one or more outputs.
0031 
0032 Example: Information about the current video input
0033 ==================================================
0034 
0035 .. code-block:: c
0036 
0037     struct v4l2_input input;
0038     int index;
0039 
0040     if (-1 == ioctl(fd, VIDIOC_G_INPUT, &index)) {
0041         perror("VIDIOC_G_INPUT");
0042         exit(EXIT_FAILURE);
0043     }
0044 
0045     memset(&input, 0, sizeof(input));
0046     input.index = index;
0047 
0048     if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &input)) {
0049         perror("VIDIOC_ENUMINPUT");
0050         exit(EXIT_FAILURE);
0051     }
0052 
0053     printf("Current input: %s\\n", input.name);
0054 
0055 
0056 Example: Switching to the first video input
0057 ===========================================
0058 
0059 .. code-block:: c
0060 
0061     int index;
0062 
0063     index = 0;
0064 
0065     if (-1 == ioctl(fd, VIDIOC_S_INPUT, &index)) {
0066         perror("VIDIOC_S_INPUT");
0067         exit(EXIT_FAILURE);
0068     }