Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux...
[sfrench/cifs-2.6.git] / Documentation / DocBook / media / v4l / vidioc-subscribe-event.xml
1 <refentry id="vidioc-subscribe-event">
2   <refmeta>
3     <refentrytitle>ioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT</refentrytitle>
4     &manvol;
5   </refmeta>
6
7   <refnamediv>
8     <refname>VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT</refname>
9     <refpurpose>Subscribe or unsubscribe event</refpurpose>
10   </refnamediv>
11
12   <refsynopsisdiv>
13     <funcsynopsis>
14       <funcprototype>
15         <funcdef>int <function>ioctl</function></funcdef>
16         <paramdef>int <parameter>fd</parameter></paramdef>
17         <paramdef>int <parameter>request</parameter></paramdef>
18         <paramdef>struct v4l2_event_subscription
19 *<parameter>argp</parameter></paramdef>
20       </funcprototype>
21     </funcsynopsis>
22   </refsynopsisdiv>
23
24   <refsect1>
25     <title>Arguments</title>
26
27     <variablelist>
28       <varlistentry>
29         <term><parameter>fd</parameter></term>
30         <listitem>
31           <para>&fd;</para>
32         </listitem>
33       </varlistentry>
34       <varlistentry>
35         <term><parameter>request</parameter></term>
36         <listitem>
37           <para>VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT</para>
38         </listitem>
39       </varlistentry>
40       <varlistentry>
41         <term><parameter>argp</parameter></term>
42         <listitem>
43           <para></para>
44         </listitem>
45       </varlistentry>
46     </variablelist>
47   </refsect1>
48
49   <refsect1>
50     <title>Description</title>
51
52     <para>Subscribe or unsubscribe V4L2 event. Subscribed events are
53     dequeued by using the &VIDIOC-DQEVENT; ioctl.</para>
54
55     <table frame="none" pgwide="1" id="v4l2-event-subscription">
56       <title>struct <structname>v4l2_event_subscription</structname></title>
57       <tgroup cols="3">
58         &cs-str;
59         <tbody valign="top">
60           <row>
61             <entry>__u32</entry>
62             <entry><structfield>type</structfield></entry>
63             <entry>Type of the event.</entry>
64           </row>
65           <row>
66             <entry>__u32</entry>
67             <entry><structfield>id</structfield></entry>
68             <entry>ID of the event source. If there is no ID associated with
69                 the event source, then set this to 0. Whether or not an event
70                 needs an ID depends on the event type.</entry>
71           </row>
72           <row>
73             <entry>__u32</entry>
74             <entry><structfield>flags</structfield></entry>
75             <entry>Event flags, see <xref linkend="event-flags" />.</entry>
76           </row>
77           <row>
78             <entry>__u32</entry>
79             <entry><structfield>reserved</structfield>[5]</entry>
80             <entry>Reserved for future extensions. Drivers and applications
81             must set the array to zero.</entry>
82           </row>
83         </tbody>
84       </tgroup>
85     </table>
86
87     <table frame="none" pgwide="1" id="event-type">
88       <title>Event Types</title>
89       <tgroup cols="3">
90         &cs-def;
91         <tbody valign="top">
92           <row>
93             <entry><constant>V4L2_EVENT_ALL</constant></entry>
94             <entry>0</entry>
95             <entry>All events. V4L2_EVENT_ALL is valid only for
96             VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
97             </entry>
98           </row>
99           <row>
100             <entry><constant>V4L2_EVENT_VSYNC</constant></entry>
101             <entry>1</entry>
102             <entry>This event is triggered on the vertical sync.
103             This event has a &v4l2-event-vsync; associated with it.
104             </entry>
105           </row>
106           <row>
107             <entry><constant>V4L2_EVENT_EOS</constant></entry>
108             <entry>2</entry>
109             <entry>This event is triggered when the end of a stream is reached.
110             This is typically used with MPEG decoders to report to the application
111             when the last of the MPEG stream has been decoded.
112             </entry>
113           </row>
114           <row>
115             <entry><constant>V4L2_EVENT_CTRL</constant></entry>
116             <entry>3</entry>
117             <entry><para>This event requires that the <structfield>id</structfield>
118                 matches the control ID from which you want to receive events.
119                 This event is triggered if the control's value changes, if a
120                 button control is pressed or if the control's flags change.
121                 This event has a &v4l2-event-ctrl; associated with it. This struct
122                 contains much of the same information as &v4l2-queryctrl; and
123                 &v4l2-control;.</para>
124
125                 <para>If the event is generated due to a call to &VIDIOC-S-CTRL; or
126                 &VIDIOC-S-EXT-CTRLS;, then the event will <emphasis>not</emphasis> be sent to
127                 the file handle that called the ioctl function. This prevents
128                 nasty feedback loops. If you <emphasis>do</emphasis> want to get the
129                 event, then set the <constant>V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK</constant>
130                 flag.
131                 </para>
132
133                 <para>This event type will ensure that no information is lost when
134                 more events are raised than there is room internally. In that
135                 case the &v4l2-event-ctrl; of the second-oldest event is kept,
136                 but the <structfield>changes</structfield> field of the
137                 second-oldest event is ORed with the <structfield>changes</structfield>
138                 field of the oldest event.</para>
139             </entry>
140           </row>
141           <row>
142             <entry><constant>V4L2_EVENT_FRAME_SYNC</constant></entry>
143             <entry>4</entry>
144             <entry>
145               <para>Triggered immediately when the reception of a
146               frame has begun. This event has a
147               &v4l2-event-frame-sync; associated with it.</para>
148
149               <para>If the hardware needs to be stopped in the case of a
150               buffer underrun it might not be able to generate this event.
151               In such cases the <structfield>frame_sequence</structfield>
152               field in &v4l2-event-frame-sync; will not be incremented. This
153               causes two consecutive frame sequence numbers to have n times
154               frame interval in between them.</para>
155             </entry>
156           </row>
157           <row>
158             <entry><constant>V4L2_EVENT_SOURCE_CHANGE</constant></entry>
159             <entry>5</entry>
160             <entry>
161               <para>This event is triggered when a source parameter change is
162                detected during runtime by the video device. It can be a
163                runtime resolution change triggered by a video decoder or the
164                format change happening on an input connector.
165                This event requires that the <structfield>id</structfield>
166                matches the input index (when used with a video device node)
167                or the pad index (when used with a subdevice node) from which
168                you want to receive events.</para>
169
170               <para>This event has a &v4l2-event-src-change; associated
171               with it. The <structfield>changes</structfield> bitfield denotes
172               what has changed for the subscribed pad. If multiple events
173               occurred before application could dequeue them, then the changes
174               will have the ORed value of all the events generated.</para>
175             </entry>
176           </row>
177           <row>
178             <entry><constant>V4L2_EVENT_MOTION_DET</constant></entry>
179             <entry>6</entry>
180             <entry>
181               <para>Triggered whenever the motion detection state for one or more of the regions
182               changes. This event has a &v4l2-event-motion-det; associated with it.</para>
183             </entry>
184           </row>
185           <row>
186             <entry><constant>V4L2_EVENT_PRIVATE_START</constant></entry>
187             <entry>0x08000000</entry>
188             <entry>Base event number for driver-private events.</entry>
189           </row>
190         </tbody>
191       </tgroup>
192     </table>
193
194     <table pgwide="1" frame="none" id="event-flags">
195       <title>Event Flags</title>
196       <tgroup cols="3">
197         &cs-def;
198         <tbody valign="top">
199           <row>
200             <entry><constant>V4L2_EVENT_SUB_FL_SEND_INITIAL</constant></entry>
201             <entry>0x0001</entry>
202             <entry>When this event is subscribed an initial event will be sent
203                 containing the current status. This only makes sense for events
204                 that are triggered by a status change such as <constant>V4L2_EVENT_CTRL</constant>.
205                 Other events will ignore this flag.</entry>
206           </row>
207           <row>
208             <entry><constant>V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK</constant></entry>
209             <entry>0x0002</entry>
210             <entry><para>If set, then events directly caused by an ioctl will also be sent to
211                 the filehandle that called that ioctl. For example, changing a control using
212                 &VIDIOC-S-CTRL; will cause a V4L2_EVENT_CTRL to be sent back to that same
213                 filehandle. Normally such events are suppressed to prevent feedback loops
214                 where an application changes a control to a one value and then another, and
215                 then receives an event telling it that that control has changed to the first
216                 value.</para>
217
218                 <para>Since it can't tell whether that event was caused by another application
219                 or by the &VIDIOC-S-CTRL; call it is hard to decide whether to set the
220                 control to the value in the event, or ignore it.</para>
221
222                 <para>Think carefully when you set this flag so you won't get into situations
223                 like that.</para>
224             </entry>
225           </row>
226         </tbody>
227       </tgroup>
228     </table>
229
230   </refsect1>
231   <refsect1>
232     &return-value;
233   </refsect1>
234 </refentry>