]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/video/v4l2-ioctl.c
V4L/DVB (11367): v4l2-common: remove legacy code
[linux-2.6-omap-h63xx.git] / drivers / media / video / v4l2-ioctl.c
index 64b4fda08dd55da4d715c9cf27cea962a6fe3ab5..88f10d6cbc92e899fd2c19d7f65797685728e5cd 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/kernel.h>
 
 #define __OLD_VIDIOC_ /* To allow fixing old calls */
+#include <linux/videodev.h>
 #include <linux/videodev2.h>
 
 #ifdef CONFIG_VIDEO_V4L1
@@ -25,7 +26,6 @@
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-chip-ident.h>
-#include <linux/video_decoder.h>
 
 #define dbgarg(cmd, fmt, arg...) \
                do {                                                    \
@@ -101,25 +101,27 @@ const char *v4l2_norm_to_name(v4l2_std_id id)
 }
 EXPORT_SYMBOL(v4l2_norm_to_name);
 
+/* Returns frame period for the given standard */
+void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod)
+{
+       if (id & V4L2_STD_525_60) {
+               frameperiod->numerator = 1001;
+               frameperiod->denominator = 30000;
+       } else {
+               frameperiod->numerator = 1;
+               frameperiod->denominator = 25;
+       }
+}
+EXPORT_SYMBOL(v4l2_video_std_frame_period);
+
 /* Fill in the fields of a v4l2_standard structure according to the
    'id' and 'transmission' parameters.  Returns negative on error.  */
 int v4l2_video_std_construct(struct v4l2_standard *vs,
                             int id, const char *name)
 {
-       u32 index = vs->index;
-
-       memset(vs, 0, sizeof(struct v4l2_standard));
-       vs->index = index;
-       vs->id    = id;
-       if (id & V4L2_STD_525_60) {
-               vs->frameperiod.numerator = 1001;
-               vs->frameperiod.denominator = 30000;
-               vs->framelines = 525;
-       } else {
-               vs->frameperiod.numerator = 1;
-               vs->frameperiod.denominator = 25;
-               vs->framelines = 625;
-       }
+       vs->id = id;
+       v4l2_video_std_frame_period(id, &vs->frameperiod);
+       vs->framelines = (id & V4L2_STD_525_60) ? 525 : 625;
        strlcpy(vs->name, name, sizeof(vs->name));
        return 0;
 }
@@ -273,45 +275,6 @@ static const char *v4l2_ioctls[] = {
 };
 #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
 
-static const char *v4l2_int_ioctls[] = {
-#ifdef CONFIG_VIDEO_V4L1_COMPAT
-       [_IOC_NR(DECODER_GET_CAPABILITIES)]    = "DECODER_GET_CAPABILITIES",
-       [_IOC_NR(DECODER_GET_STATUS)]          = "DECODER_GET_STATUS",
-       [_IOC_NR(DECODER_SET_NORM)]            = "DECODER_SET_NORM",
-       [_IOC_NR(DECODER_SET_INPUT)]           = "DECODER_SET_INPUT",
-       [_IOC_NR(DECODER_SET_OUTPUT)]          = "DECODER_SET_OUTPUT",
-       [_IOC_NR(DECODER_ENABLE_OUTPUT)]       = "DECODER_ENABLE_OUTPUT",
-       [_IOC_NR(DECODER_SET_PICTURE)]         = "DECODER_SET_PICTURE",
-       [_IOC_NR(DECODER_SET_GPIO)]            = "DECODER_SET_GPIO",
-       [_IOC_NR(DECODER_INIT)]                = "DECODER_INIT",
-       [_IOC_NR(DECODER_SET_VBI_BYPASS)]      = "DECODER_SET_VBI_BYPASS",
-       [_IOC_NR(DECODER_DUMP)]                = "DECODER_DUMP",
-#endif
-       [_IOC_NR(AUDC_SET_RADIO)]              = "AUDC_SET_RADIO",
-
-       [_IOC_NR(TUNER_SET_TYPE_ADDR)]         = "TUNER_SET_TYPE_ADDR",
-       [_IOC_NR(TUNER_SET_STANDBY)]           = "TUNER_SET_STANDBY",
-       [_IOC_NR(TUNER_SET_CONFIG)]            = "TUNER_SET_CONFIG",
-
-       [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)]     = "VIDIOC_INT_S_TUNER_MODE",
-       [_IOC_NR(VIDIOC_INT_RESET)]            = "VIDIOC_INT_RESET",
-       [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
-       [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)]  = "VIDIOC_INT_DECODE_VBI_LINE",
-       [_IOC_NR(VIDIOC_INT_S_VBI_DATA)]       = "VIDIOC_INT_S_VBI_DATA",
-       [_IOC_NR(VIDIOC_INT_G_VBI_DATA)]       = "VIDIOC_INT_G_VBI_DATA",
-       [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)]   = "VIDIOC_INT_I2S_CLOCK_FREQ",
-       [_IOC_NR(VIDIOC_INT_S_STANDBY)]        = "VIDIOC_INT_S_STANDBY",
-       [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)]  = "VIDIOC_INT_S_AUDIO_ROUTING",
-       [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)]  = "VIDIOC_INT_G_AUDIO_ROUTING",
-       [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)]  = "VIDIOC_INT_S_VIDEO_ROUTING",
-       [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)]  = "VIDIOC_INT_G_VIDEO_ROUTING",
-       [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)]   = "VIDIOC_INT_S_CRYSTAL_FREQ",
-       [_IOC_NR(VIDIOC_INT_INIT)]             = "VIDIOC_INT_INIT",
-       [_IOC_NR(VIDIOC_INT_G_STD_OUTPUT)]     = "VIDIOC_INT_G_STD_OUTPUT",
-       [_IOC_NR(VIDIOC_INT_S_STD_OUTPUT)]     = "VIDIOC_INT_S_STD_OUTPUT",
-};
-#define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls)
-
 /* Common ioctl debug function. This function can be used by
    external ioctl messages as well as internal V4L ioctl */
 void v4l_printk_ioctl(unsigned int cmd)
@@ -320,12 +283,8 @@ void v4l_printk_ioctl(unsigned int cmd)
 
        switch (_IOC_TYPE(cmd)) {
        case 'd':
-               if (_IOC_NR(cmd) >= V4L2_INT_IOCTLS) {
-                       type = "v4l2_int";
-                       break;
-               }
-               printk("%s", v4l2_int_ioctls[_IOC_NR(cmd)]);
-               return;
+               type = "v4l2_int";
+               break;
 #ifdef CONFIG_VIDEO_V4L1_COMPAT
        case 'v':
                if (_IOC_NR(cmd) >= V4L1_IOCTLS) {
@@ -1076,7 +1035,6 @@ static long __video_do_ioctl(struct file *file,
                        return -EINVAL;
 
                v4l2_video_std_construct(p, curr_id, descr);
-               p->index = index;
 
                dbgarg(cmd, "index=%d, id=0x%Lx, name=%s, fps=%d/%d, "
                                "framelines=%d\n", p->index,
@@ -1563,17 +1521,16 @@ static long __video_do_ioctl(struct file *file,
                struct v4l2_streamparm *p = arg;
 
                if (ops->vidioc_g_parm) {
+                       ret = check_fmt(ops, p->type);
+                       if (ret)
+                               break;
                        ret = ops->vidioc_g_parm(file, fh, p);
                } else {
-                       struct v4l2_standard s;
-
                        if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
                                return -EINVAL;
 
-                       v4l2_video_std_construct(&s, vfd->current_norm,
-                                                v4l2_norm_to_name(vfd->current_norm));
-
-                       p->parm.capture.timeperframe = s.frameperiod;
+                       v4l2_video_std_frame_period(vfd->current_norm,
+                                                   &p->parm.capture.timeperframe);
                        ret = 0;
                }
 
@@ -1586,6 +1543,10 @@ static long __video_do_ioctl(struct file *file,
 
                if (!ops->vidioc_s_parm)
                        break;
+               ret = check_fmt(ops, p->type);
+               if (ret)
+                       break;
+
                dbgarg(cmd, "type=%d\n", p->type);
                ret = ops->vidioc_s_parm(file, fh, p);
                break;
@@ -1708,11 +1669,6 @@ static long __video_do_ioctl(struct file *file,
                        dbgarg(cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision);
                break;
        }
-       case VIDIOC_G_CHIP_IDENT_OLD:
-               printk(KERN_ERR "VIDIOC_G_CHIP_IDENT has been deprecated and will disappear in 2.6.30.\n");
-               printk(KERN_ERR "It is a debugging ioctl and must not be used in applications!\n");
-               return -EINVAL;
-
        case VIDIOC_S_HW_FREQ_SEEK:
        {
                struct v4l2_hw_freq_seek *p = arg;
@@ -1817,11 +1773,12 @@ static long __video_do_ioctl(struct file *file,
 static unsigned long cmd_input_size(unsigned int cmd)
 {
        /* Size of structure up to and including 'field' */
-#define CMDINSIZE(cmd, type, field) case _IOC_NR(VIDIOC_##cmd): return \
-               offsetof(struct v4l2_##type, field) + \
-               sizeof(((struct v4l2_##type *)0)->field);
+#define CMDINSIZE(cmd, type, field)                            \
+       case VIDIOC_##cmd:                                      \
+               return offsetof(struct v4l2_##type, field) +    \
+                       sizeof(((struct v4l2_##type *)0)->field);
 
-       switch (_IOC_NR(cmd)) {
+       switch (cmd) {
                CMDINSIZE(ENUM_FMT,             fmtdesc,        type);
                CMDINSIZE(G_FMT,                format,         type);
                CMDINSIZE(QUERYBUF,             buffer,         type);