blob: e0b74a430b3aa0597b8aa86e6b906206bb34cf25 [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>
Hans Verkuil35ea11f2008-07-20 08:12:02 -030014#include <linux/mutex.h>
15#include <linux/compiler.h> /* need __user */
Hans Verkuil35ea11f2008-07-20 08:12:02 -030016#include <linux/videodev2.h>
Hans Verkuil35ea11f2008-07-20 08:12:02 -030017
Sakari Ailusd3d7c962010-03-27 11:02:10 -030018struct v4l2_fh;
19
Hans Verkuila3998102008-07-21 02:57:38 -030020struct v4l2_ioctl_ops {
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);
Pawel Osciakd14e6d72010-12-23 04:15:27 -030039 int (*vidioc_enum_fmt_vid_cap_mplane)(struct file *file, void *fh,
40 struct v4l2_fmtdesc *f);
41 int (*vidioc_enum_fmt_vid_out_mplane)(struct file *file, void *fh,
42 struct v4l2_fmtdesc *f);
Hans Verkuila3998102008-07-21 02:57:38 -030043
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);
Pawel Osciakd14e6d72010-12-23 04:15:27 -030061 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);
Hans Verkuila3998102008-07-21 02:57:38 -030065
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);
Pawel Osciakd14e6d72010-12-23 04:15:27 -030083 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);
Hans Verkuila3998102008-07-21 02:57:38 -030087
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);
95 int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh,
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);
101 int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh,
102 struct v4l2_format *f);
103 int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh,
104 struct v4l2_format *f);
Pawel Osciakd14e6d72010-12-23 04:15:27 -0300105 int (*vidioc_try_fmt_vid_cap_mplane)(struct file *file, void *fh,
106 struct v4l2_format *f);
107 int (*vidioc_try_fmt_vid_out_mplane)(struct file *file, void *fh,
108 struct v4l2_format *f);
Hans Verkuila3998102008-07-21 02:57:38 -0300109
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);
Tomasz Stanislawskib799d092012-06-14 11:32:23 -0300114 int (*vidioc_expbuf) (struct file *file, void *fh,
115 struct v4l2_exportbuffer *e);
Hans Verkuila3998102008-07-21 02:57:38 -0300116 int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b);
117
Guennadi Liakhovetski21501582011-09-28 11:34:06 -0300118 int (*vidioc_create_bufs)(struct file *file, void *fh, struct v4l2_create_buffers *b);
119 int (*vidioc_prepare_buf)(struct file *file, void *fh, struct v4l2_buffer *b);
Hans Verkuila3998102008-07-21 02:57:38 -0300120
121 int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i);
Hans Verkuila3998102008-07-21 02:57:38 -0300122 int (*vidioc_g_fbuf) (struct file *file, void *fh,
123 struct v4l2_framebuffer *a);
124 int (*vidioc_s_fbuf) (struct file *file, void *fh,
Hans Verkuile6eb28c2012-09-04 10:26:45 -0300125 const struct v4l2_framebuffer *a);
Hans Verkuila3998102008-07-21 02:57:38 -0300126
127 /* Stream on/off */
128 int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i);
129 int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i);
130
131 /* Standard handling
132 ENUMSTD is handled by videodev.c
133 */
134 int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm);
Hans Verkuil314527a2013-03-15 06:10:40 -0300135 int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id norm);
Hans Verkuila3998102008-07-21 02:57:38 -0300136 int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a);
137
138 /* Input handling */
139 int (*vidioc_enum_input)(struct file *file, void *fh,
140 struct v4l2_input *inp);
141 int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i);
142 int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i);
143
144 /* Output handling */
145 int (*vidioc_enum_output) (struct file *file, void *fh,
146 struct v4l2_output *a);
147 int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i);
148 int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i);
149
150 /* Control handling */
151 int (*vidioc_queryctrl) (struct file *file, void *fh,
152 struct v4l2_queryctrl *a);
153 int (*vidioc_g_ctrl) (struct file *file, void *fh,
154 struct v4l2_control *a);
155 int (*vidioc_s_ctrl) (struct file *file, void *fh,
156 struct v4l2_control *a);
157 int (*vidioc_g_ext_ctrls) (struct file *file, void *fh,
158 struct v4l2_ext_controls *a);
159 int (*vidioc_s_ext_ctrls) (struct file *file, void *fh,
160 struct v4l2_ext_controls *a);
161 int (*vidioc_try_ext_ctrls) (struct file *file, void *fh,
162 struct v4l2_ext_controls *a);
163 int (*vidioc_querymenu) (struct file *file, void *fh,
164 struct v4l2_querymenu *a);
165
166 /* Audio ioctls */
167 int (*vidioc_enumaudio) (struct file *file, void *fh,
168 struct v4l2_audio *a);
169 int (*vidioc_g_audio) (struct file *file, void *fh,
170 struct v4l2_audio *a);
171 int (*vidioc_s_audio) (struct file *file, void *fh,
Hans Verkuil0e8025b92012-09-04 11:59:31 -0300172 const struct v4l2_audio *a);
Hans Verkuila3998102008-07-21 02:57:38 -0300173
174 /* Audio out ioctls */
175 int (*vidioc_enumaudout) (struct file *file, void *fh,
176 struct v4l2_audioout *a);
177 int (*vidioc_g_audout) (struct file *file, void *fh,
178 struct v4l2_audioout *a);
179 int (*vidioc_s_audout) (struct file *file, void *fh,
Hans Verkuilba9425b2012-09-04 12:03:49 -0300180 const struct v4l2_audioout *a);
Hans Verkuila3998102008-07-21 02:57:38 -0300181 int (*vidioc_g_modulator) (struct file *file, void *fh,
182 struct v4l2_modulator *a);
183 int (*vidioc_s_modulator) (struct file *file, void *fh,
Hans Verkuil3f70e1f52012-09-04 12:08:47 -0300184 const struct v4l2_modulator *a);
Hans Verkuila3998102008-07-21 02:57:38 -0300185 /* Crop ioctls */
186 int (*vidioc_cropcap) (struct file *file, void *fh,
187 struct v4l2_cropcap *a);
188 int (*vidioc_g_crop) (struct file *file, void *fh,
189 struct v4l2_crop *a);
190 int (*vidioc_s_crop) (struct file *file, void *fh,
Hans Verkuil4f996592012-09-05 05:10:48 -0300191 const struct v4l2_crop *a);
Tomasz Stanislawski0e8caac2011-08-10 10:37:47 -0300192 int (*vidioc_g_selection) (struct file *file, void *fh,
193 struct v4l2_selection *s);
194 int (*vidioc_s_selection) (struct file *file, void *fh,
195 struct v4l2_selection *s);
Hans Verkuila3998102008-07-21 02:57:38 -0300196 /* Compression ioctls */
197 int (*vidioc_g_jpegcomp) (struct file *file, void *fh,
198 struct v4l2_jpegcompression *a);
199 int (*vidioc_s_jpegcomp) (struct file *file, void *fh,
Hans Verkuild88aab52012-09-17 05:05:25 -0300200 const struct v4l2_jpegcompression *a);
Hans Verkuila3998102008-07-21 02:57:38 -0300201 int (*vidioc_g_enc_index) (struct file *file, void *fh,
202 struct v4l2_enc_idx *a);
203 int (*vidioc_encoder_cmd) (struct file *file, void *fh,
204 struct v4l2_encoder_cmd *a);
205 int (*vidioc_try_encoder_cmd) (struct file *file, void *fh,
206 struct v4l2_encoder_cmd *a);
Hans Verkuila45c0ad2011-11-24 09:53:43 -0300207 int (*vidioc_decoder_cmd) (struct file *file, void *fh,
208 struct v4l2_decoder_cmd *a);
209 int (*vidioc_try_decoder_cmd) (struct file *file, void *fh,
210 struct v4l2_decoder_cmd *a);
Hans Verkuila3998102008-07-21 02:57:38 -0300211
212 /* Stream type-dependent parameter ioctls */
213 int (*vidioc_g_parm) (struct file *file, void *fh,
214 struct v4l2_streamparm *a);
215 int (*vidioc_s_parm) (struct file *file, void *fh,
216 struct v4l2_streamparm *a);
217
218 /* Tuner ioctls */
219 int (*vidioc_g_tuner) (struct file *file, void *fh,
220 struct v4l2_tuner *a);
221 int (*vidioc_s_tuner) (struct file *file, void *fh,
Hans Verkuil2f73c7c2013-03-15 06:10:06 -0300222 const struct v4l2_tuner *a);
Hans Verkuila3998102008-07-21 02:57:38 -0300223 int (*vidioc_g_frequency) (struct file *file, void *fh,
224 struct v4l2_frequency *a);
225 int (*vidioc_s_frequency) (struct file *file, void *fh,
Hans Verkuilb530a442013-03-19 04:09:26 -0300226 const struct v4l2_frequency *a);
Hans Verkuil82b655b2012-07-05 06:37:08 -0300227 int (*vidioc_enum_freq_bands) (struct file *file, void *fh,
228 struct v4l2_frequency_band *band);
Hans Verkuila3998102008-07-21 02:57:38 -0300229
230 /* Sliced VBI cap */
231 int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh,
232 struct v4l2_sliced_vbi_cap *a);
233
234 /* Log status ioctl */
235 int (*vidioc_log_status) (struct file *file, void *fh);
236
237 int (*vidioc_s_hw_freq_seek) (struct file *file, void *fh,
Hans Verkuilec6f4322012-09-14 07:41:18 -0300238 const struct v4l2_hw_freq_seek *a);
Hans Verkuila3998102008-07-21 02:57:38 -0300239
240 /* Debugging ioctls */
241#ifdef CONFIG_VIDEO_ADV_DEBUG
242 int (*vidioc_g_register) (struct file *file, void *fh,
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300243 struct v4l2_dbg_register *reg);
Hans Verkuila3998102008-07-21 02:57:38 -0300244 int (*vidioc_s_register) (struct file *file, void *fh,
Hans Verkuil977ba3b2013-03-24 08:28:46 -0300245 const struct v4l2_dbg_register *reg);
Hans Verkuila3998102008-07-21 02:57:38 -0300246
Hans Verkuil96b03d22013-04-06 06:16:58 -0300247 int (*vidioc_g_chip_info) (struct file *file, void *fh,
248 struct v4l2_dbg_chip_info *chip);
Hans Verkuilcd634f12013-03-27 08:04:23 -0300249#endif
Hans Verkuil79b0c642013-03-18 12:16:34 -0300250
Mauro Carvalho Chehab74d83fa2008-11-11 21:13:47 -0300251 int (*vidioc_enum_framesizes) (struct file *file, void *fh,
252 struct v4l2_frmsizeenum *fsize);
253
254 int (*vidioc_enum_frameintervals) (struct file *file, void *fh,
255 struct v4l2_frmivalenum *fival);
256
Muralidharan Karicherib6456c02009-11-19 12:00:31 -0300257 /* DV Timings IOCTLs */
Muralidharan Karicherib6456c02009-11-19 12:00:31 -0300258 int (*vidioc_s_dv_timings) (struct file *file, void *fh,
259 struct v4l2_dv_timings *timings);
260 int (*vidioc_g_dv_timings) (struct file *file, void *fh,
261 struct v4l2_dv_timings *timings);
Hans Verkuil5d7758e2012-05-15 08:06:44 -0300262 int (*vidioc_query_dv_timings) (struct file *file, void *fh,
263 struct v4l2_dv_timings *timings);
264 int (*vidioc_enum_dv_timings) (struct file *file, void *fh,
265 struct v4l2_enum_dv_timings *timings);
266 int (*vidioc_dv_timings_cap) (struct file *file, void *fh,
267 struct v4l2_dv_timings_cap *cap);
Muralidharan Karicherib6456c02009-11-19 12:00:31 -0300268
Sakari Ailusd3d7c962010-03-27 11:02:10 -0300269 int (*vidioc_subscribe_event) (struct v4l2_fh *fh,
Hans Verkuil85f5fe32012-09-04 11:46:09 -0300270 const struct v4l2_event_subscription *sub);
Sakari Ailusd3d7c962010-03-27 11:02:10 -0300271 int (*vidioc_unsubscribe_event)(struct v4l2_fh *fh,
Hans Verkuil85f5fe32012-09-04 11:46:09 -0300272 const struct v4l2_event_subscription *sub);
Sakari Ailusd3d7c962010-03-27 11:02:10 -0300273
Hans Verkuila3998102008-07-21 02:57:38 -0300274 /* For other private ioctls */
Hans Verkuil069b7472008-12-30 07:04:34 -0300275 long (*vidioc_default) (struct file *file, void *fh,
Mauro Carvalho Chehab6d43be72013-03-26 08:04:52 -0300276 bool valid_prio, unsigned int cmd, void *arg);
Hans Verkuila3998102008-07-21 02:57:38 -0300277};
278
279
Mauro Carvalho Chehab28644622008-07-20 20:26:54 -0300280/* v4l debugging and diagnostics */
281
282/* Debug bitmask flags to be used on V4L2 */
283#define V4L2_DEBUG_IOCTL 0x01
284#define V4L2_DEBUG_IOCTL_ARG 0x02
285
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300286/* Video standard functions */
287extern const char *v4l2_norm_to_name(v4l2_std_id id);
Trent Piepho51f0b8d52009-03-04 01:21:02 -0300288extern void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod);
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300289extern int v4l2_video_std_construct(struct v4l2_standard *vs,
290 int id, const char *name);
Hans Verkuil4a085162012-06-22 06:38:06 -0300291/* Prints the ioctl in a human-readable format. If prefix != NULL,
292 then do printk(KERN_DEBUG "%s: ", prefix) first. */
293extern void v4l_printk_ioctl(const char *prefix, unsigned int cmd);
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300294
Hans Verkuil5a5adf62012-06-22 07:29:35 -0300295/* Internal use only: get the mutex (if any) that we need to lock for the
296 given command. */
297struct video_device;
298extern struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev, unsigned cmd);
299
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300300/* names for fancy debug output */
301extern const char *v4l2_field_names[];
302extern const char *v4l2_type_names[];
303
Hans Verkuilbec43662008-12-30 06:58:20 -0300304#ifdef CONFIG_COMPAT
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300305/* 32 Bits compatibility layer for 64 bits processors */
Hans Verkuil9bb7cde2008-12-30 06:42:40 -0300306extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd,
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300307 unsigned long arg);
Hans Verkuilbec43662008-12-30 06:58:20 -0300308#endif
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300309
Hans Verkuil08af2452010-12-24 10:33:19 -0300310typedef long (*v4l2_kioctl)(struct file *file,
311 unsigned int cmd, void *arg);
312
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300313/* Include support for obsoleted stuff */
Hans Verkuil069b7472008-12-30 07:04:34 -0300314extern long video_usercopy(struct file *file, unsigned int cmd,
Hans Verkuilf473bf72008-11-01 08:25:11 -0300315 unsigned long arg, v4l2_kioctl func);
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300316
Mauro Carvalho Chehab8a522c92008-10-21 11:58:39 -0300317/* Standard handlers for V4L ioctl's */
Hans Verkuil069b7472008-12-30 07:04:34 -0300318extern long video_ioctl2(struct file *file,
Mauro Carvalho Chehab8a522c92008-10-21 11:58:39 -0300319 unsigned int cmd, unsigned long arg);
320
Hans Verkuil35ea11f2008-07-20 08:12:02 -0300321#endif /* _V4L2_IOCTL_H */