Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
v4l2-ioctl.h
Go to the documentation of this file.
1 /*
2  *
3  * V 4 L 2 D R I V E R H E L P E R A P I
4  *
5  * Moved from videodev2.h
6  *
7  * Some commonly needed functions for drivers (v4l2-common.o module)
8  */
9 #ifndef _V4L2_IOCTL_H
10 #define _V4L2_IOCTL_H
11 
12 #include <linux/poll.h>
13 #include <linux/fs.h>
14 #include <linux/mutex.h>
15 #include <linux/compiler.h> /* need __user */
16 #include <linux/videodev2.h>
17 
18 struct v4l2_fh;
19 
21  /* ioctl callbacks */
22 
23  /* VIDIOC_QUERYCAP handler */
24  int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap);
25 
26  /* Priority handling */
27  int (*vidioc_g_priority) (struct file *file, void *fh,
28  enum v4l2_priority *p);
29  int (*vidioc_s_priority) (struct file *file, void *fh,
30  enum v4l2_priority p);
31 
32  /* VIDIOC_ENUM_FMT handlers */
33  int (*vidioc_enum_fmt_vid_cap) (struct file *file, void *fh,
34  struct v4l2_fmtdesc *f);
35  int (*vidioc_enum_fmt_vid_overlay) (struct file *file, void *fh,
36  struct v4l2_fmtdesc *f);
37  int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh,
38  struct v4l2_fmtdesc *f);
40  struct v4l2_fmtdesc *f);
42  struct v4l2_fmtdesc *f);
43 
44  /* VIDIOC_G_FMT handlers */
45  int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh,
46  struct v4l2_format *f);
47  int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
48  struct v4l2_format *f);
49  int (*vidioc_g_fmt_vid_out) (struct file *file, void *fh,
50  struct v4l2_format *f);
51  int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
52  struct v4l2_format *f);
53  int (*vidioc_g_fmt_vbi_cap) (struct file *file, void *fh,
54  struct v4l2_format *f);
55  int (*vidioc_g_fmt_vbi_out) (struct file *file, void *fh,
56  struct v4l2_format *f);
57  int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
58  struct v4l2_format *f);
59  int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
60  struct v4l2_format *f);
61  int (*vidioc_g_fmt_vid_cap_mplane)(struct file *file, void *fh,
62  struct v4l2_format *f);
63  int (*vidioc_g_fmt_vid_out_mplane)(struct file *file, void *fh,
64  struct v4l2_format *f);
65 
66  /* VIDIOC_S_FMT handlers */
67  int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh,
68  struct v4l2_format *f);
69  int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
70  struct v4l2_format *f);
71  int (*vidioc_s_fmt_vid_out) (struct file *file, void *fh,
72  struct v4l2_format *f);
73  int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
74  struct v4l2_format *f);
75  int (*vidioc_s_fmt_vbi_cap) (struct file *file, void *fh,
76  struct v4l2_format *f);
77  int (*vidioc_s_fmt_vbi_out) (struct file *file, void *fh,
78  struct v4l2_format *f);
79  int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
80  struct v4l2_format *f);
81  int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
82  struct v4l2_format *f);
83  int (*vidioc_s_fmt_vid_cap_mplane)(struct file *file, void *fh,
84  struct v4l2_format *f);
85  int (*vidioc_s_fmt_vid_out_mplane)(struct file *file, void *fh,
86  struct v4l2_format *f);
87 
88  /* VIDIOC_TRY_FMT handlers */
89  int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
90  struct v4l2_format *f);
91  int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
92  struct v4l2_format *f);
93  int (*vidioc_try_fmt_vid_out) (struct file *file, void *fh,
94  struct v4l2_format *f);
96  struct v4l2_format *f);
97  int (*vidioc_try_fmt_vbi_cap) (struct file *file, void *fh,
98  struct v4l2_format *f);
99  int (*vidioc_try_fmt_vbi_out) (struct file *file, void *fh,
100  struct v4l2_format *f);
102  struct v4l2_format *f);
104  struct v4l2_format *f);
106  struct v4l2_format *f);
108  struct v4l2_format *f);
109 
110  /* Buffer handlers */
111  int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
112  int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b);
113  int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
114  int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
115 
116  int (*vidioc_create_bufs)(struct file *file, void *fh, struct v4l2_create_buffers *b);
117  int (*vidioc_prepare_buf)(struct file *file, void *fh, struct v4l2_buffer *b);
118 
119  int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
120  int (*vidioc_g_fbuf) (struct file *file, void *fh,
121  struct v4l2_framebuffer *a);
122  int (*vidioc_s_fbuf) (struct file *file, void *fh,
123  const struct v4l2_framebuffer *a);
124 
125  /* Stream on/off */
126  int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i);
127  int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
128 
129  /* Standard handling
130  ENUMSTD is handled by videodev.c
131  */
132  int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm);
133  int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id *norm);
134  int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
135 
136  /* Input handling */
137  int (*vidioc_enum_input)(struct file *file, void *fh,
138  struct v4l2_input *inp);
139  int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i);
140  int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i);
141 
142  /* Output handling */
143  int (*vidioc_enum_output) (struct file *file, void *fh,
144  struct v4l2_output *a);
145  int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i);
146  int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i);
147 
148  /* Control handling */
149  int (*vidioc_queryctrl) (struct file *file, void *fh,
150  struct v4l2_queryctrl *a);
151  int (*vidioc_g_ctrl) (struct file *file, void *fh,
152  struct v4l2_control *a);
153  int (*vidioc_s_ctrl) (struct file *file, void *fh,
154  struct v4l2_control *a);
155  int (*vidioc_g_ext_ctrls) (struct file *file, void *fh,
156  struct v4l2_ext_controls *a);
157  int (*vidioc_s_ext_ctrls) (struct file *file, void *fh,
158  struct v4l2_ext_controls *a);
159  int (*vidioc_try_ext_ctrls) (struct file *file, void *fh,
160  struct v4l2_ext_controls *a);
161  int (*vidioc_querymenu) (struct file *file, void *fh,
162  struct v4l2_querymenu *a);
163 
164  /* Audio ioctls */
165  int (*vidioc_enumaudio) (struct file *file, void *fh,
166  struct v4l2_audio *a);
167  int (*vidioc_g_audio) (struct file *file, void *fh,
168  struct v4l2_audio *a);
169  int (*vidioc_s_audio) (struct file *file, void *fh,
170  const struct v4l2_audio *a);
171 
172  /* Audio out ioctls */
173  int (*vidioc_enumaudout) (struct file *file, void *fh,
174  struct v4l2_audioout *a);
175  int (*vidioc_g_audout) (struct file *file, void *fh,
176  struct v4l2_audioout *a);
177  int (*vidioc_s_audout) (struct file *file, void *fh,
178  const struct v4l2_audioout *a);
179  int (*vidioc_g_modulator) (struct file *file, void *fh,
180  struct v4l2_modulator *a);
181  int (*vidioc_s_modulator) (struct file *file, void *fh,
182  const struct v4l2_modulator *a);
183  /* Crop ioctls */
184  int (*vidioc_cropcap) (struct file *file, void *fh,
185  struct v4l2_cropcap *a);
186  int (*vidioc_g_crop) (struct file *file, void *fh,
187  struct v4l2_crop *a);
188  int (*vidioc_s_crop) (struct file *file, void *fh,
189  const struct v4l2_crop *a);
190  int (*vidioc_g_selection) (struct file *file, void *fh,
191  struct v4l2_selection *s);
192  int (*vidioc_s_selection) (struct file *file, void *fh,
193  struct v4l2_selection *s);
194  /* Compression ioctls */
195  int (*vidioc_g_jpegcomp) (struct file *file, void *fh,
196  struct v4l2_jpegcompression *a);
197  int (*vidioc_s_jpegcomp) (struct file *file, void *fh,
198  const struct v4l2_jpegcompression *a);
199  int (*vidioc_g_enc_index) (struct file *file, void *fh,
200  struct v4l2_enc_idx *a);
201  int (*vidioc_encoder_cmd) (struct file *file, void *fh,
202  struct v4l2_encoder_cmd *a);
203  int (*vidioc_try_encoder_cmd) (struct file *file, void *fh,
204  struct v4l2_encoder_cmd *a);
205  int (*vidioc_decoder_cmd) (struct file *file, void *fh,
206  struct v4l2_decoder_cmd *a);
207  int (*vidioc_try_decoder_cmd) (struct file *file, void *fh,
208  struct v4l2_decoder_cmd *a);
209 
210  /* Stream type-dependent parameter ioctls */
211  int (*vidioc_g_parm) (struct file *file, void *fh,
212  struct v4l2_streamparm *a);
213  int (*vidioc_s_parm) (struct file *file, void *fh,
214  struct v4l2_streamparm *a);
215 
216  /* Tuner ioctls */
217  int (*vidioc_g_tuner) (struct file *file, void *fh,
218  struct v4l2_tuner *a);
219  int (*vidioc_s_tuner) (struct file *file, void *fh,
220  struct v4l2_tuner *a);
221  int (*vidioc_g_frequency) (struct file *file, void *fh,
222  struct v4l2_frequency *a);
223  int (*vidioc_s_frequency) (struct file *file, void *fh,
224  struct v4l2_frequency *a);
225  int (*vidioc_enum_freq_bands) (struct file *file, void *fh,
226  struct v4l2_frequency_band *band);
227 
228  /* Sliced VBI cap */
229  int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh,
230  struct v4l2_sliced_vbi_cap *a);
231 
232  /* Log status ioctl */
233  int (*vidioc_log_status) (struct file *file, void *fh);
234 
235  int (*vidioc_s_hw_freq_seek) (struct file *file, void *fh,
236  const struct v4l2_hw_freq_seek *a);
237 
238  /* Debugging ioctls */
239 #ifdef CONFIG_VIDEO_ADV_DEBUG
240  int (*vidioc_g_register) (struct file *file, void *fh,
241  struct v4l2_dbg_register *reg);
242  int (*vidioc_s_register) (struct file *file, void *fh,
243  struct v4l2_dbg_register *reg);
244 #endif
245  int (*vidioc_g_chip_ident) (struct file *file, void *fh,
246  struct v4l2_dbg_chip_ident *chip);
247 
248  int (*vidioc_enum_framesizes) (struct file *file, void *fh,
249  struct v4l2_frmsizeenum *fsize);
250 
251  int (*vidioc_enum_frameintervals) (struct file *file, void *fh,
252  struct v4l2_frmivalenum *fival);
253 
254  /* DV Timings IOCTLs */
255  int (*vidioc_enum_dv_presets) (struct file *file, void *fh,
256  struct v4l2_dv_enum_preset *preset);
257 
258  int (*vidioc_s_dv_preset) (struct file *file, void *fh,
259  struct v4l2_dv_preset *preset);
260  int (*vidioc_g_dv_preset) (struct file *file, void *fh,
261  struct v4l2_dv_preset *preset);
262  int (*vidioc_query_dv_preset) (struct file *file, void *fh,
263  struct v4l2_dv_preset *qpreset);
264  int (*vidioc_s_dv_timings) (struct file *file, void *fh,
265  struct v4l2_dv_timings *timings);
266  int (*vidioc_g_dv_timings) (struct file *file, void *fh,
267  struct v4l2_dv_timings *timings);
268  int (*vidioc_query_dv_timings) (struct file *file, void *fh,
269  struct v4l2_dv_timings *timings);
270  int (*vidioc_enum_dv_timings) (struct file *file, void *fh,
271  struct v4l2_enum_dv_timings *timings);
272  int (*vidioc_dv_timings_cap) (struct file *file, void *fh,
273  struct v4l2_dv_timings_cap *cap);
274 
276  const struct v4l2_event_subscription *sub);
278  const struct v4l2_event_subscription *sub);
279 
280  /* For other private ioctls */
281  long (*vidioc_default) (struct file *file, void *fh,
282  bool valid_prio, int cmd, void *arg);
283 };
284 
285 
286 /* v4l debugging and diagnostics */
287 
288 /* Debug bitmask flags to be used on V4L2 */
289 #define V4L2_DEBUG_IOCTL 0x01
290 #define V4L2_DEBUG_IOCTL_ARG 0x02
291 
292 /* Video standard functions */
293 extern const char *v4l2_norm_to_name(v4l2_std_id id);
294 extern void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod);
295 extern int v4l2_video_std_construct(struct v4l2_standard *vs,
296  int id, const char *name);
297 /* Prints the ioctl in a human-readable format. If prefix != NULL,
298  then do printk(KERN_DEBUG "%s: ", prefix) first. */
299 extern void v4l_printk_ioctl(const char *prefix, unsigned int cmd);
300 
301 /* Internal use only: get the mutex (if any) that we need to lock for the
302  given command. */
303 struct video_device;
304 extern struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev, unsigned cmd);
305 
306 /* names for fancy debug output */
307 extern const char *v4l2_field_names[];
308 extern const char *v4l2_type_names[];
309 
310 #ifdef CONFIG_COMPAT
311 /* 32 Bits compatibility layer for 64 bits processors */
312 extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd,
313  unsigned long arg);
314 #endif
315 
316 typedef long (*v4l2_kioctl)(struct file *file,
317  unsigned int cmd, void *arg);
318 
319 /* Include support for obsoleted stuff */
320 extern long video_usercopy(struct file *file, unsigned int cmd,
321  unsigned long arg, v4l2_kioctl func);
322 
323 /* Standard handlers for V4L ioctl's */
324 extern long video_ioctl2(struct file *file,
325  unsigned int cmd, unsigned long arg);
326 
327 #endif /* _V4L2_IOCTL_H */