Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame^] | 1 | .. -*- coding: utf-8; mode: rst -*- |
| 2 | |
| 3 | .. _video: |
| 4 | |
| 5 | ************************ |
| 6 | Video Inputs and Outputs |
| 7 | ************************ |
| 8 | |
| 9 | Video inputs and outputs are physical connectors of a device. These can |
| 10 | be for example RF connectors (antenna/cable), CVBS a.k.a. Composite |
| 11 | Video, S-Video or RGB connectors. Video and VBI capture devices have |
| 12 | inputs. Video and VBI output devices have outputs, at least one each. |
| 13 | Radio devices have no video inputs or outputs. |
| 14 | |
| 15 | To learn about the number and attributes of the available inputs and |
| 16 | outputs applications can enumerate them with the |
| 17 | :ref:`VIDIOC_ENUMINPUT <vidioc-enuminput>` and |
| 18 | :ref:`VIDIOC_ENUMOUTPUT <vidioc-enumoutput>` ioctl, respectively. The |
| 19 | struct :ref:`v4l2_input <v4l2-input>` returned by the |
| 20 | ``VIDIOC_ENUMINPUT`` ioctl also contains signal status information |
| 21 | applicable when the current video input is queried. |
| 22 | |
| 23 | The :ref:`VIDIOC_G_INPUT <vidioc-g-input>` and |
| 24 | :ref:`VIDIOC_G_OUTPUT <vidioc-g-output>` ioctls return the index of |
| 25 | the current video input or output. To select a different input or output |
| 26 | applications call the :ref:`VIDIOC_S_INPUT <vidioc-g-input>` and |
| 27 | :ref:`VIDIOC_S_OUTPUT <vidioc-g-output>` ioctls. Drivers must |
| 28 | implement all the input ioctls when the device has one or more inputs, |
| 29 | all the output ioctls when the device has one or more outputs. |
| 30 | |
| 31 | |
| 32 | .. code-block:: c |
| 33 | |
| 34 | struct v4l2_input input; |
| 35 | int index; |
| 36 | |
| 37 | if (-1 == ioctl(fd, VIDIOC_G_INPUT, &index)) { |
| 38 | perror("VIDIOC_G_INPUT"); |
| 39 | exit(EXIT_FAILURE); |
| 40 | } |
| 41 | |
| 42 | memset(&input, 0, sizeof(input)); |
| 43 | input.index = index; |
| 44 | |
| 45 | if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &input)) { |
| 46 | perror("VIDIOC_ENUMINPUT"); |
| 47 | exit(EXIT_FAILURE); |
| 48 | } |
| 49 | |
| 50 | printf("Current input: %s\\n", input.name); |
| 51 | |
| 52 | |
| 53 | .. code-block:: c |
| 54 | |
| 55 | int index; |
| 56 | |
| 57 | index = 0; |
| 58 | |
| 59 | if (-1 == ioctl(fd, VIDIOC_S_INPUT, &index)) { |
| 60 | perror("VIDIOC_S_INPUT"); |
| 61 | exit(EXIT_FAILURE); |
| 62 | } |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | .. ------------------------------------------------------------------------------ |
| 68 | .. This file was automatically converted from DocBook-XML with the dbxml |
| 69 | .. library (https://github.com/return42/sphkerneldoc). The origin XML comes |
| 70 | .. from the linux kernel, refer to: |
| 71 | .. |
| 72 | .. * https://github.com/torvalds/linux/tree/master/Documentation/DocBook |
| 73 | .. ------------------------------------------------------------------------------ |