KWorld Global TV Terminator remote control part2.patch

From MythTV

Jump to: navigation, search
--- linux/drivers/media/video/ir-kbd-i2c.c.orig	2006-11-03 17:33:58.000000000 -0800
+++ linux/drivers/media/video/ir-kbd-i2c.c	2007-02-11 02:06:08.000000000 -0800
@@ -59,6 +59,8 @@
 #define dprintk(level, fmt, arg...)	if (debug >= level) \
 	printk(KERN_DEBUG DEVNAME ": " fmt , ## arg)
 
+static int polling_interval = 100; /* ms */
+
 /* ----------------------------------------------------------------------- */
 
 static int get_key_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
@@ -263,7 +265,7 @@
 {
 	struct IR_i2c *ir = data;
 	ir_key_poll(ir);
-	mod_timer(&ir->timer, jiffies+HZ/10);
+	mod_timer(&ir->timer, jiffies + polling_interval*HZ/1000);
 }
 
 /* ----------------------------------------------------------------------- */
@@ -339,6 +341,9 @@
 		}
 		break;
 	case 0x30:
+		if (adap->id == I2C_HW_SAA7134) /* Handled by saa7134-input */
+			polling_interval = 50; /* ms */
+
 		name        = "KNC One";
 		ir->get_key = get_key_knc1;
 		ir_type     = IR_TYPE_OTHER;
@@ -430,7 +435,7 @@
 	*/
 
 	static const int probe_bttv[] = { 0x1a, 0x18, 0x4b, 0x64, 0x30, -1};
-	static const int probe_saa7134[] = { 0x7a, 0x47, -1 };
+	static const int probe_saa7134[] = { 0x7a, 0x47, 0x30, -1 };
 	static const int probe_em28XX[] = { 0x30, 0x47, -1 };
 	const int *probe = NULL;
 	struct i2c_client c;
@@ -458,7 +463,36 @@
 	c.adapter = adap;
 	for (i = 0; -1 != probe[i]; i++) {
 		c.addr = probe[i];
-		rc = i2c_master_recv(&c,&buf,0);
+		
+		/* Special case for MSI TV@nywhere Plus remote */
+		if (c.adapter->id == I2C_HW_SAA7134 && probe[i] == 0x30)
+		{
+			struct i2c_client c2;
+
+			memset (&c2, 0, sizeof(c2));
+			c2.adapter = c.adapter;
+
+			/* MSI TV@nywhere Plus' controller doesn't seem to
+			respond to probes unless we read something from an
+			existing device. Weird... */
+						
+			/* Find a device that responds. If none found, oh well. */
+			for (c2.addr=127; c2.addr >= 0; c2.addr--)
+			{
+				if (0 == i2c_master_recv(&c2,&buf,0))
+					break;
+			}
+
+			/* Now do the probe. The controller does not respond
+			   to 0-byte reads, so we use a 1-byte read instead. */
+			rc = i2c_master_recv(&c,&buf,1);
+			rc--;
+		}
+		else
+		{
+			rc = i2c_master_recv(&c,&buf,0);
+		}
+		
 		dprintk(1,"probe 0x%02x @ %s: %s\n",
 			probe[i], adap->name,
 			(0 == rc) ? "yes" : "no");
Personal tools