162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci.. _video: 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci************************ 662306a36Sopenharmony_ciVideo Inputs and Outputs 762306a36Sopenharmony_ci************************ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ciVideo inputs and outputs are physical connectors of a device. These can 1062306a36Sopenharmony_cibe for example: RF connectors (antenna/cable), CVBS a.k.a. Composite 1162306a36Sopenharmony_ciVideo, S-Video and RGB connectors. Camera sensors are also considered to 1262306a36Sopenharmony_cibe a video input. Video and VBI capture devices have inputs. Video and 1362306a36Sopenharmony_ciVBI output devices have outputs, at least one each. Radio devices have 1462306a36Sopenharmony_cino video inputs or outputs. 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ciTo learn about the number and attributes of the available inputs and 1762306a36Sopenharmony_cioutputs applications can enumerate them with the 1862306a36Sopenharmony_ci:ref:`VIDIOC_ENUMINPUT` and 1962306a36Sopenharmony_ci:ref:`VIDIOC_ENUMOUTPUT` ioctl, respectively. The 2062306a36Sopenharmony_cistruct :c:type:`v4l2_input` returned by the 2162306a36Sopenharmony_ci:ref:`VIDIOC_ENUMINPUT` ioctl also contains signal 2262306a36Sopenharmony_cistatus information applicable when the current video input is queried. 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ciThe :ref:`VIDIOC_G_INPUT <VIDIOC_G_INPUT>` and 2562306a36Sopenharmony_ci:ref:`VIDIOC_G_OUTPUT <VIDIOC_G_OUTPUT>` ioctls return the index of 2662306a36Sopenharmony_cithe current video input or output. To select a different input or output 2762306a36Sopenharmony_ciapplications call the :ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` and 2862306a36Sopenharmony_ci:ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` ioctls. Drivers must 2962306a36Sopenharmony_ciimplement all the input ioctls when the device has one or more inputs, 3062306a36Sopenharmony_ciall the output ioctls when the device has one or more outputs. 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ciExample: Information about the current video input 3362306a36Sopenharmony_ci================================================== 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci.. code-block:: c 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci struct v4l2_input input; 3862306a36Sopenharmony_ci int index; 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci if (-1 == ioctl(fd, VIDIOC_G_INPUT, &index)) { 4162306a36Sopenharmony_ci perror("VIDIOC_G_INPUT"); 4262306a36Sopenharmony_ci exit(EXIT_FAILURE); 4362306a36Sopenharmony_ci } 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci memset(&input, 0, sizeof(input)); 4662306a36Sopenharmony_ci input.index = index; 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &input)) { 4962306a36Sopenharmony_ci perror("VIDIOC_ENUMINPUT"); 5062306a36Sopenharmony_ci exit(EXIT_FAILURE); 5162306a36Sopenharmony_ci } 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci printf("Current input: %s\\n", input.name); 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ciExample: Switching to the first video input 5762306a36Sopenharmony_ci=========================================== 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci.. code-block:: c 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci int index; 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci index = 0; 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci if (-1 == ioctl(fd, VIDIOC_S_INPUT, &index)) { 6662306a36Sopenharmony_ci perror("VIDIOC_S_INPUT"); 6762306a36Sopenharmony_ci exit(EXIT_FAILURE); 6862306a36Sopenharmony_ci } 69