Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 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/device.h> |
| 15 | #include <linux/mutex.h> |
| 16 | #include <linux/compiler.h> /* need __user */ |
| 17 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
Mauro Carvalho Chehab | 7e0a16f | 2009-03-10 05:31:34 -0300 | [diff] [blame] | 18 | #define __MIN_V4L1 |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 19 | #include <linux/videodev.h> |
| 20 | #else |
| 21 | #include <linux/videodev2.h> |
| 22 | #endif |
| 23 | |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 24 | struct 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 Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 43 | 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 Verkuil | aecde8b5 | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 229 | struct v4l2_dbg_register *reg); |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 230 | int (*vidioc_s_register) (struct file *file, void *fh, |
Hans Verkuil | aecde8b5 | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 231 | struct v4l2_dbg_register *reg); |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 232 | #endif |
| 233 | int (*vidioc_g_chip_ident) (struct file *file, void *fh, |
Hans Verkuil | aecde8b5 | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 234 | struct v4l2_dbg_chip_ident *chip); |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 235 | |
Mauro Carvalho Chehab | 74d83fa | 2008-11-11 21:13:47 -0300 | [diff] [blame] | 236 | 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 | |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 242 | /* For other private ioctls */ |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 243 | long (*vidioc_default) (struct file *file, void *fh, |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 244 | int cmd, void *arg); |
| 245 | }; |
| 246 | |
| 247 | |
Mauro Carvalho Chehab | 2864462 | 2008-07-20 20:26:54 -0300 | [diff] [blame] | 248 | /* v4l debugging and diagnostics */ |
| 249 | |
| 250 | /* Debug bitmask flags to be used on V4L2 */ |
| 251 | #define V4L2_DEBUG_IOCTL 0x01 |
| 252 | #define V4L2_DEBUG_IOCTL_ARG 0x02 |
| 253 | |
| 254 | /* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */ |
| 255 | #define v4l_print_ioctl(name, cmd) \ |
| 256 | do { \ |
| 257 | printk(KERN_DEBUG "%s: ", name); \ |
| 258 | v4l_printk_ioctl(cmd); \ |
| 259 | } while (0) |
| 260 | |
| 261 | /* Use this macro in I2C drivers where 'client' is the struct i2c_client |
| 262 | pointer */ |
| 263 | #define v4l_i2c_print_ioctl(client, cmd) \ |
| 264 | do { \ |
| 265 | v4l_client_printk(KERN_DEBUG, client, ""); \ |
| 266 | v4l_printk_ioctl(cmd); \ |
| 267 | } while (0) |
| 268 | |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 269 | /* Video standard functions */ |
| 270 | extern const char *v4l2_norm_to_name(v4l2_std_id id); |
Trent Piepho | 51f0b8d5 | 2009-03-04 01:21:02 -0300 | [diff] [blame] | 271 | extern void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod); |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 272 | extern int v4l2_video_std_construct(struct v4l2_standard *vs, |
| 273 | int id, const char *name); |
| 274 | /* Prints the ioctl in a human-readable format */ |
| 275 | extern void v4l_printk_ioctl(unsigned int cmd); |
| 276 | |
| 277 | /* names for fancy debug output */ |
| 278 | extern const char *v4l2_field_names[]; |
| 279 | extern const char *v4l2_type_names[]; |
| 280 | |
| 281 | /* Compatibility layer interface -- v4l1-compat module */ |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 282 | typedef long (*v4l2_kioctl)(struct file *file, |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 283 | unsigned int cmd, void *arg); |
| 284 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 285 | long v4l_compat_translate_ioctl(struct file *file, |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 286 | int cmd, void *arg, v4l2_kioctl driver_ioctl); |
| 287 | #else |
Mauro Carvalho Chehab | b1f8840 | 2008-10-21 11:27:20 -0300 | [diff] [blame] | 288 | #define v4l_compat_translate_ioctl(file, cmd, arg, ioctl) (-EINVAL) |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 289 | #endif |
| 290 | |
Hans Verkuil | bec4366 | 2008-12-30 06:58:20 -0300 | [diff] [blame] | 291 | #ifdef CONFIG_COMPAT |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 292 | /* 32 Bits compatibility layer for 64 bits processors */ |
Hans Verkuil | 9bb7cde | 2008-12-30 06:42:40 -0300 | [diff] [blame] | 293 | extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 294 | unsigned long arg); |
Hans Verkuil | bec4366 | 2008-12-30 06:58:20 -0300 | [diff] [blame] | 295 | #endif |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 296 | |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 297 | /* Include support for obsoleted stuff */ |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 298 | extern long video_usercopy(struct file *file, unsigned int cmd, |
Hans Verkuil | f473bf7 | 2008-11-01 08:25:11 -0300 | [diff] [blame] | 299 | unsigned long arg, v4l2_kioctl func); |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 300 | |
Mauro Carvalho Chehab | 8a522c9 | 2008-10-21 11:58:39 -0300 | [diff] [blame] | 301 | /* Standard handlers for V4L ioctl's */ |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 302 | extern long video_ioctl2(struct file *file, |
Mauro Carvalho Chehab | 8a522c9 | 2008-10-21 11:58:39 -0300 | [diff] [blame] | 303 | unsigned int cmd, unsigned long arg); |
| 304 | |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 305 | #endif /* _V4L2_IOCTL_H */ |