V4L/DVB (8523): v4l2-dev: remove unused type and type2 field from video_device
[pandora-kernel.git] / drivers / media / video / usbvision / usbvision-video.c
index df52f8a..b977116 100644 (file)
@@ -53,7 +53,6 @@
 #include <linux/mm.h>
 #include <linux/utsname.h>
 #include <linux/highmem.h>
-#include <linux/videodev.h>
 #include <linux/vmalloc.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -65,8 +64,8 @@
 
 #include <media/saa7115.h>
 #include <media/v4l2-common.h>
+#include <media/v4l2-ioctl.h>
 #include <media/tuner.h>
-#include <media/audiochip.h>
 
 #include <linux/workqueue.h>
 
@@ -97,10 +96,10 @@ USBVISION_DRIVER_VERSION_PATCHLEVEL)
 
 
 #ifdef USBVISION_DEBUG
-       #define PDEBUG(level, fmt, args...) \
+       #define PDEBUG(level, fmt, args...) \
                if (video_debug & (level)) \
-                       info("[%s:%d] " fmt, __PRETTY_FUNCTION__, __LINE__ ,\
-                               ## args)
+                       info("[%s:%d] " fmt, __func__, __LINE__ , ## args); \
+       }
 #else
        #define PDEBUG(level, fmt, args...) do {} while(0)
 #endif
@@ -115,7 +114,7 @@ USBVISION_DRIVER_VERSION_PATCHLEVEL)
 
 
 /* sequential number of usbvision device */
-static int usbvision_nr = 0;
+static int usbvision_nr;
 
 static struct usbvision_v4l2_format_st usbvision_v4l2_format[] = {
        { 1, 1,  8, V4L2_PIX_FMT_GREY    , "GREY" },
@@ -135,7 +134,7 @@ static void usbvision_release(struct usb_usbvision *usbvision);
 /* Set the default format for ISOC endpoint */
 static int isocMode = ISOC_MODE_COMPRESS;
 /* Set the default Debug Mode of the device driver */
-static int video_debug = 0;
+static int video_debug;
 /* Set the default device to power on at startup */
 static int PowerOnAtOpen = 1;
 /* Sequential Number of Video Device */
@@ -179,13 +178,12 @@ MODULE_ALIAS(DRIVER_ALIAS);
 /*   /sys/bus/usb/drivers/USBVision Video Grabber                            */
 /*****************************************************************************/
 
-
 #define YES_NO(x) ((x) ? "Yes" : "No")
 
 static inline struct usb_usbvision *cd_to_usbvision(struct device *cd)
 {
        struct video_device *vdev =
-               container_of(cd, struct video_device, class_dev);
+               container_of(cd, struct video_device, dev);
        return video_get_drvdata(vdev);
 }
 
@@ -200,7 +198,7 @@ static ssize_t show_model(struct device *cd,
                          struct device_attribute *attr, char *buf)
 {
        struct video_device *vdev =
-               container_of(cd, struct video_device, class_dev);
+               container_of(cd, struct video_device, dev);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        return sprintf(buf, "%s\n",
                       usbvision_device_data[usbvision->DevModel].ModelString);
@@ -211,7 +209,7 @@ static ssize_t show_hue(struct device *cd,
                        struct device_attribute *attr, char *buf)
 {
        struct video_device *vdev =
-               container_of(cd, struct video_device, class_dev);
+               container_of(cd, struct video_device, dev);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        struct v4l2_control ctrl;
        ctrl.id = V4L2_CID_HUE;
@@ -226,7 +224,7 @@ static ssize_t show_contrast(struct device *cd,
                             struct device_attribute *attr, char *buf)
 {
        struct video_device *vdev =
-               container_of(cd, struct video_device, class_dev);
+               container_of(cd, struct video_device, dev);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        struct v4l2_control ctrl;
        ctrl.id = V4L2_CID_CONTRAST;
@@ -241,7 +239,7 @@ static ssize_t show_brightness(struct device *cd,
                               struct device_attribute *attr, char *buf)
 {
        struct video_device *vdev =
-               container_of(cd, struct video_device, class_dev);
+               container_of(cd, struct video_device, dev);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        struct v4l2_control ctrl;
        ctrl.id = V4L2_CID_BRIGHTNESS;
@@ -256,7 +254,7 @@ static ssize_t show_saturation(struct device *cd,
                               struct device_attribute *attr, char *buf)
 {
        struct video_device *vdev =
-               container_of(cd, struct video_device, class_dev);
+               container_of(cd, struct video_device, dev);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        struct v4l2_control ctrl;
        ctrl.id = V4L2_CID_SATURATION;
@@ -271,7 +269,7 @@ static ssize_t show_streaming(struct device *cd,
                              struct device_attribute *attr, char *buf)
 {
        struct video_device *vdev =
-               container_of(cd, struct video_device, class_dev);
+               container_of(cd, struct video_device, dev);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        return sprintf(buf, "%s\n",
                       YES_NO(usbvision->streaming==Stream_On?1:0));
@@ -282,7 +280,7 @@ static ssize_t show_compression(struct device *cd,
                                struct device_attribute *attr, char *buf)
 {
        struct video_device *vdev =
-               container_of(cd, struct video_device, class_dev);
+               container_of(cd, struct video_device, dev);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        return sprintf(buf, "%s\n",
                       YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS));
@@ -293,7 +291,7 @@ static ssize_t show_device_bridge(struct device *cd,
                                  struct device_attribute *attr, char *buf)
 {
        struct video_device *vdev =
-               container_of(cd, struct video_device, class_dev);
+               container_of(cd, struct video_device, dev);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        return sprintf(buf, "%d\n", usbvision->bridgeType);
 }
@@ -305,72 +303,53 @@ static void usbvision_create_sysfs(struct video_device *vdev)
        if (!vdev)
                return;
        do {
-               res = device_create_file(&vdev->class_dev,
-                                        &dev_attr_version);
+               res = device_create_file(&vdev->dev, &dev_attr_version);
                if (res<0)
                        break;
-               res = device_create_file(&vdev->class_dev,
-                                        &dev_attr_model);
+               res = device_create_file(&vdev->dev, &dev_attr_model);
                if (res<0)
                        break;
-               res = device_create_file(&vdev->class_dev,
-                                        &dev_attr_hue);
+               res = device_create_file(&vdev->dev, &dev_attr_hue);
                if (res<0)
                        break;
-               res = device_create_file(&vdev->class_dev,
-                                        &dev_attr_contrast);
+               res = device_create_file(&vdev->dev, &dev_attr_contrast);
                if (res<0)
                        break;
-               res = device_create_file(&vdev->class_dev,
-                                        &dev_attr_brightness);
+               res = device_create_file(&vdev->dev, &dev_attr_brightness);
                if (res<0)
                        break;
-               res = device_create_file(&vdev->class_dev,
-                                        &dev_attr_saturation);
+               res = device_create_file(&vdev->dev, &dev_attr_saturation);
                if (res<0)
                        break;
-               res = device_create_file(&vdev->class_dev,
-                                        &dev_attr_streaming);
+               res = device_create_file(&vdev->dev, &dev_attr_streaming);
                if (res<0)
                        break;
-               res = device_create_file(&vdev->class_dev,
-                                        &dev_attr_compression);
+               res = device_create_file(&vdev->dev, &dev_attr_compression);
                if (res<0)
                        break;
-               res = device_create_file(&vdev->class_dev,
-                                        &dev_attr_bridge);
+               res = device_create_file(&vdev->dev, &dev_attr_bridge);
                if (res>=0)
                        return;
        } while (0);
 
-       err("%s error: %d\n", __FUNCTION__, res);
+       err("%s error: %d\n", __func__, res);
 }
 
 static void usbvision_remove_sysfs(struct video_device *vdev)
 {
        if (vdev) {
-               device_remove_file(&vdev->class_dev,
-                                        &dev_attr_version);
-               device_remove_file(&vdev->class_dev,
-                                        &dev_attr_model);
-               device_remove_file(&vdev->class_dev,
-                                        &dev_attr_hue);
-               device_remove_file(&vdev->class_dev,
-                                        &dev_attr_contrast);
-               device_remove_file(&vdev->class_dev,
-                                        &dev_attr_brightness);
-               device_remove_file(&vdev->class_dev,
-                                        &dev_attr_saturation);
-               device_remove_file(&vdev->class_dev,
-                                        &dev_attr_streaming);
-               device_remove_file(&vdev->class_dev,
-                                        &dev_attr_compression);
-               device_remove_file(&vdev->class_dev,
-                                        &dev_attr_bridge);
+               device_remove_file(&vdev->dev, &dev_attr_version);
+               device_remove_file(&vdev->dev, &dev_attr_model);
+               device_remove_file(&vdev->dev, &dev_attr_hue);
+               device_remove_file(&vdev->dev, &dev_attr_contrast);
+               device_remove_file(&vdev->dev, &dev_attr_brightness);
+               device_remove_file(&vdev->dev, &dev_attr_saturation);
+               device_remove_file(&vdev->dev, &dev_attr_streaming);
+               device_remove_file(&vdev->dev, &dev_attr_compression);
+               device_remove_file(&vdev->dev, &dev_attr_bridge);
        }
 }
 
-
 /*
  * usbvision_open()
  *
@@ -388,7 +367,6 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
 
        PDEBUG(DBG_IO, "open");
 
-
        usbvision_reset_powerOffTimer(usbvision);
 
        if (usbvision->user)
@@ -442,9 +420,6 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
                mutex_unlock(&usbvision->lock);
        }
 
-       if (errCode) {
-       }
-
        /* prepare queues */
        usbvision_empty_framequeues(usbvision);
 
@@ -490,13 +465,11 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file)
        mutex_unlock(&usbvision->lock);
 
        if (usbvision->remove_pending) {
-               printk(KERN_INFO "%s: Final disconnect\n", __FUNCTION__);
+               printk(KERN_INFO "%s: Final disconnect\n", __func__);
                usbvision_release(usbvision);
        }
 
        PDEBUG(DBG_IO, "success");
-
-
        return 0;
 }
 
@@ -522,7 +495,7 @@ static int vidioc_g_register (struct file *file, void *priv,
        errCode = usbvision_read_reg(usbvision, reg->reg&0xff);
        if (errCode < 0) {
                err("%s: VIDIOC_DBG_G_REGISTER failed: error %d",
-                   __FUNCTION__, errCode);
+                   __func__, errCode);
                return errCode;
        }
        reg->val = errCode;
@@ -543,7 +516,7 @@ static int vidioc_s_register (struct file *file, void *priv,
        errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val);
        if (errCode < 0) {
                err("%s: VIDIOC_DBG_S_REGISTER failed: error %d",
-                   __FUNCTION__, errCode);
+                   __func__, errCode);
                return errCode;
        }
        return 0;
@@ -998,7 +971,7 @@ static int vidioc_streamoff(struct file *file,
        return 0;
 }
 
-static int vidioc_enum_fmt_cap (struct file *file, void  *priv,
+static int vidioc_enum_fmt_vid_cap (struct file *file, void  *priv,
                                        struct v4l2_fmtdesc *vfd)
 {
        if(vfd->index>=USBVISION_SUPPORTED_PALETTES-1) {
@@ -1012,7 +985,7 @@ static int vidioc_enum_fmt_cap (struct file *file, void  *priv,
        return 0;
 }
 
-static int vidioc_g_fmt_cap (struct file *file, void *priv,
+static int vidioc_g_fmt_vid_cap (struct file *file, void *priv,
                                        struct v4l2_format *vf)
 {
        struct video_device *dev = video_devdata(file);
@@ -1030,7 +1003,7 @@ static int vidioc_g_fmt_cap (struct file *file, void *priv,
        return 0;
 }
 
-static int vidioc_try_fmt_cap (struct file *file, void *priv,
+static int vidioc_try_fmt_vid_cap (struct file *file, void *priv,
                               struct v4l2_format *vf)
 {
        struct video_device *dev = video_devdata(file);
@@ -1060,7 +1033,7 @@ static int vidioc_try_fmt_cap (struct file *file, void *priv,
        return 0;
 }
 
-static int vidioc_s_fmt_cap(struct file *file, void *priv,
+static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
                               struct v4l2_format *vf)
 {
        struct video_device *dev = video_devdata(file);
@@ -1068,7 +1041,7 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv,
                (struct usb_usbvision *) video_get_drvdata(dev);
        int ret;
 
-       if( 0 != (ret=vidioc_try_fmt_cap (file, priv, vf)) ) {
+       if( 0 != (ret=vidioc_try_fmt_vid_cap (file, priv, vf)) ) {
                return ret;
        }
 
@@ -1102,7 +1075,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf,
        int ret,i;
        struct usbvision_frame *frame;
 
-       PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __FUNCTION__,
+       PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __func__,
               (unsigned long)count, noblock);
 
        if (!USBVISION_IS_OPERATIONAL(usbvision) || (buf == NULL))
@@ -1171,7 +1144,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf,
        }
 
        PDEBUG(DBG_IO, "%s: frmx=%d, bytes_read=%ld, scanlength=%ld",
-              __FUNCTION__,
+              __func__,
               frame->index, frame->bytes_read, frame->scanlength);
 
        /* copy bytes to user space; we allow for partials reads */
@@ -1184,7 +1157,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf,
 
        frame->bytes_read += count;
        PDEBUG(DBG_IO, "%s: {copy} count used=%ld, new bytes_read=%ld",
-              __FUNCTION__,
+              __func__,
               (unsigned long)count, frame->bytes_read);
 
        /* For now, forget the frame if it has not been read in one shot. */
@@ -1269,12 +1242,12 @@ static int usbvision_radio_open(struct inode *inode, struct file *file)
                (struct usb_usbvision *) video_get_drvdata(dev);
        int errCode = 0;
 
-       PDEBUG(DBG_IO, "%s:", __FUNCTION__);
+       PDEBUG(DBG_IO, "%s:", __func__);
 
        mutex_lock(&usbvision->lock);
 
        if (usbvision->user) {
-               err("%s: Someone tried to open an already opened USBVision Radio!", __FUNCTION__);
+               err("%s: Someone tried to open an already opened USBVision Radio!", __func__);
                errCode = -EBUSY;
        }
        else {
@@ -1342,13 +1315,11 @@ static int usbvision_radio_close(struct inode *inode, struct file *file)
        mutex_unlock(&usbvision->lock);
 
        if (usbvision->remove_pending) {
-               printk(KERN_INFO "%s: Final disconnect\n", __FUNCTION__);
+               printk(KERN_INFO "%s: Final disconnect\n", __func__);
                usbvision_release(usbvision);
        }
 
-
        PDEBUG(DBG_IO, "success");
-
        return errCode;
 }
 
@@ -1360,7 +1331,6 @@ static int usbvision_vbi_open(struct inode *inode, struct file *file)
 {
        /* TODO */
        return -ENODEV;
-
 }
 
 static int usbvision_vbi_close(struct inode *inode, struct file *file)
@@ -1399,18 +1369,13 @@ static const struct file_operations usbvision_fops = {
 /*     .poll          = video_poll, */
        .compat_ioctl  = v4l_compat_ioctl32,
 };
-static struct video_device usbvision_video_template = {
-       .owner             = THIS_MODULE,
-       .type           = VID_TYPE_TUNER | VID_TYPE_CAPTURE,
-       .fops           = &usbvision_fops,
-       .name           = "usbvision-video",
-       .release        = video_device_release,
-       .minor          = -1,
+
+static const struct v4l2_ioctl_ops usbvision_ioctl_ops = {
        .vidioc_querycap      = vidioc_querycap,
-       .vidioc_enum_fmt_cap  = vidioc_enum_fmt_cap,
-       .vidioc_g_fmt_cap     = vidioc_g_fmt_cap,
-       .vidioc_try_fmt_cap   = vidioc_try_fmt_cap,
-       .vidioc_s_fmt_cap     = vidioc_s_fmt_cap,
+       .vidioc_enum_fmt_vid_cap  = vidioc_enum_fmt_vid_cap,
+       .vidioc_g_fmt_vid_cap     = vidioc_g_fmt_vid_cap,
+       .vidioc_try_fmt_vid_cap   = vidioc_try_fmt_vid_cap,
+       .vidioc_s_fmt_vid_cap     = vidioc_s_fmt_vid_cap,
        .vidioc_reqbufs       = vidioc_reqbufs,
        .vidioc_querybuf      = vidioc_querybuf,
        .vidioc_qbuf          = vidioc_qbuf,
@@ -1437,6 +1402,14 @@ static struct video_device usbvision_video_template = {
        .vidioc_g_register    = vidioc_g_register,
        .vidioc_s_register    = vidioc_s_register,
 #endif
+};
+
+static struct video_device usbvision_video_template = {
+       .fops           = &usbvision_fops,
+       .ioctl_ops      = &usbvision_ioctl_ops,
+       .name           = "usbvision-video",
+       .release        = video_device_release,
+       .minor          = -1,
        .tvnorms              = USBVISION_NORMS,
        .current_norm         = V4L2_STD_PAL
 };
@@ -1452,14 +1425,7 @@ static const struct file_operations usbvision_radio_fops = {
        .compat_ioctl  = v4l_compat_ioctl32,
 };
 
-static struct video_device usbvision_radio_template=
-{
-       .owner             = THIS_MODULE,
-       .type           = VID_TYPE_TUNER,
-       .fops           = &usbvision_radio_fops,
-       .name           = "usbvision-radio",
-       .release        = video_device_release,
-       .minor          = -1,
+static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = {
        .vidioc_querycap      = vidioc_querycap,
        .vidioc_enum_input    = vidioc_enum_input,
        .vidioc_g_input       = vidioc_g_input,
@@ -1473,6 +1439,14 @@ static struct video_device usbvision_radio_template=
        .vidioc_s_tuner       = vidioc_s_tuner,
        .vidioc_g_frequency   = vidioc_g_frequency,
        .vidioc_s_frequency   = vidioc_s_frequency,
+};
+
+static struct video_device usbvision_radio_template = {
+       .fops           = &usbvision_radio_fops,
+       .name           = "usbvision-radio",
+       .release        = video_device_release,
+       .minor          = -1,
+       .ioctl_ops      = &usbvision_radio_ioctl_ops,
 
        .tvnorms              = USBVISION_NORMS,
        .current_norm         = V4L2_STD_PAL
@@ -1490,8 +1464,6 @@ static const struct file_operations usbvision_vbi_fops = {
 
 static struct video_device usbvision_vbi_template=
 {
-       .owner             = THIS_MODULE,
-       .type           = VID_TYPE_TUNER,
        .fops           = &usbvision_vbi_fops,
        .release        = video_device_release,
        .name           = "usbvision-vbi",
@@ -1507,7 +1479,7 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision,
        struct video_device *vdev;
 
        if (usb_dev == NULL) {
-               err("%s: usbvision->dev is not set", __FUNCTION__);
+               err("%s: usbvision->dev is not set", __func__);
                return NULL;
        }
 
@@ -1517,7 +1489,7 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision,
        }
        *vdev = *vdev_template;
 //     vdev->minor   = -1;
-       vdev->dev     = &usb_dev->dev;
+       vdev->parent  = &usb_dev->dev;
        snprintf(vdev->name, sizeof(vdev->name), "%s", name);
        video_set_drvdata(vdev, usbvision);
        return vdev;
@@ -1759,7 +1731,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf,
                PDEBUG(DBG_PROBE, "model out of bounds %d",model);
                return -ENODEV;
        }
-       printk(KERN_INFO "%s: %s found\n", __FUNCTION__,
+       printk(KERN_INFO "%s: %s found\n", __func__,
                                usbvision_device_data[model].ModelString);
 
        if (usbvision_device_data[model].Interface >= 0) {
@@ -1771,20 +1743,20 @@ static int __devinit usbvision_probe(struct usb_interface *intf,
        if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) !=
            USB_ENDPOINT_XFER_ISOC) {
                err("%s: interface %d. has non-ISO endpoint!",
-                   __FUNCTION__, ifnum);
+                   __func__, ifnum);
                err("%s: Endpoint attributes %d",
-                   __FUNCTION__, endpoint->bmAttributes);
+                   __func__, endpoint->bmAttributes);
                return -ENODEV;
        }
        if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ==
            USB_DIR_OUT) {
                err("%s: interface %d. has ISO OUT endpoint!",
-                   __FUNCTION__, ifnum);
+                   __func__, ifnum);
                return -ENODEV;
        }
 
        if ((usbvision = usbvision_alloc(dev)) == NULL) {
-               err("%s: couldn't allocate USBVision struct", __FUNCTION__);
+               err("%s: couldn't allocate USBVision struct", __func__);
                return -ENOMEM;
        }
 
@@ -1868,7 +1840,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf)
        PDEBUG(DBG_PROBE, "");
 
        if (usbvision == NULL) {
-               err("%s: usb_get_intfdata() failed", __FUNCTION__);
+               err("%s: usb_get_intfdata() failed", __func__);
                return;
        }
        usb_set_intfdata (intf, NULL);
@@ -1891,7 +1863,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf)
 
        if (usbvision->user) {
                printk(KERN_INFO "%s: In use, disconnect pending\n",
-                      __FUNCTION__);
+                      __func__);
                wake_up_interruptible(&usbvision->wait_frame);
                wake_up_interruptible(&usbvision->wait_stream);
        } else {
@@ -1899,7 +1871,6 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf)
        }
 
        PDEBUG(DBG_PROBE, "success");
-
 }
 
 static struct usb_driver usbvision_driver = {