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 .. flat-table:: struct v4l2_event
58 - Type of the event, see :ref:`event-type`.
72 - struct :ref:`v4l2_event_vsync <v4l2-event-vsync>`
76 - Event data for event ``V4L2_EVENT_VSYNC``.
81 - struct :ref:`v4l2_event_ctrl <v4l2-event-ctrl>`
85 - Event data for event ``V4L2_EVENT_CTRL``.
90 - struct :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>`
94 - Event data for event ``V4L2_EVENT_FRAME_SYNC``.
99 - struct :ref:`v4l2_event_motion_det <v4l2-event-motion-det>`
103 - Event data for event V4L2_EVENT_MOTION_DET.
108 - struct :ref:`v4l2_event_src_change <v4l2-event-src-change>`
112 - Event data for event V4L2_EVENT_SOURCE_CHANGE.
121 - Event data. Defined by the event type. The union should be used to
122 define easily accessible type for events.
131 - Number of pending events excluding this one.
140 - Event sequence number. The sequence number is incremented for
141 every subscribed event that takes place. If sequence numbers are
142 not contiguous it means that events have been lost.
151 - Event timestamp. The timestamp has been taken from the
152 ``CLOCK_MONOTONIC`` clock. To access the same clock outside V4L2,
153 use :c:func:`clock_gettime(2)`.
162 - The ID associated with the event source. If the event does not
163 have an associated ID (this depends on the event type), then this
173 - Reserved for future extensions. Drivers must set the array to
180 .. flat-table:: Event Types
192 - All events. V4L2_EVENT_ALL is valid only for
193 VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
197 - ``V4L2_EVENT_VSYNC``
201 - This event is triggered on the vertical sync. This event has a
202 struct :ref:`v4l2_event_vsync <v4l2-event-vsync>` associated
211 - This event is triggered when the end of a stream is reached. This
212 is typically used with MPEG decoders to report to the application
213 when the last of the MPEG stream has been decoded.
217 - ``V4L2_EVENT_CTRL``
221 - This event requires that the ``id`` matches the control ID from
222 which you want to receive events. This event is triggered if the
223 control's value changes, if a button control is pressed or if the
224 control's flags change. This event has a struct
225 :ref:`v4l2_event_ctrl <v4l2-event-ctrl>` associated with it.
226 This struct contains much of the same information as struct
227 :ref:`v4l2_queryctrl <v4l2-queryctrl>` and struct
228 :ref:`v4l2_control <v4l2-control>`.
230 If the event is generated due to a call to
231 :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` or
232 :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then the
233 event will *not* be sent to the file handle that called the ioctl
234 function. This prevents nasty feedback loops. If you *do* want to
235 get the event, then set the ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``
238 This event type will ensure that no information is lost when more
239 events are raised than there is room internally. In that case the
240 struct :ref:`v4l2_event_ctrl <v4l2-event-ctrl>` of the
241 second-oldest event is kept, but the ``changes`` field of the
242 second-oldest event is ORed with the ``changes`` field of the
247 - ``V4L2_EVENT_FRAME_SYNC``
251 - Triggered immediately when the reception of a frame has begun.
252 This event has a struct
253 :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>`
256 If the hardware needs to be stopped in the case of a buffer
257 underrun it might not be able to generate this event. In such
258 cases the ``frame_sequence`` field in struct
259 :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>` will not
260 be incremented. This causes two consecutive frame sequence numbers
261 to have n times frame interval in between them.
265 - ``V4L2_EVENT_SOURCE_CHANGE``
269 - This event is triggered when a source parameter change is detected
270 during runtime by the video device. It can be a runtime resolution
271 change triggered by a video decoder or the format change happening
272 on an input connector. This event requires that the ``id`` matches
273 the input index (when used with a video device node) or the pad
274 index (when used with a subdevice node) from which you want to
277 This event has a struct
278 :ref:`v4l2_event_src_change <v4l2-event-src-change>`
279 associated with it. The ``changes`` bitfield denotes what has
280 changed for the subscribed pad. If multiple events occurred before
281 application could dequeue them, then the changes will have the
282 ORed value of all the events generated.
286 - ``V4L2_EVENT_MOTION_DET``
290 - Triggered whenever the motion detection state for one or more of
291 the regions changes. This event has a struct
292 :ref:`v4l2_event_motion_det <v4l2-event-motion-det>`
297 - ``V4L2_EVENT_PRIVATE_START``
301 - Base event number for driver-private events.
305 .. _v4l2-event-vsync:
307 .. flat-table:: struct v4l2_event_vsync
319 - The upcoming field. See enum :ref:`v4l2_field <v4l2-field>`.
325 .. flat-table:: struct v4l2_event_ctrl
338 - A bitmask that tells what has changed. See
339 :ref:`ctrl-changes-flags`.
348 - The type of the control. See enum
349 :ref:`v4l2_ctrl_type <v4l2-ctrl-type>`.
366 - The 32-bit value of the control for 32-bit control types. This is
367 0 for string controls since the value of a string cannot be passed
368 using :ref:`VIDIOC_DQEVENT`.
377 - The 64-bit value of the control for 64-bit control types.
386 - The control flags. See :ref:`control-flags`.
395 - The minimum value of the control. See struct
396 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
405 - The maximum value of the control. See struct
406 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
415 - The step value of the control. See struct
416 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
425 - The default value value of the control. See struct
426 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
430 .. _v4l2-event-frame-sync:
432 .. flat-table:: struct v4l2_event_frame_sync
444 - The sequence number of the frame being received.
448 .. _v4l2-event-src-change:
450 .. flat-table:: struct v4l2_event_src_change
462 - A bitmask that tells what has changed. See
463 :ref:`src-changes-flags`.
467 .. _v4l2-event-motion-det:
469 .. flat-table:: struct v4l2_event_motion_det
481 - Currently only one flag is available: if
482 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` is set, then the
483 ``frame_sequence`` field is valid, otherwise that field should be
492 - The sequence number of the frame being received. Only valid if the
493 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` flag was set.
501 - The bitmask of the regions that reported motion. There is at least
502 one region. If this field is 0, then no motion was detected at
503 all. If there is no ``V4L2_CID_DETECT_MD_REGION_GRID`` control
504 (see :ref:`detect-controls`) to assign a different region to
505 each cell in the motion detection grid, then that all cells are
506 automatically assigned to the default region 0.
510 .. _ctrl-changes-flags:
512 .. flat-table:: Control Changes
520 - ``V4L2_EVENT_CTRL_CH_VALUE``
524 - This control event was triggered because the value of the control
525 changed. Special cases: Volatile controls do no generate this
526 event; If a control has the ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE``
527 flag set, then this event is sent as well, regardless its value.
531 - ``V4L2_EVENT_CTRL_CH_FLAGS``
535 - This control event was triggered because the control flags
540 - ``V4L2_EVENT_CTRL_CH_RANGE``
544 - This control event was triggered because the minimum, maximum,
545 step or the default value of the control changed.
549 .. _src-changes-flags:
551 .. flat-table:: Source Changes
559 - ``V4L2_EVENT_SRC_CH_RESOLUTION``
563 - This event gets triggered when a resolution change is detected at
564 an input. This can come from an input connector or from a video
571 On success 0 is returned, on error -1 and the ``errno`` variable is set
572 appropriately. The generic error codes are described at the
573 :ref:`Generic Error Codes <gen-errors>` chapter.