Skip to content

Commit 52b9815

Browse files
maciejsszmigierogregkh
authored andcommitted
saa7134: fix warm Medion 7134 EEPROM read
commit 5a91206ff0d0548939f3e85a65fb76b400fb0e89 upstream. When saa7134 module driving a Medion 7134 card is reloaded reads of this card EEPROM (required for automatic detection of tuner model) will be corrupted due to I2C gate in DVB-T demod being left closed. This sometimes also happens on first saa7134 module load after a warm reboot. Fix this by opening this I2C gate before doing EEPROM read during i2c initialization. Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Cc: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 646b658 commit 52b9815

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

drivers/media/pci/saa7134/saa7134-i2c.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,43 @@ static struct i2c_client saa7134_client_template = {
355355

356356
/* ----------------------------------------------------------- */
357357

358+
/* On Medion 7134 reading EEPROM needs DVB-T demod i2c gate open */
359+
static void saa7134_i2c_eeprom_md7134_gate(struct saa7134_dev *dev)
360+
{
361+
u8 subaddr = 0x7, dmdregval;
362+
u8 data[2];
363+
int ret;
364+
struct i2c_msg i2cgatemsg_r[] = { {.addr = 0x08, .flags = 0,
365+
.buf = &subaddr, .len = 1},
366+
{.addr = 0x08,
367+
.flags = I2C_M_RD,
368+
.buf = &dmdregval, .len = 1}
369+
};
370+
struct i2c_msg i2cgatemsg_w[] = { {.addr = 0x08, .flags = 0,
371+
.buf = data, .len = 2} };
372+
373+
ret = i2c_transfer(&dev->i2c_adap, i2cgatemsg_r, 2);
374+
if ((ret == 2) && (dmdregval & 0x2)) {
375+
pr_debug("%s: DVB-T demod i2c gate was left closed\n",
376+
dev->name);
377+
378+
data[0] = subaddr;
379+
data[1] = (dmdregval & ~0x2);
380+
if (i2c_transfer(&dev->i2c_adap, i2cgatemsg_w, 1) != 1)
381+
pr_err("%s: EEPROM i2c gate open failure\n",
382+
dev->name);
383+
}
384+
}
385+
358386
static int
359387
saa7134_i2c_eeprom(struct saa7134_dev *dev, unsigned char *eedata, int len)
360388
{
361389
unsigned char buf;
362390
int i,err;
363391

392+
if (dev->board == SAA7134_BOARD_MD7134)
393+
saa7134_i2c_eeprom_md7134_gate(dev);
394+
364395
dev->i2c_client.addr = 0xa0 >> 1;
365396
buf = 0;
366397
if (1 != (err = i2c_master_send(&dev->i2c_client,&buf,1))) {

0 commit comments

Comments
 (0)