vidioc-streamon.rst 3.3 KB
Newer Older
1 2
.. -*- coding: utf-8; mode: rst -*-

3
.. _VIDIOC_STREAMON:
4 5 6 7 8

***************************************
ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF
***************************************

9
Name
10
====
11

12
VIDIOC_STREAMON - VIDIOC_STREAMOFF - Start or stop streaming I/O
13

14 15

Synopsis
16 17
========

18
.. cpp:function:: int ioctl( int fd, int request, const int *argp )
19

20

21
Arguments
22 23 24 25 26 27 28 29 30 31 32
=========

``fd``
    File descriptor returned by :ref:`open() <func-open>`.

``request``
    VIDIOC_STREAMON, VIDIOC_STREAMOFF

``argp``


33
Description
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
===========

The ``VIDIOC_STREAMON`` and ``VIDIOC_STREAMOFF`` ioctl start and stop
the capture or output process during streaming
(:ref:`memory mapping <mmap>`, :ref:`user pointer <userp>` or
:ref:`DMABUF <dmabuf>`) I/O.

Capture hardware is disabled and no input buffers are filled (if there
are any empty buffers in the incoming queue) until ``VIDIOC_STREAMON``
has been called. Output hardware is disabled and no video signal is
produced until ``VIDIOC_STREAMON`` has been called. The ioctl will
succeed when at least one output buffer is in the incoming queue.

Memory-to-memory devices will not start until ``VIDIOC_STREAMON`` has
been called for both the capture and output stream types.

If ``VIDIOC_STREAMON`` fails then any already queued buffers will remain
queued.

The ``VIDIOC_STREAMOFF`` ioctl, apart of aborting or finishing any DMA
in progress, unlocks any user pointer buffers locked in physical memory,
and it removes all buffers from the incoming and outgoing queues. That
means all images captured but not dequeued yet will be lost, likewise
all images enqueued for output but not transmitted yet. I/O returns to
the same state as after calling
59
:ref:`VIDIOC_REQBUFS` and can be restarted
60 61
accordingly.

62
If buffers have been queued with :ref:`VIDIOC_QBUF` and
63 64 65
``VIDIOC_STREAMOFF`` is called without ever having called
``VIDIOC_STREAMON``, then those queued buffers will also be removed from
the incoming queue and all are returned to the same state as after
66
calling :ref:`VIDIOC_REQBUFS` and can be restarted
67 68 69 70 71 72 73 74 75 76 77 78
accordingly.

Both ioctls take a pointer to an integer, the desired buffer or stream
type. This is the same as struct
:ref:`v4l2_requestbuffers <v4l2-requestbuffers>` ``type``.

If ``VIDIOC_STREAMON`` is called when streaming is already in progress,
or if ``VIDIOC_STREAMOFF`` is called when streaming is already stopped,
then 0 is returned. Nothing happens in the case of ``VIDIOC_STREAMON``,
but ``VIDIOC_STREAMOFF`` will return queued buffers to their starting
state as mentioned above.

79 80 81 82
.. note:: Applications can be preempted for unknown periods right before
   or after the ``VIDIOC_STREAMON`` or ``VIDIOC_STREAMOFF`` calls, there is
   no notion of starting or stopping "now". Buffer timestamps can be used
   to synchronize with other events.
83 84


85
Return Value
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
============

On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter.

EINVAL
    The buffer ``type`` is not supported, or no buffers have been
    allocated (memory mapping) or enqueued (output) yet.

EPIPE
    The driver implements
    :ref:`pad-level format configuration <pad-level-formats>` and the
    pipeline configuration is invalid.

ENOLINK
    The driver implements Media Controller interface and the pipeline
    link configuration is invalid.