^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) .. c:namespace:: V4L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) .. _VIDIOC_SUBSCRIBE_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) .. _VIDIOC_UNSUBSCRIBE_EVENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ******************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) ioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) ******************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) Name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) VIDIOC_SUBSCRIBE_EVENT - VIDIOC_UNSUBSCRIBE_EVENT - Subscribe or unsubscribe event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) Synopsis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) .. c:macro:: VIDIOC_SUBSCRIBE_EVENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) ``int ioctl(int fd, VIDIOC_SUBSCRIBE_EVENT, struct v4l2_event_subscription *argp)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) .. c:macro:: VIDIOC_UNSUBSCRIBE_EVENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) ``int ioctl(int fd, VIDIOC_UNSUBSCRIBE_EVENT, struct v4l2_event_subscription *argp)``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) Arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) =========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ``fd``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) File descriptor returned by :c:func:`open()`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) ``argp``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) Pointer to struct :c:type:`v4l2_event_subscription`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) Subscribe or unsubscribe V4L2 event. Subscribed events are dequeued by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) using the :ref:`VIDIOC_DQEVENT` ioctl.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) .. tabularcolumns:: |p{4.6cm}|p{4.4cm}|p{8.7cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) .. c:type:: v4l2_event_subscription
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) .. flat-table:: struct v4l2_event_subscription
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) :header-rows: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) :widths: 1 1 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) - ``type``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) - Type of the event, see :ref:`event-type`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) .. note::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ``V4L2_EVENT_ALL`` can be used with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) :ref:`VIDIOC_UNSUBSCRIBE_EVENT <VIDIOC_SUBSCRIBE_EVENT>` for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) unsubscribing all events at once.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) - ``id``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) - ID of the event source. If there is no ID associated with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) event source, then set this to 0. Whether or not an event needs an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ID depends on the event type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) - ``flags``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) - Event flags, see :ref:`event-flags`.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * - __u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) - ``reserved``\ [5]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) - Reserved for future extensions. Drivers and applications must set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) the array to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) .. tabularcolumns:: |p{6.8cm}|p{2.2cm}|p{8.5cm}|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) .. _event-flags:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) .. flat-table:: Event Flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) :header-rows: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) :stub-columns: 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) :widths: 3 1 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * - ``V4L2_EVENT_SUB_FL_SEND_INITIAL``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) - 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) - When this event is subscribed an initial event will be sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) containing the current status. This only makes sense for events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) that are triggered by a status change such as ``V4L2_EVENT_CTRL``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) Other events will ignore this flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * - ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) - 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) - If set, then events directly caused by an ioctl will also be sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) to the filehandle that called that ioctl. For example, changing a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) control using :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` will cause
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) a V4L2_EVENT_CTRL to be sent back to that same filehandle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) Normally such events are suppressed to prevent feedback loops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) where an application changes a control to a one value and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) another, and then receives an event telling it that that control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) has changed to the first value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) Since it can't tell whether that event was caused by another
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) application or by the :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) call it is hard to decide whether to set the control to the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) in the event, or ignore it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) Think carefully when you set this flag so you won't get into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) situations like that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) Return Value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) On success 0 is returned, on error -1 and the ``errno`` variable is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) appropriately. The generic error codes are described at the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) :ref:`Generic Error Codes <gen-errors>` chapter.