aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/v4l2-ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/v4l2-ioctl.c')
-rw-r--r--drivers/media/video/v4l2-ioctl.c662
1 files changed, 233 insertions, 429 deletions
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 5b2ec1fd2d0a..91be4e871f43 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -55,19 +55,6 @@
55 memset((u8 *)(p) + offsetof(typeof(*(p)), field) + sizeof((p)->field), \ 55 memset((u8 *)(p) + offsetof(typeof(*(p)), field) + sizeof((p)->field), \
56 0, sizeof(*(p)) - offsetof(typeof(*(p)), field) - sizeof((p)->field)) 56 0, sizeof(*(p)) - offsetof(typeof(*(p)), field) - sizeof((p)->field))
57 57
58#define have_fmt_ops(foo) ( \
59 ops->vidioc_##foo##_fmt_vid_cap || \
60 ops->vidioc_##foo##_fmt_vid_out || \
61 ops->vidioc_##foo##_fmt_vid_cap_mplane || \
62 ops->vidioc_##foo##_fmt_vid_out_mplane || \
63 ops->vidioc_##foo##_fmt_vid_overlay || \
64 ops->vidioc_##foo##_fmt_vbi_cap || \
65 ops->vidioc_##foo##_fmt_vid_out_overlay || \
66 ops->vidioc_##foo##_fmt_vbi_out || \
67 ops->vidioc_##foo##_fmt_sliced_vbi_cap || \
68 ops->vidioc_##foo##_fmt_sliced_vbi_out || \
69 ops->vidioc_##foo##_fmt_type_private)
70
71struct std_descr { 58struct std_descr {
72 v4l2_std_id std; 59 v4l2_std_id std;
73 const char *descr; 60 const char *descr;
@@ -195,93 +182,118 @@ static const char *v4l2_memory_names[] = {
195 182
196/* ------------------------------------------------------------------ */ 183/* ------------------------------------------------------------------ */
197/* debug help functions */ 184/* debug help functions */
198static const char *v4l2_ioctls[] = { 185
199 [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP", 186struct v4l2_ioctl_info {
200 [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED", 187 unsigned int ioctl;
201 [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", 188 u16 flags;
202 [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", 189 const char * const name;
203 [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", 190};
204 [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", 191
205 [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", 192/* This control needs a priority check */
206 [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", 193#define INFO_FL_PRIO (1 << 0)
207 [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF", 194/* This control can be valid if the filehandle passes a control handler. */
208 [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY", 195#define INFO_FL_CTRL (1 << 1)
209 [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF", 196
210 [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF", 197#define IOCTL_INFO(_ioctl, _flags) [_IOC_NR(_ioctl)] = { \
211 [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON", 198 .ioctl = _ioctl, \
212 [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF", 199 .flags = _flags, \
213 [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM", 200 .name = #_ioctl, \
214 [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM", 201}
215 [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD", 202
216 [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD", 203static struct v4l2_ioctl_info v4l2_ioctls[] = {
217 [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD", 204 IOCTL_INFO(VIDIOC_QUERYCAP, 0),
218 [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT", 205 IOCTL_INFO(VIDIOC_ENUM_FMT, 0),
219 [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL", 206 IOCTL_INFO(VIDIOC_G_FMT, 0),
220 [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL", 207 IOCTL_INFO(VIDIOC_S_FMT, INFO_FL_PRIO),
221 [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER", 208 IOCTL_INFO(VIDIOC_REQBUFS, INFO_FL_PRIO),
222 [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER", 209 IOCTL_INFO(VIDIOC_QUERYBUF, 0),
223 [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO", 210 IOCTL_INFO(VIDIOC_G_FBUF, 0),
224 [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO", 211 IOCTL_INFO(VIDIOC_S_FBUF, INFO_FL_PRIO),
225 [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL", 212 IOCTL_INFO(VIDIOC_OVERLAY, INFO_FL_PRIO),
226 [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU", 213 IOCTL_INFO(VIDIOC_QBUF, 0),
227 [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT", 214 IOCTL_INFO(VIDIOC_DQBUF, 0),
228 [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT", 215 IOCTL_INFO(VIDIOC_STREAMON, INFO_FL_PRIO),
229 [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT", 216 IOCTL_INFO(VIDIOC_STREAMOFF, INFO_FL_PRIO),
230 [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT", 217 IOCTL_INFO(VIDIOC_G_PARM, 0),
231 [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT", 218 IOCTL_INFO(VIDIOC_S_PARM, INFO_FL_PRIO),
232 [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT", 219 IOCTL_INFO(VIDIOC_G_STD, 0),
233 [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT", 220 IOCTL_INFO(VIDIOC_S_STD, INFO_FL_PRIO),
234 [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR", 221 IOCTL_INFO(VIDIOC_ENUMSTD, 0),
235 [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR", 222 IOCTL_INFO(VIDIOC_ENUMINPUT, 0),
236 [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY", 223 IOCTL_INFO(VIDIOC_G_CTRL, INFO_FL_CTRL),
237 [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY", 224 IOCTL_INFO(VIDIOC_S_CTRL, INFO_FL_PRIO | INFO_FL_CTRL),
238 [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP", 225 IOCTL_INFO(VIDIOC_G_TUNER, 0),
239 [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP", 226 IOCTL_INFO(VIDIOC_S_TUNER, INFO_FL_PRIO),
240 [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP", 227 IOCTL_INFO(VIDIOC_G_AUDIO, 0),
241 [_IOC_NR(VIDIOC_G_SELECTION)] = "VIDIOC_G_SELECTION", 228 IOCTL_INFO(VIDIOC_S_AUDIO, INFO_FL_PRIO),
242 [_IOC_NR(VIDIOC_S_SELECTION)] = "VIDIOC_S_SELECTION", 229 IOCTL_INFO(VIDIOC_QUERYCTRL, INFO_FL_CTRL),
243 [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP", 230 IOCTL_INFO(VIDIOC_QUERYMENU, INFO_FL_CTRL),
244 [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP", 231 IOCTL_INFO(VIDIOC_G_INPUT, 0),
245 [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD", 232 IOCTL_INFO(VIDIOC_S_INPUT, INFO_FL_PRIO),
246 [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT", 233 IOCTL_INFO(VIDIOC_G_OUTPUT, 0),
247 [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO", 234 IOCTL_INFO(VIDIOC_S_OUTPUT, INFO_FL_PRIO),
248 [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT", 235 IOCTL_INFO(VIDIOC_ENUMOUTPUT, 0),
249 [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY", 236 IOCTL_INFO(VIDIOC_G_AUDOUT, 0),
250 [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY", 237 IOCTL_INFO(VIDIOC_S_AUDOUT, INFO_FL_PRIO),
251 [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP", 238 IOCTL_INFO(VIDIOC_G_MODULATOR, 0),
252 [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS", 239 IOCTL_INFO(VIDIOC_S_MODULATOR, INFO_FL_PRIO),
253 [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS", 240 IOCTL_INFO(VIDIOC_G_FREQUENCY, 0),
254 [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS", 241 IOCTL_INFO(VIDIOC_S_FREQUENCY, INFO_FL_PRIO),
255 [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS", 242 IOCTL_INFO(VIDIOC_CROPCAP, 0),
256#if 1 243 IOCTL_INFO(VIDIOC_G_CROP, 0),
257 [_IOC_NR(VIDIOC_ENUM_FRAMESIZES)] = "VIDIOC_ENUM_FRAMESIZES", 244 IOCTL_INFO(VIDIOC_S_CROP, INFO_FL_PRIO),
258 [_IOC_NR(VIDIOC_ENUM_FRAMEINTERVALS)] = "VIDIOC_ENUM_FRAMEINTERVALS", 245 IOCTL_INFO(VIDIOC_G_SELECTION, 0),
259 [_IOC_NR(VIDIOC_G_ENC_INDEX)] = "VIDIOC_G_ENC_INDEX", 246 IOCTL_INFO(VIDIOC_S_SELECTION, INFO_FL_PRIO),
260 [_IOC_NR(VIDIOC_ENCODER_CMD)] = "VIDIOC_ENCODER_CMD", 247 IOCTL_INFO(VIDIOC_G_JPEGCOMP, 0),
261 [_IOC_NR(VIDIOC_TRY_ENCODER_CMD)] = "VIDIOC_TRY_ENCODER_CMD", 248 IOCTL_INFO(VIDIOC_S_JPEGCOMP, INFO_FL_PRIO),
262 249 IOCTL_INFO(VIDIOC_QUERYSTD, 0),
263 [_IOC_NR(VIDIOC_DECODER_CMD)] = "VIDIOC_DECODER_CMD", 250 IOCTL_INFO(VIDIOC_TRY_FMT, 0),
264 [_IOC_NR(VIDIOC_TRY_DECODER_CMD)] = "VIDIOC_TRY_DECODER_CMD", 251 IOCTL_INFO(VIDIOC_ENUMAUDIO, 0),
265 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER", 252 IOCTL_INFO(VIDIOC_ENUMAUDOUT, 0),
266 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER", 253 IOCTL_INFO(VIDIOC_G_PRIORITY, 0),
267 254 IOCTL_INFO(VIDIOC_S_PRIORITY, INFO_FL_PRIO),
268 [_IOC_NR(VIDIOC_DBG_G_CHIP_IDENT)] = "VIDIOC_DBG_G_CHIP_IDENT", 255 IOCTL_INFO(VIDIOC_G_SLICED_VBI_CAP, 0),
269 [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)] = "VIDIOC_S_HW_FREQ_SEEK", 256 IOCTL_INFO(VIDIOC_LOG_STATUS, 0),
257 IOCTL_INFO(VIDIOC_G_EXT_CTRLS, INFO_FL_CTRL),
258 IOCTL_INFO(VIDIOC_S_EXT_CTRLS, INFO_FL_PRIO | INFO_FL_CTRL),
259 IOCTL_INFO(VIDIOC_TRY_EXT_CTRLS, 0),
260 IOCTL_INFO(VIDIOC_ENUM_FRAMESIZES, 0),
261 IOCTL_INFO(VIDIOC_ENUM_FRAMEINTERVALS, 0),
262 IOCTL_INFO(VIDIOC_G_ENC_INDEX, 0),
263 IOCTL_INFO(VIDIOC_ENCODER_CMD, INFO_FL_PRIO),
264 IOCTL_INFO(VIDIOC_TRY_ENCODER_CMD, 0),
265 IOCTL_INFO(VIDIOC_DECODER_CMD, INFO_FL_PRIO),
266 IOCTL_INFO(VIDIOC_TRY_DECODER_CMD, 0),
267#ifdef CONFIG_VIDEO_ADV_DEBUG
268 IOCTL_INFO(VIDIOC_DBG_S_REGISTER, 0),
269 IOCTL_INFO(VIDIOC_DBG_G_REGISTER, 0),
270#endif 270#endif
271 [_IOC_NR(VIDIOC_ENUM_DV_PRESETS)] = "VIDIOC_ENUM_DV_PRESETS", 271 IOCTL_INFO(VIDIOC_DBG_G_CHIP_IDENT, 0),
272 [_IOC_NR(VIDIOC_S_DV_PRESET)] = "VIDIOC_S_DV_PRESET", 272 IOCTL_INFO(VIDIOC_S_HW_FREQ_SEEK, INFO_FL_PRIO),
273 [_IOC_NR(VIDIOC_G_DV_PRESET)] = "VIDIOC_G_DV_PRESET", 273 IOCTL_INFO(VIDIOC_ENUM_DV_PRESETS, 0),
274 [_IOC_NR(VIDIOC_QUERY_DV_PRESET)] = "VIDIOC_QUERY_DV_PRESET", 274 IOCTL_INFO(VIDIOC_S_DV_PRESET, INFO_FL_PRIO),
275 [_IOC_NR(VIDIOC_S_DV_TIMINGS)] = "VIDIOC_S_DV_TIMINGS", 275 IOCTL_INFO(VIDIOC_G_DV_PRESET, 0),
276 [_IOC_NR(VIDIOC_G_DV_TIMINGS)] = "VIDIOC_G_DV_TIMINGS", 276 IOCTL_INFO(VIDIOC_QUERY_DV_PRESET, 0),
277 [_IOC_NR(VIDIOC_DQEVENT)] = "VIDIOC_DQEVENT", 277 IOCTL_INFO(VIDIOC_S_DV_TIMINGS, INFO_FL_PRIO),
278 [_IOC_NR(VIDIOC_SUBSCRIBE_EVENT)] = "VIDIOC_SUBSCRIBE_EVENT", 278 IOCTL_INFO(VIDIOC_G_DV_TIMINGS, 0),
279 [_IOC_NR(VIDIOC_UNSUBSCRIBE_EVENT)] = "VIDIOC_UNSUBSCRIBE_EVENT", 279 IOCTL_INFO(VIDIOC_DQEVENT, 0),
280 [_IOC_NR(VIDIOC_CREATE_BUFS)] = "VIDIOC_CREATE_BUFS", 280 IOCTL_INFO(VIDIOC_SUBSCRIBE_EVENT, 0),
281 [_IOC_NR(VIDIOC_PREPARE_BUF)] = "VIDIOC_PREPARE_BUF", 281 IOCTL_INFO(VIDIOC_UNSUBSCRIBE_EVENT, 0),
282 IOCTL_INFO(VIDIOC_CREATE_BUFS, INFO_FL_PRIO),
283 IOCTL_INFO(VIDIOC_PREPARE_BUF, 0),
284 IOCTL_INFO(VIDIOC_ENUM_DV_TIMINGS, 0),
285 IOCTL_INFO(VIDIOC_QUERY_DV_TIMINGS, 0),
286 IOCTL_INFO(VIDIOC_DV_TIMINGS_CAP, 0),
282}; 287};
283#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) 288#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
284 289
290bool v4l2_is_known_ioctl(unsigned int cmd)
291{
292 if (_IOC_NR(cmd) >= V4L2_IOCTLS)
293 return false;
294 return v4l2_ioctls[_IOC_NR(cmd)].ioctl == cmd;
295}
296
285/* Common ioctl debug function. This function can be used by 297/* Common ioctl debug function. This function can be used by
286 external ioctl messages as well as internal V4L ioctl */ 298 external ioctl messages as well as internal V4L ioctl */
287void v4l_printk_ioctl(unsigned int cmd) 299void v4l_printk_ioctl(unsigned int cmd)
@@ -297,7 +309,7 @@ void v4l_printk_ioctl(unsigned int cmd)
297 type = "v4l2"; 309 type = "v4l2";
298 break; 310 break;
299 } 311 }
300 printk("%s", v4l2_ioctls[_IOC_NR(cmd)]); 312 printk("%s", v4l2_ioctls[_IOC_NR(cmd)].name);
301 return; 313 return;
302 default: 314 default:
303 type = "unknown"; 315 type = "unknown";
@@ -359,6 +371,34 @@ static inline void dbgrect(struct video_device *vfd, char *s,
359 r->width, r->height); 371 r->width, r->height);
360}; 372};
361 373
374static void dbgtimings(struct video_device *vfd,
375 const struct v4l2_dv_timings *p)
376{
377 switch (p->type) {
378 case V4L2_DV_BT_656_1120:
379 dbgarg2("bt-656/1120:interlaced=%d,"
380 " pixelclock=%lld,"
381 " width=%d, height=%d, polarities=%x,"
382 " hfrontporch=%d, hsync=%d,"
383 " hbackporch=%d, vfrontporch=%d,"
384 " vsync=%d, vbackporch=%d,"
385 " il_vfrontporch=%d, il_vsync=%d,"
386 " il_vbackporch=%d, standards=%x, flags=%x\n",
387 p->bt.interlaced, p->bt.pixelclock,
388 p->bt.width, p->bt.height,
389 p->bt.polarities, p->bt.hfrontporch,
390 p->bt.hsync, p->bt.hbackporch,
391 p->bt.vfrontporch, p->bt.vsync,
392 p->bt.vbackporch, p->bt.il_vfrontporch,
393 p->bt.il_vsync, p->bt.il_vbackporch,
394 p->bt.standards, p->bt.flags);
395 break;
396 default:
397 dbgarg2("Unknown type %d!\n", p->type);
398 break;
399 }
400}
401
362static inline void v4l_print_pix_fmt(struct video_device *vfd, 402static inline void v4l_print_pix_fmt(struct video_device *vfd,
363 struct v4l2_pix_format *fmt) 403 struct v4l2_pix_format *fmt)
364{ 404{
@@ -504,7 +544,6 @@ static long __video_do_ioctl(struct file *file,
504 void *fh = file->private_data; 544 void *fh = file->private_data;
505 struct v4l2_fh *vfh = NULL; 545 struct v4l2_fh *vfh = NULL;
506 int use_fh_prio = 0; 546 int use_fh_prio = 0;
507 long ret_prio = 0;
508 long ret = -ENOTTY; 547 long ret = -ENOTTY;
509 548
510 if (ops == NULL) { 549 if (ops == NULL) {
@@ -513,19 +552,30 @@ static long __video_do_ioctl(struct file *file,
513 return ret; 552 return ret;
514 } 553 }
515 554
516 if ((vfd->debug & V4L2_DEBUG_IOCTL) &&
517 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
518 v4l_print_ioctl(vfd->name, cmd);
519 printk(KERN_CONT "\n");
520 }
521
522 if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { 555 if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
523 vfh = file->private_data; 556 vfh = file->private_data;
524 use_fh_prio = test_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); 557 use_fh_prio = test_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags);
525 } 558 }
526 559
527 if (use_fh_prio) 560 if (v4l2_is_known_ioctl(cmd)) {
528 ret_prio = v4l2_prio_check(vfd->prio, vfh->prio); 561 struct v4l2_ioctl_info *info = &v4l2_ioctls[_IOC_NR(cmd)];
562
563 if (!test_bit(_IOC_NR(cmd), vfd->valid_ioctls) &&
564 !((info->flags & INFO_FL_CTRL) && vfh && vfh->ctrl_handler))
565 return -ENOTTY;
566
567 if (use_fh_prio && (info->flags & INFO_FL_PRIO)) {
568 ret = v4l2_prio_check(vfd->prio, vfh->prio);
569 if (ret)
570 return ret;
571 }
572 }
573
574 if ((vfd->debug & V4L2_DEBUG_IOCTL) &&
575 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
576 v4l_print_ioctl(vfd->name, cmd);
577 printk(KERN_CONT "\n");
578 }
529 579
530 switch (cmd) { 580 switch (cmd) {
531 581
@@ -534,9 +584,6 @@ static long __video_do_ioctl(struct file *file,
534 { 584 {
535 struct v4l2_capability *cap = (struct v4l2_capability *)arg; 585 struct v4l2_capability *cap = (struct v4l2_capability *)arg;
536 586
537 if (!ops->vidioc_querycap)
538 break;
539
540 cap->version = LINUX_VERSION_CODE; 587 cap->version = LINUX_VERSION_CODE;
541 ret = ops->vidioc_querycap(file, fh, cap); 588 ret = ops->vidioc_querycap(file, fh, cap);
542 if (!ret) 589 if (!ret)
@@ -570,14 +617,11 @@ static long __video_do_ioctl(struct file *file,
570 { 617 {
571 enum v4l2_priority *p = arg; 618 enum v4l2_priority *p = arg;
572 619
573 if (!ops->vidioc_s_priority && !use_fh_prio)
574 break;
575 dbgarg(cmd, "setting priority to %d\n", *p); 620 dbgarg(cmd, "setting priority to %d\n", *p);
576 if (ops->vidioc_s_priority) 621 if (ops->vidioc_s_priority)
577 ret = ops->vidioc_s_priority(file, fh, *p); 622 ret = ops->vidioc_s_priority(file, fh, *p);
578 else 623 else
579 ret = ret_prio ? ret_prio : 624 ret = v4l2_prio_change(&vfd->v4l2_dev->prio,
580 v4l2_prio_change(&vfd->v4l2_dev->prio,
581 &vfh->prio, *p); 625 &vfh->prio, *p);
582 break; 626 break;
583 } 627 }
@@ -587,6 +631,7 @@ static long __video_do_ioctl(struct file *file,
587 { 631 {
588 struct v4l2_fmtdesc *f = arg; 632 struct v4l2_fmtdesc *f = arg;
589 633
634 ret = -EINVAL;
590 switch (f->type) { 635 switch (f->type) {
591 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 636 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
592 if (likely(ops->vidioc_enum_fmt_vid_cap)) 637 if (likely(ops->vidioc_enum_fmt_vid_cap))
@@ -619,7 +664,7 @@ static long __video_do_ioctl(struct file *file,
619 default: 664 default:
620 break; 665 break;
621 } 666 }
622 if (likely (!ret)) 667 if (likely(!ret))
623 dbgarg(cmd, "index=%d, type=%d, flags=%d, " 668 dbgarg(cmd, "index=%d, type=%d, flags=%d, "
624 "pixelformat=%c%c%c%c, description='%s'\n", 669 "pixelformat=%c%c%c%c, description='%s'\n",
625 f->index, f->type, f->flags, 670 f->index, f->type, f->flags,
@@ -628,14 +673,6 @@ static long __video_do_ioctl(struct file *file,
628 (f->pixelformat >> 16) & 0xff, 673 (f->pixelformat >> 16) & 0xff,
629 (f->pixelformat >> 24) & 0xff, 674 (f->pixelformat >> 24) & 0xff,
630 f->description); 675 f->description);
631 else if (ret == -ENOTTY &&
632 (ops->vidioc_enum_fmt_vid_cap ||
633 ops->vidioc_enum_fmt_vid_out ||
634 ops->vidioc_enum_fmt_vid_cap_mplane ||
635 ops->vidioc_enum_fmt_vid_out_mplane ||
636 ops->vidioc_enum_fmt_vid_overlay ||
637 ops->vidioc_enum_fmt_type_private))
638 ret = -EINVAL;
639 break; 676 break;
640 } 677 }
641 case VIDIOC_G_FMT: 678 case VIDIOC_G_FMT:
@@ -645,6 +682,7 @@ static long __video_do_ioctl(struct file *file,
645 /* FIXME: Should be one dump per type */ 682 /* FIXME: Should be one dump per type */
646 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names)); 683 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names));
647 684
685 ret = -EINVAL;
648 switch (f->type) { 686 switch (f->type) {
649 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 687 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
650 if (ops->vidioc_g_fmt_vid_cap) 688 if (ops->vidioc_g_fmt_vid_cap)
@@ -706,21 +744,12 @@ static long __video_do_ioctl(struct file *file,
706 fh, f); 744 fh, f);
707 break; 745 break;
708 } 746 }
709 if (unlikely(ret == -ENOTTY && have_fmt_ops(g)))
710 ret = -EINVAL;
711
712 break; 747 break;
713 } 748 }
714 case VIDIOC_S_FMT: 749 case VIDIOC_S_FMT:
715 { 750 {
716 struct v4l2_format *f = (struct v4l2_format *)arg; 751 struct v4l2_format *f = (struct v4l2_format *)arg;
717 752
718 if (!have_fmt_ops(s))
719 break;
720 if (ret_prio) {
721 ret = ret_prio;
722 break;
723 }
724 ret = -EINVAL; 753 ret = -EINVAL;
725 754
726 /* FIXME: Should be one dump per type */ 755 /* FIXME: Should be one dump per type */
@@ -804,6 +833,7 @@ static long __video_do_ioctl(struct file *file,
804 /* FIXME: Should be one dump per type */ 833 /* FIXME: Should be one dump per type */
805 dbgarg(cmd, "type=%s\n", prt_names(f->type, 834 dbgarg(cmd, "type=%s\n", prt_names(f->type,
806 v4l2_type_names)); 835 v4l2_type_names));
836 ret = -EINVAL;
807 switch (f->type) { 837 switch (f->type) {
808 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 838 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
809 CLEAR_AFTER_FIELD(f, fmt.pix); 839 CLEAR_AFTER_FIELD(f, fmt.pix);
@@ -876,8 +906,6 @@ static long __video_do_ioctl(struct file *file,
876 fh, f); 906 fh, f);
877 break; 907 break;
878 } 908 }
879 if (unlikely(ret == -ENOTTY && have_fmt_ops(try)))
880 ret = -EINVAL;
881 break; 909 break;
882 } 910 }
883 /* FIXME: Those buf reqs could be handled here, 911 /* FIXME: Those buf reqs could be handled here,
@@ -888,12 +916,6 @@ static long __video_do_ioctl(struct file *file,
888 { 916 {
889 struct v4l2_requestbuffers *p = arg; 917 struct v4l2_requestbuffers *p = arg;
890 918
891 if (!ops->vidioc_reqbufs)
892 break;
893 if (ret_prio) {
894 ret = ret_prio;
895 break;
896 }
897 ret = check_fmt(ops, p->type); 919 ret = check_fmt(ops, p->type);
898 if (ret) 920 if (ret)
899 break; 921 break;
@@ -912,8 +934,6 @@ static long __video_do_ioctl(struct file *file,
912 { 934 {
913 struct v4l2_buffer *p = arg; 935 struct v4l2_buffer *p = arg;
914 936
915 if (!ops->vidioc_querybuf)
916 break;
917 ret = check_fmt(ops, p->type); 937 ret = check_fmt(ops, p->type);
918 if (ret) 938 if (ret)
919 break; 939 break;
@@ -927,8 +947,6 @@ static long __video_do_ioctl(struct file *file,
927 { 947 {
928 struct v4l2_buffer *p = arg; 948 struct v4l2_buffer *p = arg;
929 949
930 if (!ops->vidioc_qbuf)
931 break;
932 ret = check_fmt(ops, p->type); 950 ret = check_fmt(ops, p->type);
933 if (ret) 951 if (ret)
934 break; 952 break;
@@ -942,8 +960,6 @@ static long __video_do_ioctl(struct file *file,
942 { 960 {
943 struct v4l2_buffer *p = arg; 961 struct v4l2_buffer *p = arg;
944 962
945 if (!ops->vidioc_dqbuf)
946 break;
947 ret = check_fmt(ops, p->type); 963 ret = check_fmt(ops, p->type);
948 if (ret) 964 if (ret)
949 break; 965 break;
@@ -957,12 +973,6 @@ static long __video_do_ioctl(struct file *file,
957 { 973 {
958 int *i = arg; 974 int *i = arg;
959 975
960 if (!ops->vidioc_overlay)
961 break;
962 if (ret_prio) {
963 ret = ret_prio;
964 break;
965 }
966 dbgarg(cmd, "value=%d\n", *i); 976 dbgarg(cmd, "value=%d\n", *i);
967 ret = ops->vidioc_overlay(file, fh, *i); 977 ret = ops->vidioc_overlay(file, fh, *i);
968 break; 978 break;
@@ -971,8 +981,6 @@ static long __video_do_ioctl(struct file *file,
971 { 981 {
972 struct v4l2_framebuffer *p = arg; 982 struct v4l2_framebuffer *p = arg;
973 983
974 if (!ops->vidioc_g_fbuf)
975 break;
976 ret = ops->vidioc_g_fbuf(file, fh, arg); 984 ret = ops->vidioc_g_fbuf(file, fh, arg);
977 if (!ret) { 985 if (!ret) {
978 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n", 986 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n",
@@ -986,12 +994,6 @@ static long __video_do_ioctl(struct file *file,
986 { 994 {
987 struct v4l2_framebuffer *p = arg; 995 struct v4l2_framebuffer *p = arg;
988 996
989 if (!ops->vidioc_s_fbuf)
990 break;
991 if (ret_prio) {
992 ret = ret_prio;
993 break;
994 }
995 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n", 997 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n",
996 p->capability, p->flags, (unsigned long)p->base); 998 p->capability, p->flags, (unsigned long)p->base);
997 v4l_print_pix_fmt(vfd, &p->fmt); 999 v4l_print_pix_fmt(vfd, &p->fmt);
@@ -1002,12 +1004,6 @@ static long __video_do_ioctl(struct file *file,
1002 { 1004 {
1003 enum v4l2_buf_type i = *(int *)arg; 1005 enum v4l2_buf_type i = *(int *)arg;
1004 1006
1005 if (!ops->vidioc_streamon)
1006 break;
1007 if (ret_prio) {
1008 ret = ret_prio;
1009 break;
1010 }
1011 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); 1007 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
1012 ret = ops->vidioc_streamon(file, fh, i); 1008 ret = ops->vidioc_streamon(file, fh, i);
1013 break; 1009 break;
@@ -1016,12 +1012,6 @@ static long __video_do_ioctl(struct file *file,
1016 { 1012 {
1017 enum v4l2_buf_type i = *(int *)arg; 1013 enum v4l2_buf_type i = *(int *)arg;
1018 1014
1019 if (!ops->vidioc_streamoff)
1020 break;
1021 if (ret_prio) {
1022 ret = ret_prio;
1023 break;
1024 }
1025 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); 1015 dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names));
1026 ret = ops->vidioc_streamoff(file, fh, i); 1016 ret = ops->vidioc_streamoff(file, fh, i);
1027 break; 1017 break;
@@ -1091,13 +1081,6 @@ static long __video_do_ioctl(struct file *file,
1091 1081
1092 dbgarg(cmd, "std=%08Lx\n", (long long unsigned)*id); 1082 dbgarg(cmd, "std=%08Lx\n", (long long unsigned)*id);
1093 1083
1094 if (!ops->vidioc_s_std)
1095 break;
1096
1097 if (ret_prio) {
1098 ret = ret_prio;
1099 break;
1100 }
1101 ret = -EINVAL; 1084 ret = -EINVAL;
1102 norm = (*id) & vfd->tvnorms; 1085 norm = (*id) & vfd->tvnorms;
1103 if (vfd->tvnorms && !norm) /* Check if std is supported */ 1086 if (vfd->tvnorms && !norm) /* Check if std is supported */
@@ -1115,8 +1098,6 @@ static long __video_do_ioctl(struct file *file,
1115 { 1098 {
1116 v4l2_std_id *p = arg; 1099 v4l2_std_id *p = arg;
1117 1100
1118 if (!ops->vidioc_querystd)
1119 break;
1120 /* 1101 /*
1121 * If nothing detected, it should return all supported 1102 * If nothing detected, it should return all supported
1122 * Drivers just need to mask the std argument, in order 1103 * Drivers just need to mask the std argument, in order
@@ -1150,9 +1131,6 @@ static long __video_do_ioctl(struct file *file,
1150 if (ops->vidioc_s_dv_timings) 1131 if (ops->vidioc_s_dv_timings)
1151 p->capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS; 1132 p->capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS;
1152 1133
1153 if (!ops->vidioc_enum_input)
1154 break;
1155
1156 ret = ops->vidioc_enum_input(file, fh, p); 1134 ret = ops->vidioc_enum_input(file, fh, p);
1157 if (!ret) 1135 if (!ret)
1158 dbgarg(cmd, "index=%d, name=%s, type=%d, " 1136 dbgarg(cmd, "index=%d, name=%s, type=%d, "
@@ -1168,8 +1146,6 @@ static long __video_do_ioctl(struct file *file,
1168 { 1146 {
1169 unsigned int *i = arg; 1147 unsigned int *i = arg;
1170 1148
1171 if (!ops->vidioc_g_input)
1172 break;
1173 ret = ops->vidioc_g_input(file, fh, i); 1149 ret = ops->vidioc_g_input(file, fh, i);
1174 if (!ret) 1150 if (!ret)
1175 dbgarg(cmd, "value=%d\n", *i); 1151 dbgarg(cmd, "value=%d\n", *i);
@@ -1179,12 +1155,6 @@ static long __video_do_ioctl(struct file *file,
1179 { 1155 {
1180 unsigned int *i = arg; 1156 unsigned int *i = arg;
1181 1157
1182 if (!ops->vidioc_s_input)
1183 break;
1184 if (ret_prio) {
1185 ret = ret_prio;
1186 break;
1187 }
1188 dbgarg(cmd, "value=%d\n", *i); 1158 dbgarg(cmd, "value=%d\n", *i);
1189 ret = ops->vidioc_s_input(file, fh, *i); 1159 ret = ops->vidioc_s_input(file, fh, *i);
1190 break; 1160 break;
@@ -1195,9 +1165,6 @@ static long __video_do_ioctl(struct file *file,
1195 { 1165 {
1196 struct v4l2_output *p = arg; 1166 struct v4l2_output *p = arg;
1197 1167
1198 if (!ops->vidioc_enum_output)
1199 break;
1200
1201 /* 1168 /*
1202 * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & 1169 * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS &
1203 * CAP_STD here based on ioctl handler provided by the 1170 * CAP_STD here based on ioctl handler provided by the
@@ -1224,8 +1191,6 @@ static long __video_do_ioctl(struct file *file,
1224 { 1191 {
1225 unsigned int *i = arg; 1192 unsigned int *i = arg;
1226 1193
1227 if (!ops->vidioc_g_output)
1228 break;
1229 ret = ops->vidioc_g_output(file, fh, i); 1194 ret = ops->vidioc_g_output(file, fh, i);
1230 if (!ret) 1195 if (!ret)
1231 dbgarg(cmd, "value=%d\n", *i); 1196 dbgarg(cmd, "value=%d\n", *i);
@@ -1235,12 +1200,6 @@ static long __video_do_ioctl(struct file *file,
1235 { 1200 {
1236 unsigned int *i = arg; 1201 unsigned int *i = arg;
1237 1202
1238 if (!ops->vidioc_s_output)
1239 break;
1240 if (ret_prio) {
1241 ret = ret_prio;
1242 break;
1243 }
1244 dbgarg(cmd, "value=%d\n", *i); 1203 dbgarg(cmd, "value=%d\n", *i);
1245 ret = ops->vidioc_s_output(file, fh, *i); 1204 ret = ops->vidioc_s_output(file, fh, *i);
1246 break; 1205 break;
@@ -1310,10 +1269,6 @@ static long __video_do_ioctl(struct file *file,
1310 if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler && 1269 if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler &&
1311 !ops->vidioc_s_ctrl && !ops->vidioc_s_ext_ctrls) 1270 !ops->vidioc_s_ctrl && !ops->vidioc_s_ext_ctrls)
1312 break; 1271 break;
1313 if (ret_prio) {
1314 ret = ret_prio;
1315 break;
1316 }
1317 1272
1318 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value); 1273 dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value);
1319 1274
@@ -1369,10 +1324,6 @@ static long __video_do_ioctl(struct file *file,
1369 if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler && 1324 if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler &&
1370 !ops->vidioc_s_ext_ctrls) 1325 !ops->vidioc_s_ext_ctrls)
1371 break; 1326 break;
1372 if (ret_prio) {
1373 ret = ret_prio;
1374 break;
1375 }
1376 v4l_print_ext_ctrls(cmd, vfd, p, 1); 1327 v4l_print_ext_ctrls(cmd, vfd, p, 1);
1377 if (vfh && vfh->ctrl_handler) 1328 if (vfh && vfh->ctrl_handler)
1378 ret = v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, p); 1329 ret = v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, p);
@@ -1428,8 +1379,6 @@ static long __video_do_ioctl(struct file *file,
1428 { 1379 {
1429 struct v4l2_audio *p = arg; 1380 struct v4l2_audio *p = arg;
1430 1381
1431 if (!ops->vidioc_enumaudio)
1432 break;
1433 ret = ops->vidioc_enumaudio(file, fh, p); 1382 ret = ops->vidioc_enumaudio(file, fh, p);
1434 if (!ret) 1383 if (!ret)
1435 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, " 1384 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
@@ -1443,9 +1392,6 @@ static long __video_do_ioctl(struct file *file,
1443 { 1392 {
1444 struct v4l2_audio *p = arg; 1393 struct v4l2_audio *p = arg;
1445 1394
1446 if (!ops->vidioc_g_audio)
1447 break;
1448
1449 ret = ops->vidioc_g_audio(file, fh, p); 1395 ret = ops->vidioc_g_audio(file, fh, p);
1450 if (!ret) 1396 if (!ret)
1451 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, " 1397 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
@@ -1459,12 +1405,6 @@ static long __video_do_ioctl(struct file *file,
1459 { 1405 {
1460 struct v4l2_audio *p = arg; 1406 struct v4l2_audio *p = arg;
1461 1407
1462 if (!ops->vidioc_s_audio)
1463 break;
1464 if (ret_prio) {
1465 ret = ret_prio;
1466 break;
1467 }
1468 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, " 1408 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
1469 "mode=0x%x\n", p->index, p->name, 1409 "mode=0x%x\n", p->index, p->name,
1470 p->capability, p->mode); 1410 p->capability, p->mode);
@@ -1475,8 +1415,6 @@ static long __video_do_ioctl(struct file *file,
1475 { 1415 {
1476 struct v4l2_audioout *p = arg; 1416 struct v4l2_audioout *p = arg;
1477 1417
1478 if (!ops->vidioc_enumaudout)
1479 break;
1480 dbgarg(cmd, "Enum for index=%d\n", p->index); 1418 dbgarg(cmd, "Enum for index=%d\n", p->index);
1481 ret = ops->vidioc_enumaudout(file, fh, p); 1419 ret = ops->vidioc_enumaudout(file, fh, p);
1482 if (!ret) 1420 if (!ret)
@@ -1489,9 +1427,6 @@ static long __video_do_ioctl(struct file *file,
1489 { 1427 {
1490 struct v4l2_audioout *p = arg; 1428 struct v4l2_audioout *p = arg;
1491 1429
1492 if (!ops->vidioc_g_audout)
1493 break;
1494
1495 ret = ops->vidioc_g_audout(file, fh, p); 1430 ret = ops->vidioc_g_audout(file, fh, p);
1496 if (!ret) 1431 if (!ret)
1497 dbgarg2("index=%d, name=%s, capability=%d, " 1432 dbgarg2("index=%d, name=%s, capability=%d, "
@@ -1503,12 +1438,6 @@ static long __video_do_ioctl(struct file *file,
1503 { 1438 {
1504 struct v4l2_audioout *p = arg; 1439 struct v4l2_audioout *p = arg;
1505 1440
1506 if (!ops->vidioc_s_audout)
1507 break;
1508 if (ret_prio) {
1509 ret = ret_prio;
1510 break;
1511 }
1512 dbgarg(cmd, "index=%d, name=%s, capability=%d, " 1441 dbgarg(cmd, "index=%d, name=%s, capability=%d, "
1513 "mode=%d\n", p->index, p->name, 1442 "mode=%d\n", p->index, p->name,
1514 p->capability, p->mode); 1443 p->capability, p->mode);
@@ -1520,8 +1449,6 @@ static long __video_do_ioctl(struct file *file,
1520 { 1449 {
1521 struct v4l2_modulator *p = arg; 1450 struct v4l2_modulator *p = arg;
1522 1451
1523 if (!ops->vidioc_g_modulator)
1524 break;
1525 ret = ops->vidioc_g_modulator(file, fh, p); 1452 ret = ops->vidioc_g_modulator(file, fh, p);
1526 if (!ret) 1453 if (!ret)
1527 dbgarg(cmd, "index=%d, name=%s, " 1454 dbgarg(cmd, "index=%d, name=%s, "
@@ -1536,12 +1463,6 @@ static long __video_do_ioctl(struct file *file,
1536 { 1463 {
1537 struct v4l2_modulator *p = arg; 1464 struct v4l2_modulator *p = arg;
1538 1465
1539 if (!ops->vidioc_s_modulator)
1540 break;
1541 if (ret_prio) {
1542 ret = ret_prio;
1543 break;
1544 }
1545 dbgarg(cmd, "index=%d, name=%s, capability=%d, " 1466 dbgarg(cmd, "index=%d, name=%s, capability=%d, "
1546 "rangelow=%d, rangehigh=%d, txsubchans=%d\n", 1467 "rangelow=%d, rangehigh=%d, txsubchans=%d\n",
1547 p->index, p->name, p->capability, p->rangelow, 1468 p->index, p->name, p->capability, p->rangelow,
@@ -1553,9 +1474,6 @@ static long __video_do_ioctl(struct file *file,
1553 { 1474 {
1554 struct v4l2_crop *p = arg; 1475 struct v4l2_crop *p = arg;
1555 1476
1556 if (!ops->vidioc_g_crop && !ops->vidioc_g_selection)
1557 break;
1558
1559 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); 1477 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1560 1478
1561 if (ops->vidioc_g_crop) { 1479 if (ops->vidioc_g_crop) {
@@ -1587,13 +1505,6 @@ static long __video_do_ioctl(struct file *file,
1587 { 1505 {
1588 struct v4l2_crop *p = arg; 1506 struct v4l2_crop *p = arg;
1589 1507
1590 if (!ops->vidioc_s_crop && !ops->vidioc_s_selection)
1591 break;
1592
1593 if (ret_prio) {
1594 ret = ret_prio;
1595 break;
1596 }
1597 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); 1508 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1598 dbgrect(vfd, "", &p->c); 1509 dbgrect(vfd, "", &p->c);
1599 1510
@@ -1620,9 +1531,6 @@ static long __video_do_ioctl(struct file *file,
1620 { 1531 {
1621 struct v4l2_selection *p = arg; 1532 struct v4l2_selection *p = arg;
1622 1533
1623 if (!ops->vidioc_g_selection)
1624 break;
1625
1626 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); 1534 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1627 1535
1628 ret = ops->vidioc_g_selection(file, fh, p); 1536 ret = ops->vidioc_g_selection(file, fh, p);
@@ -1634,13 +1542,6 @@ static long __video_do_ioctl(struct file *file,
1634 { 1542 {
1635 struct v4l2_selection *p = arg; 1543 struct v4l2_selection *p = arg;
1636 1544
1637 if (!ops->vidioc_s_selection)
1638 break;
1639
1640 if (ret_prio) {
1641 ret = ret_prio;
1642 break;
1643 }
1644 1545
1645 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); 1546 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1646 dbgrect(vfd, "", &p->r); 1547 dbgrect(vfd, "", &p->r);
@@ -1653,9 +1554,6 @@ static long __video_do_ioctl(struct file *file,
1653 struct v4l2_cropcap *p = arg; 1554 struct v4l2_cropcap *p = arg;
1654 1555
1655 /*FIXME: Should also show v4l2_fract pixelaspect */ 1556 /*FIXME: Should also show v4l2_fract pixelaspect */
1656 if (!ops->vidioc_cropcap && !ops->vidioc_g_selection)
1657 break;
1658
1659 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); 1557 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1660 if (ops->vidioc_cropcap) { 1558 if (ops->vidioc_cropcap) {
1661 ret = ops->vidioc_cropcap(file, fh, p); 1559 ret = ops->vidioc_cropcap(file, fh, p);
@@ -1699,9 +1597,6 @@ static long __video_do_ioctl(struct file *file,
1699 { 1597 {
1700 struct v4l2_jpegcompression *p = arg; 1598 struct v4l2_jpegcompression *p = arg;
1701 1599
1702 if (!ops->vidioc_g_jpegcomp)
1703 break;
1704
1705 ret = ops->vidioc_g_jpegcomp(file, fh, p); 1600 ret = ops->vidioc_g_jpegcomp(file, fh, p);
1706 if (!ret) 1601 if (!ret)
1707 dbgarg(cmd, "quality=%d, APPn=%d, " 1602 dbgarg(cmd, "quality=%d, APPn=%d, "
@@ -1715,12 +1610,6 @@ static long __video_do_ioctl(struct file *file,
1715 { 1610 {
1716 struct v4l2_jpegcompression *p = arg; 1611 struct v4l2_jpegcompression *p = arg;
1717 1612
1718 if (!ops->vidioc_g_jpegcomp)
1719 break;
1720 if (ret_prio) {
1721 ret = ret_prio;
1722 break;
1723 }
1724 dbgarg(cmd, "quality=%d, APPn=%d, APP_len=%d, " 1613 dbgarg(cmd, "quality=%d, APPn=%d, APP_len=%d, "
1725 "COM_len=%d, jpeg_markers=%d\n", 1614 "COM_len=%d, jpeg_markers=%d\n",
1726 p->quality, p->APPn, p->APP_len, 1615 p->quality, p->APPn, p->APP_len,
@@ -1732,8 +1621,6 @@ static long __video_do_ioctl(struct file *file,
1732 { 1621 {
1733 struct v4l2_enc_idx *p = arg; 1622 struct v4l2_enc_idx *p = arg;
1734 1623
1735 if (!ops->vidioc_g_enc_index)
1736 break;
1737 ret = ops->vidioc_g_enc_index(file, fh, p); 1624 ret = ops->vidioc_g_enc_index(file, fh, p);
1738 if (!ret) 1625 if (!ret)
1739 dbgarg(cmd, "entries=%d, entries_cap=%d\n", 1626 dbgarg(cmd, "entries=%d, entries_cap=%d\n",
@@ -1744,12 +1631,6 @@ static long __video_do_ioctl(struct file *file,
1744 { 1631 {
1745 struct v4l2_encoder_cmd *p = arg; 1632 struct v4l2_encoder_cmd *p = arg;
1746 1633
1747 if (!ops->vidioc_encoder_cmd)
1748 break;
1749 if (ret_prio) {
1750 ret = ret_prio;
1751 break;
1752 }
1753 ret = ops->vidioc_encoder_cmd(file, fh, p); 1634 ret = ops->vidioc_encoder_cmd(file, fh, p);
1754 if (!ret) 1635 if (!ret)
1755 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); 1636 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
@@ -1759,8 +1640,6 @@ static long __video_do_ioctl(struct file *file,
1759 { 1640 {
1760 struct v4l2_encoder_cmd *p = arg; 1641 struct v4l2_encoder_cmd *p = arg;
1761 1642
1762 if (!ops->vidioc_try_encoder_cmd)
1763 break;
1764 ret = ops->vidioc_try_encoder_cmd(file, fh, p); 1643 ret = ops->vidioc_try_encoder_cmd(file, fh, p);
1765 if (!ret) 1644 if (!ret)
1766 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); 1645 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
@@ -1770,12 +1649,6 @@ static long __video_do_ioctl(struct file *file,
1770 { 1649 {
1771 struct v4l2_decoder_cmd *p = arg; 1650 struct v4l2_decoder_cmd *p = arg;
1772 1651
1773 if (!ops->vidioc_decoder_cmd)
1774 break;
1775 if (ret_prio) {
1776 ret = ret_prio;
1777 break;
1778 }
1779 ret = ops->vidioc_decoder_cmd(file, fh, p); 1652 ret = ops->vidioc_decoder_cmd(file, fh, p);
1780 if (!ret) 1653 if (!ret)
1781 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); 1654 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
@@ -1785,8 +1658,6 @@ static long __video_do_ioctl(struct file *file,
1785 { 1658 {
1786 struct v4l2_decoder_cmd *p = arg; 1659 struct v4l2_decoder_cmd *p = arg;
1787 1660
1788 if (!ops->vidioc_try_decoder_cmd)
1789 break;
1790 ret = ops->vidioc_try_decoder_cmd(file, fh, p); 1661 ret = ops->vidioc_try_decoder_cmd(file, fh, p);
1791 if (!ret) 1662 if (!ret)
1792 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); 1663 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
@@ -1796,8 +1667,6 @@ static long __video_do_ioctl(struct file *file,
1796 { 1667 {
1797 struct v4l2_streamparm *p = arg; 1668 struct v4l2_streamparm *p = arg;
1798 1669
1799 if (!ops->vidioc_g_parm && !vfd->current_norm)
1800 break;
1801 if (ops->vidioc_g_parm) { 1670 if (ops->vidioc_g_parm) {
1802 ret = check_fmt(ops, p->type); 1671 ret = check_fmt(ops, p->type);
1803 if (ret) 1672 if (ret)
@@ -1825,12 +1694,6 @@ static long __video_do_ioctl(struct file *file,
1825 { 1694 {
1826 struct v4l2_streamparm *p = arg; 1695 struct v4l2_streamparm *p = arg;
1827 1696
1828 if (!ops->vidioc_s_parm)
1829 break;
1830 if (ret_prio) {
1831 ret = ret_prio;
1832 break;
1833 }
1834 ret = check_fmt(ops, p->type); 1697 ret = check_fmt(ops, p->type);
1835 if (ret) 1698 if (ret)
1836 break; 1699 break;
@@ -1843,9 +1706,6 @@ static long __video_do_ioctl(struct file *file,
1843 { 1706 {
1844 struct v4l2_tuner *p = arg; 1707 struct v4l2_tuner *p = arg;
1845 1708
1846 if (!ops->vidioc_g_tuner)
1847 break;
1848
1849 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1709 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
1850 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1710 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1851 ret = ops->vidioc_g_tuner(file, fh, p); 1711 ret = ops->vidioc_g_tuner(file, fh, p);
@@ -1864,12 +1724,6 @@ static long __video_do_ioctl(struct file *file,
1864 { 1724 {
1865 struct v4l2_tuner *p = arg; 1725 struct v4l2_tuner *p = arg;
1866 1726
1867 if (!ops->vidioc_s_tuner)
1868 break;
1869 if (ret_prio) {
1870 ret = ret_prio;
1871 break;
1872 }
1873 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1727 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
1874 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1728 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1875 dbgarg(cmd, "index=%d, name=%s, type=%d, " 1729 dbgarg(cmd, "index=%d, name=%s, type=%d, "
@@ -1887,9 +1741,6 @@ static long __video_do_ioctl(struct file *file,
1887 { 1741 {
1888 struct v4l2_frequency *p = arg; 1742 struct v4l2_frequency *p = arg;
1889 1743
1890 if (!ops->vidioc_g_frequency)
1891 break;
1892
1893 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1744 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
1894 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1745 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1895 ret = ops->vidioc_g_frequency(file, fh, p); 1746 ret = ops->vidioc_g_frequency(file, fh, p);
@@ -1903,12 +1754,6 @@ static long __video_do_ioctl(struct file *file,
1903 struct v4l2_frequency *p = arg; 1754 struct v4l2_frequency *p = arg;
1904 enum v4l2_tuner_type type; 1755 enum v4l2_tuner_type type;
1905 1756
1906 if (!ops->vidioc_s_frequency)
1907 break;
1908 if (ret_prio) {
1909 ret = ret_prio;
1910 break;
1911 }
1912 type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1757 type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
1913 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1758 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1914 dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n", 1759 dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n",
@@ -1923,9 +1768,6 @@ static long __video_do_ioctl(struct file *file,
1923 { 1768 {
1924 struct v4l2_sliced_vbi_cap *p = arg; 1769 struct v4l2_sliced_vbi_cap *p = arg;
1925 1770
1926 if (!ops->vidioc_g_sliced_vbi_cap)
1927 break;
1928
1929 /* Clear up to type, everything after type is zerod already */ 1771 /* Clear up to type, everything after type is zerod already */
1930 memset(p, 0, offsetof(struct v4l2_sliced_vbi_cap, type)); 1772 memset(p, 0, offsetof(struct v4l2_sliced_vbi_cap, type));
1931 1773
@@ -1937,8 +1779,6 @@ static long __video_do_ioctl(struct file *file,
1937 } 1779 }
1938 case VIDIOC_LOG_STATUS: 1780 case VIDIOC_LOG_STATUS:
1939 { 1781 {
1940 if (!ops->vidioc_log_status)
1941 break;
1942 if (vfd->v4l2_dev) 1782 if (vfd->v4l2_dev)
1943 pr_info("%s: ================= START STATUS =================\n", 1783 pr_info("%s: ================= START STATUS =================\n",
1944 vfd->v4l2_dev->name); 1784 vfd->v4l2_dev->name);
@@ -1948,38 +1788,34 @@ static long __video_do_ioctl(struct file *file,
1948 vfd->v4l2_dev->name); 1788 vfd->v4l2_dev->name);
1949 break; 1789 break;
1950 } 1790 }
1951#ifdef CONFIG_VIDEO_ADV_DEBUG
1952 case VIDIOC_DBG_G_REGISTER: 1791 case VIDIOC_DBG_G_REGISTER:
1953 { 1792 {
1793#ifdef CONFIG_VIDEO_ADV_DEBUG
1954 struct v4l2_dbg_register *p = arg; 1794 struct v4l2_dbg_register *p = arg;
1955 1795
1956 if (ops->vidioc_g_register) { 1796 if (!capable(CAP_SYS_ADMIN))
1957 if (!capable(CAP_SYS_ADMIN)) 1797 ret = -EPERM;
1958 ret = -EPERM; 1798 else
1959 else 1799 ret = ops->vidioc_g_register(file, fh, p);
1960 ret = ops->vidioc_g_register(file, fh, p); 1800#endif
1961 }
1962 break; 1801 break;
1963 } 1802 }
1964 case VIDIOC_DBG_S_REGISTER: 1803 case VIDIOC_DBG_S_REGISTER:
1965 { 1804 {
1805#ifdef CONFIG_VIDEO_ADV_DEBUG
1966 struct v4l2_dbg_register *p = arg; 1806 struct v4l2_dbg_register *p = arg;
1967 1807
1968 if (ops->vidioc_s_register) { 1808 if (!capable(CAP_SYS_ADMIN))
1969 if (!capable(CAP_SYS_ADMIN)) 1809 ret = -EPERM;
1970 ret = -EPERM; 1810 else
1971 else 1811 ret = ops->vidioc_s_register(file, fh, p);
1972 ret = ops->vidioc_s_register(file, fh, p); 1812#endif
1973 }
1974 break; 1813 break;
1975 } 1814 }
1976#endif
1977 case VIDIOC_DBG_G_CHIP_IDENT: 1815 case VIDIOC_DBG_G_CHIP_IDENT:
1978 { 1816 {
1979 struct v4l2_dbg_chip_ident *p = arg; 1817 struct v4l2_dbg_chip_ident *p = arg;
1980 1818
1981 if (!ops->vidioc_g_chip_ident)
1982 break;
1983 p->ident = V4L2_IDENT_NONE; 1819 p->ident = V4L2_IDENT_NONE;
1984 p->revision = 0; 1820 p->revision = 0;
1985 ret = ops->vidioc_g_chip_ident(file, fh, p); 1821 ret = ops->vidioc_g_chip_ident(file, fh, p);
@@ -1992,12 +1828,6 @@ static long __video_do_ioctl(struct file *file,
1992 struct v4l2_hw_freq_seek *p = arg; 1828 struct v4l2_hw_freq_seek *p = arg;
1993 enum v4l2_tuner_type type; 1829 enum v4l2_tuner_type type;
1994 1830
1995 if (!ops->vidioc_s_hw_freq_seek)
1996 break;
1997 if (ret_prio) {
1998 ret = ret_prio;
1999 break;
2000 }
2001 type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1831 type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
2002 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1832 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
2003 dbgarg(cmd, 1833 dbgarg(cmd,
@@ -2013,9 +1843,6 @@ static long __video_do_ioctl(struct file *file,
2013 { 1843 {
2014 struct v4l2_frmsizeenum *p = arg; 1844 struct v4l2_frmsizeenum *p = arg;
2015 1845
2016 if (!ops->vidioc_enum_framesizes)
2017 break;
2018
2019 ret = ops->vidioc_enum_framesizes(file, fh, p); 1846 ret = ops->vidioc_enum_framesizes(file, fh, p);
2020 dbgarg(cmd, 1847 dbgarg(cmd,
2021 "index=%d, pixelformat=%c%c%c%c, type=%d ", 1848 "index=%d, pixelformat=%c%c%c%c, type=%d ",
@@ -2049,9 +1876,6 @@ static long __video_do_ioctl(struct file *file,
2049 { 1876 {
2050 struct v4l2_frmivalenum *p = arg; 1877 struct v4l2_frmivalenum *p = arg;
2051 1878
2052 if (!ops->vidioc_enum_frameintervals)
2053 break;
2054
2055 ret = ops->vidioc_enum_frameintervals(file, fh, p); 1879 ret = ops->vidioc_enum_frameintervals(file, fh, p);
2056 dbgarg(cmd, 1880 dbgarg(cmd,
2057 "index=%d, pixelformat=%d, width=%d, height=%d, type=%d ", 1881 "index=%d, pixelformat=%d, width=%d, height=%d, type=%d ",
@@ -2084,9 +1908,6 @@ static long __video_do_ioctl(struct file *file,
2084 { 1908 {
2085 struct v4l2_dv_enum_preset *p = arg; 1909 struct v4l2_dv_enum_preset *p = arg;
2086 1910
2087 if (!ops->vidioc_enum_dv_presets)
2088 break;
2089
2090 ret = ops->vidioc_enum_dv_presets(file, fh, p); 1911 ret = ops->vidioc_enum_dv_presets(file, fh, p);
2091 if (!ret) 1912 if (!ret)
2092 dbgarg(cmd, 1913 dbgarg(cmd,
@@ -2100,13 +1921,6 @@ static long __video_do_ioctl(struct file *file,
2100 { 1921 {
2101 struct v4l2_dv_preset *p = arg; 1922 struct v4l2_dv_preset *p = arg;
2102 1923
2103 if (!ops->vidioc_s_dv_preset)
2104 break;
2105 if (ret_prio) {
2106 ret = ret_prio;
2107 break;
2108 }
2109
2110 dbgarg(cmd, "preset=%d\n", p->preset); 1924 dbgarg(cmd, "preset=%d\n", p->preset);
2111 ret = ops->vidioc_s_dv_preset(file, fh, p); 1925 ret = ops->vidioc_s_dv_preset(file, fh, p);
2112 break; 1926 break;
@@ -2115,9 +1929,6 @@ static long __video_do_ioctl(struct file *file,
2115 { 1929 {
2116 struct v4l2_dv_preset *p = arg; 1930 struct v4l2_dv_preset *p = arg;
2117 1931
2118 if (!ops->vidioc_g_dv_preset)
2119 break;
2120
2121 ret = ops->vidioc_g_dv_preset(file, fh, p); 1932 ret = ops->vidioc_g_dv_preset(file, fh, p);
2122 if (!ret) 1933 if (!ret)
2123 dbgarg(cmd, "preset=%d\n", p->preset); 1934 dbgarg(cmd, "preset=%d\n", p->preset);
@@ -2127,9 +1938,6 @@ static long __video_do_ioctl(struct file *file,
2127 { 1938 {
2128 struct v4l2_dv_preset *p = arg; 1939 struct v4l2_dv_preset *p = arg;
2129 1940
2130 if (!ops->vidioc_query_dv_preset)
2131 break;
2132
2133 ret = ops->vidioc_query_dv_preset(file, fh, p); 1941 ret = ops->vidioc_query_dv_preset(file, fh, p);
2134 if (!ret) 1942 if (!ret)
2135 dbgarg(cmd, "preset=%d\n", p->preset); 1943 dbgarg(cmd, "preset=%d\n", p->preset);
@@ -2139,32 +1947,13 @@ static long __video_do_ioctl(struct file *file,
2139 { 1947 {
2140 struct v4l2_dv_timings *p = arg; 1948 struct v4l2_dv_timings *p = arg;
2141 1949
2142 if (!ops->vidioc_s_dv_timings) 1950 dbgtimings(vfd, p);
2143 break;
2144 if (ret_prio) {
2145 ret = ret_prio;
2146 break;
2147 }
2148
2149 switch (p->type) { 1951 switch (p->type) {
2150 case V4L2_DV_BT_656_1120: 1952 case V4L2_DV_BT_656_1120:
2151 dbgarg2("bt-656/1120:interlaced=%d, pixelclock=%lld,"
2152 " width=%d, height=%d, polarities=%x,"
2153 " hfrontporch=%d, hsync=%d, hbackporch=%d,"
2154 " vfrontporch=%d, vsync=%d, vbackporch=%d,"
2155 " il_vfrontporch=%d, il_vsync=%d,"
2156 " il_vbackporch=%d\n",
2157 p->bt.interlaced, p->bt.pixelclock,
2158 p->bt.width, p->bt.height, p->bt.polarities,
2159 p->bt.hfrontporch, p->bt.hsync,
2160 p->bt.hbackporch, p->bt.vfrontporch,
2161 p->bt.vsync, p->bt.vbackporch,
2162 p->bt.il_vfrontporch, p->bt.il_vsync,
2163 p->bt.il_vbackporch);
2164 ret = ops->vidioc_s_dv_timings(file, fh, p); 1953 ret = ops->vidioc_s_dv_timings(file, fh, p);
2165 break; 1954 break;
2166 default: 1955 default:
2167 dbgarg2("Unknown type %d!\n", p->type); 1956 ret = -EINVAL;
2168 break; 1957 break;
2169 } 1958 }
2170 break; 1959 break;
@@ -2173,43 +1962,68 @@ static long __video_do_ioctl(struct file *file,
2173 { 1962 {
2174 struct v4l2_dv_timings *p = arg; 1963 struct v4l2_dv_timings *p = arg;
2175 1964
2176 if (!ops->vidioc_g_dv_timings) 1965 ret = ops->vidioc_g_dv_timings(file, fh, p);
1966 if (!ret)
1967 dbgtimings(vfd, p);
1968 break;
1969 }
1970 case VIDIOC_ENUM_DV_TIMINGS:
1971 {
1972 struct v4l2_enum_dv_timings *p = arg;
1973
1974 if (!ops->vidioc_enum_dv_timings)
2177 break; 1975 break;
2178 1976
2179 ret = ops->vidioc_g_dv_timings(file, fh, p); 1977 ret = ops->vidioc_enum_dv_timings(file, fh, p);
2180 if (!ret) { 1978 if (!ret) {
2181 switch (p->type) { 1979 dbgarg(cmd, "index=%d: ", p->index);
2182 case V4L2_DV_BT_656_1120: 1980 dbgtimings(vfd, &p->timings);
2183 dbgarg2("bt-656/1120:interlaced=%d,"
2184 " pixelclock=%lld,"
2185 " width=%d, height=%d, polarities=%x,"
2186 " hfrontporch=%d, hsync=%d,"
2187 " hbackporch=%d, vfrontporch=%d,"
2188 " vsync=%d, vbackporch=%d,"
2189 " il_vfrontporch=%d, il_vsync=%d,"
2190 " il_vbackporch=%d\n",
2191 p->bt.interlaced, p->bt.pixelclock,
2192 p->bt.width, p->bt.height,
2193 p->bt.polarities, p->bt.hfrontporch,
2194 p->bt.hsync, p->bt.hbackporch,
2195 p->bt.vfrontporch, p->bt.vsync,
2196 p->bt.vbackporch, p->bt.il_vfrontporch,
2197 p->bt.il_vsync, p->bt.il_vbackporch);
2198 break;
2199 default:
2200 dbgarg2("Unknown type %d!\n", p->type);
2201 break;
2202 }
2203 } 1981 }
2204 break; 1982 break;
2205 } 1983 }
2206 case VIDIOC_DQEVENT: 1984 case VIDIOC_QUERY_DV_TIMINGS:
2207 { 1985 {
2208 struct v4l2_event *ev = arg; 1986 struct v4l2_dv_timings *p = arg;
1987
1988 if (!ops->vidioc_query_dv_timings)
1989 break;
2209 1990
2210 if (!ops->vidioc_subscribe_event) 1991 ret = ops->vidioc_query_dv_timings(file, fh, p);
1992 if (!ret)
1993 dbgtimings(vfd, p);
1994 break;
1995 }
1996 case VIDIOC_DV_TIMINGS_CAP:
1997 {
1998 struct v4l2_dv_timings_cap *p = arg;
1999
2000 if (!ops->vidioc_dv_timings_cap)
2211 break; 2001 break;
2212 2002
2003 ret = ops->vidioc_dv_timings_cap(file, fh, p);
2004 if (ret)
2005 break;
2006 switch (p->type) {
2007 case V4L2_DV_BT_656_1120:
2008 dbgarg(cmd,
2009 "type=%d, width=%u-%u, height=%u-%u, "
2010 "pixelclock=%llu-%llu, standards=%x, capabilities=%x ",
2011 p->type,
2012 p->bt.min_width, p->bt.max_width,
2013 p->bt.min_height, p->bt.max_height,
2014 p->bt.min_pixelclock, p->bt.max_pixelclock,
2015 p->bt.standards, p->bt.capabilities);
2016 break;
2017 default:
2018 dbgarg(cmd, "unknown type ");
2019 break;
2020 }
2021 break;
2022 }
2023 case VIDIOC_DQEVENT:
2024 {
2025 struct v4l2_event *ev = arg;
2026
2213 ret = v4l2_event_dequeue(fh, ev, file->f_flags & O_NONBLOCK); 2027 ret = v4l2_event_dequeue(fh, ev, file->f_flags & O_NONBLOCK);
2214 if (ret < 0) { 2028 if (ret < 0) {
2215 dbgarg(cmd, "no pending events?"); 2029 dbgarg(cmd, "no pending events?");
@@ -2226,9 +2040,6 @@ static long __video_do_ioctl(struct file *file,
2226 { 2040 {
2227 struct v4l2_event_subscription *sub = arg; 2041 struct v4l2_event_subscription *sub = arg;
2228 2042
2229 if (!ops->vidioc_subscribe_event)
2230 break;
2231
2232 ret = ops->vidioc_subscribe_event(fh, sub); 2043 ret = ops->vidioc_subscribe_event(fh, sub);
2233 if (ret < 0) { 2044 if (ret < 0) {
2234 dbgarg(cmd, "failed, ret=%ld", ret); 2045 dbgarg(cmd, "failed, ret=%ld", ret);
@@ -2241,9 +2052,6 @@ static long __video_do_ioctl(struct file *file,
2241 { 2052 {
2242 struct v4l2_event_subscription *sub = arg; 2053 struct v4l2_event_subscription *sub = arg;
2243 2054
2244 if (!ops->vidioc_unsubscribe_event)
2245 break;
2246
2247 ret = ops->vidioc_unsubscribe_event(fh, sub); 2055 ret = ops->vidioc_unsubscribe_event(fh, sub);
2248 if (ret < 0) { 2056 if (ret < 0) {
2249 dbgarg(cmd, "failed, ret=%ld", ret); 2057 dbgarg(cmd, "failed, ret=%ld", ret);
@@ -2256,12 +2064,6 @@ static long __video_do_ioctl(struct file *file,
2256 { 2064 {
2257 struct v4l2_create_buffers *create = arg; 2065 struct v4l2_create_buffers *create = arg;
2258 2066
2259 if (!ops->vidioc_create_bufs)
2260 break;
2261 if (ret_prio) {
2262 ret = ret_prio;
2263 break;
2264 }
2265 ret = check_fmt(ops, create->format.type); 2067 ret = check_fmt(ops, create->format.type);
2266 if (ret) 2068 if (ret)
2267 break; 2069 break;
@@ -2275,8 +2077,6 @@ static long __video_do_ioctl(struct file *file,
2275 { 2077 {
2276 struct v4l2_buffer *b = arg; 2078 struct v4l2_buffer *b = arg;
2277 2079
2278 if (!ops->vidioc_prepare_buf)
2279 break;
2280 ret = check_fmt(ops, b->type); 2080 ret = check_fmt(ops, b->type);
2281 if (ret) 2081 if (ret)
2282 break; 2082 break;
@@ -2289,7 +2089,9 @@ static long __video_do_ioctl(struct file *file,
2289 default: 2089 default:
2290 if (!ops->vidioc_default) 2090 if (!ops->vidioc_default)
2291 break; 2091 break;
2292 ret = ops->vidioc_default(file, fh, ret_prio >= 0, cmd, arg); 2092 ret = ops->vidioc_default(file, fh, use_fh_prio ?
2093 v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0,
2094 cmd, arg);
2293 break; 2095 break;
2294 } /* switch */ 2096 } /* switch */
2295 2097
@@ -2463,7 +2265,9 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
2463 err = -EFAULT; 2265 err = -EFAULT;
2464 goto out_array_args; 2266 goto out_array_args;
2465 } 2267 }
2466 if (err < 0) 2268 /* VIDIOC_QUERY_DV_TIMINGS can return an error, but still have valid
2269 results that must be returned. */
2270 if (err < 0 && cmd != VIDIOC_QUERY_DV_TIMINGS)
2467 goto out; 2271 goto out;
2468 2272
2469out_array_args: 2273out_array_args: