- :ref:`DTV_TUNE <DTV-TUNE>`
-The code that would do the above is:
+The code that would that would do the above is show in
+:ref:`dtv-prop-example`.
+.. _dtv-prop-example:
+
+Example: Setting digital TV frontend properties
+===============================================
.. code-block:: c
.. _tuning:
-Tuning
-======
+Example: Tuning
+===============
We will start with a generic tuning subroutine that uses the frontend
and SEC, as well as the demux devices. The example is given for QPSK
.. _the_dvr_device:
-The DVR device
-==============
+Example: The DVR device
+========================
The following program code shows how to use the DVR device for
recording.
the :ref:`VIDIOC_QUERYCAP` ioctl.
+Example: Information about the current audio input
+==================================================
+
.. code-block:: c
- :caption: Example 1.3. Information about the current audio input
struct v4l2_audio audio;
printf("Current input: %s\\n", audio.name);
+Example: Switching to the first audio input
+===========================================
+
.. code-block:: c
- :caption: Example 1.4. Switching to the first audio input
struct v4l2_audio audio;
.. _enum_all_controls:
+Example: Enumerating all user controls
+======================================
+
.. code-block:: c
- :caption: Example 1.8. Enumerating all user controls
struct v4l2_queryctrl queryctrl;
}
+Example: Enumerating all user controls (alternative)
+====================================================
+
.. code-block:: c
- :caption: Example 1.9. Enumerating all user controls (alternative)
memset(&queryctrl, 0, sizeof(queryctrl));
exit(EXIT_FAILURE);
}
+Example: Changing controls
+==========================
.. code-block:: c
- :caption: Example 1.10. Changing controls
struct v4l2_queryctrl queryctrl;
struct v4l2_control control;
**NOTE:** on the next two examples, a video capture device is assumed;
change ``V4L2_BUF_TYPE_VIDEO_CAPTURE`` for other types of device.
+Example: Resetting the cropping parameters
+==========================================
+
.. code-block:: c
- :caption: Example 1.11. Resetting the cropping parameters
struct v4l2_cropcap cropcap;
struct v4l2_crop crop;
exit (EXIT_FAILURE);
}
+
+Example: Simple downscaling
+===========================
+
.. code-block:: c
- :caption: Example 1.12. Simple downscaling
struct v4l2_cropcap cropcap;
struct v4l2_format format;
/* We could check the actual image size now, the actual scaling factor
or if the driver can scale at all. */
+Example: Selecting an output area
+=================================
+
**NOTE:** This example assumes an output device.
.. code-block:: c
- :caption: Example 1.13. Selecting an output area
struct v4l2_cropcap cropcap;
struct v4l2_crop crop;
exit (EXIT_FAILURE);
}
+Example: Current scaling factor and pixel aspect
+================================================
+
**NOTE:** This example assumes a video capture device.
.. code-block:: c
- :caption: Example 1.14. Current scaling factor and pixel aspect
struct v4l2_cropcap cropcap;
struct v4l2_crop crop;
(or any other ioctl which would imply a framebuffer size change) with an
``EBUSY`` error code until all applications closed the framebuffer device.
+Example: Finding a framebuffer device for OSD
+---------------------------------------------
.. code-block:: c
- :caption: Example 4.1. Finding a framebuffer device for OSD
#include <linux/fb.h>
:ref:`VIDIOC_REQBUFS <VIDIOC_REQBUFS>` with the desired buffer type.
+Example: Initiating streaming I/O with DMABUF file descriptors
+==============================================================
+
.. code-block:: c
- :caption: Example 3.4. Initiating streaming I/O with DMABUF file descriptors
struct v4l2_requestbuffers reqbuf;
descriptor. Although buffers are commonly cycled, applications can pass
a different DMABUF descriptor at each :ref:`VIDIOC_QBUF <VIDIOC_QBUF>` call.
+Example: Queueing DMABUF using single plane API
+===============================================
.. code-block:: c
- :caption: Example 3.5. Queueing DMABUF using single plane API
int buffer_queue(int v4lfd, int index, int dmafd)
{
return 0;
}
+Example 3.6. Queueing DMABUF using multi plane API
+==================================================
.. code-block:: c
- :caption: Example 3.6. Queueing DMABUF using multi plane API
int buffer_queue_mp(int v4lfd, int index, int dmafd[], int n_planes)
{
swapped out to disk. Applications should free the buffers as soon as
possible with the :ref:`munmap() <func-munmap>` function.
+Example: Mapping buffers in the single-planar API
+=================================================
.. code-block:: c
- :caption: Example 3.1. Mapping buffers in the single-planar API
struct v4l2_requestbuffers reqbuf;
struct {
munmap(buffers[i].start, buffers[i].length);
+Example: Mapping buffers in the multi-planar API
+================================================
+
.. code-block:: c
- :caption: Example 3.2. Mapping buffers in the multi-planar API
struct v4l2_requestbuffers reqbuf;
/* Our current format uses 3 planes per buffer */
``V4L2_BUF_TYPE_VIDEO_CAPTURE`` for other devices; change target to
``V4L2_SEL_TGT_COMPOSE_*`` family to configure composing area)
+Example: Resetting the cropping parameters
+==========================================
.. code-block:: c
- :caption: Example 1.15. Resetting the cropping parameters
struct v4l2_selection sel = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
Setting a composing area on output of size of *at most* half of limit
placed at a center of a display.
+Example: Simple downscaling
+===========================
.. code-block:: c
- :caption: Example 1.16. Simple downscaling
struct v4l2_selection sel = {
.type = V4L2_BUF_TYPE_VIDEO_OUTPUT,
A video output device is assumed; change ``V4L2_BUF_TYPE_VIDEO_OUTPUT``
for other devices
+Example: Querying for scaling factors
+=====================================
.. code-block:: c
- :caption: Example 1.17. Querying for scaling factors
struct v4l2_selection compose = {
.type = V4L2_BUF_TYPE_VIDEO_OUTPUT,
:ref:`output-capabilities` flags to determine whether the video
standard ioctls can be used with the given input or output.
+Example: Information about the current video standard
+=====================================================
.. code-block:: c
- :caption: Example 1.5. Information about the current video standard
v4l2_std_id std_id;
struct v4l2_standard standard;
exit(EXIT_FAILURE);
}
+Example: Listing the video standards supported by the current input
+===================================================================
.. code-block:: c
- :caption: Example 1.6. Listing the video standards supported by the current input
struct v4l2_input input;
struct v4l2_standard standard;
exit(EXIT_FAILURE);
}
+Example: Selecting a new video standard
+=======================================
.. code-block:: c
- :caption: Example 1.7. Selecting a new video standard
struct v4l2_input input;
v4l2_std_id std_id;
indexed and cannot be queried like mapped buffers with the
:ref:`VIDIOC_QUERYBUF <VIDIOC_QUERYBUF>` ioctl.
+Example: Initiating streaming I/O with user pointers
+====================================================
.. code-block:: c
- :caption: Example 3.3. Initiating streaming I/O with user pointers
struct v4l2_requestbuffers reqbuf;
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.
+Example: Information about the current video input
+==================================================
+
.. code-block:: c
- :caption: Example 1.1. Information about the current video input
struct v4l2_input input;
int index;
printf("Current input: %s\\n", input.name);
+Example: Switching to the first video input
+===========================================
+
.. code-block:: c
- :caption: Example 1.2. Switching to the first video input
int index;