1 .. -*- coding: utf-8; mode: rst -*-
9 *man VIDIOC_DQEVENT(2)*
17 .. cpp:function:: int ioctl( int fd, int request, struct v4l2_event *argp )
23 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 :ref:`v4l2_event <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
43 .. flat-table:: struct v4l2_event
56 - Type of the event, see :ref:`event-type`.
70 - struct :ref:`v4l2_event_vsync <v4l2-event-vsync>`
74 - Event data for event ``V4L2_EVENT_VSYNC``.
79 - struct :ref:`v4l2_event_ctrl <v4l2-event-ctrl>`
83 - Event data for event ``V4L2_EVENT_CTRL``.
88 - struct :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>`
92 - Event data for event ``V4L2_EVENT_FRAME_SYNC``.
97 - struct :ref:`v4l2_event_motion_det <v4l2-event-motion-det>`
101 - Event data for event V4L2_EVENT_MOTION_DET.
106 - struct :ref:`v4l2_event_src_change <v4l2-event-src-change>`
110 - Event data for event V4L2_EVENT_SOURCE_CHANGE.
119 - Event data. Defined by the event type. The union should be used to
120 define easily accessible type for events.
129 - Number of pending events excluding this one.
138 - Event sequence number. The sequence number is incremented for
139 every subscribed event that takes place. If sequence numbers are
140 not contiguous it means that events have been lost.
149 - Event timestamp. The timestamp has been taken from the
150 ``CLOCK_MONOTONIC`` clock. To access the same clock outside V4L2,
151 use :c:func:`clock_gettime(2)`.
160 - The ID associated with the event source. If the event does not
161 have an associated ID (this depends on the event type), then this
171 - Reserved for future extensions. Drivers must set the array to
178 .. flat-table:: Event Types
190 - All events. V4L2_EVENT_ALL is valid only for
191 VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
195 - ``V4L2_EVENT_VSYNC``
199 - This event is triggered on the vertical sync. This event has a
200 struct :ref:`v4l2_event_vsync <v4l2-event-vsync>` associated
209 - This event is triggered when the end of a stream is reached. This
210 is typically used with MPEG decoders to report to the application
211 when the last of the MPEG stream has been decoded.
215 - ``V4L2_EVENT_CTRL``
219 - This event requires that the ``id`` matches the control ID from
220 which you want to receive events. This event is triggered if the
221 control's value changes, if a button control is pressed or if the
222 control's flags change. This event has a struct
223 :ref:`v4l2_event_ctrl <v4l2-event-ctrl>` associated with it.
224 This struct contains much of the same information as struct
225 :ref:`v4l2_queryctrl <v4l2-queryctrl>` and struct
226 :ref:`v4l2_control <v4l2-control>`.
228 If the event is generated due to a call to
229 :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` or
230 :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then the
231 event will *not* be sent to the file handle that called the ioctl
232 function. This prevents nasty feedback loops. If you *do* want to
233 get the event, then set the ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``
236 This event type will ensure that no information is lost when more
237 events are raised than there is room internally. In that case the
238 struct :ref:`v4l2_event_ctrl <v4l2-event-ctrl>` of the
239 second-oldest event is kept, but the ``changes`` field of the
240 second-oldest event is ORed with the ``changes`` field of the
245 - ``V4L2_EVENT_FRAME_SYNC``
249 - Triggered immediately when the reception of a frame has begun.
250 This event has a struct
251 :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>`
254 If the hardware needs to be stopped in the case of a buffer
255 underrun it might not be able to generate this event. In such
256 cases the ``frame_sequence`` field in struct
257 :ref:`v4l2_event_frame_sync <v4l2-event-frame-sync>` will not
258 be incremented. This causes two consecutive frame sequence numbers
259 to have n times frame interval in between them.
263 - ``V4L2_EVENT_SOURCE_CHANGE``
267 - This event is triggered when a source parameter change is detected
268 during runtime by the video device. It can be a runtime resolution
269 change triggered by a video decoder or the format change happening
270 on an input connector. This event requires that the ``id`` matches
271 the input index (when used with a video device node) or the pad
272 index (when used with a subdevice node) from which you want to
275 This event has a struct
276 :ref:`v4l2_event_src_change <v4l2-event-src-change>`
277 associated with it. The ``changes`` bitfield denotes what has
278 changed for the subscribed pad. If multiple events occurred before
279 application could dequeue them, then the changes will have the
280 ORed value of all the events generated.
284 - ``V4L2_EVENT_MOTION_DET``
288 - Triggered whenever the motion detection state for one or more of
289 the regions changes. This event has a struct
290 :ref:`v4l2_event_motion_det <v4l2-event-motion-det>`
295 - ``V4L2_EVENT_PRIVATE_START``
299 - Base event number for driver-private events.
303 .. _v4l2-event-vsync:
305 .. flat-table:: struct v4l2_event_vsync
317 - The upcoming field. See enum :ref:`v4l2_field <v4l2-field>`.
323 .. flat-table:: struct v4l2_event_ctrl
336 - A bitmask that tells what has changed. See
337 :ref:`ctrl-changes-flags`.
346 - The type of the control. See enum
347 :ref:`v4l2_ctrl_type <v4l2-ctrl-type>`.
364 - The 32-bit value of the control for 32-bit control types. This is
365 0 for string controls since the value of a string cannot be passed
366 using :ref:`VIDIOC_DQEVENT`.
375 - The 64-bit value of the control for 64-bit control types.
384 - The control flags. See :ref:`control-flags`.
393 - The minimum value of the control. See struct
394 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
403 - The maximum value of the control. See struct
404 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
413 - The step value of the control. See struct
414 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
423 - The default value value of the control. See struct
424 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
428 .. _v4l2-event-frame-sync:
430 .. flat-table:: struct v4l2_event_frame_sync
442 - The sequence number of the frame being received.
446 .. _v4l2-event-src-change:
448 .. flat-table:: struct v4l2_event_src_change
460 - A bitmask that tells what has changed. See
461 :ref:`src-changes-flags`.
465 .. _v4l2-event-motion-det:
467 .. flat-table:: struct v4l2_event_motion_det
479 - Currently only one flag is available: if
480 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` is set, then the
481 ``frame_sequence`` field is valid, otherwise that field should be
490 - The sequence number of the frame being received. Only valid if the
491 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` flag was set.
499 - The bitmask of the regions that reported motion. There is at least
500 one region. If this field is 0, then no motion was detected at
501 all. If there is no ``V4L2_CID_DETECT_MD_REGION_GRID`` control
502 (see :ref:`detect-controls`) to assign a different region to
503 each cell in the motion detection grid, then that all cells are
504 automatically assigned to the default region 0.
508 .. _ctrl-changes-flags:
510 .. flat-table:: Control Changes
518 - ``V4L2_EVENT_CTRL_CH_VALUE``
522 - This control event was triggered because the value of the control
523 changed. Special cases: Volatile controls do no generate this
524 event; If a control has the ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE``
525 flag set, then this event is sent as well, regardless its value.
529 - ``V4L2_EVENT_CTRL_CH_FLAGS``
533 - This control event was triggered because the control flags
538 - ``V4L2_EVENT_CTRL_CH_RANGE``
542 - This control event was triggered because the minimum, maximum,
543 step or the default value of the control changed.
547 .. _src-changes-flags:
549 .. flat-table:: Source Changes
557 - ``V4L2_EVENT_SRC_CH_RESOLUTION``
561 - This event gets triggered when a resolution change is detected at
562 an input. This can come from an input connector or from a video
570 On success 0 is returned, on error -1 and the ``errno`` variable is set
571 appropriately. The generic error codes are described at the
572 :ref:`Generic Error Codes <gen-errors>` chapter.
575 .. ------------------------------------------------------------------------------
576 .. This file was automatically converted from DocBook-XML with the dbxml
577 .. library (https://github.com/return42/sphkerneldoc). The origin XML comes
578 .. from the linux kernel, refer to:
580 .. * https://github.com/torvalds/linux/tree/master/Documentation/DocBook
581 .. ------------------------------------------------------------------------------