V4L/DVB (11327): ov772x: add edge contrl support
[safe/jmp/linux-2.6] / drivers / media / video / meye.c
index fd16ef0..2ad11f0 100644 (file)
@@ -841,19 +841,18 @@ again:
 /* video4linux integration                                                  */
 /****************************************************************************/
 
-static int meye_open(struct inode *inode, struct file *file)
+static int meye_open(struct file *file)
 {
-       int i, err;
+       int i;
 
-       err = video_exclusive_open(inode, file);
-       if (err < 0)
-               return err;
+       if (test_and_set_bit(0, &meye.in_use))
+               return -EBUSY;
 
        mchip_hic_stop();
 
        if (mchip_dma_alloc()) {
                printk(KERN_ERR "meye: mchip framebuffer allocation failed\n");
-               video_exclusive_release(inode, file);
+               clear_bit(0, &meye.in_use);
                return -ENOBUFS;
        }
 
@@ -864,11 +863,11 @@ static int meye_open(struct inode *inode, struct file *file)
        return 0;
 }
 
-static int meye_release(struct inode *inode, struct file *file)
+static int meye_release(struct file *file)
 {
        mchip_hic_stop();
        mchip_dma_free();
-       video_exclusive_release(inode, file);
+       clear_bit(0, &meye.in_use);
        return 0;
 }
 
@@ -1018,7 +1017,6 @@ static int meyeioc_stilljcapt(int *len)
 static int vidioc_querycap(struct file *file, void *fh,
                                struct v4l2_capability *cap)
 {
-       memset(cap, 0, sizeof(*cap));
        strcpy(cap->driver, "meye");
        strcpy(cap->card, "meye");
        sprintf(cap->bus_info, "PCI:%s", pci_name(meye.mchip_dev));
@@ -1037,8 +1035,6 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
        if (i->index != 0)
                return -EINVAL;
 
-       memset(i, 0, sizeof(*i));
-       i->index = 0;
        strcpy(i->name, "Camera");
        i->type = V4L2_INPUT_TYPE_CAMERA;
 
@@ -1260,22 +1256,13 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh,
        if (f->index > 1)
                return -EINVAL;
 
-       if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
        if (f->index == 0) {
                /* standard YUV 422 capture */
-               memset(f, 0, sizeof(*f));
-               f->index = 0;
-               f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
                f->flags = 0;
                strcpy(f->description, "YUV422");
                f->pixelformat = V4L2_PIX_FMT_YUYV;
        } else {
                /* compressed MJPEG capture */
-               memset(f, 0, sizeof(*f));
-               f->index = 1;
-               f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
                f->flags = V4L2_FMT_FLAG_COMPRESSED;
                strcpy(f->description, "MJPEG");
                f->pixelformat = V4L2_PIX_FMT_MJPEG;
@@ -1287,9 +1274,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh,
 static int vidioc_try_fmt_vid_cap(struct file *file, void *fh,
                                struct v4l2_format *f)
 {
-       if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
        if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
            f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
                return -EINVAL;
@@ -1320,12 +1304,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh,
 static int vidioc_g_fmt_vid_cap(struct file *file, void *fh,
                                    struct v4l2_format *f)
 {
-       if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
-       memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format));
-       f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
        switch (meye.mchip_mode) {
        case MCHIP_HIC_MODE_CONT_OUT:
        default:
@@ -1342,8 +1320,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *fh,
        f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
        f->fmt.pix.sizeimage = f->fmt.pix.height *
                               f->fmt.pix.bytesperline;
-       f->fmt.pix.colorspace = 0;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
@@ -1351,9 +1327,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *fh,
 static int vidioc_s_fmt_vid_cap(struct file *file, void *fh,
                                    struct v4l2_format *f)
 {
-       if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
        if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
            f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
                return -EINVAL;
@@ -1399,9 +1372,6 @@ static int vidioc_reqbufs(struct file *file, void *fh,
 {
        int i;
 
-       if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
        if (req->memory != V4L2_MEMORY_MMAP)
                return -EINVAL;
 
@@ -1442,15 +1412,11 @@ static int vidioc_reqbufs(struct file *file, void *fh,
 
 static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
 {
-       int index = buf->index;
+       unsigned int index = buf->index;
 
-       if (index < 0 || index >= gbuffers)
+       if (index >= gbuffers)
                return -EINVAL;
 
-       memset(buf, 0, sizeof(*buf));
-
-       buf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       buf->index = index;
        buf->bytesused = meye.grab_buffer[index].size;
        buf->flags = V4L2_BUF_FLAG_MAPPED;
 
@@ -1472,13 +1438,10 @@ static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
 
 static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
 {
-       if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
        if (buf->memory != V4L2_MEMORY_MMAP)
                return -EINVAL;
 
-       if (buf->index < 0 || buf->index >= gbuffers)
+       if (buf->index >= gbuffers)
                return -EINVAL;
 
        if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED)
@@ -1498,9 +1461,6 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
 {
        int reqnr;
 
-       if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-               return -EINVAL;
-
        if (buf->memory != V4L2_MEMORY_MMAP)
                return -EINVAL;
 
@@ -1578,7 +1538,7 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
        return 0;
 }
 
-static int vidioc_default(struct file *file, void *fh, int cmd, void *arg)
+static long vidioc_default(struct file *file, void *fh, int cmd, void *arg)
 {
        switch (cmd) {
        case MEYEIOC_G_PARAMS:
@@ -1685,17 +1645,13 @@ static int meye_mmap(struct file *file, struct vm_area_struct *vma)
        return 0;
 }
 
-static const struct file_operations meye_fops = {
+static const struct v4l2_file_operations meye_fops = {
        .owner          = THIS_MODULE,
        .open           = meye_open,
        .release        = meye_release,
        .mmap           = meye_mmap,
        .ioctl          = video_ioctl2,
-#ifdef CONFIG_COMPAT
-       .compat_ioctl   = v4l_compat_ioctl32,
-#endif
        .poll           = meye_poll,
-       .llseek         = no_llseek,
 };
 
 static const struct v4l2_ioctl_ops meye_ioctl_ops = {
@@ -1720,9 +1676,7 @@ static const struct v4l2_ioctl_ops meye_ioctl_ops = {
 };
 
 static struct video_device meye_template = {
-       .owner          = THIS_MODULE,
        .name           = "meye",
-       .type           = VID_TYPE_CAPTURE,
        .fops           = &meye_fops,
        .ioctl_ops      = &meye_ioctl_ops,
        .release        = video_device_release,
@@ -1776,6 +1730,7 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
                goto outnotdev;
        }
 
+       ret = -ENOMEM;
        meye.mchip_dev = pcidev;
        meye.video_dev = video_device_alloc();
        if (!meye.video_dev) {
@@ -1783,7 +1738,6 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
                goto outnotdev;
        }
 
-       ret = -ENOMEM;
        meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE);
        if (!meye.grab_temp) {
                printk(KERN_ERR "meye: grab buffer allocation failed\n");
@@ -1808,6 +1762,7 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
        memcpy(meye.video_dev, &meye_template, sizeof(meye_template));
        meye.video_dev->parent = &meye.mchip_dev->dev;
 
+       ret = -EIO;
        if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) {
                printk(KERN_ERR "meye: unable to power on the camera\n");
                printk(KERN_ERR "meye: did you enable the camera in "
@@ -1815,7 +1770,6 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
                goto outsonypienable;
        }
 
-       ret = -EIO;
        if ((ret = pci_enable_device(meye.mchip_dev))) {
                printk(KERN_ERR "meye: pci_enable_device failed\n");
                goto outenabledev;