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 |
| 18 | #include <linux/videodev.h> |
| 19 | #else |
| 20 | #include <linux/videodev2.h> |
| 21 | #endif |
| 22 | |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 23 | struct v4l2_ioctl_ops { |
| 24 | /* ioctl callbacks */ |
| 25 | |
| 26 | /* VIDIOC_QUERYCAP handler */ |
| 27 | int (*vidioc_querycap)(struct file *file, void *fh, struct v4l2_capability *cap); |
| 28 | |
| 29 | /* Priority handling */ |
| 30 | int (*vidioc_g_priority) (struct file *file, void *fh, |
| 31 | enum v4l2_priority *p); |
| 32 | int (*vidioc_s_priority) (struct file *file, void *fh, |
| 33 | enum v4l2_priority p); |
| 34 | |
| 35 | /* VIDIOC_ENUM_FMT handlers */ |
| 36 | int (*vidioc_enum_fmt_vid_cap) (struct file *file, void *fh, |
| 37 | struct v4l2_fmtdesc *f); |
| 38 | int (*vidioc_enum_fmt_vid_overlay) (struct file *file, void *fh, |
| 39 | struct v4l2_fmtdesc *f); |
| 40 | int (*vidioc_enum_fmt_vid_out) (struct file *file, void *fh, |
| 41 | struct v4l2_fmtdesc *f); |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 42 | int (*vidioc_enum_fmt_type_private)(struct file *file, void *fh, |
| 43 | struct v4l2_fmtdesc *f); |
| 44 | |
| 45 | /* VIDIOC_G_FMT handlers */ |
| 46 | int (*vidioc_g_fmt_vid_cap) (struct file *file, void *fh, |
| 47 | struct v4l2_format *f); |
| 48 | int (*vidioc_g_fmt_vid_overlay)(struct file *file, void *fh, |
| 49 | struct v4l2_format *f); |
| 50 | int (*vidioc_g_fmt_vid_out) (struct file *file, void *fh, |
| 51 | struct v4l2_format *f); |
| 52 | int (*vidioc_g_fmt_vid_out_overlay)(struct file *file, void *fh, |
| 53 | struct v4l2_format *f); |
| 54 | int (*vidioc_g_fmt_vbi_cap) (struct file *file, void *fh, |
| 55 | struct v4l2_format *f); |
| 56 | int (*vidioc_g_fmt_vbi_out) (struct file *file, void *fh, |
| 57 | struct v4l2_format *f); |
| 58 | int (*vidioc_g_fmt_sliced_vbi_cap)(struct file *file, void *fh, |
| 59 | struct v4l2_format *f); |
| 60 | int (*vidioc_g_fmt_sliced_vbi_out)(struct file *file, void *fh, |
| 61 | struct v4l2_format *f); |
| 62 | int (*vidioc_g_fmt_type_private)(struct file *file, void *fh, |
| 63 | struct v4l2_format *f); |
| 64 | |
| 65 | /* VIDIOC_S_FMT handlers */ |
| 66 | int (*vidioc_s_fmt_vid_cap) (struct file *file, void *fh, |
| 67 | struct v4l2_format *f); |
| 68 | int (*vidioc_s_fmt_vid_overlay)(struct file *file, void *fh, |
| 69 | struct v4l2_format *f); |
| 70 | int (*vidioc_s_fmt_vid_out) (struct file *file, void *fh, |
| 71 | struct v4l2_format *f); |
| 72 | int (*vidioc_s_fmt_vid_out_overlay)(struct file *file, void *fh, |
| 73 | struct v4l2_format *f); |
| 74 | int (*vidioc_s_fmt_vbi_cap) (struct file *file, void *fh, |
| 75 | struct v4l2_format *f); |
| 76 | int (*vidioc_s_fmt_vbi_out) (struct file *file, void *fh, |
| 77 | struct v4l2_format *f); |
| 78 | int (*vidioc_s_fmt_sliced_vbi_cap)(struct file *file, void *fh, |
| 79 | struct v4l2_format *f); |
| 80 | int (*vidioc_s_fmt_sliced_vbi_out)(struct file *file, void *fh, |
| 81 | struct v4l2_format *f); |
| 82 | int (*vidioc_s_fmt_type_private)(struct file *file, void *fh, |
| 83 | struct v4l2_format *f); |
| 84 | |
| 85 | /* VIDIOC_TRY_FMT handlers */ |
| 86 | int (*vidioc_try_fmt_vid_cap) (struct file *file, void *fh, |
| 87 | struct v4l2_format *f); |
| 88 | int (*vidioc_try_fmt_vid_overlay)(struct file *file, void *fh, |
| 89 | struct v4l2_format *f); |
| 90 | int (*vidioc_try_fmt_vid_out) (struct file *file, void *fh, |
| 91 | struct v4l2_format *f); |
| 92 | int (*vidioc_try_fmt_vid_out_overlay)(struct file *file, void *fh, |
| 93 | struct v4l2_format *f); |
| 94 | int (*vidioc_try_fmt_vbi_cap) (struct file *file, void *fh, |
| 95 | struct v4l2_format *f); |
| 96 | int (*vidioc_try_fmt_vbi_out) (struct file *file, void *fh, |
| 97 | struct v4l2_format *f); |
| 98 | int (*vidioc_try_fmt_sliced_vbi_cap)(struct file *file, void *fh, |
| 99 | struct v4l2_format *f); |
| 100 | int (*vidioc_try_fmt_sliced_vbi_out)(struct file *file, void *fh, |
| 101 | struct v4l2_format *f); |
| 102 | int (*vidioc_try_fmt_type_private)(struct file *file, void *fh, |
| 103 | struct v4l2_format *f); |
| 104 | |
| 105 | /* Buffer handlers */ |
| 106 | int (*vidioc_reqbufs) (struct file *file, void *fh, struct v4l2_requestbuffers *b); |
| 107 | int (*vidioc_querybuf)(struct file *file, void *fh, struct v4l2_buffer *b); |
| 108 | int (*vidioc_qbuf) (struct file *file, void *fh, struct v4l2_buffer *b); |
| 109 | int (*vidioc_dqbuf) (struct file *file, void *fh, struct v4l2_buffer *b); |
| 110 | |
| 111 | |
| 112 | int (*vidioc_overlay) (struct file *file, void *fh, unsigned int i); |
| 113 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
| 114 | /* buffer type is struct vidio_mbuf * */ |
| 115 | int (*vidiocgmbuf) (struct file *file, void *fh, struct video_mbuf *p); |
| 116 | #endif |
| 117 | int (*vidioc_g_fbuf) (struct file *file, void *fh, |
| 118 | struct v4l2_framebuffer *a); |
| 119 | int (*vidioc_s_fbuf) (struct file *file, void *fh, |
| 120 | struct v4l2_framebuffer *a); |
| 121 | |
| 122 | /* Stream on/off */ |
| 123 | int (*vidioc_streamon) (struct file *file, void *fh, enum v4l2_buf_type i); |
| 124 | int (*vidioc_streamoff)(struct file *file, void *fh, enum v4l2_buf_type i); |
| 125 | |
| 126 | /* Standard handling |
| 127 | ENUMSTD is handled by videodev.c |
| 128 | */ |
| 129 | int (*vidioc_g_std) (struct file *file, void *fh, v4l2_std_id *norm); |
| 130 | int (*vidioc_s_std) (struct file *file, void *fh, v4l2_std_id *norm); |
| 131 | int (*vidioc_querystd) (struct file *file, void *fh, v4l2_std_id *a); |
| 132 | |
| 133 | /* Input handling */ |
| 134 | int (*vidioc_enum_input)(struct file *file, void *fh, |
| 135 | struct v4l2_input *inp); |
| 136 | int (*vidioc_g_input) (struct file *file, void *fh, unsigned int *i); |
| 137 | int (*vidioc_s_input) (struct file *file, void *fh, unsigned int i); |
| 138 | |
| 139 | /* Output handling */ |
| 140 | int (*vidioc_enum_output) (struct file *file, void *fh, |
| 141 | struct v4l2_output *a); |
| 142 | int (*vidioc_g_output) (struct file *file, void *fh, unsigned int *i); |
| 143 | int (*vidioc_s_output) (struct file *file, void *fh, unsigned int i); |
| 144 | |
| 145 | /* Control handling */ |
| 146 | int (*vidioc_queryctrl) (struct file *file, void *fh, |
| 147 | struct v4l2_queryctrl *a); |
| 148 | int (*vidioc_g_ctrl) (struct file *file, void *fh, |
| 149 | struct v4l2_control *a); |
| 150 | int (*vidioc_s_ctrl) (struct file *file, void *fh, |
| 151 | struct v4l2_control *a); |
| 152 | int (*vidioc_g_ext_ctrls) (struct file *file, void *fh, |
| 153 | struct v4l2_ext_controls *a); |
| 154 | int (*vidioc_s_ext_ctrls) (struct file *file, void *fh, |
| 155 | struct v4l2_ext_controls *a); |
| 156 | int (*vidioc_try_ext_ctrls) (struct file *file, void *fh, |
| 157 | struct v4l2_ext_controls *a); |
| 158 | int (*vidioc_querymenu) (struct file *file, void *fh, |
| 159 | struct v4l2_querymenu *a); |
| 160 | |
| 161 | /* Audio ioctls */ |
| 162 | int (*vidioc_enumaudio) (struct file *file, void *fh, |
| 163 | struct v4l2_audio *a); |
| 164 | int (*vidioc_g_audio) (struct file *file, void *fh, |
| 165 | struct v4l2_audio *a); |
| 166 | int (*vidioc_s_audio) (struct file *file, void *fh, |
| 167 | struct v4l2_audio *a); |
| 168 | |
| 169 | /* Audio out ioctls */ |
| 170 | int (*vidioc_enumaudout) (struct file *file, void *fh, |
| 171 | struct v4l2_audioout *a); |
| 172 | int (*vidioc_g_audout) (struct file *file, void *fh, |
| 173 | struct v4l2_audioout *a); |
| 174 | int (*vidioc_s_audout) (struct file *file, void *fh, |
| 175 | struct v4l2_audioout *a); |
| 176 | int (*vidioc_g_modulator) (struct file *file, void *fh, |
| 177 | struct v4l2_modulator *a); |
| 178 | int (*vidioc_s_modulator) (struct file *file, void *fh, |
| 179 | struct v4l2_modulator *a); |
| 180 | /* Crop ioctls */ |
| 181 | int (*vidioc_cropcap) (struct file *file, void *fh, |
| 182 | struct v4l2_cropcap *a); |
| 183 | int (*vidioc_g_crop) (struct file *file, void *fh, |
| 184 | struct v4l2_crop *a); |
| 185 | int (*vidioc_s_crop) (struct file *file, void *fh, |
| 186 | struct v4l2_crop *a); |
| 187 | /* Compression ioctls */ |
| 188 | int (*vidioc_g_jpegcomp) (struct file *file, void *fh, |
| 189 | struct v4l2_jpegcompression *a); |
| 190 | int (*vidioc_s_jpegcomp) (struct file *file, void *fh, |
| 191 | struct v4l2_jpegcompression *a); |
| 192 | int (*vidioc_g_enc_index) (struct file *file, void *fh, |
| 193 | struct v4l2_enc_idx *a); |
| 194 | int (*vidioc_encoder_cmd) (struct file *file, void *fh, |
| 195 | struct v4l2_encoder_cmd *a); |
| 196 | int (*vidioc_try_encoder_cmd) (struct file *file, void *fh, |
| 197 | struct v4l2_encoder_cmd *a); |
| 198 | |
| 199 | /* Stream type-dependent parameter ioctls */ |
| 200 | int (*vidioc_g_parm) (struct file *file, void *fh, |
| 201 | struct v4l2_streamparm *a); |
| 202 | int (*vidioc_s_parm) (struct file *file, void *fh, |
| 203 | struct v4l2_streamparm *a); |
| 204 | |
| 205 | /* Tuner ioctls */ |
| 206 | int (*vidioc_g_tuner) (struct file *file, void *fh, |
| 207 | struct v4l2_tuner *a); |
| 208 | int (*vidioc_s_tuner) (struct file *file, void *fh, |
| 209 | struct v4l2_tuner *a); |
| 210 | int (*vidioc_g_frequency) (struct file *file, void *fh, |
| 211 | struct v4l2_frequency *a); |
| 212 | int (*vidioc_s_frequency) (struct file *file, void *fh, |
| 213 | struct v4l2_frequency *a); |
| 214 | |
| 215 | /* Sliced VBI cap */ |
| 216 | int (*vidioc_g_sliced_vbi_cap) (struct file *file, void *fh, |
| 217 | struct v4l2_sliced_vbi_cap *a); |
| 218 | |
| 219 | /* Log status ioctl */ |
| 220 | int (*vidioc_log_status) (struct file *file, void *fh); |
| 221 | |
| 222 | int (*vidioc_s_hw_freq_seek) (struct file *file, void *fh, |
| 223 | struct v4l2_hw_freq_seek *a); |
| 224 | |
| 225 | /* Debugging ioctls */ |
| 226 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
| 227 | int (*vidioc_g_register) (struct file *file, void *fh, |
Hans Verkuil | aecde8b | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 228 | struct v4l2_dbg_register *reg); |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 229 | int (*vidioc_s_register) (struct file *file, void *fh, |
Hans Verkuil | aecde8b | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 230 | struct v4l2_dbg_register *reg); |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 231 | #endif |
| 232 | int (*vidioc_g_chip_ident) (struct file *file, void *fh, |
Hans Verkuil | aecde8b | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 233 | struct v4l2_dbg_chip_ident *chip); |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 234 | |
Mauro Carvalho Chehab | 74d83fa | 2008-11-11 21:13:47 -0300 | [diff] [blame] | 235 | int (*vidioc_enum_framesizes) (struct file *file, void *fh, |
| 236 | struct v4l2_frmsizeenum *fsize); |
| 237 | |
| 238 | int (*vidioc_enum_frameintervals) (struct file *file, void *fh, |
| 239 | struct v4l2_frmivalenum *fival); |
| 240 | |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 241 | /* For other private ioctls */ |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 242 | long (*vidioc_default) (struct file *file, void *fh, |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 243 | int cmd, void *arg); |
| 244 | }; |
| 245 | |
| 246 | |
Mauro Carvalho Chehab | 2864462 | 2008-07-20 20:26:54 -0300 | [diff] [blame] | 247 | /* v4l debugging and diagnostics */ |
| 248 | |
| 249 | /* Debug bitmask flags to be used on V4L2 */ |
| 250 | #define V4L2_DEBUG_IOCTL 0x01 |
| 251 | #define V4L2_DEBUG_IOCTL_ARG 0x02 |
| 252 | |
| 253 | /* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */ |
| 254 | #define v4l_print_ioctl(name, cmd) \ |
| 255 | do { \ |
| 256 | printk(KERN_DEBUG "%s: ", name); \ |
| 257 | v4l_printk_ioctl(cmd); \ |
| 258 | } while (0) |
| 259 | |
| 260 | /* Use this macro in I2C drivers where 'client' is the struct i2c_client |
| 261 | pointer */ |
| 262 | #define v4l_i2c_print_ioctl(client, cmd) \ |
| 263 | do { \ |
| 264 | v4l_client_printk(KERN_DEBUG, client, ""); \ |
| 265 | v4l_printk_ioctl(cmd); \ |
| 266 | } while (0) |
| 267 | |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 268 | /* Video standard functions */ |
| 269 | extern const char *v4l2_norm_to_name(v4l2_std_id id); |
| 270 | extern int v4l2_video_std_construct(struct v4l2_standard *vs, |
| 271 | int id, const char *name); |
| 272 | /* Prints the ioctl in a human-readable format */ |
| 273 | extern void v4l_printk_ioctl(unsigned int cmd); |
| 274 | |
| 275 | /* names for fancy debug output */ |
| 276 | extern const char *v4l2_field_names[]; |
| 277 | extern const char *v4l2_type_names[]; |
| 278 | |
| 279 | /* Compatibility layer interface -- v4l1-compat module */ |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 280 | typedef long (*v4l2_kioctl)(struct file *file, |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 281 | unsigned int cmd, void *arg); |
| 282 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 283 | long v4l_compat_translate_ioctl(struct file *file, |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 284 | int cmd, void *arg, v4l2_kioctl driver_ioctl); |
| 285 | #else |
Mauro Carvalho Chehab | b1f8840 | 2008-10-21 11:27:20 -0300 | [diff] [blame] | 286 | #define v4l_compat_translate_ioctl(file, cmd, arg, ioctl) (-EINVAL) |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 287 | #endif |
| 288 | |
Hans Verkuil | bec4366 | 2008-12-30 06:58:20 -0300 | [diff] [blame] | 289 | #ifdef CONFIG_COMPAT |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 290 | /* 32 Bits compatibility layer for 64 bits processors */ |
Hans Verkuil | 9bb7cde | 2008-12-30 06:42:40 -0300 | [diff] [blame] | 291 | extern long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 292 | unsigned long arg); |
Hans Verkuil | bec4366 | 2008-12-30 06:58:20 -0300 | [diff] [blame] | 293 | #endif |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 294 | |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 295 | /* Include support for obsoleted stuff */ |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 296 | extern long video_usercopy(struct file *file, unsigned int cmd, |
Hans Verkuil | f473bf7 | 2008-11-01 08:25:11 -0300 | [diff] [blame] | 297 | unsigned long arg, v4l2_kioctl func); |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 298 | |
Mauro Carvalho Chehab | 8a522c9 | 2008-10-21 11:58:39 -0300 | [diff] [blame] | 299 | /* Standard handlers for V4L ioctl's */ |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 300 | extern long video_ioctl2(struct file *file, |
Mauro Carvalho Chehab | 8a522c9 | 2008-10-21 11:58:39 -0300 | [diff] [blame] | 301 | unsigned int cmd, unsigned long arg); |
| 302 | |
Hans Verkuil | 35ea11f | 2008-07-20 08:12:02 -0300 | [diff] [blame] | 303 | #endif /* _V4L2_IOCTL_H */ |