162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 262306a36Sopenharmony_ci.. c:namespace:: V4L 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci.. _VIDIOC_SUBSCRIBE_EVENT: 562306a36Sopenharmony_ci.. _VIDIOC_UNSUBSCRIBE_EVENT: 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci****************************************************** 862306a36Sopenharmony_ciioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT 962306a36Sopenharmony_ci****************************************************** 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ciName 1262306a36Sopenharmony_ci==== 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ciVIDIOC_SUBSCRIBE_EVENT - VIDIOC_UNSUBSCRIBE_EVENT - Subscribe or unsubscribe event 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ciSynopsis 1762306a36Sopenharmony_ci======== 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci.. c:macro:: VIDIOC_SUBSCRIBE_EVENT 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_SUBSCRIBE_EVENT, struct v4l2_event_subscription *argp)`` 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci.. c:macro:: VIDIOC_UNSUBSCRIBE_EVENT 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci``int ioctl(int fd, VIDIOC_UNSUBSCRIBE_EVENT, struct v4l2_event_subscription *argp)`` 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ciArguments 2862306a36Sopenharmony_ci========= 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci``fd`` 3162306a36Sopenharmony_ci File descriptor returned by :c:func:`open()`. 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci``argp`` 3462306a36Sopenharmony_ci Pointer to struct :c:type:`v4l2_event_subscription`. 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ciDescription 3762306a36Sopenharmony_ci=========== 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ciSubscribe or unsubscribe V4L2 event. Subscribed events are dequeued by 4062306a36Sopenharmony_ciusing the :ref:`VIDIOC_DQEVENT` ioctl. 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci.. tabularcolumns:: |p{2.6cm}|p{4.4cm}|p{10.3cm}| 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci.. c:type:: v4l2_event_subscription 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci.. flat-table:: struct v4l2_event_subscription 4762306a36Sopenharmony_ci :header-rows: 0 4862306a36Sopenharmony_ci :stub-columns: 0 4962306a36Sopenharmony_ci :widths: 1 1 2 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci * - __u32 5262306a36Sopenharmony_ci - ``type`` 5362306a36Sopenharmony_ci - Type of the event, see :ref:`event-type`. 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci .. note:: 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci ``V4L2_EVENT_ALL`` can be used with 5862306a36Sopenharmony_ci :ref:`VIDIOC_UNSUBSCRIBE_EVENT <VIDIOC_SUBSCRIBE_EVENT>` for 5962306a36Sopenharmony_ci unsubscribing all events at once. 6062306a36Sopenharmony_ci * - __u32 6162306a36Sopenharmony_ci - ``id`` 6262306a36Sopenharmony_ci - ID of the event source. If there is no ID associated with the 6362306a36Sopenharmony_ci event source, then set this to 0. Whether or not an event needs an 6462306a36Sopenharmony_ci ID depends on the event type. 6562306a36Sopenharmony_ci * - __u32 6662306a36Sopenharmony_ci - ``flags`` 6762306a36Sopenharmony_ci - Event flags, see :ref:`event-flags`. 6862306a36Sopenharmony_ci * - __u32 6962306a36Sopenharmony_ci - ``reserved``\ [5] 7062306a36Sopenharmony_ci - Reserved for future extensions. Drivers and applications must set 7162306a36Sopenharmony_ci the array to zero. 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci.. tabularcolumns:: |p{7.5cm}|p{2.0cm}|p{7.8cm}| 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci.. _event-flags: 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci.. flat-table:: Event Flags 7962306a36Sopenharmony_ci :header-rows: 0 8062306a36Sopenharmony_ci :stub-columns: 0 8162306a36Sopenharmony_ci :widths: 3 1 4 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci * - ``V4L2_EVENT_SUB_FL_SEND_INITIAL`` 8462306a36Sopenharmony_ci - 0x0001 8562306a36Sopenharmony_ci - When this event is subscribed an initial event will be sent 8662306a36Sopenharmony_ci containing the current status. This only makes sense for events 8762306a36Sopenharmony_ci that are triggered by a status change such as ``V4L2_EVENT_CTRL``. 8862306a36Sopenharmony_ci Other events will ignore this flag. 8962306a36Sopenharmony_ci * - ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK`` 9062306a36Sopenharmony_ci - 0x0002 9162306a36Sopenharmony_ci - If set, then events directly caused by an ioctl will also be sent 9262306a36Sopenharmony_ci to the filehandle that called that ioctl. For example, changing a 9362306a36Sopenharmony_ci control using :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` will cause 9462306a36Sopenharmony_ci a V4L2_EVENT_CTRL to be sent back to that same filehandle. 9562306a36Sopenharmony_ci Normally such events are suppressed to prevent feedback loops 9662306a36Sopenharmony_ci where an application changes a control to a one value and then 9762306a36Sopenharmony_ci another, and then receives an event telling it that that control 9862306a36Sopenharmony_ci has changed to the first value. 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci Since it can't tell whether that event was caused by another 10162306a36Sopenharmony_ci application or by the :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` 10262306a36Sopenharmony_ci call it is hard to decide whether to set the control to the value 10362306a36Sopenharmony_ci in the event, or ignore it. 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci Think carefully when you set this flag so you won't get into 10662306a36Sopenharmony_ci situations like that. 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ciReturn Value 10962306a36Sopenharmony_ci============ 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ciOn success 0 is returned, on error -1 and the ``errno`` variable is set 11262306a36Sopenharmony_ciappropriately. The generic error codes are described at the 11362306a36Sopenharmony_ci:ref:`Generic Error Codes <gen-errors>` chapter. 114