1<refentry id="vidioc-subscribe-event">
2  <refmeta>
3    <refentrytitle>ioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT</refentrytitle>
4    &manvol;
5  </refmeta>
6
7  <refnamediv>
8      <refname>VIDIOC_SUBSCRIBE_EVENT</refname>
9      <refname>VIDIOC_UNSUBSCRIBE_EVENT</refname>
10    <refpurpose>Subscribe or unsubscribe event</refpurpose>
11  </refnamediv>
12
13  <refsynopsisdiv>
14    <funcsynopsis>
15      <funcprototype>
16	<funcdef>int <function>ioctl</function></funcdef>
17	<paramdef>int <parameter>fd</parameter></paramdef>
18	<paramdef>int <parameter>request</parameter></paramdef>
19	<paramdef>struct v4l2_event_subscription
20*<parameter>argp</parameter></paramdef>
21      </funcprototype>
22    </funcsynopsis>
23  </refsynopsisdiv>
24
25  <refsect1>
26    <title>Arguments</title>
27
28    <variablelist>
29      <varlistentry>
30	<term><parameter>fd</parameter></term>
31	<listitem>
32	  <para>&fd;</para>
33	</listitem>
34      </varlistentry>
35      <varlistentry>
36	<term><parameter>request</parameter></term>
37	<listitem>
38	  <para>VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT</para>
39	</listitem>
40      </varlistentry>
41      <varlistentry>
42	<term><parameter>argp</parameter></term>
43	<listitem>
44	  <para></para>
45	</listitem>
46      </varlistentry>
47    </variablelist>
48  </refsect1>
49
50  <refsect1>
51    <title>Description</title>
52
53    <para>Subscribe or unsubscribe V4L2 event. Subscribed events are
54    dequeued by using the &VIDIOC-DQEVENT; ioctl.</para>
55
56    <table frame="none" pgwide="1" id="v4l2-event-subscription">
57      <title>struct <structname>v4l2_event_subscription</structname></title>
58      <tgroup cols="3">
59	&cs-str;
60	<tbody valign="top">
61	  <row>
62	    <entry>__u32</entry>
63	    <entry><structfield>type</structfield></entry>
64	    <entry>Type of the event, see <xref linkend="event-type" />. Note that
65<constant>V4L2_EVENT_ALL</constant> can be used with VIDIOC_UNSUBSCRIBE_EVENT
66for unsubscribing all events at once.</entry>
67	  </row>
68	  <row>
69	    <entry>__u32</entry>
70	    <entry><structfield>id</structfield></entry>
71	    <entry>ID of the event source. If there is no ID associated with
72		the event source, then set this to 0. Whether or not an event
73		needs an ID depends on the event type.</entry>
74	  </row>
75	  <row>
76	    <entry>__u32</entry>
77	    <entry><structfield>flags</structfield></entry>
78	    <entry>Event flags, see <xref linkend="event-flags" />.</entry>
79	  </row>
80	  <row>
81	    <entry>__u32</entry>
82	    <entry><structfield>reserved</structfield>[5]</entry>
83	    <entry>Reserved for future extensions. Drivers and applications
84	    must set the array to zero.</entry>
85	  </row>
86	</tbody>
87      </tgroup>
88    </table>
89
90    <table pgwide="1" frame="none" id="event-flags">
91      <title>Event Flags</title>
92      <tgroup cols="3">
93	&cs-def;
94	<tbody valign="top">
95	  <row>
96	    <entry><constant>V4L2_EVENT_SUB_FL_SEND_INITIAL</constant></entry>
97	    <entry>0x0001</entry>
98	    <entry>When this event is subscribed an initial event will be sent
99		containing the current status. This only makes sense for events
100		that are triggered by a status change such as <constant>V4L2_EVENT_CTRL</constant>.
101		Other events will ignore this flag.</entry>
102	  </row>
103	  <row>
104	    <entry><constant>V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK</constant></entry>
105	    <entry>0x0002</entry>
106	    <entry><para>If set, then events directly caused by an ioctl will also be sent to
107		the filehandle that called that ioctl. For example, changing a control using
108		&VIDIOC-S-CTRL; will cause a V4L2_EVENT_CTRL to be sent back to that same
109		filehandle. Normally such events are suppressed to prevent feedback loops
110		where an application changes a control to a one value and then another, and
111		then receives an event telling it that that control has changed to the first
112		value.</para>
113
114		<para>Since it can't tell whether that event was caused by another application
115		or by the &VIDIOC-S-CTRL; call it is hard to decide whether to set the
116		control to the value in the event, or ignore it.</para>
117
118		<para>Think carefully when you set this flag so you won't get into situations
119		like that.</para>
120	    </entry>
121	  </row>
122	</tbody>
123      </tgroup>
124    </table>
125
126  </refsect1>
127  <refsect1>
128    &return-value;
129  </refsect1>
130</refentry>
131