1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>ioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT</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-subdev-g-selection.html" title="ioctl VIDIOC_SUBDEV_G_SELECTION, VIDIOC_SUBDEV_S_SELECTION"><link rel="next" href="func-mmap.html" title="V4L2 mmap()"></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_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="vidioc-subdev-g-selection.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="func-mmap.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="vidioc-subscribe-event"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT &#8212; Subscribe or unsubscribe event</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>struct v4l2_event_subscription
2*<var class="pdparam">argp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1116820748"></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_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT</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="idp1116824868"></a><h2>Description</h2><p>Subscribe or unsubscribe V4L2 event. Subscribed events are
3    dequeued by using the <a class="link" href="vidioc-dqevent.html" title="ioctl VIDIOC_DQEVENT"><code class="constant">VIDIOC_DQEVENT</code></a> ioctl.</p><div class="table"><a name="v4l2-event-subscription"></a><p class="title"><b>Table&#160;A.110.&#160;struct <span class="structname">v4l2_event_subscription</span></b></p><div class="table-contents"><table summary="struct v4l2_event_subscription" width="100%" border="0"><colgroup><col class="c1"><col class="c2"><col class="c3"></colgroup><tbody valign="top"><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>type</code></em></td><td valign="top">Type of the event, see <a class="xref" href="vidioc-dqevent.html#event-type" title="Table&#160;A.13.&#160;Event Types">Table&#160;A.13, &#8220;Event Types&#8221;</a>. Note that
4<code class="constant">V4L2_EVENT_ALL</code> can be used with VIDIOC_UNSUBSCRIBE_EVENT
5for unsubscribing all events at once.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>id</code></em></td><td valign="top">ID of the event source. If there is no ID associated with
6		the event source, then set this to 0. Whether or not an event
7		needs an ID depends on the event type.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>flags</code></em></td><td valign="top">Event flags, see <a class="xref" href="vidioc-subscribe-event.html#event-flags" title="Table&#160;A.111.&#160;Event Flags">Table&#160;A.111, &#8220;Event Flags&#8221;</a>.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>reserved</code></em>[5]</td><td valign="top">Reserved for future extensions. Drivers and applications
8	    must set the array to zero.</td></tr></tbody></table></div></div><br class="table-break"><div class="table"><a name="event-flags"></a><p class="title"><b>Table&#160;A.111.&#160;Event Flags</b></p><div class="table-contents"><table summary="Event Flags" width="100%" border="0"><colgroup><col class="c1"><col class="c2"><col class="c3"></colgroup><tbody valign="top"><tr><td valign="top"><code class="constant">V4L2_EVENT_SUB_FL_SEND_INITIAL</code></td><td valign="top">0x0001</td><td valign="top">When this event is subscribed an initial event will be sent
9		containing the current status. This only makes sense for events
10		that are triggered by a status change such as <code class="constant">V4L2_EVENT_CTRL</code>.
11		Other events will ignore this flag.</td></tr><tr><td valign="top"><code class="constant">V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK</code></td><td valign="top">0x0002</td><td valign="top"><p>If set, then events directly caused by an ioctl will also be sent to
12		the filehandle that called that ioctl. For example, changing a control using
13		<a class="link" href="vidioc-g-ctrl.html" title="ioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL"><code class="constant">VIDIOC_S_CTRL</code></a> will cause a V4L2_EVENT_CTRL to be sent back to that same
14		filehandle. Normally such events are suppressed to prevent feedback loops
15		where an application changes a control to a one value and then another, and
16		then receives an event telling it that that control has changed to the first
17		value.</p>
18
19		<p>Since it can't tell whether that event was caused by another application
20		or by the <a class="link" href="vidioc-g-ctrl.html" title="ioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL"><code class="constant">VIDIOC_S_CTRL</code></a> call it is hard to decide whether to set the
21		control to the value in the event, or ignore it.</p>
22
23		<p>Think carefully when you set this flag so you won't get into situations
24		like that.</p>
25	    </td></tr></tbody></table></div></div><br class="table-break"></div><div class="refsect1"><a name="idp1116909676"></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></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="vidioc-subdev-g-selection.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="func-mmap.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ioctl VIDIOC_SUBDEV_G_SELECTION, VIDIOC_SUBDEV_S_SELECTION&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;V4L2 mmap()</td></tr></table></div></body></html>
26