1 .. -*- coding: utf-8; mode: rst -*-
12 VIDIOC_DQEVENT - Dequeue event
18 .. c:function:: int ioctl( int fd, VIDIOC_DQEVENT, struct v4l2_event *argp )
26 File descriptor returned by :ref:`open() <func-open>`.
34 Dequeue an event from a video device. No input is required for this
35 ioctl. All the fields of the struct :c:type:`v4l2_event`
36 structure are filled by the driver. The file handle will also receive
37 exceptions which the application may get by e.g. using the select system
41 .. tabularcolumns:: |p{3.0cm}|p{4.3cm}|p{2.5cm}|p{7.7cm}|
43 .. c:type:: v4l2_event
45 .. cssclass: longtable
47 .. flat-table:: struct v4l2_event
60 - Type of the event, see :ref:`event-type`.
74 - struct :c:type:`v4l2_event_vsync`
78 - Event data for event ``V4L2_EVENT_VSYNC``.
83 - struct :c:type:`v4l2_event_ctrl`
87 - Event data for event ``V4L2_EVENT_CTRL``.
92 - struct :c:type:`v4l2_event_frame_sync`
96 - Event data for event ``V4L2_EVENT_FRAME_SYNC``.
101 - struct :c:type:`v4l2_event_motion_det`
105 - Event data for event V4L2_EVENT_MOTION_DET.
110 - struct :c:type:`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`.
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
180 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
182 .. cssclass:: longtable
186 .. flat-table:: Event Types
198 - All events. V4L2_EVENT_ALL is valid only for
199 VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
203 - ``V4L2_EVENT_VSYNC``
207 - This event is triggered on the vertical sync. This event has a
208 struct :c:type:`v4l2_event_vsync` associated
217 - This event is triggered when the end of a stream is reached. This
218 is typically used with MPEG decoders to report to the application
219 when the last of the MPEG stream has been decoded.
223 - ``V4L2_EVENT_CTRL``
227 - This event requires that the ``id`` matches the control ID from
228 which you want to receive events. This event is triggered if the
229 control's value changes, if a button control is pressed or if the
230 control's flags change. This event has a struct
231 :c:type:`v4l2_event_ctrl` associated with it.
232 This struct contains much of the same information as struct
233 :ref:`v4l2_queryctrl <v4l2-queryctrl>` and struct
234 :c:type:`v4l2_control`.
236 If the event is generated due to a call to
237 :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` or
238 :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then the
239 event will *not* be sent to the file handle that called the ioctl
240 function. This prevents nasty feedback loops. If you *do* want to
241 get the event, then set the ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``
244 This event type will ensure that no information is lost when more
245 events are raised than there is room internally. In that case the
246 struct :c:type:`v4l2_event_ctrl` of the
247 second-oldest event is kept, but the ``changes`` field of the
248 second-oldest event is ORed with the ``changes`` field of the
253 - ``V4L2_EVENT_FRAME_SYNC``
257 - Triggered immediately when the reception of a frame has begun.
258 This event has a struct
259 :c:type:`v4l2_event_frame_sync`
262 If the hardware needs to be stopped in the case of a buffer
263 underrun it might not be able to generate this event. In such
264 cases the ``frame_sequence`` field in struct
265 :c:type:`v4l2_event_frame_sync` will not
266 be incremented. This causes two consecutive frame sequence numbers
267 to have n times frame interval in between them.
271 - ``V4L2_EVENT_SOURCE_CHANGE``
275 - This event is triggered when a source parameter change is detected
276 during runtime by the video device. It can be a runtime resolution
277 change triggered by a video decoder or the format change happening
278 on an input connector. This event requires that the ``id`` matches
279 the input index (when used with a video device node) or the pad
280 index (when used with a subdevice node) from which you want to
283 This event has a struct
284 :c:type:`v4l2_event_src_change`
285 associated with it. The ``changes`` bitfield denotes what has
286 changed for the subscribed pad. If multiple events occurred before
287 application could dequeue them, then the changes will have the
288 ORed value of all the events generated.
292 - ``V4L2_EVENT_MOTION_DET``
296 - Triggered whenever the motion detection state for one or more of
297 the regions changes. This event has a struct
298 :c:type:`v4l2_event_motion_det`
303 - ``V4L2_EVENT_PRIVATE_START``
307 - Base event number for driver-private events.
311 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
313 .. c:type:: v4l2_event_vsync
315 .. flat-table:: struct v4l2_event_vsync
327 - The upcoming field. See enum :c:type:`v4l2_field`.
331 .. tabularcolumns:: |p{3.5cm}|p{3.0cm}|p{1.8cm}|p{8.5cm}|
333 .. c:type:: v4l2_event_ctrl
335 .. flat-table:: struct v4l2_event_ctrl
348 - A bitmask that tells what has changed. See
349 :ref:`ctrl-changes-flags`.
358 - The type of the control. See enum
359 :c:type:`v4l2_ctrl_type`.
376 - The 32-bit value of the control for 32-bit control types. This is
377 0 for string controls since the value of a string cannot be passed
378 using :ref:`VIDIOC_DQEVENT`.
387 - The 64-bit value of the control for 64-bit control types.
396 - The control flags. See :ref:`control-flags`.
405 - The minimum value of the control. See struct
406 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
415 - The maximum value of the control. See struct
416 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
425 - The step value of the control. See struct
426 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
435 - The default value value of the control. See struct
436 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
440 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
442 .. c:type:: v4l2_event_frame_sync
444 .. flat-table:: struct v4l2_event_frame_sync
456 - The sequence number of the frame being received.
460 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
462 .. c:type:: v4l2_event_src_change
464 .. flat-table:: struct v4l2_event_src_change
476 - A bitmask that tells what has changed. See
477 :ref:`src-changes-flags`.
481 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
483 .. c:type:: v4l2_event_motion_det
485 .. flat-table:: struct v4l2_event_motion_det
497 - Currently only one flag is available: if
498 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` is set, then the
499 ``frame_sequence`` field is valid, otherwise that field should be
508 - The sequence number of the frame being received. Only valid if the
509 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` flag was set.
517 - The bitmask of the regions that reported motion. There is at least
518 one region. If this field is 0, then no motion was detected at
519 all. If there is no ``V4L2_CID_DETECT_MD_REGION_GRID`` control
520 (see :ref:`detect-controls`) to assign a different region to
521 each cell in the motion detection grid, then that all cells are
522 automatically assigned to the default region 0.
526 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
528 .. _ctrl-changes-flags:
530 .. flat-table:: Control Changes
538 - ``V4L2_EVENT_CTRL_CH_VALUE``
542 - This control event was triggered because the value of the control
543 changed. Special cases: Volatile controls do no generate this
544 event; If a control has the ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE``
545 flag set, then this event is sent as well, regardless its value.
549 - ``V4L2_EVENT_CTRL_CH_FLAGS``
553 - This control event was triggered because the control flags
558 - ``V4L2_EVENT_CTRL_CH_RANGE``
562 - This control event was triggered because the minimum, maximum,
563 step or the default value of the control changed.
567 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
569 .. _src-changes-flags:
571 .. flat-table:: Source Changes
579 - ``V4L2_EVENT_SRC_CH_RESOLUTION``
583 - This event gets triggered when a resolution change is detected at
584 an input. This can come from an input connector or from a video
591 On success 0 is returned, on error -1 and the ``errno`` variable is set
592 appropriately. The generic error codes are described at the
593 :ref:`Generic Error Codes <gen-errors>` chapter.