aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/zoran
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2009-01-12 11:09:46 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-01-29 05:35:38 -0500
commit17faeb20912af5d2a1422fdb606e785f9b1d88ba (patch)
tree9feb015ec6dfba0397208a7bd8e51ce5cba924ac /drivers/media/video/zoran
parent601139e08339b15997c6ae638dc5bf42c51ea204 (diff)
V4L/DVB (10224): zoran: Use pci device table to get card type
Instead of using custom code, just let the device layer look it up for us from the pci device table. This requires extending the pci device table to list each known card, plus a catch-all entry for the cards that don't have sub-system vendor/device data. Improve some of the info and error messages too. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Acked-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/zoran')
-rw-r--r--drivers/media/video/zoran/zoran.h1
-rw-r--r--drivers/media/video/zoran/zoran_card.c110
2 files changed, 47 insertions, 64 deletions
diff --git a/drivers/media/video/zoran/zoran.h b/drivers/media/video/zoran/zoran.h
index 46b7ad477ceb..7273abf5eb46 100644
--- a/drivers/media/video/zoran/zoran.h
+++ b/drivers/media/video/zoran/zoran.h
@@ -349,7 +349,6 @@ struct card_info {
349 u16 i2c_decoder, i2c_encoder; /* I2C types */ 349 u16 i2c_decoder, i2c_encoder; /* I2C types */
350 u16 video_vfe, video_codec; /* videocodec types */ 350 u16 video_vfe, video_codec; /* videocodec types */
351 u16 audio_chip; /* audio type */ 351 u16 audio_chip; /* audio type */
352 u16 vendor_id, device_id; /* subsystem vendor/device ID */
353 352
354 int inputs; /* number of video inputs */ 353 int inputs; /* number of video inputs */
355 struct input { 354 struct input {
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c
index 117650fecd89..7b73d83e1273 100644
--- a/drivers/media/video/zoran/zoran_card.c
+++ b/drivers/media/video/zoran/zoran_card.c
@@ -153,8 +153,16 @@ MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver");
153MODULE_AUTHOR("Serguei Miridonov"); 153MODULE_AUTHOR("Serguei Miridonov");
154MODULE_LICENSE("GPL"); 154MODULE_LICENSE("GPL");
155 155
156#define ZR_DEVICE(subven, subdev, data) { \
157 .vendor = PCI_VENDOR_ID_ZORAN, .device = PCI_DEVICE_ID_ZORAN_36057, \
158 .subvendor = (subven), .subdevice = (subdev), .driver_data = (data) }
159
156static struct pci_device_id zr36067_pci_tbl[] = { 160static struct pci_device_id zr36067_pci_tbl[] = {
157 { PCI_DEVICE(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36057), }, 161 ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC10PLUS, DC10plus),
162 ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC30PLUS, DC30plus),
163 ZR_DEVICE(PCI_VENDOR_ID_ELECTRONICDESIGNGMBH, PCI_DEVICE_ID_LML_33R10, LML33R10),
164 ZR_DEVICE(PCI_VENDOR_ID_IOMEGA, PCI_DEVICE_ID_IOMEGA_BUZ, BUZ),
165 ZR_DEVICE(PCI_ANY_ID, PCI_ANY_ID, NUM_CARDS),
158 {0} 166 {0}
159}; 167};
160MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl); 168MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl);
@@ -476,8 +484,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
476 }, { 484 }, {
477 .type = DC10plus, 485 .type = DC10plus,
478 .name = "DC10plus", 486 .name = "DC10plus",
479 .vendor_id = PCI_VENDOR_ID_MIRO,
480 .device_id = PCI_DEVICE_ID_MIRO_DC10PLUS,
481 .i2c_decoder = I2C_DRIVERID_SAA7110, 487 .i2c_decoder = I2C_DRIVERID_SAA7110,
482 .i2c_encoder = I2C_DRIVERID_ADV7175, 488 .i2c_encoder = I2C_DRIVERID_ADV7175,
483 .video_codec = CODEC_TYPE_ZR36060, 489 .video_codec = CODEC_TYPE_ZR36060,
@@ -535,8 +541,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
535 }, { 541 }, {
536 .type = DC30plus, 542 .type = DC30plus,
537 .name = "DC30plus", 543 .name = "DC30plus",
538 .vendor_id = PCI_VENDOR_ID_MIRO,
539 .device_id = PCI_DEVICE_ID_MIRO_DC30PLUS,
540 .i2c_decoder = I2C_DRIVERID_VPX3220, 544 .i2c_decoder = I2C_DRIVERID_VPX3220,
541 .i2c_encoder = I2C_DRIVERID_ADV7175, 545 .i2c_encoder = I2C_DRIVERID_ADV7175,
542 .video_codec = CODEC_TYPE_ZR36050, 546 .video_codec = CODEC_TYPE_ZR36050,
@@ -593,8 +597,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
593 }, { 597 }, {
594 .type = LML33R10, 598 .type = LML33R10,
595 .name = "LML33R10", 599 .name = "LML33R10",
596 .vendor_id = PCI_VENDOR_ID_ELECTRONICDESIGNGMBH,
597 .device_id = PCI_DEVICE_ID_LML_33R10,
598 .i2c_decoder = I2C_DRIVERID_SAA7114, 600 .i2c_decoder = I2C_DRIVERID_SAA7114,
599 .i2c_encoder = I2C_DRIVERID_ADV7170, 601 .i2c_encoder = I2C_DRIVERID_ADV7170,
600 .video_codec = CODEC_TYPE_ZR36060, 602 .video_codec = CODEC_TYPE_ZR36060,
@@ -622,8 +624,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
622 }, { 624 }, {
623 .type = BUZ, 625 .type = BUZ,
624 .name = "Buz", 626 .name = "Buz",
625 .vendor_id = PCI_VENDOR_ID_IOMEGA,
626 .device_id = PCI_DEVICE_ID_IOMEGA_BUZ,
627 .i2c_decoder = I2C_DRIVERID_SAA7111A, 627 .i2c_decoder = I2C_DRIVERID_SAA7111A,
628 .i2c_encoder = I2C_DRIVERID_SAA7185B, 628 .i2c_encoder = I2C_DRIVERID_SAA7185B,
629 .video_codec = CODEC_TYPE_ZR36060, 629 .video_codec = CODEC_TYPE_ZR36060,
@@ -653,8 +653,6 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = {
653 .name = "6-Eyes", 653 .name = "6-Eyes",
654 /* AverMedia chose not to brand the 6-Eyes. Thus it 654 /* AverMedia chose not to brand the 6-Eyes. Thus it
655 can't be autodetected, and requires card=x. */ 655 can't be autodetected, and requires card=x. */
656 .vendor_id = -1,
657 .device_id = -1,
658 .i2c_decoder = I2C_DRIVERID_KS0127, 656 .i2c_decoder = I2C_DRIVERID_KS0127,
659 .i2c_encoder = I2C_DRIVERID_BT866, 657 .i2c_encoder = I2C_DRIVERID_BT866,
660 .video_codec = CODEC_TYPE_ZR36060, 658 .video_codec = CODEC_TYPE_ZR36060,
@@ -1284,7 +1282,6 @@ static int __devinit zoran_probe(struct pci_dev *pdev,
1284 return -ENOENT; 1282 return -ENOENT;
1285 } 1283 }
1286 1284
1287 card_num = card[nr];
1288 zr = kzalloc(sizeof(struct zoran), GFP_KERNEL); 1285 zr = kzalloc(sizeof(struct zoran), GFP_KERNEL);
1289 if (!zr) { 1286 if (!zr) {
1290 dprintk(1, 1287 dprintk(1,
@@ -1302,68 +1299,55 @@ static int __devinit zoran_probe(struct pci_dev *pdev,
1302 goto zr_free_mem; 1299 goto zr_free_mem;
1303 zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0); 1300 zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0);
1304 pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, &zr->revision); 1301 pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, &zr->revision);
1305 if (zr->revision < 2) { 1302
1303 dprintk(1,
1304 KERN_INFO
1305 "%s: Zoran ZR360%c7 (rev %d), irq: %d, memory: 0x%08x\n",
1306 ZR_DEVNAME(zr), zr->revision < 2 ? '5' : '6', zr->revision,
1307 zr->pci_dev->irq, zr->zr36057_adr);
1308 if (zr->revision >= 2) {
1306 dprintk(1, 1309 dprintk(1,
1307 KERN_INFO 1310 KERN_INFO
1308 "%s: Zoran ZR36057 (rev %d) irq: %d, memory: 0x%08x.\n", 1311 "%s: Subsystem vendor=0x%04x id=0x%04x\n",
1309 ZR_DEVNAME(zr), zr->revision, zr->pci_dev->irq, 1312 ZR_DEVNAME(zr), zr->pci_dev->subsystem_vendor,
1310 zr->zr36057_adr); 1313 zr->pci_dev->subsystem_device);
1314 }
1311 1315
1312 if (card_num == -1) { 1316 /* Use auto-detected card type? */
1317 if (card[nr] == -1) {
1318 if (zr->revision < 2) {
1319 dprintk(1,
1320 KERN_ERR
1321 "%s: No card type specified, please use the card=X module parameter\n",
1322 ZR_DEVNAME(zr));
1313 dprintk(1, 1323 dprintk(1,
1314 KERN_ERR 1324 KERN_ERR
1315 "%s: find_zr36057() - no card specified, please use the card=X insmod option\n", 1325 "%s: It is not possible to auto-detect ZR36057 based cards\n",
1316 ZR_DEVNAME(zr)); 1326 ZR_DEVNAME(zr));
1317 goto zr_free_mem; 1327 goto zr_free_mem;
1318 } 1328 }
1319 } else {
1320 int i;
1321 unsigned short ss_vendor, ss_device;
1322 1329
1323 ss_vendor = zr->pci_dev->subsystem_vendor; 1330 card_num = ent->driver_data;
1324 ss_device = zr->pci_dev->subsystem_device; 1331 if (card_num >= NUM_CARDS) {
1325 dprintk(1, 1332 dprintk(1,
1326 KERN_INFO 1333 KERN_ERR
1327 "%s: Zoran ZR36067 (rev %d) irq: %d, memory: 0x%08x\n", 1334 "%s: Unknown card, try specifying card=X module parameter\n",
1328 ZR_DEVNAME(zr), zr->revision, zr->pci_dev->irq,
1329 zr->zr36057_adr);
1330 dprintk(1,
1331 KERN_INFO
1332 "%s: subsystem vendor=0x%04x id=0x%04x\n",
1333 ZR_DEVNAME(zr), ss_vendor, ss_device);
1334 if (card_num == -1) {
1335 dprintk(3,
1336 KERN_DEBUG
1337 "%s: find_zr36057() - trying to autodetect card type\n",
1338 ZR_DEVNAME(zr)); 1335 ZR_DEVNAME(zr));
1339 for (i = 0; i < NUM_CARDS; i++) { 1336 goto zr_free_mem;
1340 if (ss_vendor == zoran_cards[i].vendor_id && 1337 }
1341 ss_device == zoran_cards[i].device_id) { 1338 dprintk(3,
1342 dprintk(3, 1339 KERN_DEBUG
1343 KERN_DEBUG 1340 "%s: %s() - card %s detected\n",
1344 "%s: find_zr36057() - card %s detected\n", 1341 ZR_DEVNAME(zr), __func__, zoran_cards[card_num].name);
1345 ZR_DEVNAME(zr), 1342 } else {
1346 zoran_cards[i].name); 1343 card_num = card[nr];
1347 card_num = i; 1344 if (card_num >= NUM_CARDS || card_num < 0) {
1348 break; 1345 dprintk(1,
1349 } 1346 KERN_ERR
1350 } 1347 "%s: User specified card type %d out of range (0 .. %d)\n",
1351 if (i == NUM_CARDS) { 1348 ZR_DEVNAME(zr), card_num, NUM_CARDS - 1);
1352 dprintk(1, 1349 goto zr_free_mem;
1353 KERN_ERR
1354 "%s: find_zr36057() - unknown card\n",
1355 ZR_DEVNAME(zr));
1356 goto zr_free_mem;
1357 }
1358 } 1350 }
1359 }
1360
1361 if (card_num < 0 || card_num >= NUM_CARDS) {
1362 dprintk(2,
1363 KERN_ERR
1364 "%s: find_zr36057() - invalid cardnum %d\n",
1365 ZR_DEVNAME(zr), card_num);
1366 goto zr_free_mem;
1367 } 1351 }
1368 1352
1369 /* even though we make this a non pointer and thus 1353 /* even though we make this a non pointer and thus