1*4882a593Smuzhiyun.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 2*4882a593Smuzhiyun.. c:namespace:: V4L 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun.. _VIDIOC_DQEVENT: 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun******************** 7*4882a593Smuzhiyunioctl VIDIOC_DQEVENT 8*4882a593Smuzhiyun******************** 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunName 11*4882a593Smuzhiyun==== 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunVIDIOC_DQEVENT - Dequeue event 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunSynopsis 16*4882a593Smuzhiyun======== 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun.. c:macro:: VIDIOC_DQEVENT 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun``int ioctl(int fd, VIDIOC_DQEVENT, struct v4l2_event *argp)`` 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunArguments 23*4882a593Smuzhiyun========= 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun``fd`` 26*4882a593Smuzhiyun File descriptor returned by :c:func:`open()`. 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun``argp`` 29*4882a593Smuzhiyun Pointer to struct :c:type:`v4l2_event`. 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunDescription 32*4882a593Smuzhiyun=========== 33*4882a593Smuzhiyun 34*4882a593SmuzhiyunDequeue an event from a video device. No input is required for this 35*4882a593Smuzhiyunioctl. All the fields of the struct :c:type:`v4l2_event` 36*4882a593Smuzhiyunstructure are filled by the driver. The file handle will also receive 37*4882a593Smuzhiyunexceptions which the application may get by e.g. using the select system 38*4882a593Smuzhiyuncall. 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun.. tabularcolumns:: |p{3.0cm}|p{4.4cm}|p{2.4cm}|p{7.7cm}| 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun.. c:type:: v4l2_event 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun.. cssclass: longtable 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun.. flat-table:: struct v4l2_event 47*4882a593Smuzhiyun :header-rows: 0 48*4882a593Smuzhiyun :stub-columns: 0 49*4882a593Smuzhiyun :widths: 1 1 2 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun * - __u32 52*4882a593Smuzhiyun - ``type`` 53*4882a593Smuzhiyun - Type of the event, see :ref:`event-type`. 54*4882a593Smuzhiyun * - union { 55*4882a593Smuzhiyun - ``u`` 56*4882a593Smuzhiyun * - struct :c:type:`v4l2_event_vsync` 57*4882a593Smuzhiyun - ``vsync`` 58*4882a593Smuzhiyun - Event data for event ``V4L2_EVENT_VSYNC``. 59*4882a593Smuzhiyun * - struct :c:type:`v4l2_event_ctrl` 60*4882a593Smuzhiyun - ``ctrl`` 61*4882a593Smuzhiyun - Event data for event ``V4L2_EVENT_CTRL``. 62*4882a593Smuzhiyun * - struct :c:type:`v4l2_event_frame_sync` 63*4882a593Smuzhiyun - ``frame_sync`` 64*4882a593Smuzhiyun - Event data for event ``V4L2_EVENT_FRAME_SYNC``. 65*4882a593Smuzhiyun * - struct :c:type:`v4l2_event_motion_det` 66*4882a593Smuzhiyun - ``motion_det`` 67*4882a593Smuzhiyun - Event data for event V4L2_EVENT_MOTION_DET. 68*4882a593Smuzhiyun * - struct :c:type:`v4l2_event_src_change` 69*4882a593Smuzhiyun - ``src_change`` 70*4882a593Smuzhiyun - Event data for event V4L2_EVENT_SOURCE_CHANGE. 71*4882a593Smuzhiyun * - __u8 72*4882a593Smuzhiyun - ``data``\ [64] 73*4882a593Smuzhiyun - Event data. Defined by the event type. The union should be used to 74*4882a593Smuzhiyun define easily accessible type for events. 75*4882a593Smuzhiyun * - } 76*4882a593Smuzhiyun - 77*4882a593Smuzhiyun * - __u32 78*4882a593Smuzhiyun - ``pending`` 79*4882a593Smuzhiyun - Number of pending events excluding this one. 80*4882a593Smuzhiyun * - __u32 81*4882a593Smuzhiyun - ``sequence`` 82*4882a593Smuzhiyun - Event sequence number. The sequence number is incremented for 83*4882a593Smuzhiyun every subscribed event that takes place. If sequence numbers are 84*4882a593Smuzhiyun not contiguous it means that events have been lost. 85*4882a593Smuzhiyun * - struct timespec 86*4882a593Smuzhiyun - ``timestamp`` 87*4882a593Smuzhiyun - Event timestamp. The timestamp has been taken from the 88*4882a593Smuzhiyun ``CLOCK_MONOTONIC`` clock. To access the same clock outside V4L2, 89*4882a593Smuzhiyun use :c:func:`clock_gettime`. 90*4882a593Smuzhiyun * - u32 91*4882a593Smuzhiyun - ``id`` 92*4882a593Smuzhiyun - The ID associated with the event source. If the event does not 93*4882a593Smuzhiyun have an associated ID (this depends on the event type), then this 94*4882a593Smuzhiyun is 0. 95*4882a593Smuzhiyun * - __u32 96*4882a593Smuzhiyun - ``reserved``\ [8] 97*4882a593Smuzhiyun - Reserved for future extensions. Drivers must set the array to 98*4882a593Smuzhiyun zero. 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 102*4882a593Smuzhiyun 103*4882a593Smuzhiyun.. cssclass:: longtable 104*4882a593Smuzhiyun 105*4882a593Smuzhiyun.. _event-type: 106*4882a593Smuzhiyun 107*4882a593Smuzhiyun.. flat-table:: Event Types 108*4882a593Smuzhiyun :header-rows: 0 109*4882a593Smuzhiyun :stub-columns: 0 110*4882a593Smuzhiyun :widths: 3 1 4 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun * - ``V4L2_EVENT_ALL`` 113*4882a593Smuzhiyun - 0 114*4882a593Smuzhiyun - All events. V4L2_EVENT_ALL is valid only for 115*4882a593Smuzhiyun VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once. 116*4882a593Smuzhiyun * - ``V4L2_EVENT_VSYNC`` 117*4882a593Smuzhiyun - 1 118*4882a593Smuzhiyun - This event is triggered on the vertical sync. This event has a 119*4882a593Smuzhiyun struct :c:type:`v4l2_event_vsync` associated 120*4882a593Smuzhiyun with it. 121*4882a593Smuzhiyun * - ``V4L2_EVENT_EOS`` 122*4882a593Smuzhiyun - 2 123*4882a593Smuzhiyun - This event is triggered when the end of a stream is reached. This 124*4882a593Smuzhiyun is typically used with MPEG decoders to report to the application 125*4882a593Smuzhiyun when the last of the MPEG stream has been decoded. 126*4882a593Smuzhiyun * - ``V4L2_EVENT_CTRL`` 127*4882a593Smuzhiyun - 3 128*4882a593Smuzhiyun - This event requires that the ``id`` matches the control ID from 129*4882a593Smuzhiyun which you want to receive events. This event is triggered if the 130*4882a593Smuzhiyun control's value changes, if a button control is pressed or if the 131*4882a593Smuzhiyun control's flags change. This event has a struct 132*4882a593Smuzhiyun :c:type:`v4l2_event_ctrl` associated with it. 133*4882a593Smuzhiyun This struct contains much of the same information as struct 134*4882a593Smuzhiyun :ref:`v4l2_queryctrl <v4l2-queryctrl>` and struct 135*4882a593Smuzhiyun :c:type:`v4l2_control`. 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun If the event is generated due to a call to 138*4882a593Smuzhiyun :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` or 139*4882a593Smuzhiyun :ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then the 140*4882a593Smuzhiyun event will *not* be sent to the file handle that called the ioctl 141*4882a593Smuzhiyun function. This prevents nasty feedback loops. If you *do* want to 142*4882a593Smuzhiyun get the event, then set the ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK`` 143*4882a593Smuzhiyun flag. 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun This event type will ensure that no information is lost when more 146*4882a593Smuzhiyun events are raised than there is room internally. In that case the 147*4882a593Smuzhiyun struct :c:type:`v4l2_event_ctrl` of the 148*4882a593Smuzhiyun second-oldest event is kept, but the ``changes`` field of the 149*4882a593Smuzhiyun second-oldest event is ORed with the ``changes`` field of the 150*4882a593Smuzhiyun oldest event. 151*4882a593Smuzhiyun * - ``V4L2_EVENT_FRAME_SYNC`` 152*4882a593Smuzhiyun - 4 153*4882a593Smuzhiyun - Triggered immediately when the reception of a frame has begun. 154*4882a593Smuzhiyun This event has a struct 155*4882a593Smuzhiyun :c:type:`v4l2_event_frame_sync` 156*4882a593Smuzhiyun associated with it. 157*4882a593Smuzhiyun 158*4882a593Smuzhiyun If the hardware needs to be stopped in the case of a buffer 159*4882a593Smuzhiyun underrun it might not be able to generate this event. In such 160*4882a593Smuzhiyun cases the ``frame_sequence`` field in struct 161*4882a593Smuzhiyun :c:type:`v4l2_event_frame_sync` will not 162*4882a593Smuzhiyun be incremented. This causes two consecutive frame sequence numbers 163*4882a593Smuzhiyun to have n times frame interval in between them. 164*4882a593Smuzhiyun * - ``V4L2_EVENT_SOURCE_CHANGE`` 165*4882a593Smuzhiyun - 5 166*4882a593Smuzhiyun - This event is triggered when a source parameter change is detected 167*4882a593Smuzhiyun during runtime by the video device. It can be a runtime resolution 168*4882a593Smuzhiyun change triggered by a video decoder or the format change happening 169*4882a593Smuzhiyun on an input connector. This event requires that the ``id`` matches 170*4882a593Smuzhiyun the input index (when used with a video device node) or the pad 171*4882a593Smuzhiyun index (when used with a subdevice node) from which you want to 172*4882a593Smuzhiyun receive events. 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun This event has a struct 175*4882a593Smuzhiyun :c:type:`v4l2_event_src_change` 176*4882a593Smuzhiyun associated with it. The ``changes`` bitfield denotes what has 177*4882a593Smuzhiyun changed for the subscribed pad. If multiple events occurred before 178*4882a593Smuzhiyun application could dequeue them, then the changes will have the 179*4882a593Smuzhiyun ORed value of all the events generated. 180*4882a593Smuzhiyun * - ``V4L2_EVENT_MOTION_DET`` 181*4882a593Smuzhiyun - 6 182*4882a593Smuzhiyun - Triggered whenever the motion detection state for one or more of 183*4882a593Smuzhiyun the regions changes. This event has a struct 184*4882a593Smuzhiyun :c:type:`v4l2_event_motion_det` 185*4882a593Smuzhiyun associated with it. 186*4882a593Smuzhiyun * - ``V4L2_EVENT_PRIVATE_START`` 187*4882a593Smuzhiyun - 0x08000000 188*4882a593Smuzhiyun - Base event number for driver-private events. 189*4882a593Smuzhiyun 190*4882a593Smuzhiyun 191*4882a593Smuzhiyun.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 192*4882a593Smuzhiyun 193*4882a593Smuzhiyun.. c:type:: v4l2_event_vsync 194*4882a593Smuzhiyun 195*4882a593Smuzhiyun.. flat-table:: struct v4l2_event_vsync 196*4882a593Smuzhiyun :header-rows: 0 197*4882a593Smuzhiyun :stub-columns: 0 198*4882a593Smuzhiyun :widths: 1 1 2 199*4882a593Smuzhiyun 200*4882a593Smuzhiyun * - __u8 201*4882a593Smuzhiyun - ``field`` 202*4882a593Smuzhiyun - The upcoming field. See enum :c:type:`v4l2_field`. 203*4882a593Smuzhiyun 204*4882a593Smuzhiyun 205*4882a593Smuzhiyun.. tabularcolumns:: |p{3.5cm}|p{3.0cm}|p{1.8cm}|p{8.5cm}| 206*4882a593Smuzhiyun 207*4882a593Smuzhiyun.. c:type:: v4l2_event_ctrl 208*4882a593Smuzhiyun 209*4882a593Smuzhiyun.. flat-table:: struct v4l2_event_ctrl 210*4882a593Smuzhiyun :header-rows: 0 211*4882a593Smuzhiyun :stub-columns: 0 212*4882a593Smuzhiyun :widths: 1 1 2 213*4882a593Smuzhiyun 214*4882a593Smuzhiyun * - __u32 215*4882a593Smuzhiyun - ``changes`` 216*4882a593Smuzhiyun - A bitmask that tells what has changed. See 217*4882a593Smuzhiyun :ref:`ctrl-changes-flags`. 218*4882a593Smuzhiyun * - __u32 219*4882a593Smuzhiyun - ``type`` 220*4882a593Smuzhiyun - The type of the control. See enum 221*4882a593Smuzhiyun :c:type:`v4l2_ctrl_type`. 222*4882a593Smuzhiyun * - union { 223*4882a593Smuzhiyun - (anonymous) 224*4882a593Smuzhiyun * - __s32 225*4882a593Smuzhiyun - ``value`` 226*4882a593Smuzhiyun - The 32-bit value of the control for 32-bit control types. This is 227*4882a593Smuzhiyun 0 for string controls since the value of a string cannot be passed 228*4882a593Smuzhiyun using :ref:`VIDIOC_DQEVENT`. 229*4882a593Smuzhiyun * - __s64 230*4882a593Smuzhiyun - ``value64`` 231*4882a593Smuzhiyun - The 64-bit value of the control for 64-bit control types. 232*4882a593Smuzhiyun * - } 233*4882a593Smuzhiyun - 234*4882a593Smuzhiyun * - __u32 235*4882a593Smuzhiyun - ``flags`` 236*4882a593Smuzhiyun - The control flags. See :ref:`control-flags`. 237*4882a593Smuzhiyun * - __s32 238*4882a593Smuzhiyun - ``minimum`` 239*4882a593Smuzhiyun - The minimum value of the control. See struct 240*4882a593Smuzhiyun :ref:`v4l2_queryctrl <v4l2-queryctrl>`. 241*4882a593Smuzhiyun * - __s32 242*4882a593Smuzhiyun - ``maximum`` 243*4882a593Smuzhiyun - The maximum value of the control. See struct 244*4882a593Smuzhiyun :ref:`v4l2_queryctrl <v4l2-queryctrl>`. 245*4882a593Smuzhiyun * - __s32 246*4882a593Smuzhiyun - ``step`` 247*4882a593Smuzhiyun - The step value of the control. See struct 248*4882a593Smuzhiyun :ref:`v4l2_queryctrl <v4l2-queryctrl>`. 249*4882a593Smuzhiyun * - __s32 250*4882a593Smuzhiyun - ``default_value`` 251*4882a593Smuzhiyun - The default value of the control. See struct 252*4882a593Smuzhiyun :ref:`v4l2_queryctrl <v4l2-queryctrl>`. 253*4882a593Smuzhiyun 254*4882a593Smuzhiyun 255*4882a593Smuzhiyun.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 256*4882a593Smuzhiyun 257*4882a593Smuzhiyun.. c:type:: v4l2_event_frame_sync 258*4882a593Smuzhiyun 259*4882a593Smuzhiyun.. flat-table:: struct v4l2_event_frame_sync 260*4882a593Smuzhiyun :header-rows: 0 261*4882a593Smuzhiyun :stub-columns: 0 262*4882a593Smuzhiyun :widths: 1 1 2 263*4882a593Smuzhiyun 264*4882a593Smuzhiyun * - __u32 265*4882a593Smuzhiyun - ``frame_sequence`` 266*4882a593Smuzhiyun - The sequence number of the frame being received. 267*4882a593Smuzhiyun 268*4882a593Smuzhiyun 269*4882a593Smuzhiyun.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 270*4882a593Smuzhiyun 271*4882a593Smuzhiyun.. c:type:: v4l2_event_src_change 272*4882a593Smuzhiyun 273*4882a593Smuzhiyun.. flat-table:: struct v4l2_event_src_change 274*4882a593Smuzhiyun :header-rows: 0 275*4882a593Smuzhiyun :stub-columns: 0 276*4882a593Smuzhiyun :widths: 1 1 2 277*4882a593Smuzhiyun 278*4882a593Smuzhiyun * - __u32 279*4882a593Smuzhiyun - ``changes`` 280*4882a593Smuzhiyun - A bitmask that tells what has changed. See 281*4882a593Smuzhiyun :ref:`src-changes-flags`. 282*4882a593Smuzhiyun 283*4882a593Smuzhiyun 284*4882a593Smuzhiyun.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| 285*4882a593Smuzhiyun 286*4882a593Smuzhiyun.. c:type:: v4l2_event_motion_det 287*4882a593Smuzhiyun 288*4882a593Smuzhiyun.. flat-table:: struct v4l2_event_motion_det 289*4882a593Smuzhiyun :header-rows: 0 290*4882a593Smuzhiyun :stub-columns: 0 291*4882a593Smuzhiyun :widths: 1 1 2 292*4882a593Smuzhiyun 293*4882a593Smuzhiyun * - __u32 294*4882a593Smuzhiyun - ``flags`` 295*4882a593Smuzhiyun - Currently only one flag is available: if 296*4882a593Smuzhiyun ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` is set, then the 297*4882a593Smuzhiyun ``frame_sequence`` field is valid, otherwise that field should be 298*4882a593Smuzhiyun ignored. 299*4882a593Smuzhiyun * - __u32 300*4882a593Smuzhiyun - ``frame_sequence`` 301*4882a593Smuzhiyun - The sequence number of the frame being received. Only valid if the 302*4882a593Smuzhiyun ``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` flag was set. 303*4882a593Smuzhiyun * - __u32 304*4882a593Smuzhiyun - ``region_mask`` 305*4882a593Smuzhiyun - The bitmask of the regions that reported motion. There is at least 306*4882a593Smuzhiyun one region. If this field is 0, then no motion was detected at 307*4882a593Smuzhiyun all. If there is no ``V4L2_CID_DETECT_MD_REGION_GRID`` control 308*4882a593Smuzhiyun (see :ref:`detect-controls`) to assign a different region to 309*4882a593Smuzhiyun each cell in the motion detection grid, then that all cells are 310*4882a593Smuzhiyun automatically assigned to the default region 0. 311*4882a593Smuzhiyun 312*4882a593Smuzhiyun 313*4882a593Smuzhiyun.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 314*4882a593Smuzhiyun 315*4882a593Smuzhiyun.. _ctrl-changes-flags: 316*4882a593Smuzhiyun 317*4882a593Smuzhiyun.. flat-table:: Control Changes 318*4882a593Smuzhiyun :header-rows: 0 319*4882a593Smuzhiyun :stub-columns: 0 320*4882a593Smuzhiyun :widths: 3 1 4 321*4882a593Smuzhiyun 322*4882a593Smuzhiyun * - ``V4L2_EVENT_CTRL_CH_VALUE`` 323*4882a593Smuzhiyun - 0x0001 324*4882a593Smuzhiyun - This control event was triggered because the value of the control 325*4882a593Smuzhiyun changed. Special cases: Volatile controls do no generate this 326*4882a593Smuzhiyun event; If a control has the ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE`` 327*4882a593Smuzhiyun flag set, then this event is sent as well, regardless its value. 328*4882a593Smuzhiyun * - ``V4L2_EVENT_CTRL_CH_FLAGS`` 329*4882a593Smuzhiyun - 0x0002 330*4882a593Smuzhiyun - This control event was triggered because the control flags 331*4882a593Smuzhiyun changed. 332*4882a593Smuzhiyun * - ``V4L2_EVENT_CTRL_CH_RANGE`` 333*4882a593Smuzhiyun - 0x0004 334*4882a593Smuzhiyun - This control event was triggered because the minimum, maximum, 335*4882a593Smuzhiyun step or the default value of the control changed. 336*4882a593Smuzhiyun 337*4882a593Smuzhiyun 338*4882a593Smuzhiyun.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}| 339*4882a593Smuzhiyun 340*4882a593Smuzhiyun.. _src-changes-flags: 341*4882a593Smuzhiyun 342*4882a593Smuzhiyun.. flat-table:: Source Changes 343*4882a593Smuzhiyun :header-rows: 0 344*4882a593Smuzhiyun :stub-columns: 0 345*4882a593Smuzhiyun :widths: 3 1 4 346*4882a593Smuzhiyun 347*4882a593Smuzhiyun * - ``V4L2_EVENT_SRC_CH_RESOLUTION`` 348*4882a593Smuzhiyun - 0x0001 349*4882a593Smuzhiyun - This event gets triggered when a resolution change is detected at 350*4882a593Smuzhiyun an input. This can come from an input connector or from a video 351*4882a593Smuzhiyun decoder. Applications will have to query the new resolution (if 352*4882a593Smuzhiyun any, the signal may also have been lost). 353*4882a593Smuzhiyun 354*4882a593Smuzhiyun For stateful decoders follow the guidelines in :ref:`decoder`. 355*4882a593Smuzhiyun Video Capture devices have to query the new timings using 356*4882a593Smuzhiyun :ref:`VIDIOC_QUERY_DV_TIMINGS` or 357*4882a593Smuzhiyun :ref:`VIDIOC_QUERYSTD <VIDIOC_QUERYSTD>`. 358*4882a593Smuzhiyun 359*4882a593Smuzhiyun *Important*: even if the new video timings appear identical to the old 360*4882a593Smuzhiyun ones, receiving this event indicates that there was an issue with the 361*4882a593Smuzhiyun video signal and you must stop and restart streaming 362*4882a593Smuzhiyun (:ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>` 363*4882a593Smuzhiyun followed by :ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>`). The reason is 364*4882a593Smuzhiyun that many Video Capture devices are not able to recover from a temporary 365*4882a593Smuzhiyun loss of signal and so restarting streaming I/O is required in order for 366*4882a593Smuzhiyun the hardware to synchronize to the video signal. 367*4882a593Smuzhiyun 368*4882a593SmuzhiyunReturn Value 369*4882a593Smuzhiyun============ 370*4882a593Smuzhiyun 371*4882a593SmuzhiyunOn success 0 is returned, on error -1 and the ``errno`` variable is set 372*4882a593Smuzhiyunappropriately. The generic error codes are described at the 373*4882a593Smuzhiyun:ref:`Generic Error Codes <gen-errors>` chapter. 374