blob: 67df37542c68d5d9607719d6517d243c9e317505 [file] [log] [blame]
Hans Verkuil35ea11f2008-07-20 08:12:02 -03001/*
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/device.h>
15#include <linux/mutex.h>
16#include <linux/compiler.h> /* need __user */
Hans Verkuil35ea11f2008-07-20 08:12:02 -030017#include <linux/videodev2.h>
Hans Verkuil35ea11f2008-07-20 08:12:02 -030018
Sakari Ailusd3d7c962010-03-27 11:02:10 -030019struct v4l2_fh;
20
Hans Verkuila3998102008-07-21 02:57:38 -030021struct v4l2_ioctl_ops {
22 /* ioctl callbacks */
23
24 /* VIDIOC_QUERYCAP handler */
25 int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap);
26
27 /* Priority handling */
28 int (*vidioc_g_priority) (struct file *file, void *fh,
29 enum v4l2_priority *p);
30 int (*vidioc_s_priority) (struct file *file, void *fh,
31 enum v4l2_priority p);
32
33 /* VIDIOC_ENUM_FMT handlers */
34 int (*vidioc_enum_fmt_vid_cap) (struct file *file, void *fh,
35 struct v4l2_fmtdesc *f);
36 int (*vidioc_enum_fmt_vid_overlay) (struct file *file, void *fh,
37 struct v4l2_fmtdesc *f);
38 int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh,
39 struct v4l2_fmtdesc *f);
Hans Verkuila3998102008-07-21 02:57:38 -030040 int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh,
41 struct v4l2_fmtdesc *f);
42
43 /* VIDIOC_G_FMT handlers */
44 int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh,
45 struct v4l2_format *f);
46 int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
47 struct v4l2_format *f);
48 int (*vidioc_g_fmt_vid_out) (struct file *file, void *fh,
49 struct v4l2_format *f);
50 int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
51 struct v4l2_format *f);
52 int (*vidioc_g_fmt_vbi_cap) (struct file *file, void *fh,
53 struct v4l2_format *f);
54 int (*vidioc_g_fmt_vbi_out) (struct file *file, void *fh,
55 struct v4l2_format *f);
56 int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
57 struct v4l2_format *f);
58 int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
59 struct v4l2_format *f);
60 int (*vidioc_g_fmt_type_private)(struct file *file, void *fh,
61 struct v4l2_format *f);
62
63 /* VIDIOC_S_FMT handlers */
64 int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh,
65 struct v4l2_format *f);
66 int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh,
67 struct v4l2_format *f);
68 int (*vidioc_s_fmt_vid_out) (struct file *file, void *fh,
69 struct v4l2_format *f);
70 int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh,
71 struct v4l2_format *f);
72 int (*vidioc_s_fmt_vbi_cap) (struct file *file, void *fh,
73 struct v4l2_format *f);
74 int (*vidioc_s_fmt_vbi_out) (struct file *file, void *fh,
75 struct v4l2_format *f);
76 int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh,
77 struct v4l2_format *f);
78 int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh,
79 struct v4l2_format *f);
80 int (*vidioc_s_fmt_type_private)(struct file *file, void *fh,
81 struct v4l2_format *f);
82
83 /* VIDIOC_TRY_FMT handlers */
84 int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
85 struct v4l2_format *f);
86 int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
87 struct v4l2_format *f);
88 int (*vidioc_try_fmt_vid_out) (struct file *file, void *fh,
89 struct v4l2_format *f);
90 int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
91 struct v4l2_format *f);
92 int (*vidioc_try_fmt_vbi_cap) (struct file *file, void *fh,
93 struct v4l2_format *f);
94 int (*vidioc_try_fmt_vbi_out) (struct file *file, void *fh,
95 struct v4l2_format *f);
96 int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
97 struct v4l2_format *f);
98 int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
99 struct v4l2_format *f);
100 int (*vidioc_try_fmt_type_private)(struct file *file, void *fh,
101 struct v4l2_format *f);
102
103 /* Buffer handlers */
104 int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
105 int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b);
106 int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
107 int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
108
109
110 int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
Hans Verkuila3998102008-07-21 02:57:38 -0300111 int (*vidioc_g_fbuf) (struct file *file, void *fh,
112 struct v4l2_framebuffer *a);
113 int (*vidioc_s_fbuf) (struct file *file, void *fh,
114 struct v4l2_framebuffer *a);
115
116 /* Stream on/off */
117 int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i);
118 int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
119
120 /* Standard handling
121 ENUMSTD is handled by videodev.c
122 */
123 int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm);
124 int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id *norm);
125 int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
126
127 /* Input handling */
128 int (*vidioc_enum_input)(struct file *file, void *fh,
129 struct v4l2_input *inp);
130 int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i);
131 int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i);
132
133 /* Output handling */
134 int (*vidioc_enum_output) (struct file *file, void *fh,
135 struct v4l2_output *a);
136 int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i);
137 int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i);
138
139 /* Control handling */
140 int (*vidioc_queryctrl) (struct file *file, void *fh,
141 struct v4l2_queryctrl *a);
142 int (*vidioc_g_ctrl) (struct file *file, void *fh,
143 struct v4l2_control *a);
144 int (*vidioc_s_ctrl) (struct file *file, void *fh,
145 struct v4l2_control *a);
146 int (*vidioc_g_ext_ctrls) (struct file *file, void *fh,
147 struct v4l2_ext_controls *a);
148 int (*vidioc_s_ext_ctrls) (struct file *file, void *fh,
149 struct v4l2_ext_controls *a);
150 int (*vidioc_try_ext_ctrls) (struct file *file, void *fh,
151 struct v4l2_ext_controls *a);
152 int (*vidioc_querymenu) (struct file *file, void *fh,
153 struct v4l2_querymenu *a);
154
155 /* Audio ioctls */
156 int (*vidioc_enumaudio) (struct file *file, void *fh,
157 struct v4l2_audio *a);
158 int (*vidioc_g_audio) (struct file *file, void *fh,
159 struct v4l2_audio *a);
160 int (*vidioc_s_audio) (struct file *file, void *fh,
161 struct v4l2_audio *a);
162
163 /* Audio out ioctls */
164 int (*vidioc_enumaudout) (struct file *file, void *fh,
165 struct v4l2_audioout *a);
166 int (*vidioc_g_audout) (struct file *file, void *fh,
167 struct v4l2_audioout *a);
168 int (*vidioc_s_audout) (struct file *file, void *fh,
169 struct v4l2_audioout *a);
170 int (*vidioc_g_modulator) (struct file *file, void *fh,
171 struct v4l2_modulator *a);
172 int (*vidioc_s_modulator) (struct file *file, void *fh,
173 struct v4l2_modulator *a);
174 /* Crop ioctls */
175 int (*vidioc_cropcap) (struct file *file, void *fh,
176 struct v4l2_cropcap *a);
177 int (*vidioc_g_crop) (struct file *file, void *fh,
178 struct v4l2_crop *a);
179 int (*vidioc_s_crop) (struct file *file, void *fh,
180 struct v4l2_crop *a);
181 /* Compression ioctls */
182 int (*vidioc_g_jpegcomp) (struct file *file, void *fh,
183 struct v4l2_jpegcompression *a);
184 int (*vidioc_s_jpegcomp) (struct file *file, void *fh,
185 struct v4l2_jpegcompression *a);
186 int (*vidioc_g_enc_index) (struct file *file, void *fh,
187 struct v4l2_enc_idx *a);
188 int (*vidioc_encoder_cmd) (struct file *file, void *fh,
189 struct v4l2_encoder_cmd *a);
190 int (*vidioc_try_encoder_cmd) (struct file *file, void *fh,
191 struct v4l2_encoder_cmd *a);
192
193 /* Stream type-dependent parameter ioctls */
194 int (*vidioc_g_parm) (struct file *file, void *fh,
195 struct v4l2_streamparm *a);
196 int (*vidioc_s_parm) (struct file *file, void *fh,
197 struct v4l2_streamparm *a);
198
199 /* Tuner ioctls */
200 int (*vidioc_g_tuner) (struct file *file, void *fh,
201 struct v4l2_tuner *a);
202 int (*vidioc_s_tuner) (struct file *file, void *fh,
203 struct v4l2_tuner *a);
204 int (*vidioc_g_frequency) (struct file *file, void *fh,
205 struct v4l2_frequency *a);
206 int (*vidioc_s_frequency) (struct file *file, void *fh,
207 struct v4l2_frequency *a);
208
209 /* Sliced VBI cap */
210 int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh,
211 struct v4l2_sliced_vbi_cap *a);
212
213 /* Log status ioctl */
214 int (*vidioc_log_status) (struct file *file, void *fh);
215
216 int (*vidioc_s_hw_freq_seek) (struct file *file, void *fh,
217 struct v4l2_hw_freq_seek *a);
218
219 /* Debugging ioctls */
220#ifdef CONFIG_VIDEO_ADV_DEBUG
221 int (*vidioc_g_register) (struct file *file, void *fh,
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300222 struct v4l2_dbg_register *reg);
Hans Verkuila3998102008-07-21 02:57:38 -0300223 int (*vidioc_s_register) (struct file *file, void *fh,
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300224 struct v4l2_dbg_register *reg);
Hans Verkuila3998102008-07-21 02:57:38 -0300225#endif
226 int (*vidioc_g_chip_ident) (struct file *file, void *fh,
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300227 struct v4l2_dbg_chip_ident *chip);
Hans Verkuila3998102008-07-21 02:57:38 -0300228
Mauro Carvalho Chehab74d83fa2008-11-11 21:13:47 -0300229 int (*vidioc_enum_framesizes) (struct file *file, void *fh,
230 struct v4l2_frmsizeenum *fsize);
231
232 int (*vidioc_enum_frameintervals) (struct file *file, void *fh,
233 struct v4l2_frmivalenum *fival);
234
Muralidharan Karicherib6456c02009-11-19 12:00:31 -0300235 /* DV Timings IOCTLs */
236 int (*vidioc_enum_dv_presets) (struct file *file, void *fh,
237 struct v4l2_dv_enum_preset *preset);
238
239 int (*vidioc_s_dv_preset) (struct file *file, void *fh,
240 struct v4l2_dv_preset *preset);
241 int (*vidioc_g_dv_preset) (struct file *file, void *fh,
242 struct v4l2_dv_preset *preset);
243 int (*vidioc_query_dv_preset) (struct file *file, void *fh,
244 struct v4l2_dv_preset *qpreset);
245 int (*vidioc_s_dv_timings) (struct file *file, void *fh,
246 struct v4l2_dv_timings *timings);
247 int (*vidioc_g_dv_timings) (struct file *file, void *fh,
248 struct v4l2_dv_timings *timings);
249
Sakari Ailusd3d7c962010-03-27 11:02:10 -0300250 int (*vidioc_subscribe_event) (struct v4l2_fh *fh,
251 struct v4l2_event_subscription *sub);
252 int (*vidioc_unsubscribe_event)(struct v4l2_fh *fh,
253 struct v4l2_event_subscription *sub);
254
Hans Verkuila3998102008-07-21 02:57:38 -0300255 /* For other private ioctls */
Hans Verkuil069b7472008-12-30 07:04:34 -0300256 long (*vidioc_default) (struct file *file, void *fh,
Hans Verkuila3998102008-07-21 02:57:38 -0300257 int cmd, void *arg);
258};
259
260
Mauro Carvalho Chehab28644622008-07-20 20:26:54 -0300261/* v4l debugging and diagnostics */
262
263/* Debug bitmask flags to be used on V4L2 */
264#define V4L2_DEBUG_IOCTL 0x01
265#define V4L2_DEBUG_IOCTL_ARG 0x02
266
267/* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */
268#define v4l_print_ioctl(name, cmd) \
269 do { \
270 printk(KERN_DEBUG "%s: ", name); \
271 v4l_printk_ioctl(cmd); \
272 } while (0)
273
274/* Use this macro in I2C drivers where 'client' is the struct i2c_client
275 pointer */
276#define v4l_i2c_print_ioctl(client, cmd) \
277 do { \
278 v4l_client_printk(KERN_DEBUG, client, ""); \
279 v4l_printk_ioctl(cmd); \
280 } while (0)
281
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300282/* Video standard functions */
283extern const char *v4l2_norm_to_name(v4l2_std_id id);
Trent Piepho51f0b8d52009-03-04 01:21:02 -0300284extern void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod);
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300285extern int v4l2_video_std_construct(struct v4l2_standard *vs,
286 int id, const char *name);
287/* Prints the ioctl in a human-readable format */
288extern void v4l_printk_ioctl(unsigned int cmd);
289
290/* names for fancy debug output */
291extern const char *v4l2_field_names[];
292extern const char *v4l2_type_names[];
293
Hans Verkuilbec43662008-12-30 06:58:20 -0300294#ifdef CONFIG_COMPAT
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300295/* 32 Bits compatibility layer for 64 bits processors */
Hans Verkuil9bb7cde2008-12-30 06:42:40 -0300296extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd,
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300297 unsigned long arg);
Hans Verkuilbec43662008-12-30 06:58:20 -0300298#endif
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300299
Hans Verkuil08af2452010-12-24 10:33:19 -0300300typedef long (*v4l2_kioctl)(struct file *file,
301 unsigned int cmd, void *arg);
302
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300303/* Include support for obsoleted stuff */
Hans Verkuil069b7472008-12-30 07:04:34 -0300304extern long video_usercopy(struct file *file, unsigned int cmd,
Hans Verkuilf473bf72008-11-01 08:25:11 -0300305 unsigned long arg, v4l2_kioctl func);
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300306
Mauro Carvalho Chehab8a522c92008-10-21 11:58:39 -0300307/* Standard handlers for V4L ioctl's */
Hans Verkuil069b7472008-12-30 07:04:34 -0300308extern long video_ioctl2(struct file *file,
Mauro Carvalho Chehab8a522c92008-10-21 11:58:39 -0300309 unsigned int cmd, unsigned long arg);
310
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300311#endif /* _V4L2_IOCTL_H */