Skip to content

Commit

Permalink
V4L/DVB (7194): cx88-mpeg: Allow concurrent access to cx88-mpeg devices
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Roland Stoll authored and Mauro Carvalho Chehab committed Feb 18, 2008
1 parent 968fb08 commit 27d0fe1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions drivers/media/video/cx88/cx88-mpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}

Expand Down
1 change: 1 addition & 0 deletions drivers/media/video/cx88/cx88.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 27d0fe1

Please sign in to comment.