378 lines · plain
1.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later2.. c:namespace:: V4L3 4.. _VIDIOC_DQEVENT:5 6********************7ioctl VIDIOC_DQEVENT8********************9 10Name11====12 13VIDIOC_DQEVENT - Dequeue event14 15Synopsis16========17 18.. c:macro:: VIDIOC_DQEVENT19 20``int ioctl(int fd, VIDIOC_DQEVENT, struct v4l2_event *argp)``21 22Arguments23=========24 25``fd``26 File descriptor returned by :c:func:`open()`.27 28``argp``29 Pointer to struct :c:type:`v4l2_event`.30 31Description32===========33 34Dequeue an event from a video device. No input is required for this35ioctl. All the fields of the struct :c:type:`v4l2_event`36structure are filled by the driver. The file handle will also receive37exceptions which the application may get by e.g. using the select system38call.39 40.. c:type:: v4l2_event41 42.. tabularcolumns:: |p{3.0cm}|p{3.4cm}|p{10.9cm}|43 44 45.. flat-table:: struct v4l2_event46 :header-rows: 047 :stub-columns: 048 :widths: 1 1 249 50 * - __u3251 - ``type``52 - Type of the event, see :ref:`event-type`.53 * - union {54 - ``u``55 * - struct :c:type:`v4l2_event_vsync`56 - ``vsync``57 - Event data for event ``V4L2_EVENT_VSYNC``.58 * - struct :c:type:`v4l2_event_ctrl`59 - ``ctrl``60 - Event data for event ``V4L2_EVENT_CTRL``.61 * - struct :c:type:`v4l2_event_frame_sync`62 - ``frame_sync``63 - Event data for event ``V4L2_EVENT_FRAME_SYNC``.64 * - struct :c:type:`v4l2_event_motion_det`65 - ``motion_det``66 - Event data for event V4L2_EVENT_MOTION_DET.67 * - struct :c:type:`v4l2_event_src_change`68 - ``src_change``69 - Event data for event V4L2_EVENT_SOURCE_CHANGE.70 * - __u871 - ``data``\ [64]72 - Event data. Defined by the event type. The union should be used to73 define easily accessible type for events.74 * - }75 -76 * - __u3277 - ``pending``78 - Number of pending events excluding this one.79 * - __u3280 - ``sequence``81 - Event sequence number. The sequence number is incremented for82 every subscribed event that takes place. If sequence numbers are83 not contiguous it means that events have been lost.84 * - struct timespec85 - ``timestamp``86 - Event timestamp. The timestamp has been taken from the87 ``CLOCK_MONOTONIC`` clock. To access the same clock outside V4L2,88 use :c:func:`clock_gettime`.89 * - u3290 - ``id``91 - The ID associated with the event source. If the event does not92 have an associated ID (this depends on the event type), then this93 is 0.94 * - __u3295 - ``reserved``\ [8]96 - Reserved for future extensions. Drivers must set the array to97 zero.98 99 100.. tabularcolumns:: |p{6.2cm}|p{2.6cm}|p{8.5cm}|101 102.. cssclass:: longtable103 104.. _event-type:105 106.. flat-table:: Event Types107 :header-rows: 0108 :stub-columns: 0109 :widths: 3 1 4110 111 * - ``V4L2_EVENT_ALL``112 - 0113 - All events. V4L2_EVENT_ALL is valid only for114 VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.115 * - ``V4L2_EVENT_VSYNC``116 - 1117 - This event is triggered on the vertical sync. This event has a118 struct :c:type:`v4l2_event_vsync` associated119 with it.120 * - ``V4L2_EVENT_EOS``121 - 2122 - This event is triggered when the end of a stream is reached. This123 is typically used with MPEG decoders to report to the application124 when the last of the MPEG stream has been decoded.125 * - ``V4L2_EVENT_CTRL``126 - 3127 - This event requires that the ``id`` matches the control ID from128 which you want to receive events. This event is triggered if the129 control's value changes, if a button control is pressed or if the130 control's flags change. This event has a struct131 :c:type:`v4l2_event_ctrl` associated with it.132 This struct contains much of the same information as struct133 :ref:`v4l2_queryctrl <v4l2-queryctrl>` and struct134 :c:type:`v4l2_control`.135 136 If the event is generated due to a call to137 :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` or138 :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then the139 event will *not* be sent to the file handle that called the ioctl140 function. This prevents nasty feedback loops. If you *do* want to141 get the event, then set the ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``142 flag.143 144 This event type will ensure that no information is lost when more145 events are raised than there is room internally. In that case the146 struct :c:type:`v4l2_event_ctrl` of the147 second-oldest event is kept, but the ``changes`` field of the148 second-oldest event is ORed with the ``changes`` field of the149 oldest event.150 * - ``V4L2_EVENT_FRAME_SYNC``151 - 4152 - Triggered immediately when the reception of a frame has begun.153 This event has a struct154 :c:type:`v4l2_event_frame_sync`155 associated with it.156 157 If the hardware needs to be stopped in the case of a buffer158 underrun it might not be able to generate this event. In such159 cases the ``frame_sequence`` field in struct160 :c:type:`v4l2_event_frame_sync` will not161 be incremented. This causes two consecutive frame sequence numbers162 to have n times frame interval in between them.163 * - ``V4L2_EVENT_SOURCE_CHANGE``164 - 5165 - This event is triggered when a source parameter change is detected166 during runtime by the video device. It can be a runtime resolution167 change triggered by a video decoder or the format change happening168 on an input connector. This event requires that the ``id`` matches169 the input index (when used with a video device node) or the pad170 index (when used with a subdevice node) from which you want to171 receive events.172 173 This event has a struct174 :c:type:`v4l2_event_src_change`175 associated with it. The ``changes`` bitfield denotes what has176 changed for the subscribed pad. If multiple events occurred before177 application could dequeue them, then the changes will have the178 ORed value of all the events generated.179 * - ``V4L2_EVENT_MOTION_DET``180 - 6181 - Triggered whenever the motion detection state for one or more of182 the regions changes. This event has a struct183 :c:type:`v4l2_event_motion_det`184 associated with it.185 * - ``V4L2_EVENT_PRIVATE_START``186 - 0x08000000187 - Base event number for driver-private events.188 189 190.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|191 192.. c:type:: v4l2_event_vsync193 194.. flat-table:: struct v4l2_event_vsync195 :header-rows: 0196 :stub-columns: 0197 :widths: 1 1 2198 199 * - __u8200 - ``field``201 - The upcoming field. See enum :c:type:`v4l2_field`.202 203 204.. tabularcolumns:: |p{3.5cm}|p{3.0cm}|p{10.8cm}|205 206.. c:type:: v4l2_event_ctrl207 208.. flat-table:: struct v4l2_event_ctrl209 :header-rows: 0210 :stub-columns: 0211 :widths: 1 1 2212 213 * - __u32214 - ``changes``215 - A bitmask that tells what has changed. See216 :ref:`ctrl-changes-flags`.217 * - __u32218 - ``type``219 - The type of the control. See enum220 :c:type:`v4l2_ctrl_type`.221 * - union {222 - (anonymous)223 * - __s32224 - ``value``225 - The 32-bit value of the control for 32-bit control types. This is226 0 for string controls since the value of a string cannot be passed227 using :ref:`VIDIOC_DQEVENT`.228 * - __s64229 - ``value64``230 - The 64-bit value of the control for 64-bit control types.231 * - }232 -233 * - __u32234 - ``flags``235 - The control flags. See :ref:`control-flags`.236 * - __s32237 - ``minimum``238 - The minimum value of the control. See struct239 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.240 * - __s32241 - ``maximum``242 - The maximum value of the control. See struct243 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.244 * - __s32245 - ``step``246 - The step value of the control. See struct247 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.248 * - __s32249 - ``default_value``250 - The default value of the control. See struct251 :ref:`v4l2_queryctrl <v4l2-queryctrl>`.252 253 254.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|255 256.. c:type:: v4l2_event_frame_sync257 258.. flat-table:: struct v4l2_event_frame_sync259 :header-rows: 0260 :stub-columns: 0261 :widths: 1 1 2262 263 * - __u32264 - ``frame_sequence``265 - The sequence number of the frame being received.266 267 268.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|269 270.. c:type:: v4l2_event_src_change271 272.. flat-table:: struct v4l2_event_src_change273 :header-rows: 0274 :stub-columns: 0275 :widths: 1 1 2276 277 * - __u32278 - ``changes``279 - A bitmask that tells what has changed. See280 :ref:`src-changes-flags`.281 282 283.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|284 285.. c:type:: v4l2_event_motion_det286 287.. flat-table:: struct v4l2_event_motion_det288 :header-rows: 0289 :stub-columns: 0290 :widths: 1 1 2291 292 * - __u32293 - ``flags``294 - Currently only one flag is available: if295 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` is set, then the296 ``frame_sequence`` field is valid, otherwise that field should be297 ignored.298 * - __u32299 - ``frame_sequence``300 - The sequence number of the frame being received. Only valid if the301 ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` flag was set.302 * - __u32303 - ``region_mask``304 - The bitmask of the regions that reported motion. There is at least305 one region. If this field is 0, then no motion was detected at306 all. If there is no ``V4L2_CID_DETECT_MD_REGION_GRID`` control307 (see :ref:`detect-controls`) to assign a different region to308 each cell in the motion detection grid, then that all cells are309 automatically assigned to the default region 0.310 311 312.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|313 314.. _ctrl-changes-flags:315 316.. flat-table:: Control Changes317 :header-rows: 0318 :stub-columns: 0319 :widths: 3 1 4320 321 * - ``V4L2_EVENT_CTRL_CH_VALUE``322 - 0x0001323 - This control event was triggered because the value of the control324 changed. Special cases: Volatile controls do no generate this325 event; If a control has the ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE``326 flag set, then this event is sent as well, regardless its value.327 * - ``V4L2_EVENT_CTRL_CH_FLAGS``328 - 0x0002329 - This control event was triggered because the control flags330 changed.331 * - ``V4L2_EVENT_CTRL_CH_RANGE``332 - 0x0004333 - This control event was triggered because the minimum, maximum,334 step or the default value of the control changed.335 * - ``V4L2_EVENT_CTRL_CH_DIMENSIONS``336 - 0x0008337 - This control event was triggered because the dimensions of the338 control changed. Note that the number of dimensions remains the339 same.340 341 342.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|343 344.. _src-changes-flags:345 346.. flat-table:: Source Changes347 :header-rows: 0348 :stub-columns: 0349 :widths: 3 1 4350 351 * - ``V4L2_EVENT_SRC_CH_RESOLUTION``352 - 0x0001353 - This event gets triggered when a resolution change is detected at354 an input. This can come from an input connector or from a video355 decoder. Applications will have to query the new resolution (if356 any, the signal may also have been lost).357 358 For stateful decoders follow the guidelines in :ref:`decoder`.359 Video Capture devices have to query the new timings using360 :ref:`VIDIOC_QUERY_DV_TIMINGS` or361 :ref:`VIDIOC_QUERYSTD <VIDIOC_QUERYSTD>`.362 363 *Important*: even if the new video timings appear identical to the old364 ones, receiving this event indicates that there was an issue with the365 video signal and you must stop and restart streaming366 (:ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`367 followed by :ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>`). The reason is368 that many Video Capture devices are not able to recover from a temporary369 loss of signal and so restarting streaming I/O is required in order for370 the hardware to synchronize to the video signal.371 372Return Value373============374 375On success 0 is returned, on error -1 and the ``errno`` variable is set376appropriately. The generic error codes are described at the377:ref:`Generic Error Codes <gen-errors>` chapter.378