V4L/DVB (12325): Implement changing resolution on the fly for zr364xx driver
[safe/jmp/linux-2.6] / drivers / media / video / pms.c
index fb6471e..a1ad38f 100644 (file)
@@ -10,8 +10,8 @@
  *     14478 Potsdam, Germany
  *
  *     Most of this code is directly derived from his userspace driver.
- *     His driver works so send any reports to alan@redhat.com unless the
- *     userspace driver also doesn't work for you...
+ *     His driver works so send any reports to alan@lxorguk.ukuu.org.uk
+ *     unless the userspace driver also doesn't work for you...
  *
  *      Changes:
  *      08/07/2003        Daniele Bellucci <bellucda@tiscali.it>
@@ -28,9 +28,9 @@
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <asm/io.h>
-#include <linux/sched.h>
 #include <linux/videodev.h>
 #include <media/v4l2-common.h>
+#include <media/v4l2-ioctl.h>
 #include <linux/mutex.h>
 
 #include <asm/uaccess.h>
@@ -47,6 +47,7 @@ struct pms_device
        struct video_picture picture;
        int height;
        int width;
+       unsigned long in_use;
        struct mutex lock;
 };
 
@@ -58,11 +59,11 @@ struct i2c_info
        u8 hits;
 };
 
-static int i2c_count           = 0;
+static int i2c_count;
 static struct i2c_info i2cinfo[64];
 
 static int decoder             = PHILIPS2;
-static int standard            = 0;    /* 0 - auto 1 - ntsc 2 - pal 3 - secam */
+static int standard;   /* 0 - auto 1 - ntsc 2 - pal 3 - secam */
 
 /*
  *     I/O ports and Shared Memory
@@ -679,8 +680,7 @@ static int pms_capture(struct pms_device *dev, char __user *buf, int rgb555, int
  *     Video4linux interfacing
  */
 
-static int pms_do_ioctl(struct inode *inode, struct file *file,
-                       unsigned int cmd, void *arg)
+static long pms_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 {
        struct video_device *dev = video_devdata(file);
        struct pms_device *pd=(struct pms_device *)dev;
@@ -805,7 +805,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
                        struct video_picture *p = arg;
                        if(!((p->palette==VIDEO_PALETTE_RGB565 && p->depth==16)
                            ||(p->palette==VIDEO_PALETTE_RGB555 && p->depth==15)))
-                               return -EINVAL;
+                               return -EINVAL;
                        pd->picture= *p;
 
                        /*
@@ -862,10 +862,10 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
        return 0;
 }
 
-static int pms_ioctl(struct inode *inode, struct file *file,
+static long pms_ioctl(struct file *file,
                     unsigned int cmd, unsigned long arg)
 {
-       return video_usercopy(inode, file, cmd, arg, pms_do_ioctl);
+       return video_usercopy(file, cmd, arg, pms_do_ioctl);
 }
 
 static ssize_t pms_read(struct file *file, char __user *buf,
@@ -881,23 +881,36 @@ static ssize_t pms_read(struct file *file, char __user *buf,
        return len;
 }
 
-static struct file_operations pms_fops = {
+static int pms_exclusive_open(struct file *file)
+{
+       struct video_device *v = video_devdata(file);
+       struct pms_device *pd = (struct pms_device *)v;
+
+       return test_and_set_bit(0, &pd->in_use) ? -EBUSY : 0;
+}
+
+static int pms_exclusive_release(struct file *file)
+{
+       struct video_device *v = video_devdata(file);
+       struct pms_device *pd = (struct pms_device *)v;
+
+       clear_bit(0, &pd->in_use);
+       return 0;
+}
+
+static const struct v4l2_file_operations pms_fops = {
        .owner          = THIS_MODULE,
-       .open           = video_exclusive_open,
-       .release        = video_exclusive_release,
+       .open           = pms_exclusive_open,
+       .release        = pms_exclusive_release,
        .ioctl          = pms_ioctl,
-       .compat_ioctl   = v4l_compat_ioctl32,
        .read           = pms_read,
-       .llseek         = no_llseek,
 };
 
 static struct video_device pms_template=
 {
-       .owner          = THIS_MODULE,
        .name           = "Mediavision PMS",
-       .type           = VID_TYPE_CAPTURE,
-       .hardware       = VID_HARDWARE_PMS,
        .fops           = &pms_fops,
+       .release        = video_device_release_empty,
 };
 
 static struct pms_device pms_device;
@@ -1020,10 +1033,23 @@ static int init_mediavision(void)
  *     Initialization and module stuff
  */
 
+#ifndef MODULE
+static int enable;
+module_param(enable, int, 0);
+#endif
+
 static int __init init_pms_cards(void)
 {
        printk(KERN_INFO "Mediavision Pro Movie Studio driver 0.02\n");
 
+#ifndef MODULE
+       if (!enable) {
+               printk(KERN_INFO "PMS: not enabled, use pms.enable=1 to "
+                                "probe\n");
+               return -ENODEV;
+       }
+#endif
+
        data_port = io_port +1;
 
        if(init_mediavision())