blob: 3f28e8c4796055de935b979d3f7a9aa5eacb7f98 [file] [log] [blame]
Markus Heiser5377d912016-06-30 15:18:56 +02001.. -*- coding: utf-8; mode: rst -*-
2
Mauro Carvalho Chehabaf4a4d02016-07-01 13:42:29 -03003.. _VIDIOC_SUBSCRIBE_EVENT:
Mauro Carvalho Chehab6710ea42016-07-13 09:11:12 -03004.. _VIDIOC_UNSUBSCRIBE_EVENT:
Markus Heiser5377d912016-06-30 15:18:56 +02005
6******************************************************
7ioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT
8******************************************************
9
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030010Name
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030011====
Markus Heiser5377d912016-06-30 15:18:56 +020012
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030013VIDIOC_SUBSCRIBE_EVENT - VIDIOC_UNSUBSCRIBE_EVENT - Subscribe or unsubscribe event
Markus Heiser5377d912016-06-30 15:18:56 +020014
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030015
16Synopsis
Markus Heiser5377d912016-06-30 15:18:56 +020017========
18
Mauro Carvalho Chehabb7e67f62016-07-02 09:49:16 -030019.. cpp:function:: int ioctl( int fd, int request, struct v4l2_event_subscription *argp )
Markus Heiser5377d912016-06-30 15:18:56 +020020
Mauro Carvalho Chehab586027c2016-07-05 07:58:48 -030021
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030022Arguments
Markus Heiser5377d912016-06-30 15:18:56 +020023=========
24
25``fd``
26 File descriptor returned by :ref:`open() <func-open>`.
27
28``request``
29 VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT
30
31``argp``
32
33
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -030034Description
Markus Heiser5377d912016-06-30 15:18:56 +020035===========
36
37Subscribe or unsubscribe V4L2 event. Subscribed events are dequeued by
Mauro Carvalho Chehab73470812016-07-01 13:58:44 -030038using the :ref:`VIDIOC_DQEVENT` ioctl.
Markus Heiser5377d912016-06-30 15:18:56 +020039
40
41.. _v4l2-event-subscription:
42
43.. flat-table:: struct v4l2_event_subscription
44 :header-rows: 0
45 :stub-columns: 0
46 :widths: 1 1 2
47
48
49 - .. row 1
50
51 - __u32
52
53 - ``type``
54
Mauro Carvalho Chehab706f8a92016-07-10 11:57:43 -030055 - Type of the event, see :ref:`event-type`.
56
57 .. note:: ``V4L2_EVENT_ALL`` can be used with
Mauro Carvalho Chehab6710ea42016-07-13 09:11:12 -030058 :ref:`VIDIOC_UNSUBSCRIBE_EVENT <VIDIOC_SUBSCRIBE_EVENT>` for
59 unsubscribing all events at once.
Markus Heiser5377d912016-06-30 15:18:56 +020060
61 - .. row 2
62
63 - __u32
64
65 - ``id``
66
67 - ID of the event source. If there is no ID associated with the
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030068 event source, then set this to 0. Whether or not an event needs an
69 ID depends on the event type.
Markus Heiser5377d912016-06-30 15:18:56 +020070
71 - .. row 3
72
73 - __u32
74
75 - ``flags``
76
77 - Event flags, see :ref:`event-flags`.
78
79 - .. row 4
80
81 - __u32
82
Mauro Carvalho Chehab8968da92016-07-13 08:43:30 -030083 - ``reserved``\ [5]
Markus Heiser5377d912016-06-30 15:18:56 +020084
85 - Reserved for future extensions. Drivers and applications must set
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -030086 the array to zero.
Markus Heiser5377d912016-06-30 15:18:56 +020087
88
89
90.. _event-flags:
91
92.. flat-table:: Event Flags
93 :header-rows: 0
94 :stub-columns: 0
95 :widths: 3 1 4
96
97
98 - .. row 1
99
100 - ``V4L2_EVENT_SUB_FL_SEND_INITIAL``
101
102 - 0x0001
103
104 - When this event is subscribed an initial event will be sent
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300105 containing the current status. This only makes sense for events
106 that are triggered by a status change such as ``V4L2_EVENT_CTRL``.
107 Other events will ignore this flag.
Markus Heiser5377d912016-06-30 15:18:56 +0200108
109 - .. row 2
110
111 - ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``
112
113 - 0x0002
114
115 - If set, then events directly caused by an ioctl will also be sent
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300116 to the filehandle that called that ioctl. For example, changing a
117 control using :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` will cause
118 a V4L2_EVENT_CTRL to be sent back to that same filehandle.
119 Normally such events are suppressed to prevent feedback loops
120 where an application changes a control to a one value and then
121 another, and then receives an event telling it that that control
122 has changed to the first value.
Markus Heiser5377d912016-06-30 15:18:56 +0200123
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300124 Since it can't tell whether that event was caused by another
125 application or by the :ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>`
126 call it is hard to decide whether to set the control to the value
127 in the event, or ignore it.
Markus Heiser5377d912016-06-30 15:18:56 +0200128
Mauro Carvalho Chehab0579e6e2016-07-04 16:25:48 -0300129 Think carefully when you set this flag so you won't get into
130 situations like that.
Markus Heiser5377d912016-06-30 15:18:56 +0200131
132
Mauro Carvalho Chehab15e7d612016-07-05 15:14:35 -0300133Return Value
Markus Heiser5377d912016-06-30 15:18:56 +0200134============
135
136On success 0 is returned, on error -1 and the ``errno`` variable is set
137appropriately. The generic error codes are described at the
138:ref:`Generic Error Codes <gen-errors>` chapter.