Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 330684
b: refs/heads/master
c: 85397ef
h: refs/heads/master
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Aug 9, 2012
1 parent 49e33d7 commit 1ffc547
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c3707357c6c651652a87a044445eabd7582f90a4
refs/heads/master: 85397ef62a27c434136d039cc60043650a379c0d
52 changes: 42 additions & 10 deletions trunk/drivers/media/video/ivtv/ivtv-fileops.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,17 @@ ssize_t ivtv_v4l2_read(struct file * filp, char __user *buf, size_t count, loff_
struct ivtv_open_id *id = fh2id(filp->private_data);
struct ivtv *itv = id->itv;
struct ivtv_stream *s = &itv->streams[id->type];
int rc;
ssize_t rc;

IVTV_DEBUG_HI_FILE("read %zd bytes from %s\n", count, s->name);

if (mutex_lock_interruptible(&itv->serialize_lock))
return -ERESTARTSYS;
rc = ivtv_start_capture(id);
if (rc)
return rc;
return ivtv_read_pos(s, buf, count, pos, filp->f_flags & O_NONBLOCK);
if (!rc)
rc = ivtv_read_pos(s, buf, count, pos, filp->f_flags & O_NONBLOCK);
mutex_unlock(&itv->serialize_lock);
return rc;
}

int ivtv_start_decoding(struct ivtv_open_id *id, int speed)
Expand Down Expand Up @@ -540,7 +543,7 @@ int ivtv_start_decoding(struct ivtv_open_id *id, int speed)
return 0;
}

ssize_t ivtv_v4l2_write(struct file *filp, const char __user *user_buf, size_t count, loff_t *pos)
static ssize_t ivtv_write(struct file *filp, const char __user *user_buf, size_t count, loff_t *pos)
{
struct ivtv_open_id *id = fh2id(filp->private_data);
struct ivtv *itv = id->itv;
Expand Down Expand Up @@ -712,6 +715,19 @@ ssize_t ivtv_v4l2_write(struct file *filp, const char __user *user_buf, size_t c
return bytes_written;
}

ssize_t ivtv_v4l2_write(struct file *filp, const char __user *user_buf, size_t count, loff_t *pos)
{
struct ivtv_open_id *id = fh2id(filp->private_data);
struct ivtv *itv = id->itv;
ssize_t res;

if (mutex_lock_interruptible(&itv->serialize_lock))
return -ERESTARTSYS;
res = ivtv_write(filp, user_buf, count, pos);
mutex_unlock(&itv->serialize_lock);
return res;
}

unsigned int ivtv_v4l2_dec_poll(struct file *filp, poll_table *wait)
{
struct ivtv_open_id *id = fh2id(filp->private_data);
Expand Down Expand Up @@ -760,7 +776,9 @@ unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table *wait)
(req_events & (POLLIN | POLLRDNORM))) {
int rc;

mutex_lock(&itv->serialize_lock);
rc = ivtv_start_capture(id);
mutex_unlock(&itv->serialize_lock);
if (rc) {
IVTV_DEBUG_INFO("Could not start capture for %s (%d)\n",
s->name, rc);
Expand Down Expand Up @@ -863,6 +881,8 @@ int ivtv_v4l2_close(struct file *filp)

IVTV_DEBUG_FILE("close %s\n", s->name);

mutex_lock(&itv->serialize_lock);

/* Stop radio */
if (id->type == IVTV_ENC_STREAM_TYPE_RAD &&
v4l2_fh_is_singular_file(filp)) {
Expand Down Expand Up @@ -892,10 +912,8 @@ int ivtv_v4l2_close(struct file *filp)
v4l2_fh_exit(fh);

/* Easy case first: this stream was never claimed by us */
if (s->fh != &id->fh) {
kfree(id);
return 0;
}
if (s->fh != &id->fh)
goto close_done;

/* 'Unclaim' this stream */

Expand All @@ -913,11 +931,13 @@ int ivtv_v4l2_close(struct file *filp)
} else {
ivtv_stop_capture(id, 0);
}
close_done:
kfree(id);
mutex_unlock(&itv->serialize_lock);
return 0;
}

int ivtv_v4l2_open(struct file *filp)
static int ivtv_open(struct file *filp)
{
struct video_device *vdev = video_devdata(filp);
struct ivtv_stream *s = video_get_drvdata(vdev);
Expand Down Expand Up @@ -1020,6 +1040,18 @@ int ivtv_v4l2_open(struct file *filp)
return 0;
}

int ivtv_v4l2_open(struct file *filp)
{
struct video_device *vdev = video_devdata(filp);
int res;

if (mutex_lock_interruptible(vdev->lock))
return -ERESTARTSYS;
res = ivtv_open(filp);
mutex_unlock(vdev->lock);
return res;
}

void ivtv_mute(struct ivtv *itv)
{
if (atomic_read(&itv->capturing))
Expand Down
4 changes: 0 additions & 4 deletions trunk/drivers/media/video/ivtv/ivtv-streams.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ static int ivtv_prep_dev(struct ivtv *itv, int type)
s->vdev->release = video_device_release;
s->vdev->tvnorms = V4L2_STD_ALL;
s->vdev->lock = &itv->serialize_lock;
/* Locking in file operations other than ioctl should be done
by the driver, not the V4L2 core.
This driver needs auditing so that this flag can be removed. */
set_bit(V4L2_FL_LOCK_ALL_FOPS, &s->vdev->flags);
set_bit(V4L2_FL_USE_FH_PRIO, &s->vdev->flags);
ivtv_set_funcs(s->vdev);
return 0;
Expand Down

0 comments on commit 1ffc547

Please sign in to comment.