if (!pdev->udev)
return -ENODEV;
- if (pdev->vopen) {
- PWC_DEBUG_OPEN("I'm busy, someone is using the device.\n");
- return -EBUSY;
- }
-
- pdev->vopen++;
file->private_data = vdev;
PWC_DEBUG_OPEN("<< video_open() returns 0.\n");
return 0;
PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev);
pdev = video_get_drvdata(vdev);
- vb2_queue_release(&pdev->vb_queue);
- pdev->vopen--;
+ if (pdev->capt_file == file) {
+ vb2_queue_release(&pdev->vb_queue);
+ pdev->capt_file = NULL;
+ }
- PWC_DEBUG_OPEN("<< video_close() vopen=%d\n", pdev->vopen);
+ PWC_DEBUG_OPEN("<< video_close()\n");
return 0;
}
if (!pdev->udev)
return -ENODEV;
+ if (pdev->capt_file != NULL &&
+ pdev->capt_file != file)
+ return -EBUSY;
+
+ pdev->capt_file = file;
+
return vb2_read(&pdev->vb_queue, buf, count, ppos,
file->f_flags & O_NONBLOCK);
}
struct video_device *vdev = file->private_data;
struct pwc_device *pdev = video_get_drvdata(vdev);
+ if (pdev->capt_file != file)
+ return -EBUSY;
+
return vb2_mmap(&pdev->vb_queue, vma);
}
}
/* ioctl(VIDIOC_SET_FMT) */
-static int pwc_vidioc_set_fmt(struct pwc_device *pdev, struct v4l2_format *f)
+
+static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
{
+ struct pwc_device *pdev = video_drvdata(file);
int ret, fps, snapshot, compression, pixelformat;
if (!pdev->udev)
return -ENODEV;
+ if (pdev->capt_file != NULL &&
+ pdev->capt_file != file)
+ return -EBUSY;
+
+ pdev->capt_file = file;
+
ret = pwc_vidioc_try_fmt(pdev, f);
if (ret<0)
return ret;
return pwc_vidioc_try_fmt(pdev, f);
}
-static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
-{
- struct pwc_device *pdev = video_drvdata(file);
-
- return pwc_vidioc_set_fmt(pdev, f);
-}
-
static int pwc_reqbufs(struct file *file, void *fh,
struct v4l2_requestbuffers *rb)
{
struct pwc_device *pdev = video_drvdata(file);
+ if (pdev->capt_file != NULL &&
+ pdev->capt_file != file)
+ return -EBUSY;
+
+ pdev->capt_file = file;
+
return vb2_reqbufs(&pdev->vb_queue, rb);
}
if (!pdev->udev)
return -ENODEV;
+ if (pdev->capt_file != file)
+ return -EBUSY;
+
return vb2_qbuf(&pdev->vb_queue, buf);
}
if (!pdev->udev)
return -ENODEV;
+ if (pdev->capt_file != file)
+ return -EBUSY;
+
return vb2_dqbuf(&pdev->vb_queue, buf, file->f_flags & O_NONBLOCK);
}
if (!pdev->udev)
return -ENODEV;
+ if (pdev->capt_file != file)
+ return -EBUSY;
+
return vb2_streamon(&pdev->vb_queue, i);
}
if (!pdev->udev)
return -ENODEV;
+ if (pdev->capt_file != file)
+ return -EBUSY;
+
return vb2_streamoff(&pdev->vb_queue, i);
}