Commit 33d27a45 authored by Antoine Jacquet's avatar Antoine Jacquet Committed by Mauro Carvalho Chehab

V4L/DVB (8732): zr364xx: handle video exclusive open internaly

Count the users and do not use video_exclusive_open() anymore.
Signed-off-by: default avatarAntoine Jacquet <royale@zerezo.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 69025c93
...@@ -116,6 +116,7 @@ struct zr364xx_camera { ...@@ -116,6 +116,7 @@ struct zr364xx_camera {
int height; int height;
int method; int method;
struct mutex lock; struct mutex lock;
int users;
}; };
...@@ -643,11 +644,10 @@ static int zr364xx_open(struct inode *inode, struct file *file) ...@@ -643,11 +644,10 @@ static int zr364xx_open(struct inode *inode, struct file *file)
mutex_lock(&cam->lock); mutex_lock(&cam->lock);
cam->skip = 2; if (cam->users) {
err = -EBUSY;
err = video_exclusive_open(inode, file);
if (err < 0)
goto out; goto out;
}
if (!cam->framebuf) { if (!cam->framebuf) {
cam->framebuf = vmalloc_32(MAX_FRAME_SIZE * FRAMES); cam->framebuf = vmalloc_32(MAX_FRAME_SIZE * FRAMES);
...@@ -669,6 +669,8 @@ static int zr364xx_open(struct inode *inode, struct file *file) ...@@ -669,6 +669,8 @@ static int zr364xx_open(struct inode *inode, struct file *file)
} }
} }
cam->skip = 2;
cam->users++;
file->private_data = vdev; file->private_data = vdev;
/* Added some delay here, since opening/closing the camera quickly, /* Added some delay here, since opening/closing the camera quickly,
...@@ -700,6 +702,10 @@ static int zr364xx_release(struct inode *inode, struct file *file) ...@@ -700,6 +702,10 @@ static int zr364xx_release(struct inode *inode, struct file *file)
udev = cam->udev; udev = cam->udev;
mutex_lock(&cam->lock); mutex_lock(&cam->lock);
cam->users--;
file->private_data = NULL;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
err = err =
send_control_msg(udev, 1, init[cam->method][i].value, send_control_msg(udev, 1, init[cam->method][i].value,
...@@ -707,21 +713,19 @@ static int zr364xx_release(struct inode *inode, struct file *file) ...@@ -707,21 +713,19 @@ static int zr364xx_release(struct inode *inode, struct file *file)
init[cam->method][i].size); init[cam->method][i].size);
if (err < 0) { if (err < 0) {
info("error during release sequence"); info("error during release sequence");
mutex_unlock(&cam->lock); goto out;
return err;
} }
} }
file->private_data = NULL;
video_exclusive_release(inode, file);
/* Added some delay here, since opening/closing the camera quickly, /* Added some delay here, since opening/closing the camera quickly,
* like Ekiga does during its startup, can crash the webcam * like Ekiga does during its startup, can crash the webcam
*/ */
mdelay(100); mdelay(100);
err = 0;
out:
mutex_unlock(&cam->lock); mutex_unlock(&cam->lock);
return 0; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment