1 .. Permission is granted to copy, distribute and/or modify this
2 .. document under the terms of the GNU Free Documentation License,
3 .. Version 1.1 or any later version published by the Free Software
4 .. Foundation, with no Invariant Sections, no Front-Cover Texts
5 .. and no Back-Cover Texts. A copy of the license is included at
6 .. Documentation/media/uapi/fdl-appendix.rst.
8 .. TODO: replace it to GFDL-1.1-or-later WITH no-invariant-sections
19 VIDIOC_DQEVENT - Dequeue event
25 .. c:function:: int ioctl( int fd, VIDIOC_DQEVENT, struct v4l2_event *argp )
33 File descriptor returned by :ref:`open() <func-open>`.
36 Pointer to struct :c:type:`v4l2_event`.
42 Dequeue an event from a video device. No input is required for this
43 ioctl. All the fields of the struct :c:type:`v4l2_event`
44 structure are filled by the driver. The file handle will also receive
45 exceptions which the application may get by e.g. using the select system
49 .. tabularcolumns:: |p{3.0cm}|p{4.4cm}|p{2.4cm}|p{7.7cm}|
51 .. c:type:: v4l2_event
53 .. cssclass: longtable
55 .. flat-table:: struct v4l2_event
63 - Type of the event, see :ref:`event-type`.
69 - struct :c:type:`v4l2_event_vsync`
71 - Event data for event ``V4L2_EVENT_VSYNC``.
73 - struct :c:type:`v4l2_event_ctrl`
75 - Event data for event ``V4L2_EVENT_CTRL``.
77 - struct :c:type:`v4l2_event_frame_sync`
79 - Event data for event ``V4L2_EVENT_FRAME_SYNC``.
81 - struct :c:type:`v4l2_event_motion_det`
83 - Event data for event V4L2_EVENT_MOTION_DET.
85 - struct :c:type:`v4l2_event_src_change`
87 - Event data for event V4L2_EVENT_SOURCE_CHANGE.
91 - Event data. Defined by the event type. The union should be used to
92 define easily accessible type for events.
96 - Number of pending events excluding this one.
100 - Event sequence number. The sequence number is incremented for
101 every subscribed event that takes place. If sequence numbers are
102 not contiguous it means that events have been lost.
106 - Event timestamp. The timestamp has been taken from the
107 ``CLOCK_MONOTONIC`` clock. To access the same clock outside V4L2,
108 use :c:func:`clock_gettime`.
112 - The ID associated with the event source. If the event does not
113 have an associated ID (this depends on the event type), then this
118 - Reserved for future extensions. Drivers must set the array to
123 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
125 .. cssclass:: longtable
129 .. flat-table:: Event Types
134 * - ``V4L2_EVENT_ALL``
136 - All events. V4L2_EVENT_ALL is valid only for
137 VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
138 * - ``V4L2_EVENT_VSYNC``
140 - This event is triggered on the vertical sync. This event has a
141 struct :c:type:`v4l2_event_vsync` associated
143 * - ``V4L2_EVENT_EOS``
145 - This event is triggered when the end of a stream is reached. This
146 is typically used with MPEG decoders to report to the application
147 when the last of the MPEG stream has been decoded.
148 * - ``V4L2_EVENT_CTRL``
150 - This event requires that the ``id`` matches the control ID from
151 which you want to receive events. This event is triggered if the
152 control's value changes, if a button control is pressed or if the
153 control's flags change. This event has a struct
154 :c:type:`v4l2_event_ctrl` associated with it.
155 This struct contains much of the same information as struct
156 :ref:`v4l2_queryctrl <v4l2-queryctrl>` and struct
157 :c:type:`v4l2_control`.
159 If the event is generated due to a call to
160 :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` or
161 :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then the
162 event will *not* be sent to the file handle that called the ioctl
163 function. This prevents nasty feedback loops. If you *do* want to
164 get the event, then set the ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``
167 This event type will ensure that no information is lost when more
168 events are raised than there is room internally. In that case the
169 struct :c:type:`v4l2_event_ctrl` of the
170 second-oldest event is kept, but the ``changes`` field of the
171 second-oldest event is ORed with the ``changes`` field of the
173 * - ``V4L2_EVENT_FRAME_SYNC``
175 - Triggered immediately when the reception of a frame has begun.
176 This event has a struct
177 :c:type:`v4l2_event_frame_sync`
180 If the hardware needs to be stopped in the case of a buffer
181 underrun it might not be able to generate this event. In such
182 cases the ``frame_sequence`` field in struct
183 :c:type:`v4l2_event_frame_sync` will not
184 be incremented. This causes two consecutive frame sequence numbers
185 to have n times frame interval in between them.
186 * - ``V4L2_EVENT_SOURCE_CHANGE``
188 - This event is triggered when a source parameter change is detected
189 during runtime by the video device. It can be a runtime resolution
190 change triggered by a video decoder or the format change happening
191 on an input connector. This event requires that the ``id`` matches
192 the input index (when used with a video device node) or the pad
193 index (when used with a subdevice node) from which you want to
196 This event has a struct
197 :c:type:`v4l2_event_src_change`
198 associated with it. The ``changes`` bitfield denotes what has
199 changed for the subscribed pad. If multiple events occurred before
200 application could dequeue them, then the changes will have the
201 ORed value of all the events generated.
202 * - ``V4L2_EVENT_MOTION_DET``
204 - Triggered whenever the motion detection state for one or more of
205 the regions changes. This event has a struct
206 :c:type:`v4l2_event_motion_det`
208 * - ``V4L2_EVENT_PRIVATE_START``
210 - Base event number for driver-private events.
214 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
216 .. c:type:: v4l2_event_vsync
218 .. flat-table:: struct v4l2_event_vsync
225 - The upcoming field. See enum :c:type:`v4l2_field`.
229 .. tabularcolumns:: |p{3.5cm}|p{3.0cm}|p{1.8cm}|p{8.5cm}|
231 .. c:type:: v4l2_event_ctrl
233 .. flat-table:: struct v4l2_event_ctrl
241 - A bitmask that tells what has changed. See
242 :ref:`ctrl-changes-flags`.
246 - The type of the control. See enum
247 :c:type:`v4l2_ctrl_type`.
248 * - union (anonymous)
255 - The 32-bit value of the control for 32-bit control types. This is
256 0 for string controls since the value of a string cannot be passed
257 using :ref:`VIDIOC_DQEVENT`.
261 - The 64-bit value of the control for 64-bit control types.
265 - The control flags. See :ref:`control-flags`.
269 - The minimum value of the control. See struct
270 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
274 - The maximum value of the control. See struct
275 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
279 - The step value of the control. See struct
280 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
284 - The default value value of the control. See struct
285 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.
289 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
291 .. c:type:: v4l2_event_frame_sync
293 .. flat-table:: struct v4l2_event_frame_sync
300 - The sequence number of the frame being received.
304 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
306 .. c:type:: v4l2_event_src_change
308 .. flat-table:: struct v4l2_event_src_change
315 - A bitmask that tells what has changed. See
316 :ref:`src-changes-flags`.
320 .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}|
322 .. c:type:: v4l2_event_motion_det
324 .. flat-table:: struct v4l2_event_motion_det
331 - Currently only one flag is available: if
332 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` is set, then the
333 ``frame_sequence`` field is valid, otherwise that field should be
337 - The sequence number of the frame being received. Only valid if the
338 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` flag was set.
341 - The bitmask of the regions that reported motion. There is at least
342 one region. If this field is 0, then no motion was detected at
343 all. If there is no ``V4L2_CID_DETECT_MD_REGION_GRID`` control
344 (see :ref:`detect-controls`) to assign a different region to
345 each cell in the motion detection grid, then that all cells are
346 automatically assigned to the default region 0.
350 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
352 .. _ctrl-changes-flags:
354 .. flat-table:: Control Changes
359 * - ``V4L2_EVENT_CTRL_CH_VALUE``
361 - This control event was triggered because the value of the control
362 changed. Special cases: Volatile controls do no generate this
363 event; If a control has the ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE``
364 flag set, then this event is sent as well, regardless its value.
365 * - ``V4L2_EVENT_CTRL_CH_FLAGS``
367 - This control event was triggered because the control flags
369 * - ``V4L2_EVENT_CTRL_CH_RANGE``
371 - This control event was triggered because the minimum, maximum,
372 step or the default value of the control changed.
376 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
378 .. _src-changes-flags:
380 .. flat-table:: Source Changes
385 * - ``V4L2_EVENT_SRC_CH_RESOLUTION``
387 - This event gets triggered when a resolution change is detected at
388 an input. This can come from an input connector or from a video
389 decoder. Applications will have to query the new resolution (if
390 any, the signal may also have been lost).
392 *Important*: even if the new video timings appear identical to the old
393 ones, receiving this event indicates that there was an issue with the
394 video signal and you must stop and restart streaming
395 (:ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`
396 followed by :ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>`). The reason is
397 that many devices are not able to recover from a temporary loss of
398 signal and so restarting streaming I/O is required in order for the
399 hardware to synchronize to the video signal.
405 On success 0 is returned, on error -1 and the ``errno`` variable is set
406 appropriately. The generic error codes are described at the
407 :ref:`Generic Error Codes <gen-errors>` chapter.