^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) .. c:namespace:: V4L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) .. _VIDIOC_STREAMON:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) ***************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) ***************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) VIDIOC_STREAMON - VIDIOC_STREAMOFF - Start or stop streaming I/O
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Synopsis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) .. c:macro:: VIDIOC_STREAMON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) ``int ioctl(int fd, VIDIOC_STREAMON, const int *argp)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) .. c:macro:: VIDIOC_STREAMOFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) ``int ioctl(int fd, VIDIOC_STREAMOFF, const int *argp)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) Arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) ``fd``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) File descriptor returned by :c:func:`open()`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) ``argp``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) Pointer to an integer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) The ``VIDIOC_STREAMON`` and ``VIDIOC_STREAMOFF`` ioctl start and stop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) the capture or output process during streaming
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) (:ref:`memory mapping <mmap>`, :ref:`user pointer <userp>` or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) :ref:`DMABUF <dmabuf>`) I/O.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) Capture hardware is disabled and no input buffers are filled (if there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) are any empty buffers in the incoming queue) until ``VIDIOC_STREAMON``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) has been called. Output hardware is disabled and no video signal is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) produced until ``VIDIOC_STREAMON`` has been called. The ioctl will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) succeed when at least one output buffer is in the incoming queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) Memory-to-memory devices will not start until ``VIDIOC_STREAMON`` has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) been called for both the capture and output stream types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) If ``VIDIOC_STREAMON`` fails then any already queued buffers will remain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) queued.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) The ``VIDIOC_STREAMOFF`` ioctl, apart of aborting or finishing any DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) in progress, unlocks any user pointer buffers locked in physical memory,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) and it removes all buffers from the incoming and outgoing queues. That
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) means all images captured but not dequeued yet will be lost, likewise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) all images enqueued for output but not transmitted yet. I/O returns to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) the same state as after calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) :ref:`VIDIOC_REQBUFS` and can be restarted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) If buffers have been queued with :ref:`VIDIOC_QBUF` and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) ``VIDIOC_STREAMOFF`` is called without ever having called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ``VIDIOC_STREAMON``, then those queued buffers will also be removed from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) the incoming queue and all are returned to the same state as after
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) calling :ref:`VIDIOC_REQBUFS` and can be restarted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) accordingly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) Both ioctls take a pointer to an integer, the desired buffer or stream
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) type. This is the same as struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) :c:type:`v4l2_requestbuffers` ``type``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) If ``VIDIOC_STREAMON`` is called when streaming is already in progress,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) or if ``VIDIOC_STREAMOFF`` is called when streaming is already stopped,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) then 0 is returned. Nothing happens in the case of ``VIDIOC_STREAMON``,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) but ``VIDIOC_STREAMOFF`` will return queued buffers to their starting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) state as mentioned above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) Applications can be preempted for unknown periods right before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) or after the ``VIDIOC_STREAMON`` or ``VIDIOC_STREAMOFF`` calls, there is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) no notion of starting or stopping "now". Buffer timestamps can be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) to synchronize with other events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) Return Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) On success 0 is returned, on error -1 and the ``errno`` variable is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) appropriately. The generic error codes are described at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) :ref:`Generic Error Codes <gen-errors>` chapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) EINVAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) The buffer ``type`` is not supported, or no buffers have been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) allocated (memory mapping) or enqueued (output) yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) EPIPE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) The driver implements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) :ref:`pad-level format configuration <pad-level-formats>` and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) pipeline configuration is invalid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) ENOLINK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) The driver implements Media Controller interface and the pipeline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) link configuration is invalid.