diff options
author | Mike Isely <isely@pobox.com> | 2006-02-22 23:42:24 -0600 |
---|---|---|
committer | Mike Isely <isely@pobox.com> | 2006-02-22 23:42:24 -0600 |
commit | e3ac0002e5f30d492444f7d6e221c634c07b8d83 (patch) | |
tree | 38e39037b786f64e1b8499d984052115f1ade1aa /v4l_experimental | |
parent | f48560d691ad084882dcee76c279efaef43a445c (diff) | |
download | mediapointer-dvb-s2-e3ac0002e5f30d492444f7d6e221c634c07b8d83.tar.gz mediapointer-dvb-s2-e3ac0002e5f30d492444f7d6e221c634c07b8d83.tar.bz2 |
Handle eeproms in pvrusb2 with 16 bit addresses
From: Mike Isely <isely@pobox.com>
Newer PVR USB2 hardware uses a larger eeprom. These changes allow the
driver to detect and handle the different eeprom.
Signed-off-by: Mike Isely <isely@pobox.com>
Diffstat (limited to 'v4l_experimental')
-rw-r--r-- | v4l_experimental/pvrusb2/pvrusb2-eeprom.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/v4l_experimental/pvrusb2/pvrusb2-eeprom.c b/v4l_experimental/pvrusb2/pvrusb2-eeprom.c index 1d26f8cb9..60ee45ca2 100644 --- a/v4l_experimental/pvrusb2/pvrusb2-eeprom.c +++ b/v4l_experimental/pvrusb2/pvrusb2-eeprom.c @@ -86,21 +86,22 @@ */ -#define PVR_EEPROM_I2C_ADDR 0x50 - #include <media/tveeprom.h> -/* We seem to only be interested in the back half of the EEPROM */ +/* We seem to only be interested in the last 128 bytes of the EEPROM */ #define EEPROM_SIZE 128 -#define EEPROM_OFFS 128 /* Grab EEPROM contents, needed for direct method. */ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw) { struct i2c_msg msg[2]; u8 *eeprom; - u8 offs; + u8 iadd[2]; + u8 addr; + u16 eepromSize; + unsigned int offs; int ret; + int mode16 = 0; unsigned pcnt,tcnt; eeprom = kmalloc(EEPROM_SIZE,GFP_KERNEL); if (!eeprom) { @@ -110,11 +111,28 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw) return 0; } - msg[0].addr = PVR_EEPROM_I2C_ADDR; + trace_eeprom("Value for eeprom addr from controller was 0x%x", + hdw->eeprom_addr); + addr = hdw->eeprom_addr; + /* Seems that if the high bit is set, then the *real* eeprom + address is shifted right now bit position (noticed this in + newer PVR USB2 hardware) */ + if (addr & 0x80) addr >>= 1; + + /* FX2 documentation states that a 16bit-addressed eeprom is + expected if the I2C address is an odd number (yeah, this is + strange bit it's what they do) */ + mode16 = (addr & 1); + eepromSize = (mode16 ? 4096 : 256); + trace_eeprom("Examining %d byte eeprom at location 0x%x" + " using %d bit addressing",eepromSize,addr, + mode16 ? 16 : 8); + + msg[0].addr = addr; msg[0].flags = 0; - msg[0].len = 1; - msg[0].buf = &offs; - msg[1].addr = PVR_EEPROM_I2C_ADDR; + msg[0].len = mode16 ? 2 : 1; + msg[0].buf = iadd; + msg[1].addr = hdw->eeprom_addr; msg[1].flags = I2C_M_RD; /* We have to do the actual eeprom data fetch ourselves, because @@ -125,7 +143,13 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw) for (tcnt = 0; tcnt < EEPROM_SIZE; tcnt += pcnt) { pcnt = 16; if (pcnt + tcnt > EEPROM_SIZE) pcnt = EEPROM_SIZE-tcnt; - offs = tcnt + EEPROM_OFFS; + offs = tcnt + (eepromSize - EEPROM_SIZE); + if (mode16) { + iadd[0] = offs >> 8; + iadd[1] = offs; + } else { + iadd[0] = offs; + } msg[1].len = pcnt; msg[1].buf = eeprom+tcnt; if ((ret = i2c_transfer( @@ -163,7 +187,7 @@ int pvr2_eeprom_analyze(struct pvr2_hdw *hdw) { struct i2c_client fake_client; /* Newer version expects a useless client interface */ - fake_client.addr = PVR_EEPROM_I2C_ADDR; + fake_client.addr = hdw->eeprom_addr; fake_client.adapter = &hdw->i2c_adap; tveeprom_hauppauge_analog(&fake_client,&tvdata,eeprom); } |