1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API"><link rel="up" href="user-func.html" title="Appendix&#160;A.&#160;Function Reference"><link rel="prev" href="vidioc-s-hw-freq-seek.html" title="ioctl VIDIOC_S_HW_FREQ_SEEK"><link rel="next" href="vidioc-subdev-enum-frame-interval.html" title="ioctl VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="vidioc-s-hw-freq-seek.html">Prev</a>&#160;</td><th width="60%" align="center">Appendix&#160;A.&#160;Function Reference</th><td width="20%" align="right">&#160;<a accesskey="n" href="vidioc-subdev-enum-frame-interval.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="vidioc-streamon"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>VIDIOC_STREAMON, VIDIOC_STREAMOFF &#8212; Start or stop streaming I/O</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">ioctl</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td>&#160;</td><td>int <var class="pdparam">request</var>, </td></tr><tr><td>&#160;</td><td>const int *<var class="pdparam">argp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1116396100"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>fd</code></em></span></dt><dd><p>File descriptor returned by <a class="link" href="func-open.html" title="V4L2 open()"><code class="function">open()</code></a>.</p></dd><dt><span class="term"><em class="parameter"><code>request</code></em></span></dt><dd><p>VIDIOC_STREAMON, VIDIOC_STREAMOFF</p></dd><dt><span class="term"><em class="parameter"><code>argp</code></em></span></dt><dd><p></p></dd></dl></div></div><div class="refsect1"><a name="idp1116400164"></a><h2>Description</h2><p>The <code class="constant">VIDIOC_STREAMON</code> and
2<code class="constant">VIDIOC_STREAMOFF</code> ioctl start and stop the capture
3or output process during streaming (<a class="link" href="mmap.html" title="Streaming I/O (Memory Mapping)">memory
4mapping</a>, <a class="link" href="userp.html" title="Streaming I/O (User Pointers)">user pointer</a> or
5<a class="link" href="dmabuf.html" title="Streaming I/O (DMA buffer importing)">DMABUF</a>) I/O.</p><p>Capture hardware is disabled and no input
6buffers are filled (if there are any empty buffers in the incoming
7queue) until <code class="constant">VIDIOC_STREAMON</code> has been called.
8Output hardware is disabled and no video signal is
9produced until <code class="constant">VIDIOC_STREAMON</code> has been called.
10The ioctl will succeed when at least one output buffer is in the
11incoming queue.</p><p>Memory-to-memory devices will not start until
12<code class="constant">VIDIOC_STREAMON</code> has been called for both the capture
13and output stream types.</p><p>If <code class="constant">VIDIOC_STREAMON</code> fails then any already
14queued buffers will remain queued.</p><p>The <code class="constant">VIDIOC_STREAMOFF</code> ioctl, apart of
15aborting or finishing any DMA in progress, unlocks any user pointer
16buffers locked in physical memory, and it removes all buffers from the
17incoming and outgoing queues. That means all images captured but not
18dequeued yet will be lost, likewise all images enqueued for output but
19not transmitted yet. I/O returns to the same state as after calling
20<a class="link" href="vidioc-reqbufs.html" title="ioctl VIDIOC_REQBUFS"><code class="constant">VIDIOC_REQBUFS</code></a> and can be restarted accordingly.</p><p>If buffers have been queued with <a class="link" href="vidioc-qbuf.html" title="ioctl VIDIOC_QBUF, VIDIOC_DQBUF"><code class="constant">VIDIOC_QBUF</code></a> and
21<code class="constant">VIDIOC_STREAMOFF</code> is called without ever having
22called <code class="constant">VIDIOC_STREAMON</code>, then those queued buffers
23will also be removed from the incoming queue and all are returned to the
24same state as after calling <a class="link" href="vidioc-reqbufs.html" title="ioctl VIDIOC_REQBUFS"><code class="constant">VIDIOC_REQBUFS</code></a> and can be restarted
25accordingly.</p><p>Both ioctls take a pointer to an integer, the desired buffer or
26stream type. This is the same as struct&#160;<a class="link" href="vidioc-reqbufs.html#v4l2-requestbuffers" title="Table&#160;A.100.&#160;struct v4l2_requestbuffers">v4l2_requestbuffers</a>
27<em class="structfield"><code>type</code></em>.</p><p>If <code class="constant">VIDIOC_STREAMON</code> is called when streaming
28is already in progress, or if <code class="constant">VIDIOC_STREAMOFF</code> is called
29when streaming is already stopped, then 0 is returned. Nothing happens in the
30case of <code class="constant">VIDIOC_STREAMON</code>, but <code class="constant">VIDIOC_STREAMOFF</code>
31will return queued buffers to their starting state as mentioned above.</p><p>Note that applications can be preempted for unknown periods right
32before or after the <code class="constant">VIDIOC_STREAMON</code> or
33<code class="constant">VIDIOC_STREAMOFF</code> calls, there is no notion of
34starting or stopping "now". Buffer timestamps can be used to
35synchronize with other events.</p></div><div class="refsect1"><a name="idp1116410564"></a><h2>Return Value</h2><p>On success <span class="returnvalue">0</span> is returned, on error <span class="returnvalue">-1</span> and the <code class="varname">errno</code> variable is set appropriately. The generic error codes are described at the <a class="link" href="gen_errors.html#gen-errors" title="Table&#160;19.1.&#160;Generic error codes">Generic Error Codes</a> chapter.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">EINVAL</span></span></dt><dd><p>The buffer <em class="structfield"><code>type</code></em> is not supported,
36	  or no buffers have been allocated (memory mapping) or enqueued
37	  (output) yet.</p></dd><dt><span class="term"><span class="errorcode">EPIPE</span></span></dt><dd><p>The driver implements <a class="link" href="subdev.html#pad-level-formats" title="Pad-level Formats">pad-level format configuration</a> and
38	  the pipeline configuration is invalid.
39	  </p></dd></dl></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="vidioc-s-hw-freq-seek.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="user-func.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="vidioc-subdev-enum-frame-interval.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ioctl VIDIOC_S_HW_FREQ_SEEK&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;ioctl VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL</td></tr></table></div></body></html>
40