V4L/DVB (12231): gspca - main: Version change.
[safe/jmp/linux-2.6] / drivers / media / video / arv.c
index 649f52f..d137bac 100644 (file)
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/mm.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>
@@ -116,6 +116,7 @@ struct ar_device {
        int width, height;
        int frame_bytes, line_bytes;
        wait_queue_head_t wait;
+       unsigned long in_use;
        struct mutex lock;
 };
 
@@ -126,8 +127,8 @@ static unsigned char        yuv[MAX_AR_FRAME_BYTES];
 /* default frequency */
 #define DEFAULT_FREQ   50      /* 50 or 75 (MHz) is available as BCLK */
 static int freq = DEFAULT_FREQ;        /* BCLK: available 50 or 70 (MHz) */
-static int vga = 0;            /* default mode(0:QVGA mode, other:VGA mode) */
-static int vga_interlace = 0;  /* 0 is normal mode for, else interlace mode */
+static int vga;                        /* default mode(0:QVGA mode, other:VGA mode) */
+static int vga_interlace;      /* 0 is normal mode for, else interlace mode */
 module_param(freq, int, 0);
 module_param(vga, int, 0);
 module_param(vga_interlace, int, 0);
@@ -269,7 +270,7 @@ static inline void wait_for_vertical_sync(int exp_line)
 static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos)
 {
        struct video_device *v = video_devdata(file);
-       struct ar_device *ar = v->priv;
+       struct ar_device *ar = video_get_drvdata(v);
        long ret = ar->frame_bytes;             /* return read bytes */
        unsigned long arvcr1 = 0;
        unsigned long flags;
@@ -395,11 +396,10 @@ out_up:
        return ret;
 }
 
-static int ar_do_ioctl(struct inode *inode, struct file *file,
-                      unsigned int cmd, void *arg)
+static long ar_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 {
        struct video_device *dev = video_devdata(file);
-       struct ar_device *ar = dev->priv;
+       struct ar_device *ar = video_get_drvdata(dev);
 
        DEBUG(1, "ar_ioctl()\n");
        switch(cmd) {
@@ -442,7 +442,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file,
        {
                struct video_window *w = arg;
                DEBUG(1, "VIDIOCGWIN:\n");
-               memset(w, 0, sizeof(w));
+               memset(w, 0, sizeof(*w));
                w->width = ar->width;
                w->height = ar->height;
                return 0;
@@ -539,10 +539,10 @@ static int ar_do_ioctl(struct inode *inode, struct file *file,
        return 0;
 }
 
-static int ar_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
+static long ar_ioctl(struct file *file, unsigned int cmd,
                    unsigned long arg)
 {
-       return video_usercopy(inode, file, cmd, arg, ar_do_ioctl);
+       return video_usercopy(file, cmd, arg, ar_do_ioctl);
 }
 
 #if USE_INT
@@ -625,7 +625,7 @@ static void ar_interrupt(int irq, void *dev)
  */
 static int ar_initialize(struct video_device *dev)
 {
-       struct ar_device *ar = dev->priv;
+       struct ar_device *ar = video_get_drvdata(dev);
        unsigned long cr = 0;
        int i,found=0;
 
@@ -732,7 +732,7 @@ static int ar_initialize(struct video_device *dev)
 
 void ar_release(struct video_device *vfd)
 {
-       struct ar_device *ar = vfd->priv;
+       struct ar_device *ar = video_get_drvdata(vfd);
        mutex_lock(&ar->lock);
        video_device_release(vfd);
 }
@@ -742,28 +742,35 @@ void ar_release(struct video_device *vfd)
  * Video4Linux Module functions
  *
  ****************************************************************************/
-static const struct file_operations ar_fops = {
+static struct ar_device ardev;
+
+static int ar_exclusive_open(struct file *file)
+{
+       return test_and_set_bit(0, &ardev.in_use) ? -EBUSY : 0;
+}
+
+static int ar_exclusive_release(struct file *file)
+{
+       clear_bit(0, &ardev.in_use);
+       return 0;
+}
+
+static const struct v4l2_file_operations ar_fops = {
        .owner          = THIS_MODULE,
-       .open           = video_exclusive_open,
-       .release        = video_exclusive_release,
+       .open           = ar_exclusive_open,
+       .release        = ar_exclusive_release,
        .read           = ar_read,
        .ioctl          = ar_ioctl,
-       .compat_ioctl   = v4l_compat_ioctl32,
-       .llseek         = no_llseek,
 };
 
 static struct video_device ar_template = {
-       .owner          = THIS_MODULE,
        .name           = "Colour AR VGA",
-       .type           = VID_TYPE_CAPTURE,
-       .hardware       = VID_HARDWARE_ARV,
        .fops           = &ar_fops,
        .release        = ar_release,
        .minor          = -1,
 };
 
 #define ALIGN4(x)      ((((int)(x)) & 0x3) == 0)
-static struct ar_device ardev;
 
 static int __init ar_init(void)
 {
@@ -803,7 +810,7 @@ static int __init ar_init(void)
                return -ENOMEM;
        }
        memcpy(ar->vdev, &ar_template, sizeof(ar_template));
-       ar->vdev->priv = ar;
+       video_set_drvdata(ar->vdev, ar);
 
        if (vga) {
                ar->width       = AR_WIDTH_VGA;
@@ -854,7 +861,7 @@ static int __init ar_init(void)
        }
 
        printk("video%d: Found M64278 VGA (IRQ %d, Freq %dMHz).\n",
-               ar->vdev->minor, M32R_IRQ_INT3, freq);
+               ar->vdev->num, M32R_IRQ_INT3, freq);
 
        return 0;