Skip to content

Commit

Permalink
V4L/DVB: ngene: properly support boards where channel 0 isn't a TS input
Browse files Browse the repository at this point in the history
The current code assumes that channel zero is always a TS input, which would
result in an oops if the "one_adapter" modprobe option is 1 (which it is by
default) and the board in question has something else on channel zero (which
is the case for the Avermedia m780, which has it's analog input wired to UVI1)

The code now explicitly tracks the first adapter created and ensures that
other channels cannot accidentially be associated with a NULL adapter.

Also, eliminate what appears to be a typo where all of the channel parameters
are getting associated with stream zero's properties, which will work if you
happen to have a dual stream board with the exact same configuration, but if
they differ then the second stream is going to end up with the first stream's
configuration.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Devin Heitmueller authored and Mauro Carvalho Chehab committed May 19, 2010
1 parent 668293a commit fdafc96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/media/dvb/ngene/ngene-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1750,16 +1750,18 @@ static int init_channel(struct ngene_channel *chan)
if (io & (NGENE_IO_TSIN | NGENE_IO_TSOUT)) {
if (nr >= STREAM_AUDIOIN1)
chan->DataFormatFlags = DF_SWAP32;
if (nr == 0 || !one_adapter) {
if (nr == 0 || !one_adapter || dev->first_adapter == NULL) {
adapter = &dev->adapter[nr];
ret = dvb_register_adapter(adapter, "nGene",
THIS_MODULE,
&chan->dev->pci_dev->dev,
adapter_nr);
if (ret < 0)
return ret;
if (dev->first_adapter == NULL)
dev->first_adapter = adapter;
} else {
adapter = &dev->adapter[0];
adapter = dev->first_adapter;
}

ret = my_dvb_dmx_ts_card_init(dvbdemux, "SW demux",
Expand Down Expand Up @@ -1796,6 +1798,7 @@ static int init_channels(struct ngene *dev)
int i, j;

for (i = 0; i < MAX_STREAM; i++) {
dev->channel[i].number = i;
if (init_channel(&dev->channel[i]) < 0) {
for (j = i - 1; j >= 0; j--)
release_channel(&dev->channel[j]);
Expand Down
1 change: 1 addition & 0 deletions drivers/media/dvb/ngene/ngene.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ struct ngene {
spinlock_t cmd_lock;

struct dvb_adapter adapter[MAX_STREAM];
struct dvb_adapter *first_adapter; /* "one_adapter" modprobe opt */
struct ngene_channel channel[MAX_STREAM];

struct ngene_info *card_info;
Expand Down

0 comments on commit fdafc96

Please sign in to comment.