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.5cm}|p{3.5cm}|p{7.0cm}|p{3.5cm}|
47 .. flat-table:: struct v4l2_event
60 - Type of the event, see :ref:`event-type`.
74 - struct :ref:`v4l2_event_vsync <v4l2-event-vsync>`
78 - Event data for event ``V4L2_EVENT_VSYNC``.
83 - struct :ref:`v4l2_event_ctrl <v4l2-event-ctrl>`
87 - Event data for event ``V4L2_EVENT_CTRL``.
92 - struct :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>`
96 - Event data for event ``V4L2_EVENT_FRAME_SYNC``.
101 - struct :ref:`v4l2_event_motion_det <v4l2-event-motion-det>`
105 - Event data for event V4L2_EVENT_MOTION_DET.
110 - struct :ref:`v4l2_event_src_change <v4l2-event-src-change>`
114 - Event data for event V4L2_EVENT_SOURCE_CHANGE.
123 - Event data. Defined by the event type. The union should be used to
124 define easily accessible type for events.
133 - Number of pending events excluding this one.
142 - Event sequence number. The sequence number is incremented for
143 every subscribed event that takes place. If sequence numbers are
144 not contiguous it means that events have been lost.
153 - Event timestamp. The timestamp has been taken from the
154 ``CLOCK_MONOTONIC`` clock. To access the same clock outside V4L2,
155 use :c:func:`clock_gettime(2)`.
164 - The ID associated with the event source. If the event does not
165 have an associated ID (this depends on the event type), then this
175 - Reserved for future extensions. Drivers must set the array to
182 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
184 .. flat-table:: Event Types
196 - All events. V4L2_EVENT_ALL is valid only for
197 VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
201 - ``V4L2_EVENT_VSYNC``
205 - This event is triggered on the vertical sync. This event has a
206 struct :ref:`v4l2_event_vsync <v4l2-event-vsync>` associated
215 - This event is triggered when the end of a stream is reached. This
216 is typically used with MPEG decoders to report to the application
217 when the last of the MPEG stream has been decoded.
221 - ``V4L2_EVENT_CTRL``
225 - This event requires that the ``id`` matches the control ID from
226 which you want to receive events. This event is triggered if the
227 control's value changes, if a button control is pressed or if the
228 control's flags change. This event has a struct
229 :ref:`v4l2_event_ctrl <v4l2-event-ctrl>` associated with it.
230 This struct contains much of the same information as struct
231 :ref:`v4l2_queryctrl <v4l2-queryctrl>` and struct
232 :ref:`v4l2_control <v4l2-control>`.
234 If the event is generated due to a call to
235 :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` or
236 :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then the
237 event will *not* be sent to the file handle that called the ioctl
238 function. This prevents nasty feedback loops. If you *do* want to
239 get the event, then set the ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``
242 This event type will ensure that no information is lost when more
243 events are raised than there is room internally. In that case the
244 struct :ref:`v4l2_event_ctrl <v4l2-event-ctrl>` of the
245 second-oldest event is kept, but the ``changes`` field of the
246 second-oldest event is ORed with the ``changes`` field of the
251 - ``V4L2_EVENT_FRAME_SYNC``
255 - Triggered immediately when the reception of a frame has begun.
256 This event has a struct
257 :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>`
260 If the hardware needs to be stopped in the case of a buffer
261 underrun it might not be able to generate this event. In such
262 cases the ``frame_sequence`` field in struct
263 :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>` will not
264 be incremented. This causes two consecutive frame sequence numbers
265 to have n times frame interval in between them.
269 - ``V4L2_EVENT_SOURCE_CHANGE``
273 - This event is triggered when a source parameter change is detected
274 during runtime by the video device. It can be a runtime resolution
275 change triggered by a video decoder or the format change happening
276 on an input connector. This event requires that the ``id`` matches
277 the input index (when used with a video device node) or the pad
278 index (when used with a subdevice node) from which you want to
281 This event has a struct
282 :ref:`v4l2_event_src_change <v4l2-event-src-change>`
283 associated with it. The ``changes`` bitfield denotes what has
284 changed for the subscribed pad. If multiple events occurred before
285 application could dequeue them, then the changes will have the
286 ORed value of all the events generated.
290 - ``V4L2_EVENT_MOTION_DET``
294 - Triggered whenever the motion detection state for one or more of
295 the regions changes. This event has a struct
296 :ref:`v4l2_event_motion_det <v4l2-event-motion-det>`
301 - ``V4L2_EVENT_PRIVATE_START``
305 - Base event number for driver-private events.
309 .. _v4l2-event-vsync:
311 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
313 .. flat-table:: struct v4l2_event_vsync
325 - The upcoming field. See enum :ref:`v4l2_field <v4l2-field>`.
331 .. tabularcolumns:: |p{3.5cm}|p{3.5cm}|p{7.0cm}|p{3.5cm}|
333 .. flat-table:: struct v4l2_event_ctrl
346 - A bitmask that tells what has changed. See
347 :ref:`ctrl-changes-flags`.
356 - The type of the control. See enum
357 :ref:`v4l2_ctrl_type <v4l2-ctrl-type>`.
374 - The 32-bit value of the control for 32-bit control types. This is
375 0 for string controls since the value of a string cannot be passed
376 using :ref:`VIDIOC_DQEVENT`.
385 - The 64-bit value of the control for 64-bit control types.
394 - The control flags. See :ref:`control-flags`.
403 - The minimum value of the control. See struct
404 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
413 - The maximum value of the control. See struct
414 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
423 - The step value of the control. See struct
424 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
433 - The default value value of the control. See struct
434 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
438 .. _v4l2-event-frame-sync:
440 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
442 .. flat-table:: struct v4l2_event_frame_sync
454 - The sequence number of the frame being received.
458 .. _v4l2-event-src-change:
460 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
462 .. flat-table:: struct v4l2_event_src_change
474 - A bitmask that tells what has changed. See
475 :ref:`src-changes-flags`.
479 .. _v4l2-event-motion-det:
481 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
483 .. flat-table:: struct v4l2_event_motion_det
495 - Currently only one flag is available: if
496 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` is set, then the
497 ``frame_sequence`` field is valid, otherwise that field should be
506 - The sequence number of the frame being received. Only valid if the
507 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` flag was set.
515 - The bitmask of the regions that reported motion. There is at least
516 one region. If this field is 0, then no motion was detected at
517 all. If there is no ``V4L2_CID_DETECT_MD_REGION_GRID`` control
518 (see :ref:`detect-controls`) to assign a different region to
519 each cell in the motion detection grid, then that all cells are
520 automatically assigned to the default region 0.
524 .. _ctrl-changes-flags:
526 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
528 .. flat-table:: Control Changes
536 - ``V4L2_EVENT_CTRL_CH_VALUE``
540 - This control event was triggered because the value of the control
541 changed. Special cases: Volatile controls do no generate this
542 event; If a control has the ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE``
543 flag set, then this event is sent as well, regardless its value.
547 - ``V4L2_EVENT_CTRL_CH_FLAGS``
551 - This control event was triggered because the control flags
556 - ``V4L2_EVENT_CTRL_CH_RANGE``
560 - This control event was triggered because the minimum, maximum,
561 step or the default value of the control changed.
565 .. _src-changes-flags:
567 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
569 .. flat-table:: Source Changes
577 - ``V4L2_EVENT_SRC_CH_RESOLUTION``
581 - This event gets triggered when a resolution change is detected at
582 an input. This can come from an input connector or from a video
589 On success 0 is returned, on error -1 and the ``errno`` variable is set
590 appropriately. The generic error codes are described at the
591 :ref:`Generic Error Codes <gen-errors>` chapter.