blob: 850cb5ed00153de79e8d8a4966f232579e556729 [file] [log] [blame]
Markus Heiser5377d912016-06-30 15:18:56 +02001.. -*- coding: utf-8; mode: rst -*-
2
Mauro Carvalho Chehabaf4a4d02016-07-01 13:42:29 -03003.. _VIDIOC_DQEVENT:
Markus Heiser5377d912016-06-30 15:18:56 +02004
5********************
6ioctl VIDIOC_DQEVENT
7********************
8
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -03009NAME
10====
Markus Heiser5377d912016-06-30 15:18:56 +020011
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030012VIDIOC_DQEVENT - Dequeue event
Markus Heiser5377d912016-06-30 15:18:56 +020013
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030014SYNOPSIS
Markus Heiser5377d912016-06-30 15:18:56 +020015========
16
Mauro Carvalho Chehabb7e67f62016-07-02 09:49:16 -030017.. cpp:function:: int ioctl( int fd, int request, struct v4l2_event *argp )
Markus Heiser5377d912016-06-30 15:18:56 +020018
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030019
20ARGUMENTS
Markus Heiser5377d912016-06-30 15:18:56 +020021=========
22
23``fd``
24 File descriptor returned by :ref:`open() <func-open>`.
25
26``request``
27 VIDIOC_DQEVENT
28
29``argp``
30
31
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030032DESCRIPTION
Markus Heiser5377d912016-06-30 15:18:56 +020033===========
34
35Dequeue an event from a video device. No input is required for this
36ioctl. All the fields of the struct :ref:`v4l2_event <v4l2-event>`
37structure are filled by the driver. The file handle will also receive
38exceptions which the application may get by e.g. using the select system
39call.
40
41
42.. _v4l2-event:
43
44.. flat-table:: struct v4l2_event
45 :header-rows: 0
46 :stub-columns: 0
47 :widths: 1 1 2 1
48
49
50 - .. row 1
51
52 - __u32
53
54 - ``type``
55
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030056 -
Markus Heiser5377d912016-06-30 15:18:56 +020057 - Type of the event, see :ref:`event-type`.
58
59 - .. row 2
60
61 - union
62
63 - ``u``
64
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030065 -
66 -
Markus Heiser5377d912016-06-30 15:18:56 +020067
68 - .. row 3
69
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030070 -
Markus Heiser5377d912016-06-30 15:18:56 +020071 - struct :ref:`v4l2_event_vsync <v4l2-event-vsync>`
72
73 - ``vsync``
74
75 - Event data for event ``V4L2_EVENT_VSYNC``.
76
77 - .. row 4
78
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030079 -
Markus Heiser5377d912016-06-30 15:18:56 +020080 - struct :ref:`v4l2_event_ctrl <v4l2-event-ctrl>`
81
82 - ``ctrl``
83
84 - Event data for event ``V4L2_EVENT_CTRL``.
85
86 - .. row 5
87
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030088 -
Markus Heiser5377d912016-06-30 15:18:56 +020089 - struct :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>`
90
91 - ``frame_sync``
92
93 - Event data for event ``V4L2_EVENT_FRAME_SYNC``.
94
95 - .. row 6
96
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030097 -
Markus Heiser5377d912016-06-30 15:18:56 +020098 - struct :ref:`v4l2_event_motion_det <v4l2-event-motion-det>`
99
100 - ``motion_det``
101
102 - Event data for event V4L2_EVENT_MOTION_DET.
103
104 - .. row 7
105
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300106 -
Markus Heiser5377d912016-06-30 15:18:56 +0200107 - struct :ref:`v4l2_event_src_change <v4l2-event-src-change>`
108
109 - ``src_change``
110
111 - Event data for event V4L2_EVENT_SOURCE_CHANGE.
112
113 - .. row 8
114
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300115 -
Markus Heiser5377d912016-06-30 15:18:56 +0200116 - __u8
117
118 - ``data``\ [64]
119
120 - Event data. Defined by the event type. The union should be used to
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300121 define easily accessible type for events.
Markus Heiser5377d912016-06-30 15:18:56 +0200122
123 - .. row 9
124
125 - __u32
126
127 - ``pending``
128
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300129 -
Markus Heiser5377d912016-06-30 15:18:56 +0200130 - Number of pending events excluding this one.
131
132 - .. row 10
133
134 - __u32
135
136 - ``sequence``
137
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300138 -
Markus Heiser5377d912016-06-30 15:18:56 +0200139 - Event sequence number. The sequence number is incremented for
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300140 every subscribed event that takes place. If sequence numbers are
141 not contiguous it means that events have been lost.
Markus Heiser5377d912016-06-30 15:18:56 +0200142
143 - .. row 11
144
145 - struct timespec
146
147 - ``timestamp``
148
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300149 -
Markus Heiser5377d912016-06-30 15:18:56 +0200150 - Event timestamp. The timestamp has been taken from the
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300151 ``CLOCK_MONOTONIC`` clock. To access the same clock outside V4L2,
152 use :c:func:`clock_gettime(2)`.
Markus Heiser5377d912016-06-30 15:18:56 +0200153
154 - .. row 12
155
156 - u32
157
158 - ``id``
159
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300160 -
Markus Heiser5377d912016-06-30 15:18:56 +0200161 - The ID associated with the event source. If the event does not
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300162 have an associated ID (this depends on the event type), then this
163 is 0.
Markus Heiser5377d912016-06-30 15:18:56 +0200164
165 - .. row 13
166
167 - __u32
168
169 - ``reserved``\ [8]
170
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300171 -
Markus Heiser5377d912016-06-30 15:18:56 +0200172 - Reserved for future extensions. Drivers must set the array to
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300173 zero.
Markus Heiser5377d912016-06-30 15:18:56 +0200174
175
176
177.. _event-type:
178
179.. flat-table:: Event Types
180 :header-rows: 0
181 :stub-columns: 0
182 :widths: 3 1 4
183
184
185 - .. row 1
186
187 - ``V4L2_EVENT_ALL``
188
189 - 0
190
191 - All events. V4L2_EVENT_ALL is valid only for
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300192 VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
Markus Heiser5377d912016-06-30 15:18:56 +0200193
194 - .. row 2
195
196 - ``V4L2_EVENT_VSYNC``
197
198 - 1
199
200 - This event is triggered on the vertical sync. This event has a
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300201 struct :ref:`v4l2_event_vsync <v4l2-event-vsync>` associated
202 with it.
Markus Heiser5377d912016-06-30 15:18:56 +0200203
204 - .. row 3
205
206 - ``V4L2_EVENT_EOS``
207
208 - 2
209
210 - This event is triggered when the end of a stream is reached. This
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300211 is typically used with MPEG decoders to report to the application
212 when the last of the MPEG stream has been decoded.
Markus Heiser5377d912016-06-30 15:18:56 +0200213
214 - .. row 4
215
216 - ``V4L2_EVENT_CTRL``
217
218 - 3
219
220 - This event requires that the ``id`` matches the control ID from
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300221 which you want to receive events. This event is triggered if the
222 control's value changes, if a button control is pressed or if the
223 control's flags change. This event has a struct
224 :ref:`v4l2_event_ctrl <v4l2-event-ctrl>` associated with it.
225 This struct contains much of the same information as struct
226 :ref:`v4l2_queryctrl <v4l2-queryctrl>` and struct
227 :ref:`v4l2_control <v4l2-control>`.
Markus Heiser5377d912016-06-30 15:18:56 +0200228
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300229 If the event is generated due to a call to
230 :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` or
231 :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then the
232 event will *not* be sent to the file handle that called the ioctl
233 function. This prevents nasty feedback loops. If you *do* want to
234 get the event, then set the ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``
235 flag.
Markus Heiser5377d912016-06-30 15:18:56 +0200236
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300237 This event type will ensure that no information is lost when more
238 events are raised than there is room internally. In that case the
239 struct :ref:`v4l2_event_ctrl <v4l2-event-ctrl>` of the
240 second-oldest event is kept, but the ``changes`` field of the
241 second-oldest event is ORed with the ``changes`` field of the
242 oldest event.
Markus Heiser5377d912016-06-30 15:18:56 +0200243
244 - .. row 5
245
246 - ``V4L2_EVENT_FRAME_SYNC``
247
248 - 4
249
250 - Triggered immediately when the reception of a frame has begun.
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300251 This event has a struct
252 :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>`
253 associated with it.
Markus Heiser5377d912016-06-30 15:18:56 +0200254
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300255 If the hardware needs to be stopped in the case of a buffer
256 underrun it might not be able to generate this event. In such
257 cases the ``frame_sequence`` field in struct
258 :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>` will not
259 be incremented. This causes two consecutive frame sequence numbers
260 to have n times frame interval in between them.
Markus Heiser5377d912016-06-30 15:18:56 +0200261
262 - .. row 6
263
264 - ``V4L2_EVENT_SOURCE_CHANGE``
265
266 - 5
267
268 - This event is triggered when a source parameter change is detected
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300269 during runtime by the video device. It can be a runtime resolution
270 change triggered by a video decoder or the format change happening
271 on an input connector. This event requires that the ``id`` matches
272 the input index (when used with a video device node) or the pad
273 index (when used with a subdevice node) from which you want to
274 receive events.
Markus Heiser5377d912016-06-30 15:18:56 +0200275
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300276 This event has a struct
277 :ref:`v4l2_event_src_change <v4l2-event-src-change>`
278 associated with it. The ``changes`` bitfield denotes what has
279 changed for the subscribed pad. If multiple events occurred before
280 application could dequeue them, then the changes will have the
281 ORed value of all the events generated.
Markus Heiser5377d912016-06-30 15:18:56 +0200282
283 - .. row 7
284
285 - ``V4L2_EVENT_MOTION_DET``
286
287 - 6
288
289 - Triggered whenever the motion detection state for one or more of
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300290 the regions changes. This event has a struct
291 :ref:`v4l2_event_motion_det <v4l2-event-motion-det>`
292 associated with it.
Markus Heiser5377d912016-06-30 15:18:56 +0200293
294 - .. row 8
295
296 - ``V4L2_EVENT_PRIVATE_START``
297
298 - 0x08000000
299
300 - Base event number for driver-private events.
301
302
303
304.. _v4l2-event-vsync:
305
306.. flat-table:: struct v4l2_event_vsync
307 :header-rows: 0
308 :stub-columns: 0
309 :widths: 1 1 2
310
311
312 - .. row 1
313
314 - __u8
315
316 - ``field``
317
318 - The upcoming field. See enum :ref:`v4l2_field <v4l2-field>`.
319
320
321
322.. _v4l2-event-ctrl:
323
324.. flat-table:: struct v4l2_event_ctrl
325 :header-rows: 0
326 :stub-columns: 0
327 :widths: 1 1 2 1
328
329
330 - .. row 1
331
332 - __u32
333
334 - ``changes``
335
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300336 -
Markus Heiser5377d912016-06-30 15:18:56 +0200337 - A bitmask that tells what has changed. See
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300338 :ref:`ctrl-changes-flags`.
Markus Heiser5377d912016-06-30 15:18:56 +0200339
340 - .. row 2
341
342 - __u32
343
344 - ``type``
345
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300346 -
Markus Heiser5377d912016-06-30 15:18:56 +0200347 - The type of the control. See enum
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300348 :ref:`v4l2_ctrl_type <v4l2-ctrl-type>`.
Markus Heiser5377d912016-06-30 15:18:56 +0200349
350 - .. row 3
351
352 - union (anonymous)
353
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300354 -
355 -
356 -
Markus Heiser5377d912016-06-30 15:18:56 +0200357
358 - .. row 4
359
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300360 -
Markus Heiser5377d912016-06-30 15:18:56 +0200361 - __s32
362
363 - ``value``
364
365 - The 32-bit value of the control for 32-bit control types. This is
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300366 0 for string controls since the value of a string cannot be passed
367 using :ref:`VIDIOC_DQEVENT`.
Markus Heiser5377d912016-06-30 15:18:56 +0200368
369 - .. row 5
370
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300371 -
Markus Heiser5377d912016-06-30 15:18:56 +0200372 - __s64
373
374 - ``value64``
375
376 - The 64-bit value of the control for 64-bit control types.
377
378 - .. row 6
379
380 - __u32
381
382 - ``flags``
383
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300384 -
Markus Heiser5377d912016-06-30 15:18:56 +0200385 - The control flags. See :ref:`control-flags`.
386
387 - .. row 7
388
389 - __s32
390
391 - ``minimum``
392
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300393 -
Markus Heiser5377d912016-06-30 15:18:56 +0200394 - The minimum value of the control. See struct
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300395 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
Markus Heiser5377d912016-06-30 15:18:56 +0200396
397 - .. row 8
398
399 - __s32
400
401 - ``maximum``
402
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300403 -
Markus Heiser5377d912016-06-30 15:18:56 +0200404 - The maximum value of the control. See struct
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300405 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
Markus Heiser5377d912016-06-30 15:18:56 +0200406
407 - .. row 9
408
409 - __s32
410
411 - ``step``
412
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300413 -
Markus Heiser5377d912016-06-30 15:18:56 +0200414 - The step value of the control. See struct
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300415 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
Markus Heiser5377d912016-06-30 15:18:56 +0200416
417 - .. row 10
418
419 - __s32
420
421 - ``default_value``
422
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300423 -
Markus Heiser5377d912016-06-30 15:18:56 +0200424 - The default value value of the control. See struct
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300425 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
Markus Heiser5377d912016-06-30 15:18:56 +0200426
427
428
429.. _v4l2-event-frame-sync:
430
431.. flat-table:: struct v4l2_event_frame_sync
432 :header-rows: 0
433 :stub-columns: 0
434 :widths: 1 1 2
435
436
437 - .. row 1
438
439 - __u32
440
441 - ``frame_sequence``
442
443 - The sequence number of the frame being received.
444
445
446
447.. _v4l2-event-src-change:
448
449.. flat-table:: struct v4l2_event_src_change
450 :header-rows: 0
451 :stub-columns: 0
452 :widths: 1 1 2
453
454
455 - .. row 1
456
457 - __u32
458
459 - ``changes``
460
461 - A bitmask that tells what has changed. See
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300462 :ref:`src-changes-flags`.
Markus Heiser5377d912016-06-30 15:18:56 +0200463
464
465
466.. _v4l2-event-motion-det:
467
468.. flat-table:: struct v4l2_event_motion_det
469 :header-rows: 0
470 :stub-columns: 0
471 :widths: 1 1 2
472
473
474 - .. row 1
475
476 - __u32
477
478 - ``flags``
479
480 - Currently only one flag is available: if
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300481 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` is set, then the
482 ``frame_sequence`` field is valid, otherwise that field should be
483 ignored.
Markus Heiser5377d912016-06-30 15:18:56 +0200484
485 - .. row 2
486
487 - __u32
488
489 - ``frame_sequence``
490
491 - The sequence number of the frame being received. Only valid if the
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300492 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` flag was set.
Markus Heiser5377d912016-06-30 15:18:56 +0200493
494 - .. row 3
495
496 - __u32
497
498 - ``region_mask``
499
500 - The bitmask of the regions that reported motion. There is at least
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300501 one region. If this field is 0, then no motion was detected at
502 all. If there is no ``V4L2_CID_DETECT_MD_REGION_GRID`` control
503 (see :ref:`detect-controls`) to assign a different region to
504 each cell in the motion detection grid, then that all cells are
505 automatically assigned to the default region 0.
Markus Heiser5377d912016-06-30 15:18:56 +0200506
507
508
509.. _ctrl-changes-flags:
510
511.. flat-table:: Control Changes
512 :header-rows: 0
513 :stub-columns: 0
514 :widths: 3 1 4
515
516
517 - .. row 1
518
519 - ``V4L2_EVENT_CTRL_CH_VALUE``
520
521 - 0x0001
522
523 - This control event was triggered because the value of the control
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300524 changed. Special cases: Volatile controls do no generate this
525 event; If a control has the ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE``
526 flag set, then this event is sent as well, regardless its value.
Markus Heiser5377d912016-06-30 15:18:56 +0200527
528 - .. row 2
529
530 - ``V4L2_EVENT_CTRL_CH_FLAGS``
531
532 - 0x0002
533
534 - This control event was triggered because the control flags
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300535 changed.
Markus Heiser5377d912016-06-30 15:18:56 +0200536
537 - .. row 3
538
539 - ``V4L2_EVENT_CTRL_CH_RANGE``
540
541 - 0x0004
542
543 - This control event was triggered because the minimum, maximum,
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300544 step or the default value of the control changed.
Markus Heiser5377d912016-06-30 15:18:56 +0200545
546
547
548.. _src-changes-flags:
549
550.. flat-table:: Source Changes
551 :header-rows: 0
552 :stub-columns: 0
553 :widths: 3 1 4
554
555
556 - .. row 1
557
558 - ``V4L2_EVENT_SRC_CH_RESOLUTION``
559
560 - 0x0001
561
562 - This event gets triggered when a resolution change is detected at
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300563 an input. This can come from an input connector or from a video
564 decoder.
Markus Heiser5377d912016-06-30 15:18:56 +0200565
566
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -0300567RETURN VALUE
Markus Heiser5377d912016-06-30 15:18:56 +0200568============
569
570On success 0 is returned, on error -1 and the ``errno`` variable is set
571appropriately. The generic error codes are described at the
572:ref:`Generic Error Codes <gen-errors>` chapter.