summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-01-10 08:33:03 -0200
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-10 08:33:03 -0200
commit0211bdd025a9d152eab4fd4643945a40bbf9cda2 (patch)
tree3b2b89a70c4fdea3dfdc7a12570c4ba06d086899
parentbd7bb69be657ca3ab2bcb1a327ab33655077aa3b (diff)
downloadmediapointer-dvb-s2-0211bdd025a9d152eab4fd4643945a40bbf9cda2.tar.gz
mediapointer-dvb-s2-0211bdd025a9d152eab4fd4643945a40bbf9cda2.tar.bz2
Replace a very dirty hack on videobuf for a clean wait_event
From: Mauro Carvalho Chehab <mchehab@infradead.org> In order to videobuf_iolock to work, mmap_mapper should be called first. Otherwise, an OOPS is generated. On some cases, .mmap file handler used to took some time to be called. On those situations, mmap_mmapper() were called after iolock. This patch properly waits for mmap_mapper to be called, otherwise generating an error. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--linux/drivers/media/video/videobuf-core.c15
-rw-r--r--linux/include/media/videobuf-core.h2
2 files changed, 13 insertions, 4 deletions
diff --git a/linux/drivers/media/video/videobuf-core.c b/linux/drivers/media/video/videobuf-core.c
index 1f6f20f46..792099865 100644
--- a/linux/drivers/media/video/videobuf-core.c
+++ b/linux/drivers/media/video/videobuf-core.c
@@ -99,13 +99,15 @@ int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb,
MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
- /* FIXME: This is required to avoid OOPS on some cases,
+ /* This is required to avoid OOPS on some cases,
since mmap_mapper() method should be called before _iolock.
On some cases, the mmap_mapper() is called only after scheduling.
-
- However, this way is just too dirty! Better to wait for some event.
*/
- schedule_timeout(HZ);
+ wait_event_timeout(vb->done, q->is_mmapped, msecs_to_jiffies(100));
+ if (!q->is_mmapped) {
+ printk(KERN_ERR "Error: mmap_mapper() never called!\n");
+ return -EINVAL;
+ }
return CALL(q, iolock, q, vb, fbuf);
}
@@ -301,7 +303,11 @@ static int __videobuf_mmap_free(struct videobuf_queue *q)
MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS);
+
rc = CALL(q, mmap_free, q);
+
+ q->is_mmapped = 0;
+
if (rc < 0)
return rc;
@@ -1023,6 +1029,7 @@ int videobuf_mmap_mapper(struct videobuf_queue *q,
mutex_lock(&q->lock);
retval = CALL(q, mmap_mapper, q, vma);
+ q->is_mmapped = 1;
mutex_unlock(&q->lock);
return retval;
diff --git a/linux/include/media/videobuf-core.h b/linux/include/media/videobuf-core.h
index dea9c53fe..9bb244716 100644
--- a/linux/include/media/videobuf-core.h
+++ b/linux/include/media/videobuf-core.h
@@ -168,6 +168,8 @@ struct videobuf_queue {
unsigned int streaming:1;
unsigned int reading:1;
+ unsigned int is_mmapped:1;
+
/* capture via mmap() + ioctl(QBUF/DQBUF) */
struct list_head stream;