162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
262306a36Sopenharmony_ci.. c:namespace:: V4L
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci.. _VIDIOC_STREAMON:
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci***************************************
762306a36Sopenharmony_ciioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF
862306a36Sopenharmony_ci***************************************
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciName
1162306a36Sopenharmony_ci====
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciVIDIOC_STREAMON - VIDIOC_STREAMOFF - Start or stop streaming I/O
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciSynopsis
1662306a36Sopenharmony_ci========
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci.. c:macro:: VIDIOC_STREAMON
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_STREAMON, const int *argp)``
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci.. c:macro:: VIDIOC_STREAMOFF
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_STREAMOFF, const int *argp)``
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciArguments
2762306a36Sopenharmony_ci=========
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci``fd``
3062306a36Sopenharmony_ci    File descriptor returned by :c:func:`open()`.
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci``argp``
3362306a36Sopenharmony_ci    Pointer to an integer.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciDescription
3662306a36Sopenharmony_ci===========
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciThe ``VIDIOC_STREAMON`` and ``VIDIOC_STREAMOFF`` ioctl start and stop
3962306a36Sopenharmony_cithe capture or output process during streaming
4062306a36Sopenharmony_ci(:ref:`memory mapping <mmap>`, :ref:`user pointer <userp>` or
4162306a36Sopenharmony_ci:ref:`DMABUF <dmabuf>`) I/O.
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ciCapture hardware is disabled and no input buffers are filled (if there
4462306a36Sopenharmony_ciare any empty buffers in the incoming queue) until ``VIDIOC_STREAMON``
4562306a36Sopenharmony_cihas been called. Output hardware is disabled and no video signal is
4662306a36Sopenharmony_ciproduced until ``VIDIOC_STREAMON`` has been called.
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ciMemory-to-memory devices will not start until ``VIDIOC_STREAMON`` has
4962306a36Sopenharmony_cibeen called for both the capture and output stream types.
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ciIf ``VIDIOC_STREAMON`` fails then any already queued buffers will remain
5262306a36Sopenharmony_ciqueued.
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciThe ``VIDIOC_STREAMOFF`` ioctl, apart of aborting or finishing any DMA
5562306a36Sopenharmony_ciin progress, unlocks any user pointer buffers locked in physical memory,
5662306a36Sopenharmony_ciand it removes all buffers from the incoming and outgoing queues. That
5762306a36Sopenharmony_cimeans all images captured but not dequeued yet will be lost, likewise
5862306a36Sopenharmony_ciall images enqueued for output but not transmitted yet. I/O returns to
5962306a36Sopenharmony_cithe same state as after calling
6062306a36Sopenharmony_ci:ref:`VIDIOC_REQBUFS` and can be restarted
6162306a36Sopenharmony_ciaccordingly.
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ciIf buffers have been queued with :ref:`VIDIOC_QBUF` and
6462306a36Sopenharmony_ci``VIDIOC_STREAMOFF`` is called without ever having called
6562306a36Sopenharmony_ci``VIDIOC_STREAMON``, then those queued buffers will also be removed from
6662306a36Sopenharmony_cithe incoming queue and all are returned to the same state as after
6762306a36Sopenharmony_cicalling :ref:`VIDIOC_REQBUFS` and can be restarted
6862306a36Sopenharmony_ciaccordingly.
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ciBoth ioctls take a pointer to an integer, the desired buffer or stream
7162306a36Sopenharmony_citype. This is the same as struct
7262306a36Sopenharmony_ci:c:type:`v4l2_requestbuffers` ``type``.
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciIf ``VIDIOC_STREAMON`` is called when streaming is already in progress,
7562306a36Sopenharmony_cior if ``VIDIOC_STREAMOFF`` is called when streaming is already stopped,
7662306a36Sopenharmony_cithen 0 is returned. Nothing happens in the case of ``VIDIOC_STREAMON``,
7762306a36Sopenharmony_cibut ``VIDIOC_STREAMOFF`` will return queued buffers to their starting
7862306a36Sopenharmony_cistate as mentioned above.
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci.. note::
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci   Applications can be preempted for unknown periods right before
8362306a36Sopenharmony_ci   or after the ``VIDIOC_STREAMON`` or ``VIDIOC_STREAMOFF`` calls, there is
8462306a36Sopenharmony_ci   no notion of starting or stopping "now". Buffer timestamps can be used
8562306a36Sopenharmony_ci   to synchronize with other events.
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ciReturn Value
8862306a36Sopenharmony_ci============
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set
9162306a36Sopenharmony_ciappropriately. The generic error codes are described at the
9262306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter.
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ciEINVAL
9562306a36Sopenharmony_ci    The buffer ``type`` is not supported, or no buffers have been
9662306a36Sopenharmony_ci    allocated (memory mapping) or enqueued (output) yet.
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ciEPIPE
9962306a36Sopenharmony_ci    The driver implements
10062306a36Sopenharmony_ci    :ref:`pad-level format configuration <pad-level-formats>` and the
10162306a36Sopenharmony_ci    pipeline configuration is invalid.
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ciENOLINK
10462306a36Sopenharmony_ci    The driver implements Media Controller interface and the pipeline
10562306a36Sopenharmony_ci    link configuration is invalid.
106