aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx
diff options
context:
space:
mode:
authorSascha Sommer <saschasommer@freenet.de>2007-11-04 06:06:48 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:01:56 -0500
commitfad7b958e753e18ff443786360f7846da50a3085 (patch)
tree7bb5af47b1c5b43269826983a16d72dbf959ecea /drivers/media/video/em28xx
parentf1f32849d65ab1eacfedbabb624876ac06c1af9f (diff)
V4L/DVB (6545): em28xx: autodetect Cinergy 200 USB and VGear PocketTV
Adds autodetection support for the Cinergy200 USB and the VGear PocketTV. Whenever a usb device with generic empia em2800 usb ids is detected the device gets scanned for connected i2c devices. If the device list matches an em2800 device in the device list the model id gets changed accordingly. Signed-off-by: Sascha Sommer <saschasommer@freenet.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/em28xx')
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c30
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c19
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c1
-rw-r--r--drivers/media/video/em28xx/em28xx.h2
4 files changed, 46 insertions, 6 deletions
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index ae6634156e76..fd7a8a5fba66 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -402,6 +402,11 @@ static struct em28xx_hash_table em28xx_hash [] = {
402 { 0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF }, 402 { 0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF },
403}; 403};
404 404
405static struct em28xx_hash_table em28xx_i2c_hash[] = {
406 { 0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC },
407 { 0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC },
408};
409
405/* Since em28xx_pre_card_setup() requires a proper dev->model, 410/* Since em28xx_pre_card_setup() requires a proper dev->model,
406 * this won't work for boards with generic PCI IDs 411 * this won't work for boards with generic PCI IDs
407 */ 412 */
@@ -498,6 +503,30 @@ static int em28xx_hint_board(struct em28xx *dev)
498 return 0; 503 return 0;
499 } 504 }
500 } 505 }
506
507 /* user did not request i2c scanning => do it now */
508 if (!dev->i2c_hash)
509 em28xx_do_i2c_scan(dev);
510
511 for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
512 if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
513 dev->model = em28xx_i2c_hash[i].model;
514 dev->tuner_type = em28xx_i2c_hash[i].tuner;
515 em28xx_errdev("Your board has no unique USB ID.\n");
516 em28xx_errdev("A hint were successfully done, "
517 "based on i2c devicelist hash.\n");
518 em28xx_errdev("This method is not 100%% failproof.\n");
519 em28xx_errdev("If the board were missdetected, "
520 "please email this log to:\n");
521 em28xx_errdev("\tV4L Mailing List "
522 " <video4linux-list@redhat.com>\n");
523 em28xx_errdev("Board detected as %s\n",
524 em28xx_boards[dev->model].name);
525
526 return 0;
527 }
528 }
529
501 em28xx_errdev("Your board has no unique USB ID and thus need a " 530 em28xx_errdev("Your board has no unique USB ID and thus need a "
502 "hint to be detected.\n"); 531 "hint to be detected.\n");
503 em28xx_errdev("You may try to use card=<n> insmod option to " 532 em28xx_errdev("You may try to use card=<n> insmod option to "
@@ -505,6 +534,7 @@ static int em28xx_hint_board(struct em28xx *dev)
505 em28xx_errdev("Please send an email with this log to:\n"); 534 em28xx_errdev("Please send an email with this log to:\n");
506 em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n"); 535 em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
507 em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash); 536 em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
537 em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
508 538
509 em28xx_errdev("Here is a list of valid choices for the card=<n>" 539 em28xx_errdev("Here is a list of valid choices for the card=<n>"
510 " insmod option:\n"); 540 " insmod option:\n");
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index e2003455f2b2..acd853d217ea 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -533,19 +533,26 @@ static char *i2c_devs[128] = {
533 * do_i2c_scan() 533 * do_i2c_scan()
534 * check i2c address range for devices 534 * check i2c address range for devices
535 */ 535 */
536static void do_i2c_scan(char *name, struct i2c_client *c) 536void em28xx_do_i2c_scan(struct em28xx *dev)
537{ 537{
538 u8 i2c_devicelist[128];
538 unsigned char buf; 539 unsigned char buf;
539 int i, rc; 540 int i, rc;
540 541
542 memset(i2c_devicelist, 0, ARRAY_SIZE(i2c_devicelist));
543
541 for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) { 544 for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) {
542 c->addr = i; 545 dev->i2c_client.addr = i;
543 rc = i2c_master_recv(c, &buf, 0); 546 rc = i2c_master_recv(&dev->i2c_client, &buf, 0);
544 if (rc < 0) 547 if (rc < 0)
545 continue; 548 continue;
546 printk(KERN_INFO "%s: found i2c device @ 0x%x [%s]\n", name, 549 i2c_devicelist[i] = i;
547 i << 1, i2c_devs[i] ? i2c_devs[i] : "???"); 550 printk(KERN_INFO "%s: found i2c device @ 0x%x [%s]\n",
551 dev->name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
548 } 552 }
553
554 dev->i2c_hash = em28xx_hash_mem(i2c_devicelist,
555 ARRAY_SIZE(i2c_devicelist), 32);
549} 556}
550 557
551/* 558/*
@@ -578,7 +585,7 @@ int em28xx_i2c_register(struct em28xx *dev)
578 em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata)); 585 em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata));
579 586
580 if (i2c_scan) 587 if (i2c_scan)
581 do_i2c_scan(dev->name, &dev->i2c_client); 588 em28xx_do_i2c_scan(dev);
582 return 0; 589 return 0;
583} 590}
584 591
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index bc495a11dc2d..b43edc3fa23e 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1510,6 +1510,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1510 dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len; 1510 dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
1511 dev->em28xx_write_regs_req = em28xx_write_regs_req; 1511 dev->em28xx_write_regs_req = em28xx_write_regs_req;
1512 dev->em28xx_read_reg_req = em28xx_read_reg_req; 1512 dev->em28xx_read_reg_req = em28xx_read_reg_req;
1513 dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
1513 1514
1514 /* setup video picture settings for saa7113h */ 1515 /* setup video picture settings for saa7113h */
1515 memset(&dev->vpic, 0, sizeof(dev->vpic)); 1516 memset(&dev->vpic, 0, sizeof(dev->vpic));
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 70fddd45d1f7..c2531da2e618 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -260,6 +260,7 @@ struct em28xx {
260 int type; 260 int type;
261 261
262 unsigned long hash; /* eeprom hash - for boards with generic ID */ 262 unsigned long hash; /* eeprom hash - for boards with generic ID */
263 unsigned long i2c_hash; /* i2c devicelist hash - for boards with generic ID */
263 264
264 /* states */ 265 /* states */
265 enum em28xx_dev_state state; 266 enum em28xx_dev_state state;
@@ -296,6 +297,7 @@ struct em28xx {
296/* Provided by em28xx-i2c.c */ 297/* Provided by em28xx-i2c.c */
297 298
298void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg); 299void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg);
300void em28xx_do_i2c_scan(struct em28xx *dev);
299int em28xx_i2c_register(struct em28xx *dev); 301int em28xx_i2c_register(struct em28xx *dev);
300int em28xx_i2c_unregister(struct em28xx *dev); 302int em28xx_i2c_unregister(struct em28xx *dev);
301 303