Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fad7b958e753e18ff443786360f7846da50a3085
Commit:     fad7b958e753e18ff443786360f7846da50a3085
Parent:     f1f32849d65ab1eacfedbabb624876ac06c1af9f
Author:     Sascha Sommer <[EMAIL PROTECTED]>
AuthorDate: Sun Nov 4 08:06:48 2007 -0300
Committer:  Mauro Carvalho Chehab <[EMAIL PROTECTED]>
CommitDate: Fri Jan 25 19:01:56 2008 -0200

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>
---
 drivers/media/video/em28xx/em28xx-cards.c |   30 +++++++++++++++++++++++++++++
 drivers/media/video/em28xx/em28xx-i2c.c   |   19 ++++++++++++-----
 drivers/media/video/em28xx/em28xx-video.c |    1 +
 drivers/media/video/em28xx/em28xx.h       |    2 +
 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 ae66341..fd7a8a5 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 [] = {
        { 0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF },
 };
 
+static struct em28xx_hash_table em28xx_i2c_hash[] = {
+       { 0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC 
},
+       { 0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC },
+};
+
 /* Since em28xx_pre_card_setup() requires a proper dev->model,
  * this won't work for boards with generic PCI IDs
  */
@@ -498,6 +503,30 @@ static int em28xx_hint_board(struct em28xx *dev)
                        return 0;
                }
        }
+
+       /* user did not request i2c scanning => do it now */
+       if (!dev->i2c_hash)
+               em28xx_do_i2c_scan(dev);
+
+       for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
+               if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
+                       dev->model = em28xx_i2c_hash[i].model;
+                       dev->tuner_type = em28xx_i2c_hash[i].tuner;
+                       em28xx_errdev("Your board has no unique USB ID.\n");
+                       em28xx_errdev("A hint were successfully done, "
+                                     "based on i2c devicelist hash.\n");
+                       em28xx_errdev("This method is not 100%% failproof.\n");
+                       em28xx_errdev("If the board were missdetected, "
+                                     "please email this log to:\n");
+                       em28xx_errdev("\tV4L Mailing List "
+                                     " <[EMAIL PROTECTED]>\n");
+                       em28xx_errdev("Board detected as %s\n",
+                                     em28xx_boards[dev->model].name);
+
+                       return 0;
+               }
+       }
+
        em28xx_errdev("Your board has no unique USB ID and thus need a "
                      "hint to be detected.\n");
        em28xx_errdev("You may try to use card=<n> insmod option to "
@@ -505,6 +534,7 @@ static int em28xx_hint_board(struct em28xx *dev)
        em28xx_errdev("Please send an email with this log to:\n");
        em28xx_errdev("\tV4L Mailing List <[EMAIL PROTECTED]>\n");
        em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
+       em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
 
        em28xx_errdev("Here is a list of valid choices for the card=<n>"
                      " insmod option:\n");
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c 
b/drivers/media/video/em28xx/em28xx-i2c.c
index e200345..acd853d 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] = {
  * do_i2c_scan()
  * check i2c address range for devices
  */
-static void do_i2c_scan(char *name, struct i2c_client *c)
+void em28xx_do_i2c_scan(struct em28xx *dev)
 {
+       u8 i2c_devicelist[128];
        unsigned char buf;
        int i, rc;
 
+       memset(i2c_devicelist, 0, ARRAY_SIZE(i2c_devicelist));
+
        for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) {
-               c->addr = i;
-               rc = i2c_master_recv(c, &buf, 0);
+               dev->i2c_client.addr = i;
+               rc = i2c_master_recv(&dev->i2c_client, &buf, 0);
                if (rc < 0)
                        continue;
-               printk(KERN_INFO "%s: found i2c device @ 0x%x [%s]\n", name,
-                      i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
+               i2c_devicelist[i] = i;
+               printk(KERN_INFO "%s: found i2c device @ 0x%x [%s]\n",
+                      dev->name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
        }
+
+       dev->i2c_hash = em28xx_hash_mem(i2c_devicelist,
+                                       ARRAY_SIZE(i2c_devicelist), 32);
 }
 
 /*
@@ -578,7 +585,7 @@ int em28xx_i2c_register(struct em28xx *dev)
        em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata));
 
        if (i2c_scan)
-               do_i2c_scan(dev->name, &dev->i2c_client);
+               em28xx_do_i2c_scan(dev);
        return 0;
 }
 
diff --git a/drivers/media/video/em28xx/em28xx-video.c 
b/drivers/media/video/em28xx/em28xx-video.c
index bc495a1..b43edc3 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,
        dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
        dev->em28xx_write_regs_req = em28xx_write_regs_req;
        dev->em28xx_read_reg_req = em28xx_read_reg_req;
+       dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
 
        /* setup video picture settings for saa7113h */
        memset(&dev->vpic, 0, sizeof(dev->vpic));
diff --git a/drivers/media/video/em28xx/em28xx.h 
b/drivers/media/video/em28xx/em28xx.h
index 70fddd4..c2531da 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -260,6 +260,7 @@ struct em28xx {
        int type;
 
        unsigned long hash;     /* eeprom hash - for boards with generic ID */
+       unsigned long i2c_hash; /* i2c devicelist hash - for boards with 
generic ID */
 
        /* states */
        enum em28xx_dev_state state;
@@ -296,6 +297,7 @@ struct em28xx {
 /* Provided by em28xx-i2c.c */
 
 void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg);
+void em28xx_do_i2c_scan(struct em28xx *dev);
 int em28xx_i2c_register(struct em28xx *dev);
 int em28xx_i2c_unregister(struct em28xx *dev);
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to