1<refentry id="vidioc-dqevent">
2  <refmeta>
3    <refentrytitle>ioctl VIDIOC_DQEVENT</refentrytitle>
4    &manvol;
5  </refmeta>
6
7  <refnamediv>
8    <refname>VIDIOC_DQEVENT</refname>
9    <refpurpose>Dequeue event</refpurpose>
10  </refnamediv>
11
12  <refsynopsisdiv>
13    <funcsynopsis>
14      <funcprototype>
15	<funcdef>int <function>ioctl</function></funcdef>
16	<paramdef>int <parameter>fd</parameter></paramdef>
17	<paramdef>int <parameter>request</parameter></paramdef>
18	<paramdef>struct v4l2_event
19*<parameter>argp</parameter></paramdef>
20      </funcprototype>
21    </funcsynopsis>
22  </refsynopsisdiv>
23
24  <refsect1>
25    <title>Arguments</title>
26
27    <variablelist>
28      <varlistentry>
29	<term><parameter>fd</parameter></term>
30	<listitem>
31	  <para>&fd;</para>
32	</listitem>
33      </varlistentry>
34      <varlistentry>
35	<term><parameter>request</parameter></term>
36	<listitem>
37	  <para>VIDIOC_DQEVENT</para>
38	</listitem>
39      </varlistentry>
40      <varlistentry>
41	<term><parameter>argp</parameter></term>
42	<listitem>
43	  <para></para>
44	</listitem>
45      </varlistentry>
46    </variablelist>
47  </refsect1>
48
49  <refsect1>
50    <title>Description</title>
51
52    <para>Dequeue an event from a video device. No input is required
53    for this ioctl. All the fields of the &v4l2-event; structure are
54    filled by the driver. The file handle will also receive exceptions
55    which the application may get by e.g. using the select system
56    call.</para>
57
58    <table frame="none" pgwide="1" id="v4l2-event">
59      <title>struct <structname>v4l2_event</structname></title>
60      <tgroup cols="4">
61	&cs-str;
62	<tbody valign="top">
63	  <row>
64	    <entry>__u32</entry>
65	    <entry><structfield>type</structfield></entry>
66            <entry></entry>
67	    <entry>Type of the event, see <xref linkend="event-type" />.</entry>
68	  </row>
69	  <row>
70	    <entry>union</entry>
71	    <entry><structfield>u</structfield></entry>
72            <entry></entry>
73	    <entry></entry>
74	  </row>
75	  <row>
76	    <entry></entry>
77	    <entry>&v4l2-event-vsync;</entry>
78            <entry><structfield>vsync</structfield></entry>
79	    <entry>Event data for event <constant>V4L2_EVENT_VSYNC</constant>.
80            </entry>
81	  </row>
82	  <row>
83	    <entry></entry>
84	    <entry>&v4l2-event-ctrl;</entry>
85            <entry><structfield>ctrl</structfield></entry>
86	    <entry>Event data for event <constant>V4L2_EVENT_CTRL</constant>.
87            </entry>
88	  </row>
89	  <row>
90	    <entry></entry>
91	    <entry>&v4l2-event-frame-sync;</entry>
92            <entry><structfield>frame_sync</structfield></entry>
93	    <entry>Event data for event
94	    <constant>V4L2_EVENT_FRAME_SYNC</constant>.</entry>
95	  </row>
96	  <row>
97	    <entry></entry>
98	    <entry>&v4l2-event-motion-det;</entry>
99            <entry><structfield>motion_det</structfield></entry>
100	    <entry>Event data for event V4L2_EVENT_MOTION_DET.</entry>
101	  </row>
102	  <row>
103	    <entry></entry>
104	    <entry>&v4l2-event-src-change;</entry>
105            <entry><structfield>src_change</structfield></entry>
106	    <entry>Event data for event V4L2_EVENT_SOURCE_CHANGE.</entry>
107	  </row>
108	  <row>
109	    <entry></entry>
110	    <entry>__u8</entry>
111            <entry><structfield>data</structfield>[64]</entry>
112	    <entry>Event data. Defined by the event type. The union
113            should be used to define easily accessible type for
114            events.</entry>
115	  </row>
116	  <row>
117	    <entry>__u32</entry>
118	    <entry><structfield>pending</structfield></entry>
119            <entry></entry>
120	    <entry>Number of pending events excluding this one.</entry>
121	  </row>
122	  <row>
123	    <entry>__u32</entry>
124	    <entry><structfield>sequence</structfield></entry>
125            <entry></entry>
126	    <entry>Event sequence number. The sequence number is
127	    incremented for every subscribed event that takes place.
128	    If sequence numbers are not contiguous it means that
129	    events have been lost.
130	    </entry>
131	  </row>
132	  <row>
133	    <entry>struct timespec</entry>
134	    <entry><structfield>timestamp</structfield></entry>
135            <entry></entry>
136	    <entry>Event timestamp.</entry>
137	  </row>
138	  <row>
139	    <entry>u32</entry>
140	    <entry><structfield>id</structfield></entry>
141            <entry></entry>
142	    <entry>The ID associated with the event source. If the event does not
143		have an associated ID (this depends on the event type), then this
144		is 0.</entry>
145	  </row>
146	  <row>
147	    <entry>__u32</entry>
148	    <entry><structfield>reserved</structfield>[8]</entry>
149            <entry></entry>
150	    <entry>Reserved for future extensions. Drivers must set
151	    the array to zero.</entry>
152	  </row>
153	</tbody>
154      </tgroup>
155    </table>
156
157    <table frame="none" pgwide="1" id="event-type">
158      <title>Event Types</title>
159      <tgroup cols="3">
160	&cs-def;
161	<tbody valign="top">
162	  <row>
163	    <entry><constant>V4L2_EVENT_ALL</constant></entry>
164	    <entry>0</entry>
165	    <entry>All events. V4L2_EVENT_ALL is valid only for
166	    VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
167	    </entry>
168	  </row>
169	  <row>
170	    <entry><constant>V4L2_EVENT_VSYNC</constant></entry>
171	    <entry>1</entry>
172	    <entry>This event is triggered on the vertical sync.
173	    This event has a &v4l2-event-vsync; associated with it.
174	    </entry>
175	  </row>
176	  <row>
177	    <entry><constant>V4L2_EVENT_EOS</constant></entry>
178	    <entry>2</entry>
179	    <entry>This event is triggered when the end of a stream is reached.
180	    This is typically used with MPEG decoders to report to the application
181	    when the last of the MPEG stream has been decoded.
182	    </entry>
183	  </row>
184	  <row>
185	    <entry><constant>V4L2_EVENT_CTRL</constant></entry>
186	    <entry>3</entry>
187	    <entry><para>This event requires that the <structfield>id</structfield>
188		matches the control ID from which you want to receive events.
189		This event is triggered if the control's value changes, if a
190		button control is pressed or if the control's flags change.
191	    	This event has a &v4l2-event-ctrl; associated with it. This struct
192		contains much of the same information as &v4l2-queryctrl; and
193		&v4l2-control;.</para>
194
195		<para>If the event is generated due to a call to &VIDIOC-S-CTRL; or
196		&VIDIOC-S-EXT-CTRLS;, then the event will <emphasis>not</emphasis> be sent to
197		the file handle that called the ioctl function. This prevents
198		nasty feedback loops. If you <emphasis>do</emphasis> want to get the
199		event, then set the <constant>V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK</constant>
200		flag.
201		</para>
202
203		<para>This event type will ensure that no information is lost when
204		more events are raised than there is room internally. In that
205		case the &v4l2-event-ctrl; of the second-oldest event is kept,
206		but the <structfield>changes</structfield> field of the
207		second-oldest event is ORed with the <structfield>changes</structfield>
208		field of the oldest event.</para>
209	    </entry>
210	  </row>
211	  <row>
212	    <entry><constant>V4L2_EVENT_FRAME_SYNC</constant></entry>
213	    <entry>4</entry>
214	    <entry>
215	      <para>Triggered immediately when the reception of a
216	      frame has begun. This event has a
217	      &v4l2-event-frame-sync; associated with it.</para>
218
219	      <para>If the hardware needs to be stopped in the case of a
220	      buffer underrun it might not be able to generate this event.
221	      In such cases the <structfield>frame_sequence</structfield>
222	      field in &v4l2-event-frame-sync; will not be incremented. This
223	      causes two consecutive frame sequence numbers to have n times
224	      frame interval in between them.</para>
225	    </entry>
226	  </row>
227	  <row>
228	    <entry><constant>V4L2_EVENT_SOURCE_CHANGE</constant></entry>
229	    <entry>5</entry>
230	    <entry>
231	      <para>This event is triggered when a source parameter change is
232	       detected during runtime by the video device. It can be a
233	       runtime resolution change triggered by a video decoder or the
234	       format change happening on an input connector.
235	       This event requires that the <structfield>id</structfield>
236	       matches the input index (when used with a video device node)
237	       or the pad index (when used with a subdevice node) from which
238	       you want to receive events.</para>
239
240              <para>This event has a &v4l2-event-src-change; associated
241	      with it. The <structfield>changes</structfield> bitfield denotes
242	      what has changed for the subscribed pad. If multiple events
243	      occurred before application could dequeue them, then the changes
244	      will have the ORed value of all the events generated.</para>
245	    </entry>
246	  </row>
247	  <row>
248	    <entry><constant>V4L2_EVENT_MOTION_DET</constant></entry>
249	    <entry>6</entry>
250	    <entry>
251	      <para>Triggered whenever the motion detection state for one or more of the regions
252	      changes. This event has a &v4l2-event-motion-det; associated with it.</para>
253	    </entry>
254	  </row>
255	  <row>
256	    <entry><constant>V4L2_EVENT_PRIVATE_START</constant></entry>
257	    <entry>0x08000000</entry>
258	    <entry>Base event number for driver-private events.</entry>
259	  </row>
260	</tbody>
261      </tgroup>
262    </table>
263
264    <table frame="none" pgwide="1" id="v4l2-event-vsync">
265      <title>struct <structname>v4l2_event_vsync</structname></title>
266      <tgroup cols="3">
267	&cs-str;
268	<tbody valign="top">
269	  <row>
270	    <entry>__u8</entry>
271	    <entry><structfield>field</structfield></entry>
272	    <entry>The upcoming field. See &v4l2-field;.</entry>
273	  </row>
274	</tbody>
275      </tgroup>
276    </table>
277
278    <table frame="none" pgwide="1" id="v4l2-event-ctrl">
279      <title>struct <structname>v4l2_event_ctrl</structname></title>
280      <tgroup cols="4">
281	&cs-str;
282	<tbody valign="top">
283	  <row>
284	    <entry>__u32</entry>
285	    <entry><structfield>changes</structfield></entry>
286	    <entry></entry>
287	    <entry>A bitmask that tells what has changed. See <xref linkend="ctrl-changes-flags" />.</entry>
288	  </row>
289	  <row>
290	    <entry>__u32</entry>
291	    <entry><structfield>type</structfield></entry>
292	    <entry></entry>
293	    <entry>The type of the control. See &v4l2-ctrl-type;.</entry>
294	  </row>
295	  <row>
296	    <entry>union (anonymous)</entry>
297	    <entry></entry>
298	    <entry></entry>
299	    <entry></entry>
300	  </row>
301	  <row>
302	    <entry></entry>
303	    <entry>__s32</entry>
304	    <entry><structfield>value</structfield></entry>
305	    <entry>The 32-bit value of the control for 32-bit control types.
306		This is 0 for string controls since the value of a string
307		cannot be passed using &VIDIOC-DQEVENT;.</entry>
308	  </row>
309	  <row>
310	    <entry></entry>
311	    <entry>__s64</entry>
312	    <entry><structfield>value64</structfield></entry>
313	    <entry>The 64-bit value of the control for 64-bit control types.</entry>
314	  </row>
315	  <row>
316	    <entry>__u32</entry>
317	    <entry><structfield>flags</structfield></entry>
318	    <entry></entry>
319	    <entry>The control flags. See <xref linkend="control-flags" />.</entry>
320	  </row>
321	  <row>
322	    <entry>__s32</entry>
323	    <entry><structfield>minimum</structfield></entry>
324	    <entry></entry>
325	    <entry>The minimum value of the control. See &v4l2-queryctrl;.</entry>
326	  </row>
327	  <row>
328	    <entry>__s32</entry>
329	    <entry><structfield>maximum</structfield></entry>
330	    <entry></entry>
331	    <entry>The maximum value of the control. See &v4l2-queryctrl;.</entry>
332	  </row>
333	  <row>
334	    <entry>__s32</entry>
335	    <entry><structfield>step</structfield></entry>
336	    <entry></entry>
337	    <entry>The step value of the control. See &v4l2-queryctrl;.</entry>
338	  </row>
339	  <row>
340	    <entry>__s32</entry>
341	    <entry><structfield>default_value</structfield></entry>
342	    <entry></entry>
343	    <entry>The default value value of the control. See &v4l2-queryctrl;.</entry>
344	  </row>
345	</tbody>
346      </tgroup>
347    </table>
348
349    <table frame="none" pgwide="1" id="v4l2-event-frame-sync">
350      <title>struct <structname>v4l2_event_frame_sync</structname></title>
351      <tgroup cols="3">
352	&cs-str;
353	<tbody valign="top">
354	  <row>
355	    <entry>__u32</entry>
356	    <entry><structfield>frame_sequence</structfield></entry>
357	    <entry>
358	      The sequence number of the frame being received.
359	    </entry>
360	  </row>
361	</tbody>
362      </tgroup>
363    </table>
364
365    <table frame="none" pgwide="1" id="v4l2-event-src-change">
366      <title>struct <structname>v4l2_event_src_change</structname></title>
367      <tgroup cols="3">
368	&cs-str;
369	<tbody valign="top">
370	  <row>
371	    <entry>__u32</entry>
372	    <entry><structfield>changes</structfield></entry>
373	    <entry>
374	      A bitmask that tells what has changed. See <xref linkend="src-changes-flags" />.
375	    </entry>
376	  </row>
377	</tbody>
378      </tgroup>
379    </table>
380
381    <table frame="none" pgwide="1" id="v4l2-event-motion-det">
382      <title>struct <structname>v4l2_event_motion_det</structname></title>
383      <tgroup cols="3">
384	&cs-str;
385	<tbody valign="top">
386	  <row>
387	    <entry>__u32</entry>
388	    <entry><structfield>flags</structfield></entry>
389	    <entry>
390	      Currently only one flag is available: if <constant>V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ</constant>
391	      is set, then the <structfield>frame_sequence</structfield> field is valid,
392	      otherwise that field should be ignored.
393	    </entry>
394	  </row>
395	  <row>
396	    <entry>__u32</entry>
397	    <entry><structfield>frame_sequence</structfield></entry>
398	    <entry>
399	      The sequence number of the frame being received. Only valid if the
400	      <constant>V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ</constant> flag was set.
401	    </entry>
402	  </row>
403	  <row>
404	    <entry>__u32</entry>
405	    <entry><structfield>region_mask</structfield></entry>
406	    <entry>
407	      The bitmask of the regions that reported motion. There is at least one
408	      region. If this field is 0, then no motion was detected at all.
409	      If there is no <constant>V4L2_CID_DETECT_MD_REGION_GRID</constant> control
410	      (see <xref linkend="detect-controls" />) to assign a different region
411	      to each cell in the motion detection grid, then that all cells
412	      are automatically assigned to the default region 0.
413	    </entry>
414	  </row>
415	</tbody>
416      </tgroup>
417    </table>
418
419    <table pgwide="1" frame="none" id="ctrl-changes-flags">
420      <title>Control Changes</title>
421      <tgroup cols="3">
422	&cs-def;
423	<tbody valign="top">
424	  <row>
425	    <entry><constant>V4L2_EVENT_CTRL_CH_VALUE</constant></entry>
426	    <entry>0x0001</entry>
427	    <entry>This control event was triggered because the value of the control
428		changed. Special cases: Volatile controls do no generate this event;
429		If a control has the <constant>V4L2_CTRL_FLAG_EXECUTE_ON_WRITE</constant>
430		flag set, then this event is sent as well, regardless its value.</entry>
431	  </row>
432	  <row>
433	    <entry><constant>V4L2_EVENT_CTRL_CH_FLAGS</constant></entry>
434	    <entry>0x0002</entry>
435	    <entry>This control event was triggered because the control flags
436		changed.</entry>
437	  </row>
438	  <row>
439	    <entry><constant>V4L2_EVENT_CTRL_CH_RANGE</constant></entry>
440	    <entry>0x0004</entry>
441	    <entry>This control event was triggered because the minimum,
442	    maximum, step or the default value of the control changed.</entry>
443	  </row>
444	</tbody>
445      </tgroup>
446    </table>
447
448    <table pgwide="1" frame="none" id="src-changes-flags">
449      <title>Source Changes</title>
450      <tgroup cols="3">
451	&cs-def;
452	<tbody valign="top">
453	  <row>
454	    <entry><constant>V4L2_EVENT_SRC_CH_RESOLUTION</constant></entry>
455	    <entry>0x0001</entry>
456	    <entry>This event gets triggered when a resolution change is
457	    detected at an input. This can come from an input connector or
458	    from a video decoder.
459	    </entry>
460	  </row>
461	</tbody>
462      </tgroup>
463    </table>
464  </refsect1>
465  <refsect1>
466    &return-value;
467  </refsect1>
468</refentry>
469