1*059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 254f38fcaSMauro Carvalho Chehab 354f38fcaSMauro Carvalho Chehab.. _video: 454f38fcaSMauro Carvalho Chehab 554f38fcaSMauro Carvalho Chehab************************ 654f38fcaSMauro Carvalho ChehabVideo Inputs and Outputs 754f38fcaSMauro Carvalho Chehab************************ 854f38fcaSMauro Carvalho Chehab 954f38fcaSMauro Carvalho ChehabVideo inputs and outputs are physical connectors of a device. These can 1054f38fcaSMauro Carvalho Chehabbe for example: RF connectors (antenna/cable), CVBS a.k.a. Composite 1154f38fcaSMauro Carvalho ChehabVideo, S-Video and RGB connectors. Camera sensors are also considered to 1254f38fcaSMauro Carvalho Chehabbe a video input. Video and VBI capture devices have inputs. Video and 1354f38fcaSMauro Carvalho ChehabVBI output devices have outputs, at least one each. Radio devices have 1454f38fcaSMauro Carvalho Chehabno video inputs or outputs. 1554f38fcaSMauro Carvalho Chehab 1654f38fcaSMauro Carvalho ChehabTo learn about the number and attributes of the available inputs and 1754f38fcaSMauro Carvalho Chehaboutputs applications can enumerate them with the 1854f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_ENUMINPUT` and 1954f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_ENUMOUTPUT` ioctl, respectively. The 2054f38fcaSMauro Carvalho Chehabstruct :c:type:`v4l2_input` returned by the 2154f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_ENUMINPUT` ioctl also contains signal 2254f38fcaSMauro Carvalho Chehabstatus information applicable when the current video input is queried. 2354f38fcaSMauro Carvalho Chehab 2454f38fcaSMauro Carvalho ChehabThe :ref:`VIDIOC_G_INPUT <VIDIOC_G_INPUT>` and 2554f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_G_OUTPUT <VIDIOC_G_OUTPUT>` ioctls return the index of 2654f38fcaSMauro Carvalho Chehabthe current video input or output. To select a different input or output 2754f38fcaSMauro Carvalho Chehabapplications call the :ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` and 2854f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` ioctls. Drivers must 2954f38fcaSMauro Carvalho Chehabimplement all the input ioctls when the device has one or more inputs, 3054f38fcaSMauro Carvalho Chehaball the output ioctls when the device has one or more outputs. 3154f38fcaSMauro Carvalho Chehab 3254f38fcaSMauro Carvalho ChehabExample: Information about the current video input 3354f38fcaSMauro Carvalho Chehab================================================== 3454f38fcaSMauro Carvalho Chehab 3554f38fcaSMauro Carvalho Chehab.. code-block:: c 3654f38fcaSMauro Carvalho Chehab 3754f38fcaSMauro Carvalho Chehab struct v4l2_input input; 3854f38fcaSMauro Carvalho Chehab int index; 3954f38fcaSMauro Carvalho Chehab 4054f38fcaSMauro Carvalho Chehab if (-1 == ioctl(fd, VIDIOC_G_INPUT, &index)) { 4154f38fcaSMauro Carvalho Chehab perror("VIDIOC_G_INPUT"); 4254f38fcaSMauro Carvalho Chehab exit(EXIT_FAILURE); 4354f38fcaSMauro Carvalho Chehab } 4454f38fcaSMauro Carvalho Chehab 4554f38fcaSMauro Carvalho Chehab memset(&input, 0, sizeof(input)); 4654f38fcaSMauro Carvalho Chehab input.index = index; 4754f38fcaSMauro Carvalho Chehab 4854f38fcaSMauro Carvalho Chehab if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &input)) { 4954f38fcaSMauro Carvalho Chehab perror("VIDIOC_ENUMINPUT"); 5054f38fcaSMauro Carvalho Chehab exit(EXIT_FAILURE); 5154f38fcaSMauro Carvalho Chehab } 5254f38fcaSMauro Carvalho Chehab 5354f38fcaSMauro Carvalho Chehab printf("Current input: %s\\n", input.name); 5454f38fcaSMauro Carvalho Chehab 5554f38fcaSMauro Carvalho Chehab 5654f38fcaSMauro Carvalho ChehabExample: Switching to the first video input 5754f38fcaSMauro Carvalho Chehab=========================================== 5854f38fcaSMauro Carvalho Chehab 5954f38fcaSMauro Carvalho Chehab.. code-block:: c 6054f38fcaSMauro Carvalho Chehab 6154f38fcaSMauro Carvalho Chehab int index; 6254f38fcaSMauro Carvalho Chehab 6354f38fcaSMauro Carvalho Chehab index = 0; 6454f38fcaSMauro Carvalho Chehab 6554f38fcaSMauro Carvalho Chehab if (-1 == ioctl(fd, VIDIOC_S_INPUT, &index)) { 6654f38fcaSMauro Carvalho Chehab perror("VIDIOC_S_INPUT"); 6754f38fcaSMauro Carvalho Chehab exit(EXIT_FAILURE); 6854f38fcaSMauro Carvalho Chehab } 69