blob: e8ba0f2efbae559887d7f75cfb1d70a19861245c [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 */
17#ifdef CONFIG_VIDEO_V4L1_COMPAT
Mauro Carvalho Chehab7e0a16f2009-03-10 05:31:34 -030018#define __MIN_V4L1
Hans Verkuil35ea11f2008-07-20 08:12:02 -030019#include <linux/videodev.h>
20#else
21#include <linux/videodev2.h>
22#endif
23
Hans Verkuila3998102008-07-21 02:57:38 -030024struct v4l2_ioctl_ops {
25 /* ioctl callbacks */
26
27 /* VIDIOC_QUERYCAP handler */
28 int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap);
29
30 /* Priority handling */
31 int (*vidioc_g_priority) (struct file *file, void *fh,
32 enum v4l2_priority *p);
33 int (*vidioc_s_priority) (struct file *file, void *fh,
34 enum v4l2_priority p);
35
36 /* VIDIOC_ENUM_FMT handlers */
37 int (*vidioc_enum_fmt_vid_cap) (struct file *file, void *fh,
38 struct v4l2_fmtdesc *f);
39 int (*vidioc_enum_fmt_vid_overlay) (struct file *file, void *fh,
40 struct v4l2_fmtdesc *f);
41 int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh,
42 struct v4l2_fmtdesc *f);
Hans Verkuila3998102008-07-21 02:57:38 -030043 int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh,
44 struct v4l2_fmtdesc *f);
45
46 /* VIDIOC_G_FMT handlers */
47 int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh,
48 struct v4l2_format *f);
49 int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh,
50 struct v4l2_format *f);
51 int (*vidioc_g_fmt_vid_out) (struct file *file, void *fh,
52 struct v4l2_format *f);
53 int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh,
54 struct v4l2_format *f);
55 int (*vidioc_g_fmt_vbi_cap) (struct file *file, void *fh,
56 struct v4l2_format *f);
57 int (*vidioc_g_fmt_vbi_out) (struct file *file, void *fh,
58 struct v4l2_format *f);
59 int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh,
60 struct v4l2_format *f);
61 int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh,
62 struct v4l2_format *f);
63 int (*vidioc_g_fmt_type_private)(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_type_private)(struct file *file, void *fh,
84 struct v4l2_format *f);
85
86 /* VIDIOC_TRY_FMT handlers */
87 int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh,
88 struct v4l2_format *f);
89 int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh,
90 struct v4l2_format *f);
91 int (*vidioc_try_fmt_vid_out) (struct file *file, void *fh,
92 struct v4l2_format *f);
93 int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
94 struct v4l2_format *f);
95 int (*vidioc_try_fmt_vbi_cap) (struct file *file, void *fh,
96 struct v4l2_format *f);
97 int (*vidioc_try_fmt_vbi_out) (struct file *file, void *fh,
98 struct v4l2_format *f);
99 int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
100 struct v4l2_format *f);
101 int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
102 struct v4l2_format *f);
103 int (*vidioc_try_fmt_type_private)(struct file *file, void *fh,
104 struct v4l2_format *f);
105
106 /* Buffer handlers */
107 int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b);
108 int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b);
109 int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
110 int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
111
112
113 int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
114#ifdef CONFIG_VIDEO_V4L1_COMPAT
115 /* buffer type is struct vidio_mbuf * */
116 int (*vidiocgmbuf) (struct file *file, void *fh, struct video_mbuf *p);
117#endif
118 int (*vidioc_g_fbuf) (struct file *file, void *fh,
119 struct v4l2_framebuffer *a);
120 int (*vidioc_s_fbuf) (struct file *file, void *fh,
121 struct v4l2_framebuffer *a);
122
123 /* Stream on/off */
124 int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i);
125 int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
126
127 /* Standard handling
128 ENUMSTD is handled by videodev.c
129 */
130 int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm);
131 int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id *norm);
132 int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
133
134 /* Input handling */
135 int (*vidioc_enum_input)(struct file *file, void *fh,
136 struct v4l2_input *inp);
137 int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i);
138 int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i);
139
140 /* Output handling */
141 int (*vidioc_enum_output) (struct file *file, void *fh,
142 struct v4l2_output *a);
143 int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i);
144 int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i);
145
146 /* Control handling */
147 int (*vidioc_queryctrl) (struct file *file, void *fh,
148 struct v4l2_queryctrl *a);
149 int (*vidioc_g_ctrl) (struct file *file, void *fh,
150 struct v4l2_control *a);
151 int (*vidioc_s_ctrl) (struct file *file, void *fh,
152 struct v4l2_control *a);
153 int (*vidioc_g_ext_ctrls) (struct file *file, void *fh,
154 struct v4l2_ext_controls *a);
155 int (*vidioc_s_ext_ctrls) (struct file *file, void *fh,
156 struct v4l2_ext_controls *a);
157 int (*vidioc_try_ext_ctrls) (struct file *file, void *fh,
158 struct v4l2_ext_controls *a);
159 int (*vidioc_querymenu) (struct file *file, void *fh,
160 struct v4l2_querymenu *a);
161
162 /* Audio ioctls */
163 int (*vidioc_enumaudio) (struct file *file, void *fh,
164 struct v4l2_audio *a);
165 int (*vidioc_g_audio) (struct file *file, void *fh,
166 struct v4l2_audio *a);
167 int (*vidioc_s_audio) (struct file *file, void *fh,
168 struct v4l2_audio *a);
169
170 /* Audio out ioctls */
171 int (*vidioc_enumaudout) (struct file *file, void *fh,
172 struct v4l2_audioout *a);
173 int (*vidioc_g_audout) (struct file *file, void *fh,
174 struct v4l2_audioout *a);
175 int (*vidioc_s_audout) (struct file *file, void *fh,
176 struct v4l2_audioout *a);
177 int (*vidioc_g_modulator) (struct file *file, void *fh,
178 struct v4l2_modulator *a);
179 int (*vidioc_s_modulator) (struct file *file, void *fh,
180 struct v4l2_modulator *a);
181 /* Crop ioctls */
182 int (*vidioc_cropcap) (struct file *file, void *fh,
183 struct v4l2_cropcap *a);
184 int (*vidioc_g_crop) (struct file *file, void *fh,
185 struct v4l2_crop *a);
186 int (*vidioc_s_crop) (struct file *file, void *fh,
187 struct v4l2_crop *a);
188 /* Compression ioctls */
189 int (*vidioc_g_jpegcomp) (struct file *file, void *fh,
190 struct v4l2_jpegcompression *a);
191 int (*vidioc_s_jpegcomp) (struct file *file, void *fh,
192 struct v4l2_jpegcompression *a);
193 int (*vidioc_g_enc_index) (struct file *file, void *fh,
194 struct v4l2_enc_idx *a);
195 int (*vidioc_encoder_cmd) (struct file *file, void *fh,
196 struct v4l2_encoder_cmd *a);
197 int (*vidioc_try_encoder_cmd) (struct file *file, void *fh,
198 struct v4l2_encoder_cmd *a);
199
200 /* Stream type-dependent parameter ioctls */
201 int (*vidioc_g_parm) (struct file *file, void *fh,
202 struct v4l2_streamparm *a);
203 int (*vidioc_s_parm) (struct file *file, void *fh,
204 struct v4l2_streamparm *a);
205
206 /* Tuner ioctls */
207 int (*vidioc_g_tuner) (struct file *file, void *fh,
208 struct v4l2_tuner *a);
209 int (*vidioc_s_tuner) (struct file *file, void *fh,
210 struct v4l2_tuner *a);
211 int (*vidioc_g_frequency) (struct file *file, void *fh,
212 struct v4l2_frequency *a);
213 int (*vidioc_s_frequency) (struct file *file, void *fh,
214 struct v4l2_frequency *a);
215
216 /* Sliced VBI cap */
217 int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh,
218 struct v4l2_sliced_vbi_cap *a);
219
220 /* Log status ioctl */
221 int (*vidioc_log_status) (struct file *file, void *fh);
222
223 int (*vidioc_s_hw_freq_seek) (struct file *file, void *fh,
224 struct v4l2_hw_freq_seek *a);
225
226 /* Debugging ioctls */
227#ifdef CONFIG_VIDEO_ADV_DEBUG
228 int (*vidioc_g_register) (struct file *file, void *fh,
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300229 struct v4l2_dbg_register *reg);
Hans Verkuila3998102008-07-21 02:57:38 -0300230 int (*vidioc_s_register) (struct file *file, void *fh,
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300231 struct v4l2_dbg_register *reg);
Hans Verkuila3998102008-07-21 02:57:38 -0300232#endif
233 int (*vidioc_g_chip_ident) (struct file *file, void *fh,
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300234 struct v4l2_dbg_chip_ident *chip);
Hans Verkuila3998102008-07-21 02:57:38 -0300235
Mauro Carvalho Chehab74d83fa2008-11-11 21:13:47 -0300236 int (*vidioc_enum_framesizes) (struct file *file, void *fh,
237 struct v4l2_frmsizeenum *fsize);
238
239 int (*vidioc_enum_frameintervals) (struct file *file, void *fh,
240 struct v4l2_frmivalenum *fival);
241
Muralidharan Karicherib6456c02009-11-19 12:00:31 -0300242 /* DV Timings IOCTLs */
243 int (*vidioc_enum_dv_presets) (struct file *file, void *fh,
244 struct v4l2_dv_enum_preset *preset);
245
246 int (*vidioc_s_dv_preset) (struct file *file, void *fh,
247 struct v4l2_dv_preset *preset);
248 int (*vidioc_g_dv_preset) (struct file *file, void *fh,
249 struct v4l2_dv_preset *preset);
250 int (*vidioc_query_dv_preset) (struct file *file, void *fh,
251 struct v4l2_dv_preset *qpreset);
252 int (*vidioc_s_dv_timings) (struct file *file, void *fh,
253 struct v4l2_dv_timings *timings);
254 int (*vidioc_g_dv_timings) (struct file *file, void *fh,
255 struct v4l2_dv_timings *timings);
256
Hans Verkuila3998102008-07-21 02:57:38 -0300257 /* For other private ioctls */
Hans Verkuil069b7472008-12-30 07:04:34 -0300258 long (*vidioc_default) (struct file *file, void *fh,
Hans Verkuila3998102008-07-21 02:57:38 -0300259 int cmd, void *arg);
260};
261
262
Mauro Carvalho Chehab28644622008-07-20 20:26:54 -0300263/* v4l debugging and diagnostics */
264
265/* Debug bitmask flags to be used on V4L2 */
266#define V4L2_DEBUG_IOCTL 0x01
267#define V4L2_DEBUG_IOCTL_ARG 0x02
268
269/* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */
270#define v4l_print_ioctl(name, cmd) \
271 do { \
272 printk(KERN_DEBUG "%s: ", name); \
273 v4l_printk_ioctl(cmd); \
274 } while (0)
275
276/* Use this macro in I2C drivers where 'client' is the struct i2c_client
277 pointer */
278#define v4l_i2c_print_ioctl(client, cmd) \
279 do { \
280 v4l_client_printk(KERN_DEBUG, client, ""); \
281 v4l_printk_ioctl(cmd); \
282 } while (0)
283
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300284/* Video standard functions */
285extern const char *v4l2_norm_to_name(v4l2_std_id id);
Trent Piepho51f0b8d52009-03-04 01:21:02 -0300286extern void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod);
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300287extern int v4l2_video_std_construct(struct v4l2_standard *vs,
288 int id, const char *name);
289/* Prints the ioctl in a human-readable format */
290extern void v4l_printk_ioctl(unsigned int cmd);
291
292/* names for fancy debug output */
293extern const char *v4l2_field_names[];
294extern const char *v4l2_type_names[];
295
296/* Compatibility layer interface -- v4l1-compat module */
Hans Verkuil069b7472008-12-30 07:04:34 -0300297typedef long (*v4l2_kioctl)(struct file *file,
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300298 unsigned int cmd, void *arg);
299#ifdef CONFIG_VIDEO_V4L1_COMPAT
Hans Verkuil069b7472008-12-30 07:04:34 -0300300long v4l_compat_translate_ioctl(struct file *file,
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300301 int cmd, void *arg, v4l2_kioctl driver_ioctl);
302#else
Mauro Carvalho Chehabb1f88402008-10-21 11:27:20 -0300303#define v4l_compat_translate_ioctl(file, cmd, arg, ioctl) (-EINVAL)
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300304#endif
305
Hans Verkuilbec43662008-12-30 06:58:20 -0300306#ifdef CONFIG_COMPAT
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300307/* 32 Bits compatibility layer for 64 bits processors */
Hans Verkuil9bb7cde2008-12-30 06:42:40 -0300308extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd,
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300309 unsigned long arg);
Hans Verkuilbec43662008-12-30 06:58:20 -0300310#endif
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300311
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300312/* Include support for obsoleted stuff */
Hans Verkuil069b7472008-12-30 07:04:34 -0300313extern long video_usercopy(struct file *file, unsigned int cmd,
Hans Verkuilf473bf72008-11-01 08:25:11 -0300314 unsigned long arg, v4l2_kioctl func);
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300315
Mauro Carvalho Chehab8a522c92008-10-21 11:58:39 -0300316/* Standard handlers for V4L ioctl's */
Hans Verkuil069b7472008-12-30 07:04:34 -0300317extern long video_ioctl2(struct file *file,
Mauro Carvalho Chehab8a522c92008-10-21 11:58:39 -0300318 unsigned int cmd, unsigned long arg);
319
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300320#endif /* _V4L2_IOCTL_H */