Re: [V4L][SAA7134] fix tda9887 detection on cold and eeprom read corruption on warm Medion 7134

Previous thread: [RFC] TRACE_EVENT: mapping "=" and memcpy to macros by Mathieu Desnoyers on Monday, October 25, 2010 - 10:39 am. (1 message)

Next thread: [PATCH] n_hdlc fix read and write locking by Paul Fulghum on Monday, October 25, 2010 - 11:22 am. (7 messages)
From: Maciej Szmigiero
Date: Monday, October 25, 2010 - 10:59 am

[V4L][SAA7134] fix tda9887 detection on cold and eeprom read corruption on warm Medion 7134

When Medion 7134 analog+DVB-T card is cold (after powerup) the tda9887 analog demodulator
won't show on i2c bus.
This results in no signal on analog TV. After loading driver for second time
eeprom (required for tuner autodetection) read is corrupted, but tda9987 is detected
properly and analog TV works when tuner model is forced.

Fix tda9887 problem by moving its detect code after tuner setup which unhides it.
The eeprom read issue is fixed by opening i2c gate in DVB-T demodulator.

Tested on Medion 7134 and also tested for reference on Typhoon Cardbus Hybrid
(which also uses saa7134 driver).

Signed-off-by: Maciej Szmigiero <mhej@o2.pl>

--- a/drivers/media/video/saa7134/saa7134-cards.c	2010-08-02 00:11:14.000000000 +0200
+++ b/drivers/media/video/saa7134/saa7134-cards.c	2010-10-25 19:19:08.000000000 +0200
@@ -7249,12 +7249,37 @@
 		break;
 	case SAA7134_BOARD_MD7134:
 	{
-		u8 subaddr;
+		u8 subaddr, dmdregval;
 		u8 data[3];
 		int ret, tuner_t;
+		struct i2c_msg i2cgatemsg_r[] = { {.addr = 0x08, .flags = 0,
+						.buf = &subaddr, .len = 1},
+						{.addr = 0x08,
+							.flags = I2C_M_RD,
+						.buf = &dmdregval, .len = 1} };
+		struct i2c_msg i2cgatemsg_w[] = { {.addr = 0x08, .flags = 0,
+						.buf = data, .len = 2} };
 		struct i2c_msg msg[] = {{.addr=0x50, .flags=0, .buf=&subaddr, .len = 1},
 					{.addr=0x50, .flags=I2C_M_RD, .buf=data, .len = 3}};
 
+		/* open i2c gate in DVB-T demod */
+		/* so eeprom read won't be corrupted */
+		subaddr = 0x7;
+		ret = i2c_transfer(&dev->i2c_adap, i2cgatemsg_r, 2);
+		if ((ret == 2) && (dmdregval & 0x2)) {
+			printk(KERN_NOTICE "%s DVB-T demod i2c gate was left"
+						    " closed\n", dev->name);
+			printk(KERN_NOTICE "%s previous informational"
+					    " EEPROM read might have been"
+					    " corrupted\n", dev->name);
+
+			data[0] = 0x7;
+			data[1] = (dmdregval & ~0x2);
+			if (i2c_transfer(&dev->i2c_adap, ...
From: Mauro Carvalho Chehab
Date: Tuesday, November 9, 2010 - 3:53 am

hmm... I don't think we need those debug messages on normal cases. Also, we want the log
shown as:
	saa7134: <foo>
and not as:


The order change for the demod probe will likely break support for other boards.
If the problem is specific to Medion 7134, what you should do, instead, is to
change the order just for MD7134 (so, inside the switch(dev->board)).

Cheers,
Mauro.
--

From: Maciej Szmigiero
Date: Tuesday, November 9, 2010 - 8:02 am

I added this message because when the gate was left closed the eeprom content (printed out unconditionally in saa7134_i2c_eeprom) looks garbled in dmesg,
so it's better to inform user that he (or she) shouldn't be worried about this.

It was done in that order (tuner first then tda9887) for a long time before it was changed.
For example ( http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=drivers/medi... ) it used to look like that:
 942         /* load i2c helpers */
 943         if (TUNER_ABSENT != dev->tuner_type)
 944                 request_module("tuner");
 945         if (dev->tda9887_conf)
 946                 request_module("tda9887");
 947         if (card_is_empress(dev)) {
 948                 request_module("saa6752hs");
 949                 request_module_depend("saa7134-empress",&need_empress);
 950         }


Best regards,
Maciej Szmigiero
--

Previous thread: [RFC] TRACE_EVENT: mapping "=" and memcpy to macros by Mathieu Desnoyers on Monday, October 25, 2010 - 10:39 am. (1 message)

Next thread: [PATCH] n_hdlc fix read and write locking by Paul Fulghum on Monday, October 25, 2010 - 11:22 am. (7 messages)