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