xref: /openbmc/linux/Documentation/userspace-api/media/v4l/vidioc-streamon.rst (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2407e84cdSMauro Carvalho Chehab.. c:namespace:: V4L
354f38fcaSMauro Carvalho Chehab
454f38fcaSMauro Carvalho Chehab.. _VIDIOC_STREAMON:
554f38fcaSMauro Carvalho Chehab
654f38fcaSMauro Carvalho Chehab***************************************
754f38fcaSMauro Carvalho Chehabioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF
854f38fcaSMauro Carvalho Chehab***************************************
954f38fcaSMauro Carvalho Chehab
1054f38fcaSMauro Carvalho ChehabName
1154f38fcaSMauro Carvalho Chehab====
1254f38fcaSMauro Carvalho Chehab
1354f38fcaSMauro Carvalho ChehabVIDIOC_STREAMON - VIDIOC_STREAMOFF - Start or stop streaming I/O
1454f38fcaSMauro Carvalho Chehab
1554f38fcaSMauro Carvalho ChehabSynopsis
1654f38fcaSMauro Carvalho Chehab========
1754f38fcaSMauro Carvalho Chehab
18407e84cdSMauro Carvalho Chehab.. c:macro:: VIDIOC_STREAMON
1954f38fcaSMauro Carvalho Chehab
20407e84cdSMauro Carvalho Chehab``int ioctl(int fd, VIDIOC_STREAMON, const int *argp)``
2154f38fcaSMauro Carvalho Chehab
22407e84cdSMauro Carvalho Chehab.. c:macro:: VIDIOC_STREAMOFF
23407e84cdSMauro Carvalho Chehab
24407e84cdSMauro Carvalho Chehab``int ioctl(int fd, VIDIOC_STREAMOFF, const int *argp)``
2554f38fcaSMauro Carvalho Chehab
2654f38fcaSMauro Carvalho ChehabArguments
2754f38fcaSMauro Carvalho Chehab=========
2854f38fcaSMauro Carvalho Chehab
2954f38fcaSMauro Carvalho Chehab``fd``
30407e84cdSMauro Carvalho Chehab    File descriptor returned by :c:func:`open()`.
3154f38fcaSMauro Carvalho Chehab
3254f38fcaSMauro Carvalho Chehab``argp``
3354f38fcaSMauro Carvalho Chehab    Pointer to an integer.
3454f38fcaSMauro Carvalho Chehab
3554f38fcaSMauro Carvalho ChehabDescription
3654f38fcaSMauro Carvalho Chehab===========
3754f38fcaSMauro Carvalho Chehab
3854f38fcaSMauro Carvalho ChehabThe ``VIDIOC_STREAMON`` and ``VIDIOC_STREAMOFF`` ioctl start and stop
3954f38fcaSMauro Carvalho Chehabthe capture or output process during streaming
4054f38fcaSMauro Carvalho Chehab(:ref:`memory mapping <mmap>`, :ref:`user pointer <userp>` or
4154f38fcaSMauro Carvalho Chehab:ref:`DMABUF <dmabuf>`) I/O.
4254f38fcaSMauro Carvalho Chehab
4354f38fcaSMauro Carvalho ChehabCapture hardware is disabled and no input buffers are filled (if there
4454f38fcaSMauro Carvalho Chehabare any empty buffers in the incoming queue) until ``VIDIOC_STREAMON``
4554f38fcaSMauro Carvalho Chehabhas been called. Output hardware is disabled and no video signal is
46*6ceb72b2SDorota Czaplejewiczproduced until ``VIDIOC_STREAMON`` has been called.
4754f38fcaSMauro Carvalho Chehab
4854f38fcaSMauro Carvalho ChehabMemory-to-memory devices will not start until ``VIDIOC_STREAMON`` has
4954f38fcaSMauro Carvalho Chehabbeen called for both the capture and output stream types.
5054f38fcaSMauro Carvalho Chehab
5154f38fcaSMauro Carvalho ChehabIf ``VIDIOC_STREAMON`` fails then any already queued buffers will remain
5254f38fcaSMauro Carvalho Chehabqueued.
5354f38fcaSMauro Carvalho Chehab
5454f38fcaSMauro Carvalho ChehabThe ``VIDIOC_STREAMOFF`` ioctl, apart of aborting or finishing any DMA
5554f38fcaSMauro Carvalho Chehabin progress, unlocks any user pointer buffers locked in physical memory,
5654f38fcaSMauro Carvalho Chehaband it removes all buffers from the incoming and outgoing queues. That
5754f38fcaSMauro Carvalho Chehabmeans all images captured but not dequeued yet will be lost, likewise
5854f38fcaSMauro Carvalho Chehaball images enqueued for output but not transmitted yet. I/O returns to
5954f38fcaSMauro Carvalho Chehabthe same state as after calling
6054f38fcaSMauro Carvalho Chehab:ref:`VIDIOC_REQBUFS` and can be restarted
6154f38fcaSMauro Carvalho Chehabaccordingly.
6254f38fcaSMauro Carvalho Chehab
6354f38fcaSMauro Carvalho ChehabIf buffers have been queued with :ref:`VIDIOC_QBUF` and
6454f38fcaSMauro Carvalho Chehab``VIDIOC_STREAMOFF`` is called without ever having called
6554f38fcaSMauro Carvalho Chehab``VIDIOC_STREAMON``, then those queued buffers will also be removed from
6654f38fcaSMauro Carvalho Chehabthe incoming queue and all are returned to the same state as after
6754f38fcaSMauro Carvalho Chehabcalling :ref:`VIDIOC_REQBUFS` and can be restarted
6854f38fcaSMauro Carvalho Chehabaccordingly.
6954f38fcaSMauro Carvalho Chehab
7054f38fcaSMauro Carvalho ChehabBoth ioctls take a pointer to an integer, the desired buffer or stream
7154f38fcaSMauro Carvalho Chehabtype. This is the same as struct
7254f38fcaSMauro Carvalho Chehab:c:type:`v4l2_requestbuffers` ``type``.
7354f38fcaSMauro Carvalho Chehab
7454f38fcaSMauro Carvalho ChehabIf ``VIDIOC_STREAMON`` is called when streaming is already in progress,
7554f38fcaSMauro Carvalho Chehabor if ``VIDIOC_STREAMOFF`` is called when streaming is already stopped,
7654f38fcaSMauro Carvalho Chehabthen 0 is returned. Nothing happens in the case of ``VIDIOC_STREAMON``,
7754f38fcaSMauro Carvalho Chehabbut ``VIDIOC_STREAMOFF`` will return queued buffers to their starting
7854f38fcaSMauro Carvalho Chehabstate as mentioned above.
7954f38fcaSMauro Carvalho Chehab
8054f38fcaSMauro Carvalho Chehab.. note::
8154f38fcaSMauro Carvalho Chehab
8254f38fcaSMauro Carvalho Chehab   Applications can be preempted for unknown periods right before
8354f38fcaSMauro Carvalho Chehab   or after the ``VIDIOC_STREAMON`` or ``VIDIOC_STREAMOFF`` calls, there is
8454f38fcaSMauro Carvalho Chehab   no notion of starting or stopping "now". Buffer timestamps can be used
8554f38fcaSMauro Carvalho Chehab   to synchronize with other events.
8654f38fcaSMauro Carvalho Chehab
8754f38fcaSMauro Carvalho ChehabReturn Value
8854f38fcaSMauro Carvalho Chehab============
8954f38fcaSMauro Carvalho Chehab
9054f38fcaSMauro Carvalho ChehabOn success 0 is returned, on error -1 and the ``errno`` variable is set
9154f38fcaSMauro Carvalho Chehabappropriately. The generic error codes are described at the
9254f38fcaSMauro Carvalho Chehab:ref:`Generic Error Codes <gen-errors>` chapter.
9354f38fcaSMauro Carvalho Chehab
9454f38fcaSMauro Carvalho ChehabEINVAL
9554f38fcaSMauro Carvalho Chehab    The buffer ``type`` is not supported, or no buffers have been
9654f38fcaSMauro Carvalho Chehab    allocated (memory mapping) or enqueued (output) yet.
9754f38fcaSMauro Carvalho Chehab
9854f38fcaSMauro Carvalho ChehabEPIPE
9954f38fcaSMauro Carvalho Chehab    The driver implements
10054f38fcaSMauro Carvalho Chehab    :ref:`pad-level format configuration <pad-level-formats>` and the
10154f38fcaSMauro Carvalho Chehab    pipeline configuration is invalid.
10254f38fcaSMauro Carvalho Chehab
10354f38fcaSMauro Carvalho ChehabENOLINK
10454f38fcaSMauro Carvalho Chehab    The driver implements Media Controller interface and the pipeline
10554f38fcaSMauro Carvalho Chehab    link configuration is invalid.
106