aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-05-10 04:36:00 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-14 08:17:28 -0400
commit48ea0be06028d97b57602372f032afbec02e7e97 (patch)
treee4d089a40163ba3491b0d5989048cec29ccbba17
parent8ab75e3ecd8f232d9564510f0c601a6aa7a149ea (diff)
[media] v4l2-dev/ioctl: determine the valid ioctls upfront
Rather than testing whether an ioctl is implemented in the driver or not every time the ioctl is called, do it upfront when the device is registered. This also allows a driver to disable certain ioctls based on the capabilities of the detected board, something you can't do today without creating separate v4l2_ioctl_ops structs for each new variation. For the most part it is pretty straightforward, but for control ioctls a flag is needed since it is possible that you have per-filehandle controls, and that can't be determined upfront of course. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/v4l2-dev.c172
-rw-r--r--drivers/media/video/v4l2-ioctl.c389
-rw-r--r--include/media/v4l2-dev.h11
3 files changed, 296 insertions, 276 deletions
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index e4a9ed67bb2e..b1f0923212e6 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -516,6 +516,175 @@ static int get_index(struct video_device *vdev)
516 return find_first_zero_bit(used, VIDEO_NUM_DEVICES); 516 return find_first_zero_bit(used, VIDEO_NUM_DEVICES);
517} 517}
518 518
519#define SET_VALID_IOCTL(ops, cmd, op) \
520 if (ops->op) \
521 set_bit(_IOC_NR(cmd), valid_ioctls)
522
523/* This determines which ioctls are actually implemented in the driver.
524 It's a one-time thing which simplifies video_ioctl2 as it can just do
525 a bit test.
526
527 Note that drivers can override this by setting bits to 1 in
528 vdev->valid_ioctls. If an ioctl is marked as 1 when this function is
529 called, then that ioctl will actually be marked as unimplemented.
530
531 It does that by first setting up the local valid_ioctls bitmap, and
532 at the end do a:
533
534 vdev->valid_ioctls = valid_ioctls & ~(vdev->valid_ioctls)
535 */
536static void determine_valid_ioctls(struct video_device *vdev)
537{
538 DECLARE_BITMAP(valid_ioctls, BASE_VIDIOC_PRIVATE);
539 const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops;
540
541 bitmap_zero(valid_ioctls, BASE_VIDIOC_PRIVATE);
542
543 SET_VALID_IOCTL(ops, VIDIOC_QUERYCAP, vidioc_querycap);
544 if (ops->vidioc_g_priority ||
545 test_bit(V4L2_FL_USE_FH_PRIO, &vdev->flags))
546 set_bit(_IOC_NR(VIDIOC_G_PRIORITY), valid_ioctls);
547 if (ops->vidioc_s_priority ||
548 test_bit(V4L2_FL_USE_FH_PRIO, &vdev->flags))
549 set_bit(_IOC_NR(VIDIOC_S_PRIORITY), valid_ioctls);
550 if (ops->vidioc_enum_fmt_vid_cap ||
551 ops->vidioc_enum_fmt_vid_out ||
552 ops->vidioc_enum_fmt_vid_cap_mplane ||
553 ops->vidioc_enum_fmt_vid_out_mplane ||
554 ops->vidioc_enum_fmt_vid_overlay ||
555 ops->vidioc_enum_fmt_type_private)
556 set_bit(_IOC_NR(VIDIOC_ENUM_FMT), valid_ioctls);
557 if (ops->vidioc_g_fmt_vid_cap ||
558 ops->vidioc_g_fmt_vid_out ||
559 ops->vidioc_g_fmt_vid_cap_mplane ||
560 ops->vidioc_g_fmt_vid_out_mplane ||
561 ops->vidioc_g_fmt_vid_overlay ||
562 ops->vidioc_g_fmt_vbi_cap ||
563 ops->vidioc_g_fmt_vid_out_overlay ||
564 ops->vidioc_g_fmt_vbi_out ||
565 ops->vidioc_g_fmt_sliced_vbi_cap ||
566 ops->vidioc_g_fmt_sliced_vbi_out ||
567 ops->vidioc_g_fmt_type_private)
568 set_bit(_IOC_NR(VIDIOC_G_FMT), valid_ioctls);
569 if (ops->vidioc_s_fmt_vid_cap ||
570 ops->vidioc_s_fmt_vid_out ||
571 ops->vidioc_s_fmt_vid_cap_mplane ||
572 ops->vidioc_s_fmt_vid_out_mplane ||
573 ops->vidioc_s_fmt_vid_overlay ||
574 ops->vidioc_s_fmt_vbi_cap ||
575 ops->vidioc_s_fmt_vid_out_overlay ||
576 ops->vidioc_s_fmt_vbi_out ||
577 ops->vidioc_s_fmt_sliced_vbi_cap ||
578 ops->vidioc_s_fmt_sliced_vbi_out ||
579 ops->vidioc_s_fmt_type_private)
580 set_bit(_IOC_NR(VIDIOC_S_FMT), valid_ioctls);
581 if (ops->vidioc_try_fmt_vid_cap ||
582 ops->vidioc_try_fmt_vid_out ||
583 ops->vidioc_try_fmt_vid_cap_mplane ||
584 ops->vidioc_try_fmt_vid_out_mplane ||
585 ops->vidioc_try_fmt_vid_overlay ||
586 ops->vidioc_try_fmt_vbi_cap ||
587 ops->vidioc_try_fmt_vid_out_overlay ||
588 ops->vidioc_try_fmt_vbi_out ||
589 ops->vidioc_try_fmt_sliced_vbi_cap ||
590 ops->vidioc_try_fmt_sliced_vbi_out ||
591 ops->vidioc_try_fmt_type_private)
592 set_bit(_IOC_NR(VIDIOC_TRY_FMT), valid_ioctls);
593 SET_VALID_IOCTL(ops, VIDIOC_REQBUFS, vidioc_reqbufs);
594 SET_VALID_IOCTL(ops, VIDIOC_QUERYBUF, vidioc_querybuf);
595 SET_VALID_IOCTL(ops, VIDIOC_QBUF, vidioc_qbuf);
596 SET_VALID_IOCTL(ops, VIDIOC_DQBUF, vidioc_dqbuf);
597 SET_VALID_IOCTL(ops, VIDIOC_OVERLAY, vidioc_overlay);
598 SET_VALID_IOCTL(ops, VIDIOC_G_FBUF, vidioc_g_fbuf);
599 SET_VALID_IOCTL(ops, VIDIOC_S_FBUF, vidioc_s_fbuf);
600 SET_VALID_IOCTL(ops, VIDIOC_STREAMON, vidioc_streamon);
601 SET_VALID_IOCTL(ops, VIDIOC_STREAMOFF, vidioc_streamoff);
602 if (vdev->tvnorms)
603 set_bit(_IOC_NR(VIDIOC_ENUMSTD), valid_ioctls);
604 if (ops->vidioc_g_std || vdev->current_norm)
605 set_bit(_IOC_NR(VIDIOC_G_STD), valid_ioctls);
606 SET_VALID_IOCTL(ops, VIDIOC_S_STD, vidioc_s_std);
607 SET_VALID_IOCTL(ops, VIDIOC_QUERYSTD, vidioc_querystd);
608 SET_VALID_IOCTL(ops, VIDIOC_ENUMINPUT, vidioc_enum_input);
609 SET_VALID_IOCTL(ops, VIDIOC_G_INPUT, vidioc_g_input);
610 SET_VALID_IOCTL(ops, VIDIOC_S_INPUT, vidioc_s_input);
611 SET_VALID_IOCTL(ops, VIDIOC_ENUMOUTPUT, vidioc_enum_output);
612 SET_VALID_IOCTL(ops, VIDIOC_G_OUTPUT, vidioc_g_output);
613 SET_VALID_IOCTL(ops, VIDIOC_S_OUTPUT, vidioc_s_output);
614 /* Note: the control handler can also be passed through the filehandle,
615 and that can't be tested here. If the bit for these control ioctls
616 is set, then the ioctl is valid. But if it is 0, then it can still
617 be valid if the filehandle passed the control handler. */
618 if (vdev->ctrl_handler || ops->vidioc_queryctrl)
619 set_bit(_IOC_NR(VIDIOC_QUERYCTRL), valid_ioctls);
620 if (vdev->ctrl_handler || ops->vidioc_g_ctrl || ops->vidioc_g_ext_ctrls)
621 set_bit(_IOC_NR(VIDIOC_G_CTRL), valid_ioctls);
622 if (vdev->ctrl_handler || ops->vidioc_s_ctrl || ops->vidioc_s_ext_ctrls)
623 set_bit(_IOC_NR(VIDIOC_S_CTRL), valid_ioctls);
624 if (vdev->ctrl_handler || ops->vidioc_g_ext_ctrls)
625 set_bit(_IOC_NR(VIDIOC_G_EXT_CTRLS), valid_ioctls);
626 if (vdev->ctrl_handler || ops->vidioc_s_ext_ctrls)
627 set_bit(_IOC_NR(VIDIOC_S_EXT_CTRLS), valid_ioctls);
628 if (vdev->ctrl_handler || ops->vidioc_try_ext_ctrls)
629 set_bit(_IOC_NR(VIDIOC_TRY_EXT_CTRLS), valid_ioctls);
630 if (vdev->ctrl_handler || ops->vidioc_querymenu)
631 set_bit(_IOC_NR(VIDIOC_QUERYMENU), valid_ioctls);
632 SET_VALID_IOCTL(ops, VIDIOC_ENUMAUDIO, vidioc_enumaudio);
633 SET_VALID_IOCTL(ops, VIDIOC_G_AUDIO, vidioc_g_audio);
634 SET_VALID_IOCTL(ops, VIDIOC_S_AUDIO, vidioc_s_audio);
635 SET_VALID_IOCTL(ops, VIDIOC_ENUMAUDOUT, vidioc_enumaudout);
636 SET_VALID_IOCTL(ops, VIDIOC_G_AUDOUT, vidioc_g_audout);
637 SET_VALID_IOCTL(ops, VIDIOC_S_AUDOUT, vidioc_s_audout);
638 SET_VALID_IOCTL(ops, VIDIOC_G_MODULATOR, vidioc_g_modulator);
639 SET_VALID_IOCTL(ops, VIDIOC_S_MODULATOR, vidioc_s_modulator);
640 if (ops->vidioc_g_crop || ops->vidioc_g_selection)
641 set_bit(_IOC_NR(VIDIOC_G_CROP), valid_ioctls);
642 if (ops->vidioc_s_crop || ops->vidioc_s_selection)
643 set_bit(_IOC_NR(VIDIOC_S_CROP), valid_ioctls);
644 SET_VALID_IOCTL(ops, VIDIOC_G_SELECTION, vidioc_g_selection);
645 SET_VALID_IOCTL(ops, VIDIOC_S_SELECTION, vidioc_s_selection);
646 if (ops->vidioc_cropcap || ops->vidioc_g_selection)
647 set_bit(_IOC_NR(VIDIOC_CROPCAP), valid_ioctls);
648 SET_VALID_IOCTL(ops, VIDIOC_G_JPEGCOMP, vidioc_g_jpegcomp);
649 SET_VALID_IOCTL(ops, VIDIOC_S_JPEGCOMP, vidioc_s_jpegcomp);
650 SET_VALID_IOCTL(ops, VIDIOC_G_ENC_INDEX, vidioc_g_enc_index);
651 SET_VALID_IOCTL(ops, VIDIOC_ENCODER_CMD, vidioc_encoder_cmd);
652 SET_VALID_IOCTL(ops, VIDIOC_TRY_ENCODER_CMD, vidioc_try_encoder_cmd);
653 SET_VALID_IOCTL(ops, VIDIOC_DECODER_CMD, vidioc_decoder_cmd);
654 SET_VALID_IOCTL(ops, VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd);
655 if (ops->vidioc_g_parm || vdev->current_norm)
656 set_bit(_IOC_NR(VIDIOC_G_PARM), valid_ioctls);
657 SET_VALID_IOCTL(ops, VIDIOC_S_PARM, vidioc_s_parm);
658 SET_VALID_IOCTL(ops, VIDIOC_G_TUNER, vidioc_g_tuner);
659 SET_VALID_IOCTL(ops, VIDIOC_S_TUNER, vidioc_s_tuner);
660 SET_VALID_IOCTL(ops, VIDIOC_G_FREQUENCY, vidioc_g_frequency);
661 SET_VALID_IOCTL(ops, VIDIOC_S_FREQUENCY, vidioc_s_frequency);
662 SET_VALID_IOCTL(ops, VIDIOC_G_SLICED_VBI_CAP, vidioc_g_sliced_vbi_cap);
663 SET_VALID_IOCTL(ops, VIDIOC_LOG_STATUS, vidioc_log_status);
664#ifdef CONFIG_VIDEO_ADV_DEBUG
665 SET_VALID_IOCTL(ops, VIDIOC_DBG_G_REGISTER, vidioc_g_register);
666 SET_VALID_IOCTL(ops, VIDIOC_DBG_S_REGISTER, vidioc_s_register);
667#endif
668 SET_VALID_IOCTL(ops, VIDIOC_DBG_G_CHIP_IDENT, vidioc_g_chip_ident);
669 SET_VALID_IOCTL(ops, VIDIOC_S_HW_FREQ_SEEK, vidioc_s_hw_freq_seek);
670 SET_VALID_IOCTL(ops, VIDIOC_ENUM_FRAMESIZES, vidioc_enum_framesizes);
671 SET_VALID_IOCTL(ops, VIDIOC_ENUM_FRAMEINTERVALS, vidioc_enum_frameintervals);
672 SET_VALID_IOCTL(ops, VIDIOC_ENUM_DV_PRESETS, vidioc_enum_dv_presets);
673 SET_VALID_IOCTL(ops, VIDIOC_S_DV_PRESET, vidioc_s_dv_preset);
674 SET_VALID_IOCTL(ops, VIDIOC_G_DV_PRESET, vidioc_g_dv_preset);
675 SET_VALID_IOCTL(ops, VIDIOC_QUERY_DV_PRESET, vidioc_query_dv_preset);
676 SET_VALID_IOCTL(ops, VIDIOC_S_DV_TIMINGS, vidioc_s_dv_timings);
677 SET_VALID_IOCTL(ops, VIDIOC_G_DV_TIMINGS, vidioc_g_dv_timings);
678 /* yes, really vidioc_subscribe_event */
679 SET_VALID_IOCTL(ops, VIDIOC_DQEVENT, vidioc_subscribe_event);
680 SET_VALID_IOCTL(ops, VIDIOC_SUBSCRIBE_EVENT, vidioc_subscribe_event);
681 SET_VALID_IOCTL(ops, VIDIOC_UNSUBSCRIBE_EVENT, vidioc_unsubscribe_event);
682 SET_VALID_IOCTL(ops, VIDIOC_CREATE_BUFS, vidioc_create_bufs);
683 SET_VALID_IOCTL(ops, VIDIOC_PREPARE_BUF, vidioc_prepare_buf);
684 bitmap_andnot(vdev->valid_ioctls, valid_ioctls, vdev->valid_ioctls,
685 BASE_VIDIOC_PRIVATE);
686}
687
519/** 688/**
520 * __video_register_device - register video4linux devices 689 * __video_register_device - register video4linux devices
521 * @vdev: video device structure we want to register 690 * @vdev: video device structure we want to register
@@ -663,6 +832,9 @@ int __video_register_device(struct video_device *vdev, int type, int nr,
663 vdev->index = get_index(vdev); 832 vdev->index = get_index(vdev);
664 mutex_unlock(&videodev_lock); 833 mutex_unlock(&videodev_lock);
665 834
835 if (vdev->ioctl_ops)
836 determine_valid_ioctls(vdev);
837
666 /* Part 3: Initialize the character device */ 838 /* Part 3: Initialize the character device */
667 vdev->cdev = cdev_alloc(); 839 vdev->cdev = cdev_alloc();
668 if (vdev->cdev == NULL) { 840 if (vdev->cdev == NULL) {
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index ef44b084132a..3df1f80f1c5c 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;
@@ -198,93 +185,98 @@ static const char *v4l2_memory_names[] = {
198 185
199struct v4l2_ioctl_info { 186struct v4l2_ioctl_info {
200 unsigned int ioctl; 187 unsigned int ioctl;
188 u16 flags;
201 const char * const name; 189 const char * const name;
202}; 190};
203 191
204#define IOCTL_INFO(_ioctl) [_IOC_NR(_ioctl)] = { \ 192/* This control can be valid if the filehandle passes a control handler. */
205 .ioctl = _ioctl, \ 193#define INFO_FL_CTRL (1 << 1)
206 .name = #_ioctl, \ 194
195#define IOCTL_INFO(_ioctl, _flags) [_IOC_NR(_ioctl)] = { \
196 .ioctl = _ioctl, \
197 .flags = _flags, \
198 .name = #_ioctl, \
207} 199}
208 200
209static struct v4l2_ioctl_info v4l2_ioctls[] = { 201static struct v4l2_ioctl_info v4l2_ioctls[] = {
210 IOCTL_INFO(VIDIOC_QUERYCAP), 202 IOCTL_INFO(VIDIOC_QUERYCAP, 0),
211 IOCTL_INFO(VIDIOC_ENUM_FMT), 203 IOCTL_INFO(VIDIOC_ENUM_FMT, 0),
212 IOCTL_INFO(VIDIOC_G_FMT), 204 IOCTL_INFO(VIDIOC_G_FMT, 0),
213 IOCTL_INFO(VIDIOC_S_FMT), 205 IOCTL_INFO(VIDIOC_S_FMT, 0),
214 IOCTL_INFO(VIDIOC_REQBUFS), 206 IOCTL_INFO(VIDIOC_REQBUFS, 0),
215 IOCTL_INFO(VIDIOC_QUERYBUF), 207 IOCTL_INFO(VIDIOC_QUERYBUF, 0),
216 IOCTL_INFO(VIDIOC_G_FBUF), 208 IOCTL_INFO(VIDIOC_G_FBUF, 0),
217 IOCTL_INFO(VIDIOC_S_FBUF), 209 IOCTL_INFO(VIDIOC_S_FBUF, 0),
218 IOCTL_INFO(VIDIOC_OVERLAY), 210 IOCTL_INFO(VIDIOC_OVERLAY, 0),
219 IOCTL_INFO(VIDIOC_QBUF), 211 IOCTL_INFO(VIDIOC_QBUF, 0),
220 IOCTL_INFO(VIDIOC_DQBUF), 212 IOCTL_INFO(VIDIOC_DQBUF, 0),
221 IOCTL_INFO(VIDIOC_STREAMON), 213 IOCTL_INFO(VIDIOC_STREAMON, 0),
222 IOCTL_INFO(VIDIOC_STREAMOFF), 214 IOCTL_INFO(VIDIOC_STREAMOFF, 0),
223 IOCTL_INFO(VIDIOC_G_PARM), 215 IOCTL_INFO(VIDIOC_G_PARM, 0),
224 IOCTL_INFO(VIDIOC_S_PARM), 216 IOCTL_INFO(VIDIOC_S_PARM, 0),
225 IOCTL_INFO(VIDIOC_G_STD), 217 IOCTL_INFO(VIDIOC_G_STD, 0),
226 IOCTL_INFO(VIDIOC_S_STD), 218 IOCTL_INFO(VIDIOC_S_STD, 0),
227 IOCTL_INFO(VIDIOC_ENUMSTD), 219 IOCTL_INFO(VIDIOC_ENUMSTD, 0),
228 IOCTL_INFO(VIDIOC_ENUMINPUT), 220 IOCTL_INFO(VIDIOC_ENUMINPUT, 0),
229 IOCTL_INFO(VIDIOC_G_CTRL), 221 IOCTL_INFO(VIDIOC_G_CTRL, INFO_FL_CTRL),
230 IOCTL_INFO(VIDIOC_S_CTRL), 222 IOCTL_INFO(VIDIOC_S_CTRL, INFO_FL_CTRL),
231 IOCTL_INFO(VIDIOC_G_TUNER), 223 IOCTL_INFO(VIDIOC_G_TUNER, 0),
232 IOCTL_INFO(VIDIOC_S_TUNER), 224 IOCTL_INFO(VIDIOC_S_TUNER, 0),
233 IOCTL_INFO(VIDIOC_G_AUDIO), 225 IOCTL_INFO(VIDIOC_G_AUDIO, 0),
234 IOCTL_INFO(VIDIOC_S_AUDIO), 226 IOCTL_INFO(VIDIOC_S_AUDIO, 0),
235 IOCTL_INFO(VIDIOC_QUERYCTRL), 227 IOCTL_INFO(VIDIOC_QUERYCTRL, INFO_FL_CTRL),
236 IOCTL_INFO(VIDIOC_QUERYMENU), 228 IOCTL_INFO(VIDIOC_QUERYMENU, INFO_FL_CTRL),
237 IOCTL_INFO(VIDIOC_G_INPUT), 229 IOCTL_INFO(VIDIOC_G_INPUT, 0),
238 IOCTL_INFO(VIDIOC_S_INPUT), 230 IOCTL_INFO(VIDIOC_S_INPUT, 0),
239 IOCTL_INFO(VIDIOC_G_OUTPUT), 231 IOCTL_INFO(VIDIOC_G_OUTPUT, 0),
240 IOCTL_INFO(VIDIOC_S_OUTPUT), 232 IOCTL_INFO(VIDIOC_S_OUTPUT, 0),
241 IOCTL_INFO(VIDIOC_ENUMOUTPUT), 233 IOCTL_INFO(VIDIOC_ENUMOUTPUT, 0),
242 IOCTL_INFO(VIDIOC_G_AUDOUT), 234 IOCTL_INFO(VIDIOC_G_AUDOUT, 0),
243 IOCTL_INFO(VIDIOC_S_AUDOUT), 235 IOCTL_INFO(VIDIOC_S_AUDOUT, 0),
244 IOCTL_INFO(VIDIOC_G_MODULATOR), 236 IOCTL_INFO(VIDIOC_G_MODULATOR, 0),
245 IOCTL_INFO(VIDIOC_S_MODULATOR), 237 IOCTL_INFO(VIDIOC_S_MODULATOR, 0),
246 IOCTL_INFO(VIDIOC_G_FREQUENCY), 238 IOCTL_INFO(VIDIOC_G_FREQUENCY, 0),
247 IOCTL_INFO(VIDIOC_S_FREQUENCY), 239 IOCTL_INFO(VIDIOC_S_FREQUENCY, 0),
248 IOCTL_INFO(VIDIOC_CROPCAP), 240 IOCTL_INFO(VIDIOC_CROPCAP, 0),
249 IOCTL_INFO(VIDIOC_G_CROP), 241 IOCTL_INFO(VIDIOC_G_CROP, 0),
250 IOCTL_INFO(VIDIOC_S_CROP), 242 IOCTL_INFO(VIDIOC_S_CROP, 0),
251 IOCTL_INFO(VIDIOC_G_SELECTION), 243 IOCTL_INFO(VIDIOC_G_SELECTION, 0),
252 IOCTL_INFO(VIDIOC_S_SELECTION), 244 IOCTL_INFO(VIDIOC_S_SELECTION, 0),
253 IOCTL_INFO(VIDIOC_G_JPEGCOMP), 245 IOCTL_INFO(VIDIOC_G_JPEGCOMP, 0),
254 IOCTL_INFO(VIDIOC_S_JPEGCOMP), 246 IOCTL_INFO(VIDIOC_S_JPEGCOMP, 0),
255 IOCTL_INFO(VIDIOC_QUERYSTD), 247 IOCTL_INFO(VIDIOC_QUERYSTD, 0),
256 IOCTL_INFO(VIDIOC_TRY_FMT), 248 IOCTL_INFO(VIDIOC_TRY_FMT, 0),
257 IOCTL_INFO(VIDIOC_ENUMAUDIO), 249 IOCTL_INFO(VIDIOC_ENUMAUDIO, 0),
258 IOCTL_INFO(VIDIOC_ENUMAUDOUT), 250 IOCTL_INFO(VIDIOC_ENUMAUDOUT, 0),
259 IOCTL_INFO(VIDIOC_G_PRIORITY), 251 IOCTL_INFO(VIDIOC_G_PRIORITY, 0),
260 IOCTL_INFO(VIDIOC_S_PRIORITY), 252 IOCTL_INFO(VIDIOC_S_PRIORITY, 0),
261 IOCTL_INFO(VIDIOC_G_SLICED_VBI_CAP), 253 IOCTL_INFO(VIDIOC_G_SLICED_VBI_CAP, 0),
262 IOCTL_INFO(VIDIOC_LOG_STATUS), 254 IOCTL_INFO(VIDIOC_LOG_STATUS, 0),
263 IOCTL_INFO(VIDIOC_G_EXT_CTRLS), 255 IOCTL_INFO(VIDIOC_G_EXT_CTRLS, INFO_FL_CTRL),
264 IOCTL_INFO(VIDIOC_S_EXT_CTRLS), 256 IOCTL_INFO(VIDIOC_S_EXT_CTRLS, INFO_FL_CTRL),
265 IOCTL_INFO(VIDIOC_TRY_EXT_CTRLS), 257 IOCTL_INFO(VIDIOC_TRY_EXT_CTRLS, 0),
266 IOCTL_INFO(VIDIOC_ENUM_FRAMESIZES), 258 IOCTL_INFO(VIDIOC_ENUM_FRAMESIZES, 0),
267 IOCTL_INFO(VIDIOC_ENUM_FRAMEINTERVALS), 259 IOCTL_INFO(VIDIOC_ENUM_FRAMEINTERVALS, 0),
268 IOCTL_INFO(VIDIOC_G_ENC_INDEX), 260 IOCTL_INFO(VIDIOC_G_ENC_INDEX, 0),
269 IOCTL_INFO(VIDIOC_ENCODER_CMD), 261 IOCTL_INFO(VIDIOC_ENCODER_CMD, 0),
270 IOCTL_INFO(VIDIOC_TRY_ENCODER_CMD), 262 IOCTL_INFO(VIDIOC_TRY_ENCODER_CMD, 0),
271 IOCTL_INFO(VIDIOC_DECODER_CMD), 263 IOCTL_INFO(VIDIOC_DECODER_CMD, 0),
272 IOCTL_INFO(VIDIOC_TRY_DECODER_CMD), 264 IOCTL_INFO(VIDIOC_TRY_DECODER_CMD, 0),
273 IOCTL_INFO(VIDIOC_DBG_S_REGISTER), 265 IOCTL_INFO(VIDIOC_DBG_S_REGISTER, 0),
274 IOCTL_INFO(VIDIOC_DBG_G_REGISTER), 266 IOCTL_INFO(VIDIOC_DBG_G_REGISTER, 0),
275 IOCTL_INFO(VIDIOC_DBG_G_CHIP_IDENT), 267 IOCTL_INFO(VIDIOC_DBG_G_CHIP_IDENT, 0),
276 IOCTL_INFO(VIDIOC_S_HW_FREQ_SEEK), 268 IOCTL_INFO(VIDIOC_S_HW_FREQ_SEEK, 0),
277 IOCTL_INFO(VIDIOC_ENUM_DV_PRESETS), 269 IOCTL_INFO(VIDIOC_ENUM_DV_PRESETS, 0),
278 IOCTL_INFO(VIDIOC_S_DV_PRESET), 270 IOCTL_INFO(VIDIOC_S_DV_PRESET, 0),
279 IOCTL_INFO(VIDIOC_G_DV_PRESET), 271 IOCTL_INFO(VIDIOC_G_DV_PRESET, 0),
280 IOCTL_INFO(VIDIOC_QUERY_DV_PRESET), 272 IOCTL_INFO(VIDIOC_QUERY_DV_PRESET, 0),
281 IOCTL_INFO(VIDIOC_S_DV_TIMINGS), 273 IOCTL_INFO(VIDIOC_S_DV_TIMINGS, 0),
282 IOCTL_INFO(VIDIOC_G_DV_TIMINGS), 274 IOCTL_INFO(VIDIOC_G_DV_TIMINGS, 0),
283 IOCTL_INFO(VIDIOC_DQEVENT), 275 IOCTL_INFO(VIDIOC_DQEVENT, 0),
284 IOCTL_INFO(VIDIOC_SUBSCRIBE_EVENT), 276 IOCTL_INFO(VIDIOC_SUBSCRIBE_EVENT, 0),
285 IOCTL_INFO(VIDIOC_UNSUBSCRIBE_EVENT), 277 IOCTL_INFO(VIDIOC_UNSUBSCRIBE_EVENT, 0),
286 IOCTL_INFO(VIDIOC_CREATE_BUFS), 278 IOCTL_INFO(VIDIOC_CREATE_BUFS, 0),
287 IOCTL_INFO(VIDIOC_PREPARE_BUF), 279 IOCTL_INFO(VIDIOC_PREPARE_BUF, 0),
288}; 280};
289#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) 281#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
290 282
@@ -526,19 +518,26 @@ static long __video_do_ioctl(struct file *file,
526 return ret; 518 return ret;
527 } 519 }
528 520
529 if ((vfd->debug & V4L2_DEBUG_IOCTL) &&
530 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
531 v4l_print_ioctl(vfd->name, cmd);
532 printk(KERN_CONT "\n");
533 }
534
535 if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { 521 if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
536 vfh = file->private_data; 522 vfh = file->private_data;
537 use_fh_prio = test_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); 523 use_fh_prio = test_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags);
524 if (use_fh_prio)
525 ret_prio = v4l2_prio_check(vfd->prio, vfh->prio);
538 } 526 }
539 527
540 if (use_fh_prio) 528 if (v4l2_is_known_ioctl(cmd)) {
541 ret_prio = v4l2_prio_check(vfd->prio, vfh->prio); 529 struct v4l2_ioctl_info *info = &v4l2_ioctls[_IOC_NR(cmd)];
530
531 if (!test_bit(_IOC_NR(cmd), vfd->valid_ioctls) &&
532 !((info->flags & INFO_FL_CTRL) && vfh && vfh->ctrl_handler))
533 return -ENOTTY;
534 }
535
536 if ((vfd->debug & V4L2_DEBUG_IOCTL) &&
537 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
538 v4l_print_ioctl(vfd->name, cmd);
539 printk(KERN_CONT "\n");
540 }
542 541
543 switch (cmd) { 542 switch (cmd) {
544 543
@@ -547,9 +546,6 @@ static long __video_do_ioctl(struct file *file,
547 { 546 {
548 struct v4l2_capability *cap = (struct v4l2_capability *)arg; 547 struct v4l2_capability *cap = (struct v4l2_capability *)arg;
549 548
550 if (!ops->vidioc_querycap)
551 break;
552
553 cap->version = LINUX_VERSION_CODE; 549 cap->version = LINUX_VERSION_CODE;
554 ret = ops->vidioc_querycap(file, fh, cap); 550 ret = ops->vidioc_querycap(file, fh, cap);
555 if (!ret) 551 if (!ret)
@@ -600,6 +596,7 @@ static long __video_do_ioctl(struct file *file,
600 { 596 {
601 struct v4l2_fmtdesc *f = arg; 597 struct v4l2_fmtdesc *f = arg;
602 598
599 ret = -EINVAL;
603 switch (f->type) { 600 switch (f->type) {
604 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 601 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
605 if (likely(ops->vidioc_enum_fmt_vid_cap)) 602 if (likely(ops->vidioc_enum_fmt_vid_cap))
@@ -632,7 +629,7 @@ static long __video_do_ioctl(struct file *file,
632 default: 629 default:
633 break; 630 break;
634 } 631 }
635 if (likely (!ret)) 632 if (likely(!ret))
636 dbgarg(cmd, "index=%d, type=%d, flags=%d, " 633 dbgarg(cmd, "index=%d, type=%d, flags=%d, "
637 "pixelformat=%c%c%c%c, description='%s'\n", 634 "pixelformat=%c%c%c%c, description='%s'\n",
638 f->index, f->type, f->flags, 635 f->index, f->type, f->flags,
@@ -641,14 +638,6 @@ static long __video_do_ioctl(struct file *file,
641 (f->pixelformat >> 16) & 0xff, 638 (f->pixelformat >> 16) & 0xff,
642 (f->pixelformat >> 24) & 0xff, 639 (f->pixelformat >> 24) & 0xff,
643 f->description); 640 f->description);
644 else if (ret == -ENOTTY &&
645 (ops->vidioc_enum_fmt_vid_cap ||
646 ops->vidioc_enum_fmt_vid_out ||
647 ops->vidioc_enum_fmt_vid_cap_mplane ||
648 ops->vidioc_enum_fmt_vid_out_mplane ||
649 ops->vidioc_enum_fmt_vid_overlay ||
650 ops->vidioc_enum_fmt_type_private))
651 ret = -EINVAL;
652 break; 641 break;
653 } 642 }
654 case VIDIOC_G_FMT: 643 case VIDIOC_G_FMT:
@@ -658,6 +647,7 @@ static long __video_do_ioctl(struct file *file,
658 /* FIXME: Should be one dump per type */ 647 /* FIXME: Should be one dump per type */
659 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names)); 648 dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names));
660 649
650 ret = -EINVAL;
661 switch (f->type) { 651 switch (f->type) {
662 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 652 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
663 if (ops->vidioc_g_fmt_vid_cap) 653 if (ops->vidioc_g_fmt_vid_cap)
@@ -719,17 +709,12 @@ static long __video_do_ioctl(struct file *file,
719 fh, f); 709 fh, f);
720 break; 710 break;
721 } 711 }
722 if (unlikely(ret == -ENOTTY && have_fmt_ops(g)))
723 ret = -EINVAL;
724
725 break; 712 break;
726 } 713 }
727 case VIDIOC_S_FMT: 714 case VIDIOC_S_FMT:
728 { 715 {
729 struct v4l2_format *f = (struct v4l2_format *)arg; 716 struct v4l2_format *f = (struct v4l2_format *)arg;
730 717
731 if (!have_fmt_ops(s))
732 break;
733 if (ret_prio) { 718 if (ret_prio) {
734 ret = ret_prio; 719 ret = ret_prio;
735 break; 720 break;
@@ -817,6 +802,7 @@ static long __video_do_ioctl(struct file *file,
817 /* FIXME: Should be one dump per type */ 802 /* FIXME: Should be one dump per type */
818 dbgarg(cmd, "type=%s\n", prt_names(f->type, 803 dbgarg(cmd, "type=%s\n", prt_names(f->type,
819 v4l2_type_names)); 804 v4l2_type_names));
805 ret = -EINVAL;
820 switch (f->type) { 806 switch (f->type) {
821 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 807 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
822 CLEAR_AFTER_FIELD(f, fmt.pix); 808 CLEAR_AFTER_FIELD(f, fmt.pix);
@@ -889,8 +875,6 @@ static long __video_do_ioctl(struct file *file,
889 fh, f); 875 fh, f);
890 break; 876 break;
891 } 877 }
892 if (unlikely(ret == -ENOTTY && have_fmt_ops(try)))
893 ret = -EINVAL;
894 break; 878 break;
895 } 879 }
896 /* FIXME: Those buf reqs could be handled here, 880 /* FIXME: Those buf reqs could be handled here,
@@ -901,8 +885,6 @@ static long __video_do_ioctl(struct file *file,
901 { 885 {
902 struct v4l2_requestbuffers *p = arg; 886 struct v4l2_requestbuffers *p = arg;
903 887
904 if (!ops->vidioc_reqbufs)
905 break;
906 if (ret_prio) { 888 if (ret_prio) {
907 ret = ret_prio; 889 ret = ret_prio;
908 break; 890 break;
@@ -925,8 +907,6 @@ static long __video_do_ioctl(struct file *file,
925 { 907 {
926 struct v4l2_buffer *p = arg; 908 struct v4l2_buffer *p = arg;
927 909
928 if (!ops->vidioc_querybuf)
929 break;
930 ret = check_fmt(ops, p->type); 910 ret = check_fmt(ops, p->type);
931 if (ret) 911 if (ret)
932 break; 912 break;
@@ -940,8 +920,6 @@ static long __video_do_ioctl(struct file *file,
940 { 920 {
941 struct v4l2_buffer *p = arg; 921 struct v4l2_buffer *p = arg;
942 922
943 if (!ops->vidioc_qbuf)
944 break;
945 ret = check_fmt(ops, p->type); 923 ret = check_fmt(ops, p->type);
946 if (ret) 924 if (ret)
947 break; 925 break;
@@ -955,8 +933,6 @@ static long __video_do_ioctl(struct file *file,
955 { 933 {
956 struct v4l2_buffer *p = arg; 934 struct v4l2_buffer *p = arg;
957 935
958 if (!ops->vidioc_dqbuf)
959 break;
960 ret = check_fmt(ops, p->type); 936 ret = check_fmt(ops, p->type);
961 if (ret) 937 if (ret)
962 break; 938 break;
@@ -970,8 +946,6 @@ static long __video_do_ioctl(struct file *file,
970 { 946 {
971 int *i = arg; 947 int *i = arg;
972 948
973 if (!ops->vidioc_overlay)
974 break;
975 if (ret_prio) { 949 if (ret_prio) {
976 ret = ret_prio; 950 ret = ret_prio;
977 break; 951 break;
@@ -984,8 +958,6 @@ static long __video_do_ioctl(struct file *file,
984 { 958 {
985 struct v4l2_framebuffer *p = arg; 959 struct v4l2_framebuffer *p = arg;
986 960
987 if (!ops->vidioc_g_fbuf)
988 break;
989 ret = ops->vidioc_g_fbuf(file, fh, arg); 961 ret = ops->vidioc_g_fbuf(file, fh, arg);
990 if (!ret) { 962 if (!ret) {
991 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n", 963 dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n",
@@ -999,8 +971,6 @@ static long __video_do_ioctl(struct file *file,
999 { 971 {
1000 struct v4l2_framebuffer *p = arg; 972 struct v4l2_framebuffer *p = arg;
1001 973
1002 if (!ops->vidioc_s_fbuf)
1003 break;
1004 if (ret_prio) { 974 if (ret_prio) {
1005 ret = ret_prio; 975 ret = ret_prio;
1006 break; 976 break;
@@ -1015,8 +985,6 @@ static long __video_do_ioctl(struct file *file,
1015 { 985 {
1016 enum v4l2_buf_type i = *(int *)arg; 986 enum v4l2_buf_type i = *(int *)arg;
1017 987
1018 if (!ops->vidioc_streamon)
1019 break;
1020 if (ret_prio) { 988 if (ret_prio) {
1021 ret = ret_prio; 989 ret = ret_prio;
1022 break; 990 break;
@@ -1029,8 +997,6 @@ static long __video_do_ioctl(struct file *file,
1029 { 997 {
1030 enum v4l2_buf_type i = *(int *)arg; 998 enum v4l2_buf_type i = *(int *)arg;
1031 999
1032 if (!ops->vidioc_streamoff)
1033 break;
1034 if (ret_prio) { 1000 if (ret_prio) {
1035 ret = ret_prio; 1001 ret = ret_prio;
1036 break; 1002 break;
@@ -1104,9 +1070,6 @@ static long __video_do_ioctl(struct file *file,
1104 1070
1105 dbgarg(cmd, "std=%08Lx\n", (long long unsigned)*id); 1071 dbgarg(cmd, "std=%08Lx\n", (long long unsigned)*id);
1106 1072
1107 if (!ops->vidioc_s_std)
1108 break;
1109
1110 if (ret_prio) { 1073 if (ret_prio) {
1111 ret = ret_prio; 1074 ret = ret_prio;
1112 break; 1075 break;
@@ -1128,8 +1091,6 @@ static long __video_do_ioctl(struct file *file,
1128 { 1091 {
1129 v4l2_std_id *p = arg; 1092 v4l2_std_id *p = arg;
1130 1093
1131 if (!ops->vidioc_querystd)
1132 break;
1133 /* 1094 /*
1134 * If nothing detected, it should return all supported 1095 * If nothing detected, it should return all supported
1135 * Drivers just need to mask the std argument, in order 1096 * Drivers just need to mask the std argument, in order
@@ -1163,9 +1124,6 @@ static long __video_do_ioctl(struct file *file,
1163 if (ops->vidioc_s_dv_timings) 1124 if (ops->vidioc_s_dv_timings)
1164 p->capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS; 1125 p->capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS;
1165 1126
1166 if (!ops->vidioc_enum_input)
1167 break;
1168
1169 ret = ops->vidioc_enum_input(file, fh, p); 1127 ret = ops->vidioc_enum_input(file, fh, p);
1170 if (!ret) 1128 if (!ret)
1171 dbgarg(cmd, "index=%d, name=%s, type=%d, " 1129 dbgarg(cmd, "index=%d, name=%s, type=%d, "
@@ -1181,8 +1139,6 @@ static long __video_do_ioctl(struct file *file,
1181 { 1139 {
1182 unsigned int *i = arg; 1140 unsigned int *i = arg;
1183 1141
1184 if (!ops->vidioc_g_input)
1185 break;
1186 ret = ops->vidioc_g_input(file, fh, i); 1142 ret = ops->vidioc_g_input(file, fh, i);
1187 if (!ret) 1143 if (!ret)
1188 dbgarg(cmd, "value=%d\n", *i); 1144 dbgarg(cmd, "value=%d\n", *i);
@@ -1192,8 +1148,6 @@ static long __video_do_ioctl(struct file *file,
1192 { 1148 {
1193 unsigned int *i = arg; 1149 unsigned int *i = arg;
1194 1150
1195 if (!ops->vidioc_s_input)
1196 break;
1197 if (ret_prio) { 1151 if (ret_prio) {
1198 ret = ret_prio; 1152 ret = ret_prio;
1199 break; 1153 break;
@@ -1208,9 +1162,6 @@ static long __video_do_ioctl(struct file *file,
1208 { 1162 {
1209 struct v4l2_output *p = arg; 1163 struct v4l2_output *p = arg;
1210 1164
1211 if (!ops->vidioc_enum_output)
1212 break;
1213
1214 /* 1165 /*
1215 * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & 1166 * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS &
1216 * CAP_STD here based on ioctl handler provided by the 1167 * CAP_STD here based on ioctl handler provided by the
@@ -1237,8 +1188,6 @@ static long __video_do_ioctl(struct file *file,
1237 { 1188 {
1238 unsigned int *i = arg; 1189 unsigned int *i = arg;
1239 1190
1240 if (!ops->vidioc_g_output)
1241 break;
1242 ret = ops->vidioc_g_output(file, fh, i); 1191 ret = ops->vidioc_g_output(file, fh, i);
1243 if (!ret) 1192 if (!ret)
1244 dbgarg(cmd, "value=%d\n", *i); 1193 dbgarg(cmd, "value=%d\n", *i);
@@ -1248,8 +1197,6 @@ static long __video_do_ioctl(struct file *file,
1248 { 1197 {
1249 unsigned int *i = arg; 1198 unsigned int *i = arg;
1250 1199
1251 if (!ops->vidioc_s_output)
1252 break;
1253 if (ret_prio) { 1200 if (ret_prio) {
1254 ret = ret_prio; 1201 ret = ret_prio;
1255 break; 1202 break;
@@ -1441,8 +1388,6 @@ static long __video_do_ioctl(struct file *file,
1441 { 1388 {
1442 struct v4l2_audio *p = arg; 1389 struct v4l2_audio *p = arg;
1443 1390
1444 if (!ops->vidioc_enumaudio)
1445 break;
1446 ret = ops->vidioc_enumaudio(file, fh, p); 1391 ret = ops->vidioc_enumaudio(file, fh, p);
1447 if (!ret) 1392 if (!ret)
1448 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, " 1393 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
@@ -1456,9 +1401,6 @@ static long __video_do_ioctl(struct file *file,
1456 { 1401 {
1457 struct v4l2_audio *p = arg; 1402 struct v4l2_audio *p = arg;
1458 1403
1459 if (!ops->vidioc_g_audio)
1460 break;
1461
1462 ret = ops->vidioc_g_audio(file, fh, p); 1404 ret = ops->vidioc_g_audio(file, fh, p);
1463 if (!ret) 1405 if (!ret)
1464 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, " 1406 dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "
@@ -1472,8 +1414,6 @@ static long __video_do_ioctl(struct file *file,
1472 { 1414 {
1473 struct v4l2_audio *p = arg; 1415 struct v4l2_audio *p = arg;
1474 1416
1475 if (!ops->vidioc_s_audio)
1476 break;
1477 if (ret_prio) { 1417 if (ret_prio) {
1478 ret = ret_prio; 1418 ret = ret_prio;
1479 break; 1419 break;
@@ -1488,8 +1428,6 @@ static long __video_do_ioctl(struct file *file,
1488 { 1428 {
1489 struct v4l2_audioout *p = arg; 1429 struct v4l2_audioout *p = arg;
1490 1430
1491 if (!ops->vidioc_enumaudout)
1492 break;
1493 dbgarg(cmd, "Enum for index=%d\n", p->index); 1431 dbgarg(cmd, "Enum for index=%d\n", p->index);
1494 ret = ops->vidioc_enumaudout(file, fh, p); 1432 ret = ops->vidioc_enumaudout(file, fh, p);
1495 if (!ret) 1433 if (!ret)
@@ -1502,9 +1440,6 @@ static long __video_do_ioctl(struct file *file,
1502 { 1440 {
1503 struct v4l2_audioout *p = arg; 1441 struct v4l2_audioout *p = arg;
1504 1442
1505 if (!ops->vidioc_g_audout)
1506 break;
1507
1508 ret = ops->vidioc_g_audout(file, fh, p); 1443 ret = ops->vidioc_g_audout(file, fh, p);
1509 if (!ret) 1444 if (!ret)
1510 dbgarg2("index=%d, name=%s, capability=%d, " 1445 dbgarg2("index=%d, name=%s, capability=%d, "
@@ -1516,8 +1451,6 @@ static long __video_do_ioctl(struct file *file,
1516 { 1451 {
1517 struct v4l2_audioout *p = arg; 1452 struct v4l2_audioout *p = arg;
1518 1453
1519 if (!ops->vidioc_s_audout)
1520 break;
1521 if (ret_prio) { 1454 if (ret_prio) {
1522 ret = ret_prio; 1455 ret = ret_prio;
1523 break; 1456 break;
@@ -1533,8 +1466,6 @@ static long __video_do_ioctl(struct file *file,
1533 { 1466 {
1534 struct v4l2_modulator *p = arg; 1467 struct v4l2_modulator *p = arg;
1535 1468
1536 if (!ops->vidioc_g_modulator)
1537 break;
1538 ret = ops->vidioc_g_modulator(file, fh, p); 1469 ret = ops->vidioc_g_modulator(file, fh, p);
1539 if (!ret) 1470 if (!ret)
1540 dbgarg(cmd, "index=%d, name=%s, " 1471 dbgarg(cmd, "index=%d, name=%s, "
@@ -1549,8 +1480,6 @@ static long __video_do_ioctl(struct file *file,
1549 { 1480 {
1550 struct v4l2_modulator *p = arg; 1481 struct v4l2_modulator *p = arg;
1551 1482
1552 if (!ops->vidioc_s_modulator)
1553 break;
1554 if (ret_prio) { 1483 if (ret_prio) {
1555 ret = ret_prio; 1484 ret = ret_prio;
1556 break; 1485 break;
@@ -1566,9 +1495,6 @@ static long __video_do_ioctl(struct file *file,
1566 { 1495 {
1567 struct v4l2_crop *p = arg; 1496 struct v4l2_crop *p = arg;
1568 1497
1569 if (!ops->vidioc_g_crop && !ops->vidioc_g_selection)
1570 break;
1571
1572 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); 1498 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1573 1499
1574 if (ops->vidioc_g_crop) { 1500 if (ops->vidioc_g_crop) {
@@ -1600,9 +1526,6 @@ static long __video_do_ioctl(struct file *file,
1600 { 1526 {
1601 struct v4l2_crop *p = arg; 1527 struct v4l2_crop *p = arg;
1602 1528
1603 if (!ops->vidioc_s_crop && !ops->vidioc_s_selection)
1604 break;
1605
1606 if (ret_prio) { 1529 if (ret_prio) {
1607 ret = ret_prio; 1530 ret = ret_prio;
1608 break; 1531 break;
@@ -1633,9 +1556,6 @@ static long __video_do_ioctl(struct file *file,
1633 { 1556 {
1634 struct v4l2_selection *p = arg; 1557 struct v4l2_selection *p = arg;
1635 1558
1636 if (!ops->vidioc_g_selection)
1637 break;
1638
1639 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); 1559 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1640 1560
1641 ret = ops->vidioc_g_selection(file, fh, p); 1561 ret = ops->vidioc_g_selection(file, fh, p);
@@ -1647,9 +1567,6 @@ static long __video_do_ioctl(struct file *file,
1647 { 1567 {
1648 struct v4l2_selection *p = arg; 1568 struct v4l2_selection *p = arg;
1649 1569
1650 if (!ops->vidioc_s_selection)
1651 break;
1652
1653 if (ret_prio) { 1570 if (ret_prio) {
1654 ret = ret_prio; 1571 ret = ret_prio;
1655 break; 1572 break;
@@ -1666,9 +1583,6 @@ static long __video_do_ioctl(struct file *file,
1666 struct v4l2_cropcap *p = arg; 1583 struct v4l2_cropcap *p = arg;
1667 1584
1668 /*FIXME: Should also show v4l2_fract pixelaspect */ 1585 /*FIXME: Should also show v4l2_fract pixelaspect */
1669 if (!ops->vidioc_cropcap && !ops->vidioc_g_selection)
1670 break;
1671
1672 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); 1586 dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names));
1673 if (ops->vidioc_cropcap) { 1587 if (ops->vidioc_cropcap) {
1674 ret = ops->vidioc_cropcap(file, fh, p); 1588 ret = ops->vidioc_cropcap(file, fh, p);
@@ -1712,9 +1626,6 @@ static long __video_do_ioctl(struct file *file,
1712 { 1626 {
1713 struct v4l2_jpegcompression *p = arg; 1627 struct v4l2_jpegcompression *p = arg;
1714 1628
1715 if (!ops->vidioc_g_jpegcomp)
1716 break;
1717
1718 ret = ops->vidioc_g_jpegcomp(file, fh, p); 1629 ret = ops->vidioc_g_jpegcomp(file, fh, p);
1719 if (!ret) 1630 if (!ret)
1720 dbgarg(cmd, "quality=%d, APPn=%d, " 1631 dbgarg(cmd, "quality=%d, APPn=%d, "
@@ -1728,8 +1639,6 @@ static long __video_do_ioctl(struct file *file,
1728 { 1639 {
1729 struct v4l2_jpegcompression *p = arg; 1640 struct v4l2_jpegcompression *p = arg;
1730 1641
1731 if (!ops->vidioc_g_jpegcomp)
1732 break;
1733 if (ret_prio) { 1642 if (ret_prio) {
1734 ret = ret_prio; 1643 ret = ret_prio;
1735 break; 1644 break;
@@ -1745,8 +1654,6 @@ static long __video_do_ioctl(struct file *file,
1745 { 1654 {
1746 struct v4l2_enc_idx *p = arg; 1655 struct v4l2_enc_idx *p = arg;
1747 1656
1748 if (!ops->vidioc_g_enc_index)
1749 break;
1750 ret = ops->vidioc_g_enc_index(file, fh, p); 1657 ret = ops->vidioc_g_enc_index(file, fh, p);
1751 if (!ret) 1658 if (!ret)
1752 dbgarg(cmd, "entries=%d, entries_cap=%d\n", 1659 dbgarg(cmd, "entries=%d, entries_cap=%d\n",
@@ -1757,8 +1664,6 @@ static long __video_do_ioctl(struct file *file,
1757 { 1664 {
1758 struct v4l2_encoder_cmd *p = arg; 1665 struct v4l2_encoder_cmd *p = arg;
1759 1666
1760 if (!ops->vidioc_encoder_cmd)
1761 break;
1762 if (ret_prio) { 1667 if (ret_prio) {
1763 ret = ret_prio; 1668 ret = ret_prio;
1764 break; 1669 break;
@@ -1772,8 +1677,6 @@ static long __video_do_ioctl(struct file *file,
1772 { 1677 {
1773 struct v4l2_encoder_cmd *p = arg; 1678 struct v4l2_encoder_cmd *p = arg;
1774 1679
1775 if (!ops->vidioc_try_encoder_cmd)
1776 break;
1777 ret = ops->vidioc_try_encoder_cmd(file, fh, p); 1680 ret = ops->vidioc_try_encoder_cmd(file, fh, p);
1778 if (!ret) 1681 if (!ret)
1779 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); 1682 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
@@ -1783,8 +1686,6 @@ static long __video_do_ioctl(struct file *file,
1783 { 1686 {
1784 struct v4l2_decoder_cmd *p = arg; 1687 struct v4l2_decoder_cmd *p = arg;
1785 1688
1786 if (!ops->vidioc_decoder_cmd)
1787 break;
1788 if (ret_prio) { 1689 if (ret_prio) {
1789 ret = ret_prio; 1690 ret = ret_prio;
1790 break; 1691 break;
@@ -1798,8 +1699,6 @@ static long __video_do_ioctl(struct file *file,
1798 { 1699 {
1799 struct v4l2_decoder_cmd *p = arg; 1700 struct v4l2_decoder_cmd *p = arg;
1800 1701
1801 if (!ops->vidioc_try_decoder_cmd)
1802 break;
1803 ret = ops->vidioc_try_decoder_cmd(file, fh, p); 1702 ret = ops->vidioc_try_decoder_cmd(file, fh, p);
1804 if (!ret) 1703 if (!ret)
1805 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); 1704 dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags);
@@ -1809,8 +1708,6 @@ static long __video_do_ioctl(struct file *file,
1809 { 1708 {
1810 struct v4l2_streamparm *p = arg; 1709 struct v4l2_streamparm *p = arg;
1811 1710
1812 if (!ops->vidioc_g_parm && !vfd->current_norm)
1813 break;
1814 if (ops->vidioc_g_parm) { 1711 if (ops->vidioc_g_parm) {
1815 ret = check_fmt(ops, p->type); 1712 ret = check_fmt(ops, p->type);
1816 if (ret) 1713 if (ret)
@@ -1838,8 +1735,6 @@ static long __video_do_ioctl(struct file *file,
1838 { 1735 {
1839 struct v4l2_streamparm *p = arg; 1736 struct v4l2_streamparm *p = arg;
1840 1737
1841 if (!ops->vidioc_s_parm)
1842 break;
1843 if (ret_prio) { 1738 if (ret_prio) {
1844 ret = ret_prio; 1739 ret = ret_prio;
1845 break; 1740 break;
@@ -1856,9 +1751,6 @@ static long __video_do_ioctl(struct file *file,
1856 { 1751 {
1857 struct v4l2_tuner *p = arg; 1752 struct v4l2_tuner *p = arg;
1858 1753
1859 if (!ops->vidioc_g_tuner)
1860 break;
1861
1862 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1754 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
1863 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1755 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1864 ret = ops->vidioc_g_tuner(file, fh, p); 1756 ret = ops->vidioc_g_tuner(file, fh, p);
@@ -1877,8 +1769,6 @@ static long __video_do_ioctl(struct file *file,
1877 { 1769 {
1878 struct v4l2_tuner *p = arg; 1770 struct v4l2_tuner *p = arg;
1879 1771
1880 if (!ops->vidioc_s_tuner)
1881 break;
1882 if (ret_prio) { 1772 if (ret_prio) {
1883 ret = ret_prio; 1773 ret = ret_prio;
1884 break; 1774 break;
@@ -1900,9 +1790,6 @@ static long __video_do_ioctl(struct file *file,
1900 { 1790 {
1901 struct v4l2_frequency *p = arg; 1791 struct v4l2_frequency *p = arg;
1902 1792
1903 if (!ops->vidioc_g_frequency)
1904 break;
1905
1906 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? 1793 p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
1907 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1794 V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1908 ret = ops->vidioc_g_frequency(file, fh, p); 1795 ret = ops->vidioc_g_frequency(file, fh, p);
@@ -1916,8 +1803,6 @@ static long __video_do_ioctl(struct file *file,
1916 struct v4l2_frequency *p = arg; 1803 struct v4l2_frequency *p = arg;
1917 enum v4l2_tuner_type type; 1804 enum v4l2_tuner_type type;
1918 1805
1919 if (!ops->vidioc_s_frequency)
1920 break;
1921 if (ret_prio) { 1806 if (ret_prio) {
1922 ret = ret_prio; 1807 ret = ret_prio;
1923 break; 1808 break;
@@ -1936,9 +1821,6 @@ static long __video_do_ioctl(struct file *file,
1936 { 1821 {
1937 struct v4l2_sliced_vbi_cap *p = arg; 1822 struct v4l2_sliced_vbi_cap *p = arg;
1938 1823
1939 if (!ops->vidioc_g_sliced_vbi_cap)
1940 break;
1941
1942 /* Clear up to type, everything after type is zerod already */ 1824 /* Clear up to type, everything after type is zerod already */
1943 memset(p, 0, offsetof(struct v4l2_sliced_vbi_cap, type)); 1825 memset(p, 0, offsetof(struct v4l2_sliced_vbi_cap, type));
1944 1826
@@ -1950,8 +1832,6 @@ static long __video_do_ioctl(struct file *file,
1950 } 1832 }
1951 case VIDIOC_LOG_STATUS: 1833 case VIDIOC_LOG_STATUS:
1952 { 1834 {
1953 if (!ops->vidioc_log_status)
1954 break;
1955 if (vfd->v4l2_dev) 1835 if (vfd->v4l2_dev)
1956 pr_info("%s: ================= START STATUS =================\n", 1836 pr_info("%s: ================= START STATUS =================\n",
1957 vfd->v4l2_dev->name); 1837 vfd->v4l2_dev->name);
@@ -1966,12 +1846,10 @@ static long __video_do_ioctl(struct file *file,
1966#ifdef CONFIG_VIDEO_ADV_DEBUG 1846#ifdef CONFIG_VIDEO_ADV_DEBUG
1967 struct v4l2_dbg_register *p = arg; 1847 struct v4l2_dbg_register *p = arg;
1968 1848
1969 if (ops->vidioc_g_register) { 1849 if (!capable(CAP_SYS_ADMIN))
1970 if (!capable(CAP_SYS_ADMIN)) 1850 ret = -EPERM;
1971 ret = -EPERM; 1851 else
1972 else 1852 ret = ops->vidioc_g_register(file, fh, p);
1973 ret = ops->vidioc_g_register(file, fh, p);
1974 }
1975#endif 1853#endif
1976 break; 1854 break;
1977 } 1855 }
@@ -1980,12 +1858,10 @@ static long __video_do_ioctl(struct file *file,
1980#ifdef CONFIG_VIDEO_ADV_DEBUG 1858#ifdef CONFIG_VIDEO_ADV_DEBUG
1981 struct v4l2_dbg_register *p = arg; 1859 struct v4l2_dbg_register *p = arg;
1982 1860
1983 if (ops->vidioc_s_register) { 1861 if (!capable(CAP_SYS_ADMIN))
1984 if (!capable(CAP_SYS_ADMIN)) 1862 ret = -EPERM;
1985 ret = -EPERM; 1863 else
1986 else 1864 ret = ops->vidioc_s_register(file, fh, p);
1987 ret = ops->vidioc_s_register(file, fh, p);
1988 }
1989#endif 1865#endif
1990 break; 1866 break;
1991 } 1867 }
@@ -1993,8 +1869,6 @@ static long __video_do_ioctl(struct file *file,
1993 { 1869 {
1994 struct v4l2_dbg_chip_ident *p = arg; 1870 struct v4l2_dbg_chip_ident *p = arg;
1995 1871
1996 if (!ops->vidioc_g_chip_ident)
1997 break;
1998 p->ident = V4L2_IDENT_NONE; 1872 p->ident = V4L2_IDENT_NONE;
1999 p->revision = 0; 1873 p->revision = 0;
2000 ret = ops->vidioc_g_chip_ident(file, fh, p); 1874 ret = ops->vidioc_g_chip_ident(file, fh, p);
@@ -2007,8 +1881,6 @@ static long __video_do_ioctl(struct file *file,
2007 struct v4l2_hw_freq_seek *p = arg; 1881 struct v4l2_hw_freq_seek *p = arg;
2008 enum v4l2_tuner_type type; 1882 enum v4l2_tuner_type type;
2009 1883
2010 if (!ops->vidioc_s_hw_freq_seek)
2011 break;
2012 if (ret_prio) { 1884 if (ret_prio) {
2013 ret = ret_prio; 1885 ret = ret_prio;
2014 break; 1886 break;
@@ -2028,9 +1900,6 @@ static long __video_do_ioctl(struct file *file,
2028 { 1900 {
2029 struct v4l2_frmsizeenum *p = arg; 1901 struct v4l2_frmsizeenum *p = arg;
2030 1902
2031 if (!ops->vidioc_enum_framesizes)
2032 break;
2033
2034 ret = ops->vidioc_enum_framesizes(file, fh, p); 1903 ret = ops->vidioc_enum_framesizes(file, fh, p);
2035 dbgarg(cmd, 1904 dbgarg(cmd,
2036 "index=%d, pixelformat=%c%c%c%c, type=%d ", 1905 "index=%d, pixelformat=%c%c%c%c, type=%d ",
@@ -2064,9 +1933,6 @@ static long __video_do_ioctl(struct file *file,
2064 { 1933 {
2065 struct v4l2_frmivalenum *p = arg; 1934 struct v4l2_frmivalenum *p = arg;
2066 1935
2067 if (!ops->vidioc_enum_frameintervals)
2068 break;
2069
2070 ret = ops->vidioc_enum_frameintervals(file, fh, p); 1936 ret = ops->vidioc_enum_frameintervals(file, fh, p);
2071 dbgarg(cmd, 1937 dbgarg(cmd,
2072 "index=%d, pixelformat=%d, width=%d, height=%d, type=%d ", 1938 "index=%d, pixelformat=%d, width=%d, height=%d, type=%d ",
@@ -2099,9 +1965,6 @@ static long __video_do_ioctl(struct file *file,
2099 { 1965 {
2100 struct v4l2_dv_enum_preset *p = arg; 1966 struct v4l2_dv_enum_preset *p = arg;
2101 1967
2102 if (!ops->vidioc_enum_dv_presets)
2103 break;
2104
2105 ret = ops->vidioc_enum_dv_presets(file, fh, p); 1968 ret = ops->vidioc_enum_dv_presets(file, fh, p);
2106 if (!ret) 1969 if (!ret)
2107 dbgarg(cmd, 1970 dbgarg(cmd,
@@ -2115,8 +1978,6 @@ static long __video_do_ioctl(struct file *file,
2115 { 1978 {
2116 struct v4l2_dv_preset *p = arg; 1979 struct v4l2_dv_preset *p = arg;
2117 1980
2118 if (!ops->vidioc_s_dv_preset)
2119 break;
2120 if (ret_prio) { 1981 if (ret_prio) {
2121 ret = ret_prio; 1982 ret = ret_prio;
2122 break; 1983 break;
@@ -2130,9 +1991,6 @@ static long __video_do_ioctl(struct file *file,
2130 { 1991 {
2131 struct v4l2_dv_preset *p = arg; 1992 struct v4l2_dv_preset *p = arg;
2132 1993
2133 if (!ops->vidioc_g_dv_preset)
2134 break;
2135
2136 ret = ops->vidioc_g_dv_preset(file, fh, p); 1994 ret = ops->vidioc_g_dv_preset(file, fh, p);
2137 if (!ret) 1995 if (!ret)
2138 dbgarg(cmd, "preset=%d\n", p->preset); 1996 dbgarg(cmd, "preset=%d\n", p->preset);
@@ -2142,9 +2000,6 @@ static long __video_do_ioctl(struct file *file,
2142 { 2000 {
2143 struct v4l2_dv_preset *p = arg; 2001 struct v4l2_dv_preset *p = arg;
2144 2002
2145 if (!ops->vidioc_query_dv_preset)
2146 break;
2147
2148 ret = ops->vidioc_query_dv_preset(file, fh, p); 2003 ret = ops->vidioc_query_dv_preset(file, fh, p);
2149 if (!ret) 2004 if (!ret)
2150 dbgarg(cmd, "preset=%d\n", p->preset); 2005 dbgarg(cmd, "preset=%d\n", p->preset);
@@ -2154,8 +2009,6 @@ static long __video_do_ioctl(struct file *file,
2154 { 2009 {
2155 struct v4l2_dv_timings *p = arg; 2010 struct v4l2_dv_timings *p = arg;
2156 2011
2157 if (!ops->vidioc_s_dv_timings)
2158 break;
2159 if (ret_prio) { 2012 if (ret_prio) {
2160 ret = ret_prio; 2013 ret = ret_prio;
2161 break; 2014 break;
@@ -2188,9 +2041,6 @@ static long __video_do_ioctl(struct file *file,
2188 { 2041 {
2189 struct v4l2_dv_timings *p = arg; 2042 struct v4l2_dv_timings *p = arg;
2190 2043
2191 if (!ops->vidioc_g_dv_timings)
2192 break;
2193
2194 ret = ops->vidioc_g_dv_timings(file, fh, p); 2044 ret = ops->vidioc_g_dv_timings(file, fh, p);
2195 if (!ret) { 2045 if (!ret) {
2196 switch (p->type) { 2046 switch (p->type) {
@@ -2222,9 +2072,6 @@ static long __video_do_ioctl(struct file *file,
2222 { 2072 {
2223 struct v4l2_event *ev = arg; 2073 struct v4l2_event *ev = arg;
2224 2074
2225 if (!ops->vidioc_subscribe_event)
2226 break;
2227
2228 ret = v4l2_event_dequeue(fh, ev, file->f_flags & O_NONBLOCK); 2075 ret = v4l2_event_dequeue(fh, ev, file->f_flags & O_NONBLOCK);
2229 if (ret < 0) { 2076 if (ret < 0) {
2230 dbgarg(cmd, "no pending events?"); 2077 dbgarg(cmd, "no pending events?");
@@ -2241,9 +2088,6 @@ static long __video_do_ioctl(struct file *file,
2241 { 2088 {
2242 struct v4l2_event_subscription *sub = arg; 2089 struct v4l2_event_subscription *sub = arg;
2243 2090
2244 if (!ops->vidioc_subscribe_event)
2245 break;
2246
2247 ret = ops->vidioc_subscribe_event(fh, sub); 2091 ret = ops->vidioc_subscribe_event(fh, sub);
2248 if (ret < 0) { 2092 if (ret < 0) {
2249 dbgarg(cmd, "failed, ret=%ld", ret); 2093 dbgarg(cmd, "failed, ret=%ld", ret);
@@ -2256,9 +2100,6 @@ static long __video_do_ioctl(struct file *file,
2256 { 2100 {
2257 struct v4l2_event_subscription *sub = arg; 2101 struct v4l2_event_subscription *sub = arg;
2258 2102
2259 if (!ops->vidioc_unsubscribe_event)
2260 break;
2261
2262 ret = ops->vidioc_unsubscribe_event(fh, sub); 2103 ret = ops->vidioc_unsubscribe_event(fh, sub);
2263 if (ret < 0) { 2104 if (ret < 0) {
2264 dbgarg(cmd, "failed, ret=%ld", ret); 2105 dbgarg(cmd, "failed, ret=%ld", ret);
@@ -2271,8 +2112,6 @@ static long __video_do_ioctl(struct file *file,
2271 { 2112 {
2272 struct v4l2_create_buffers *create = arg; 2113 struct v4l2_create_buffers *create = arg;
2273 2114
2274 if (!ops->vidioc_create_bufs)
2275 break;
2276 if (ret_prio) { 2115 if (ret_prio) {
2277 ret = ret_prio; 2116 ret = ret_prio;
2278 break; 2117 break;
@@ -2290,8 +2129,6 @@ static long __video_do_ioctl(struct file *file,
2290 { 2129 {
2291 struct v4l2_buffer *b = arg; 2130 struct v4l2_buffer *b = arg;
2292 2131
2293 if (!ops->vidioc_prepare_buf)
2294 break;
2295 ret = check_fmt(ops, b->type); 2132 ret = check_fmt(ops, b->type);
2296 if (ret) 2133 if (ret)
2297 break; 2134 break;
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index d00b9d3511f2..a5ecec66d3c8 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -126,6 +126,7 @@ struct video_device
126 126
127 /* ioctl callbacks */ 127 /* ioctl callbacks */
128 const struct v4l2_ioctl_ops *ioctl_ops; 128 const struct v4l2_ioctl_ops *ioctl_ops;
129 DECLARE_BITMAP(valid_ioctls, BASE_VIDIOC_PRIVATE);
129 130
130 /* serialization lock */ 131 /* serialization lock */
131 DECLARE_BITMAP(dont_use_lock, BASE_VIDIOC_PRIVATE); 132 DECLARE_BITMAP(dont_use_lock, BASE_VIDIOC_PRIVATE);
@@ -184,6 +185,16 @@ static inline void v4l2_dont_use_lock(struct video_device *vdev, unsigned int cm
184 set_bit(_IOC_NR(cmd), vdev->dont_use_lock); 185 set_bit(_IOC_NR(cmd), vdev->dont_use_lock);
185} 186}
186 187
188/* Mark that this command isn't implemented, must be called before
189 video_device_register. See also the comments in determine_valid_ioctls().
190 This function allows drivers to provide just one v4l2_ioctl_ops struct, but
191 disable ioctls based on the specific card that is actually found. */
192static inline void v4l2_dont_use_cmd(struct video_device *vdev, unsigned int cmd)
193{
194 if (_IOC_NR(cmd) < BASE_VIDIOC_PRIVATE)
195 set_bit(_IOC_NR(cmd), vdev->valid_ioctls);
196}
197
187/* helper functions to access driver private data. */ 198/* helper functions to access driver private data. */
188static inline void *video_get_drvdata(struct video_device *vdev) 199static inline void *video_get_drvdata(struct video_device *vdev)
189{ 200{