]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (7194): cx88-mpeg: Allow concurrent access to cx88-mpeg devices
authorRoland Stoll <roland@xindex.de>
Mon, 11 Feb 2008 16:00:34 +0000 (13:00 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Mon, 18 Feb 2008 14:15:19 +0000 (11:15 -0300)
It currently isn't possible to open the frontend device of cx88-mpeg devices
(DVB or Blackbird) multiple times concurrently. (for instance, to attach a
signal monitoring tool while reading a stream, or to send a frequency change
ioctl) This patch fixes that condition.

Signed-off-by: Roland Stoll <roland@xindex.de>
Signed-off-by: Ricardo Cerqueira <v4l@cerqueira.org>
Reviewed-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/cx88/cx88-mpeg.c
drivers/media/video/cx88/cx88.h

index 0aedbeaf94cd7edfacc59c3271e3166f3dd75cb1..f12733d6bf728acedac8cbb4b6efa4069757a669 100644 (file)
@@ -609,13 +609,19 @@ static int cx8802_request_acquire(struct cx8802_driver *drv)
        struct cx88_core *core = drv->core;
 
        /* Fail a request for hardware if the device is busy. */
-       if (core->active_type_id != CX88_BOARD_NONE)
+       if (core->active_type_id != CX88_BOARD_NONE &&
+           core->active_type_id != drv->type_id)
                return -EBUSY;
 
        if (drv->advise_acquire)
        {
-               core->active_type_id = drv->type_id;
-               drv->advise_acquire(drv);
+               core->active_ref++;
+               mutex_lock(&drv->core->lock);
+               if (core->active_type_id == CX88_BOARD_NONE) {
+                       core->active_type_id = drv->type_id;
+                       drv->advise_acquire(drv);
+               }
+               mutex_unlock(&drv->core->lock);
 
                mpeg_dbg(1,"%s() Post acquire GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO));
        }
@@ -628,10 +634,12 @@ static int cx8802_request_release(struct cx8802_driver *drv)
 {
        struct cx88_core *core = drv->core;
 
-       if (drv->advise_release)
+       if (drv->advise_release && --core->active_ref == 0)
        {
+               mutex_lock(&drv->core->lock);
                drv->advise_release(drv);
                core->active_type_id = CX88_BOARD_NONE;
+               mutex_unlock(&drv->core->lock);
                mpeg_dbg(1,"%s() Post release GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO));
        }
 
index 4e823f2a539a39eb88186c6c774f57947384617b..37e6d2e4002f54f229f9daff57894462b7ce603c 100644 (file)
@@ -336,6 +336,7 @@ struct cx88_core {
        /* cx88-video needs to access cx8802 for hybrid tuner pll access. */
        struct cx8802_dev          *dvbdev;
        enum cx88_board_type       active_type_id;
+       int                        active_ref;
 };
 
 struct cx8800_dev;