Commit 27d0fe18 authored by Roland Stoll's avatar Roland Stoll Committed by Mauro Carvalho Chehab

V4L/DVB (7194): cx88-mpeg: Allow concurrent access to cx88-mpeg devices

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: default avatarRoland Stoll <roland@xindex.de>
Signed-off-by: default avatarRicardo Cerqueira <v4l@cerqueira.org>
Reviewed-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 968fb089
...@@ -609,13 +609,19 @@ static int cx8802_request_acquire(struct cx8802_driver *drv) ...@@ -609,13 +609,19 @@ static int cx8802_request_acquire(struct cx8802_driver *drv)
struct cx88_core *core = drv->core; struct cx88_core *core = drv->core;
/* Fail a request for hardware if the device is busy. */ /* 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; return -EBUSY;
if (drv->advise_acquire) if (drv->advise_acquire)
{ {
core->active_ref++;
mutex_lock(&drv->core->lock);
if (core->active_type_id == CX88_BOARD_NONE) {
core->active_type_id = drv->type_id; core->active_type_id = drv->type_id;
drv->advise_acquire(drv); drv->advise_acquire(drv);
}
mutex_unlock(&drv->core->lock);
mpeg_dbg(1,"%s() Post acquire GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO)); 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) ...@@ -628,10 +634,12 @@ static int cx8802_request_release(struct cx8802_driver *drv)
{ {
struct cx88_core *core = drv->core; 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); drv->advise_release(drv);
core->active_type_id = CX88_BOARD_NONE; 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)); mpeg_dbg(1,"%s() Post release GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO));
} }
......
...@@ -336,6 +336,7 @@ struct cx88_core { ...@@ -336,6 +336,7 @@ struct cx88_core {
/* cx88-video needs to access cx8802 for hybrid tuner pll access. */ /* cx88-video needs to access cx8802 for hybrid tuner pll access. */
struct cx8802_dev *dvbdev; struct cx8802_dev *dvbdev;
enum cx88_board_type active_type_id; enum cx88_board_type active_type_id;
int active_ref;
}; };
struct cx8800_dev; struct cx8800_dev;
......
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