1 .. -*- coding: utf-8; mode: rst -*-
12 VIDIOC_DQEVENT - Dequeue event
18 .. cpp:function:: int ioctl( int fd, int request, struct v4l2_event *argp )
25 File descriptor returned by :ref:`open() <func-open>`.
36 Dequeue an event from a video device. No input is required for this
37 ioctl. All the fields of the struct :ref:`v4l2_event <v4l2-event>`
38 structure are filled by the driver. The file handle will also receive
39 exceptions which the application may get by e.g. using the select system
45 .. tabularcolumns:: |p{3.0cm}|p{4.3cm}|p{2.5cm}|p{7.7cm}|
47 .. cssclass: longtable
49 .. flat-table:: struct v4l2_event
62 - Type of the event, see :ref:`event-type`.
76 - struct :ref:`v4l2_event_vsync <v4l2-event-vsync>`
80 - Event data for event ``V4L2_EVENT_VSYNC``.
85 - struct :ref:`v4l2_event_ctrl <v4l2-event-ctrl>`
89 - Event data for event ``V4L2_EVENT_CTRL``.
94 - struct :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>`
98 - Event data for event ``V4L2_EVENT_FRAME_SYNC``.
103 - struct :ref:`v4l2_event_motion_det <v4l2-event-motion-det>`
107 - Event data for event V4L2_EVENT_MOTION_DET.
112 - struct :ref:`v4l2_event_src_change <v4l2-event-src-change>`
116 - Event data for event V4L2_EVENT_SOURCE_CHANGE.
125 - Event data. Defined by the event type. The union should be used to
126 define easily accessible type for events.
135 - Number of pending events excluding this one.
144 - Event sequence number. The sequence number is incremented for
145 every subscribed event that takes place. If sequence numbers are
146 not contiguous it means that events have been lost.
155 - Event timestamp. The timestamp has been taken from the
156 ``CLOCK_MONOTONIC`` clock. To access the same clock outside V4L2,
157 use :c:func:`clock_gettime(2)`.
166 - The ID associated with the event source. If the event does not
167 have an associated ID (this depends on the event type), then this
177 - Reserved for future extensions. Drivers must set the array to
184 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
186 .. cssclass:: longtable
188 .. flat-table:: Event Types
200 - All events. V4L2_EVENT_ALL is valid only for
201 VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
205 - ``V4L2_EVENT_VSYNC``
209 - This event is triggered on the vertical sync. This event has a
210 struct :ref:`v4l2_event_vsync <v4l2-event-vsync>` associated
219 - This event is triggered when the end of a stream is reached. This
220 is typically used with MPEG decoders to report to the application
221 when the last of the MPEG stream has been decoded.
225 - ``V4L2_EVENT_CTRL``
229 - This event requires that the ``id`` matches the control ID from
230 which you want to receive events. This event is triggered if the
231 control's value changes, if a button control is pressed or if the
232 control's flags change. This event has a struct
233 :ref:`v4l2_event_ctrl <v4l2-event-ctrl>` associated with it.
234 This struct contains much of the same information as struct
235 :ref:`v4l2_queryctrl <v4l2-queryctrl>` and struct
236 :ref:`v4l2_control <v4l2-control>`.
238 If the event is generated due to a call to
239 :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` or
240 :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then the
241 event will *not* be sent to the file handle that called the ioctl
242 function. This prevents nasty feedback loops. If you *do* want to
243 get the event, then set the ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``
246 This event type will ensure that no information is lost when more
247 events are raised than there is room internally. In that case the
248 struct :ref:`v4l2_event_ctrl <v4l2-event-ctrl>` of the
249 second-oldest event is kept, but the ``changes`` field of the
250 second-oldest event is ORed with the ``changes`` field of the
255 - ``V4L2_EVENT_FRAME_SYNC``
259 - Triggered immediately when the reception of a frame has begun.
260 This event has a struct
261 :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>`
264 If the hardware needs to be stopped in the case of a buffer
265 underrun it might not be able to generate this event. In such
266 cases the ``frame_sequence`` field in struct
267 :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>` will not
268 be incremented. This causes two consecutive frame sequence numbers
269 to have n times frame interval in between them.
273 - ``V4L2_EVENT_SOURCE_CHANGE``
277 - This event is triggered when a source parameter change is detected
278 during runtime by the video device. It can be a runtime resolution
279 change triggered by a video decoder or the format change happening
280 on an input connector. This event requires that the ``id`` matches
281 the input index (when used with a video device node) or the pad
282 index (when used with a subdevice node) from which you want to
285 This event has a struct
286 :ref:`v4l2_event_src_change <v4l2-event-src-change>`
287 associated with it. The ``changes`` bitfield denotes what has
288 changed for the subscribed pad. If multiple events occurred before
289 application could dequeue them, then the changes will have the
290 ORed value of all the events generated.
294 - ``V4L2_EVENT_MOTION_DET``
298 - Triggered whenever the motion detection state for one or more of
299 the regions changes. This event has a struct
300 :ref:`v4l2_event_motion_det <v4l2-event-motion-det>`
305 - ``V4L2_EVENT_PRIVATE_START``
309 - Base event number for driver-private events.
313 .. _v4l2-event-vsync:
315 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
317 .. flat-table:: struct v4l2_event_vsync
329 - The upcoming field. See enum :ref:`v4l2_field <v4l2-field>`.
335 .. tabularcolumns:: |p{3.5cm}|p{3.0cm}|p{1.8cm}|p{8.5cm}|
337 .. flat-table:: struct v4l2_event_ctrl
350 - A bitmask that tells what has changed. See
351 :ref:`ctrl-changes-flags`.
360 - The type of the control. See enum
361 :ref:`v4l2_ctrl_type <v4l2-ctrl-type>`.
378 - The 32-bit value of the control for 32-bit control types. This is
379 0 for string controls since the value of a string cannot be passed
380 using :ref:`VIDIOC_DQEVENT`.
389 - The 64-bit value of the control for 64-bit control types.
398 - The control flags. See :ref:`control-flags`.
407 - The minimum value of the control. See struct
408 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
417 - The maximum value of the control. See struct
418 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
427 - The step value of the control. See struct
428 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
437 - The default value value of the control. See struct
438 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
442 .. _v4l2-event-frame-sync:
444 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
446 .. flat-table:: struct v4l2_event_frame_sync
458 - The sequence number of the frame being received.
462 .. _v4l2-event-src-change:
464 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
466 .. flat-table:: struct v4l2_event_src_change
478 - A bitmask that tells what has changed. See
479 :ref:`src-changes-flags`.
483 .. _v4l2-event-motion-det:
485 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
487 .. flat-table:: struct v4l2_event_motion_det
499 - Currently only one flag is available: if
500 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` is set, then the
501 ``frame_sequence`` field is valid, otherwise that field should be
510 - The sequence number of the frame being received. Only valid if the
511 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` flag was set.
519 - The bitmask of the regions that reported motion. There is at least
520 one region. If this field is 0, then no motion was detected at
521 all. If there is no ``V4L2_CID_DETECT_MD_REGION_GRID`` control
522 (see :ref:`detect-controls`) to assign a different region to
523 each cell in the motion detection grid, then that all cells are
524 automatically assigned to the default region 0.
528 .. _ctrl-changes-flags:
530 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
532 .. flat-table:: Control Changes
540 - ``V4L2_EVENT_CTRL_CH_VALUE``
544 - This control event was triggered because the value of the control
545 changed. Special cases: Volatile controls do no generate this
546 event; If a control has the ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE``
547 flag set, then this event is sent as well, regardless its value.
551 - ``V4L2_EVENT_CTRL_CH_FLAGS``
555 - This control event was triggered because the control flags
560 - ``V4L2_EVENT_CTRL_CH_RANGE``
564 - This control event was triggered because the minimum, maximum,
565 step or the default value of the control changed.
569 .. _src-changes-flags:
571 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
573 .. flat-table:: Source Changes
581 - ``V4L2_EVENT_SRC_CH_RESOLUTION``
585 - This event gets triggered when a resolution change is detected at
586 an input. This can come from an input connector or from a video
593 On success 0 is returned, on error -1 and the ``errno`` variable is set
594 appropriately. The generic error codes are described at the
595 :ref:`Generic Error Codes <gen-errors>` chapter.