2018-08-30 22:15:26 +08:00
|
|
|
.. Permission is granted to copy, distribute and/or modify this
|
|
|
|
.. document under the terms of the GNU Free Documentation License,
|
|
|
|
.. Version 1.1 or any later version published by the Free Software
|
|
|
|
.. Foundation, with no Invariant Sections, no Front-Cover Texts
|
|
|
|
.. and no Back-Cover Texts. A copy of the license is included at
|
2020-03-04 17:21:39 +08:00
|
|
|
.. Documentation/userspace-api/media/fdl-appendix.rst.
|
2018-08-30 22:15:26 +08:00
|
|
|
..
|
|
|
|
.. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
|
|
|
|
|
2016-06-30 21:18:56 +08:00
|
|
|
.. _video:
|
|
|
|
|
|
|
|
************************
|
|
|
|
Video Inputs and Outputs
|
|
|
|
************************
|
|
|
|
|
|
|
|
Video inputs and outputs are physical connectors of a device. These can
|
2018-10-26 20:18:33 +08:00
|
|
|
be for example: RF connectors (antenna/cable), CVBS a.k.a. Composite
|
2017-03-29 15:59:12 +08:00
|
|
|
Video, S-Video and RGB connectors. Camera sensors are also considered to
|
|
|
|
be a video input. Video and VBI capture devices have inputs. Video and
|
|
|
|
VBI output devices have outputs, at least one each. Radio devices have
|
|
|
|
no video inputs or outputs.
|
2016-06-30 21:18:56 +08:00
|
|
|
|
|
|
|
To learn about the number and attributes of the available inputs and
|
|
|
|
outputs applications can enumerate them with the
|
2016-07-02 00:58:44 +08:00
|
|
|
:ref:`VIDIOC_ENUMINPUT` and
|
|
|
|
:ref:`VIDIOC_ENUMOUTPUT` ioctl, respectively. The
|
2016-08-30 04:37:59 +08:00
|
|
|
struct :c:type:`v4l2_input` returned by the
|
2016-07-02 00:58:44 +08:00
|
|
|
:ref:`VIDIOC_ENUMINPUT` ioctl also contains signal
|
2018-10-26 20:18:33 +08:00
|
|
|
status information applicable when the current video input is queried.
|
2016-06-30 21:18:56 +08:00
|
|
|
|
2016-07-03 21:02:29 +08:00
|
|
|
The :ref:`VIDIOC_G_INPUT <VIDIOC_G_INPUT>` and
|
|
|
|
:ref:`VIDIOC_G_OUTPUT <VIDIOC_G_OUTPUT>` ioctls return the index of
|
2016-06-30 21:18:56 +08:00
|
|
|
the current video input or output. To select a different input or output
|
2016-07-02 00:42:29 +08:00
|
|
|
applications call the :ref:`VIDIOC_S_INPUT <VIDIOC_G_INPUT>` and
|
|
|
|
:ref:`VIDIOC_S_OUTPUT <VIDIOC_G_OUTPUT>` ioctls. Drivers must
|
2016-06-30 21:18:56 +08:00
|
|
|
implement all the input ioctls when the device has one or more inputs,
|
|
|
|
all the output ioctls when the device has one or more outputs.
|
|
|
|
|
2016-07-10 19:22:19 +08:00
|
|
|
Example: Information about the current video input
|
|
|
|
==================================================
|
|
|
|
|
2016-06-30 21:18:56 +08:00
|
|
|
.. code-block:: c
|
|
|
|
|
|
|
|
struct v4l2_input input;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
if (-1 == ioctl(fd, VIDIOC_G_INPUT, &index)) {
|
2016-07-05 03:25:48 +08:00
|
|
|
perror("VIDIOC_G_INPUT");
|
|
|
|
exit(EXIT_FAILURE);
|
2016-06-30 21:18:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(&input, 0, sizeof(input));
|
|
|
|
input.index = index;
|
|
|
|
|
|
|
|
if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &input)) {
|
2016-07-05 03:25:48 +08:00
|
|
|
perror("VIDIOC_ENUMINPUT");
|
|
|
|
exit(EXIT_FAILURE);
|
2016-06-30 21:18:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("Current input: %s\\n", input.name);
|
|
|
|
|
|
|
|
|
2016-07-10 19:22:19 +08:00
|
|
|
Example: Switching to the first video input
|
|
|
|
===========================================
|
|
|
|
|
2016-06-30 21:18:56 +08:00
|
|
|
.. code-block:: c
|
|
|
|
|
|
|
|
int index;
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
|
|
|
|
if (-1 == ioctl(fd, VIDIOC_S_INPUT, &index)) {
|
2016-07-05 03:25:48 +08:00
|
|
|
perror("VIDIOC_S_INPUT");
|
|
|
|
exit(EXIT_FAILURE);
|
2016-06-30 21:18:56 +08:00
|
|
|
}
|