vidioc-subscribe-event.rst 3.2 KB

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