18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci.. _video: 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci************************ 68c2ecf20Sopenharmony_ciVideo Inputs and Outputs 78c2ecf20Sopenharmony_ci************************ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ciVideo inputs and outputs are physical connectors of a device. These can 108c2ecf20Sopenharmony_cibe for example: RF connectors (antenna/cable), CVBS a.k.a. Composite 118c2ecf20Sopenharmony_ciVideo, S-Video and RGB connectors. Camera sensors are also considered to 128c2ecf20Sopenharmony_cibe a video input. Video and VBI capture devices have inputs. Video and 138c2ecf20Sopenharmony_ciVBI output devices have outputs, at least one each. Radio devices have 148c2ecf20Sopenharmony_cino video inputs or outputs. 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciTo learn about the number and attributes of the available inputs and 178c2ecf20Sopenharmony_cioutputs applications can enumerate them with the 188c2ecf20Sopenharmony_ci:ref:`VIDIOC_ENUMINPUT` and 198c2ecf20Sopenharmony_ci:ref:`VIDIOC_ENUMOUTPUT` ioctl, respectively. The 208c2ecf20Sopenharmony_cistruct :c:type:`v4l2_input` returned by the 218c2ecf20Sopenharmony_ci:ref:`VIDIOC_ENUMINPUT` ioctl also contains signal 228c2ecf20Sopenharmony_cistatus information applicable when the current video input is queried. 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciThe :ref:`VIDIOC_G_INPUT <VIDIOC_G_INPUT>` and 258c2ecf20Sopenharmony_ci:ref:`VIDIOC_G_OUTPUT <VIDIOC_G_OUTPUT>` ioctls return the index of 268c2ecf20Sopenharmony_cithe current video input or output. To select a different input or output 278c2ecf20Sopenharmony_ciapplications call the :ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` and 288c2ecf20Sopenharmony_ci:ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` ioctls. Drivers must 298c2ecf20Sopenharmony_ciimplement all the input ioctls when the device has one or more inputs, 308c2ecf20Sopenharmony_ciall the output ioctls when the device has one or more outputs. 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciExample: Information about the current video input 338c2ecf20Sopenharmony_ci================================================== 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci.. code-block:: c 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci struct v4l2_input input; 388c2ecf20Sopenharmony_ci int index; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci if (-1 == ioctl(fd, VIDIOC_G_INPUT, &index)) { 418c2ecf20Sopenharmony_ci perror("VIDIOC_G_INPUT"); 428c2ecf20Sopenharmony_ci exit(EXIT_FAILURE); 438c2ecf20Sopenharmony_ci } 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci memset(&input, 0, sizeof(input)); 468c2ecf20Sopenharmony_ci input.index = index; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &input)) { 498c2ecf20Sopenharmony_ci perror("VIDIOC_ENUMINPUT"); 508c2ecf20Sopenharmony_ci exit(EXIT_FAILURE); 518c2ecf20Sopenharmony_ci } 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci printf("Current input: %s\\n", input.name); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ciExample: Switching to the first video input 578c2ecf20Sopenharmony_ci=========================================== 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci.. code-block:: c 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci int index; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci index = 0; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci if (-1 == ioctl(fd, VIDIOC_S_INPUT, &index)) { 668c2ecf20Sopenharmony_ci perror("VIDIOC_S_INPUT"); 678c2ecf20Sopenharmony_ci exit(EXIT_FAILURE); 688c2ecf20Sopenharmony_ci } 69