aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2008-11-19 15:16:26 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:38:06 -0500
commit181b704fd3e32cdf779bc4d5b99d43a4b2c25985 (patch)
tree27218613f61174b1d2acdbc28f65eed96bac19b1 /drivers/media/video/gspca
parent3480130a502a528373f98fb852d2b3fc5f73e58b (diff)
V4L/DVB (9707): gspca: Remove the event counter and simplify the frame wait.
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r--drivers/media/video/gspca/gspca.c40
-rw-r--r--drivers/media/video/gspca/gspca.h1
2 files changed, 12 insertions, 29 deletions
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 7f8b798deb1b..e77cc19be4ec 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -300,7 +300,6 @@ struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
300 frame->v4l2_buf.bytesused = frame->data_end - frame->data; 300 frame->v4l2_buf.bytesused = frame->data_end - frame->data;
301 frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_QUEUED; 301 frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_QUEUED;
302 frame->v4l2_buf.flags |= V4L2_BUF_FLAG_DONE; 302 frame->v4l2_buf.flags |= V4L2_BUF_FLAG_DONE;
303 atomic_inc(&gspca_dev->nevent);
304 wake_up_interruptible(&gspca_dev->wq); /* event = new frame */ 303 wake_up_interruptible(&gspca_dev->wq); /* event = new frame */
305 i = (gspca_dev->fr_i + 1) % gspca_dev->nframes; 304 i = (gspca_dev->fr_i + 1) % gspca_dev->nframes;
306 gspca_dev->fr_i = i; 305 gspca_dev->fr_i = i;
@@ -394,7 +393,6 @@ static int frame_alloc(struct gspca_dev *gspca_dev,
394 gspca_dev->fr_i = gspca_dev->fr_o = gspca_dev->fr_q = 0; 393 gspca_dev->fr_i = gspca_dev->fr_o = gspca_dev->fr_q = 0;
395 gspca_dev->last_packet_type = DISCARD_PACKET; 394 gspca_dev->last_packet_type = DISCARD_PACKET;
396 gspca_dev->sequence = 0; 395 gspca_dev->sequence = 0;
397 atomic_set(&gspca_dev->nevent, 0);
398 return 0; 396 return 0;
399} 397}
400 398
@@ -628,7 +626,6 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev)
628 goto out; 626 goto out;
629 } 627 }
630 gspca_dev->streaming = 1; 628 gspca_dev->streaming = 1;
631 atomic_set(&gspca_dev->nevent, 0);
632 629
633 /* some bulk transfers are started by the subdriver */ 630 /* some bulk transfers are started by the subdriver */
634 if (gspca_dev->alt == 0 && gspca_dev->cam.bulk_nurbs == 0) 631 if (gspca_dev->alt == 0 && gspca_dev->cam.bulk_nurbs == 0)
@@ -669,7 +666,6 @@ static int gspca_set_alt0(struct gspca_dev *gspca_dev)
669static void gspca_stream_off(struct gspca_dev *gspca_dev) 666static void gspca_stream_off(struct gspca_dev *gspca_dev)
670{ 667{
671 gspca_dev->streaming = 0; 668 gspca_dev->streaming = 0;
672 atomic_set(&gspca_dev->nevent, 0);
673 if (gspca_dev->present 669 if (gspca_dev->present
674 && gspca_dev->sd_desc->stopN) 670 && gspca_dev->sd_desc->stopN)
675 gspca_dev->sd_desc->stopN(gspca_dev); 671 gspca_dev->sd_desc->stopN(gspca_dev);
@@ -1255,7 +1251,6 @@ static int vidioc_streamoff(struct file *file, void *priv,
1255 gspca_dev->fr_i = gspca_dev->fr_o = gspca_dev->fr_q = 0; 1251 gspca_dev->fr_i = gspca_dev->fr_o = gspca_dev->fr_q = 0;
1256 gspca_dev->last_packet_type = DISCARD_PACKET; 1252 gspca_dev->last_packet_type = DISCARD_PACKET;
1257 gspca_dev->sequence = 0; 1253 gspca_dev->sequence = 0;
1258 atomic_set(&gspca_dev->nevent, 0);
1259 ret = 0; 1254 ret = 0;
1260out: 1255out:
1261 mutex_unlock(&gspca_dev->queue_lock); 1256 mutex_unlock(&gspca_dev->queue_lock);
@@ -1459,33 +1454,22 @@ static int frame_wait(struct gspca_dev *gspca_dev,
1459 i = gspca_dev->fr_o; 1454 i = gspca_dev->fr_o;
1460 j = gspca_dev->fr_queue[i]; 1455 j = gspca_dev->fr_queue[i];
1461 frame = &gspca_dev->frame[j]; 1456 frame = &gspca_dev->frame[j];
1462 if (frame->v4l2_buf.flags & V4L2_BUF_FLAG_DONE) {
1463 atomic_dec(&gspca_dev->nevent);
1464 goto ok;
1465 }
1466 if (nonblock_ing) /* no frame yet */
1467 return -EAGAIN;
1468 1457
1469 /* wait till a frame is ready */ 1458 if (!(frame->v4l2_buf.flags & V4L2_BUF_FLAG_DONE)) {
1470 for (;;) { 1459 if (nonblock_ing)
1460 return -EAGAIN;
1461
1462 /* wait till a frame is ready */
1471 ret = wait_event_interruptible_timeout(gspca_dev->wq, 1463 ret = wait_event_interruptible_timeout(gspca_dev->wq,
1472 atomic_read(&gspca_dev->nevent) > 0, 1464 (frame->v4l2_buf.flags & V4L2_BUF_FLAG_DONE) ||
1473 msecs_to_jiffies(3000)); 1465 !gspca_dev->streaming || !gspca_dev->present,
1474 if (ret <= 0) { 1466 msecs_to_jiffies(3000));
1475 if (ret < 0) 1467 if (ret < 0)
1476 return ret; /* interrupt */ 1468 return ret;
1477 return -EIO; /* timeout */ 1469 if (ret == 0 || !gspca_dev->streaming || !gspca_dev->present)
1478 }
1479 atomic_dec(&gspca_dev->nevent);
1480 if (!gspca_dev->streaming || !gspca_dev->present)
1481 return -EIO; 1470 return -EIO;
1482 i = gspca_dev->fr_o;
1483 j = gspca_dev->fr_queue[i];
1484 frame = &gspca_dev->frame[j];
1485 if (frame->v4l2_buf.flags & V4L2_BUF_FLAG_DONE)
1486 break;
1487 } 1471 }
1488ok: 1472
1489 gspca_dev->fr_o = (i + 1) % gspca_dev->nframes; 1473 gspca_dev->fr_o = (i + 1) % gspca_dev->nframes;
1490 PDEBUG(D_FRAM, "frame wait q:%d i:%d o:%d", 1474 PDEBUG(D_FRAM, "frame wait q:%d i:%d o:%d",
1491 gspca_dev->fr_q, 1475 gspca_dev->fr_q,
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index dcfc6fd2a402..15db13296b83 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -155,7 +155,6 @@ struct gspca_dev {
155 __u16 height; 155 __u16 height;
156 __u32 sequence; /* frame sequence number */ 156 __u32 sequence; /* frame sequence number */
157 157
158 atomic_t nevent; /* number of frames done */
159 wait_queue_head_t wq; /* wait queue */ 158 wait_queue_head_t wq; /* wait queue */
160 struct mutex usb_lock; /* usb exchange protection */ 159 struct mutex usb_lock; /* usb exchange protection */
161 struct mutex read_lock; /* read protection */ 160 struct mutex read_lock; /* read protection */