public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Allow RC5 codes 64 - 127 in ir-kbd-i2c.c
@ 2006-09-21 20:37 David Härdeman
  2006-09-21 21:17 ` David Härdeman
  0 siblings, 1 reply; 2+ messages in thread
From: David Härdeman @ 2006-09-21 20:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: kraxel

The RC5 coding has for a long time supported commands 64-127 in addition 
to 0-63. This is controlled by the second bit of the RC5 packet (see  
http://www.armory.com/~spcecdt/remote/RC5codes.html for details).

The attached patch modifies ir-kbd-i2c.c to allow for commands 64-127, 
tested with a PVR350 card in combination with a programmable remote.

Signed-off-by: David Härdeman <david@hardeman.nu>

-- 

diff -ur linux-2.6.18-orig/drivers/media/video/ir-kbd-i2c.c linux-2.6.18/drivers/media/video/ir-kbd-i2c.c
--- linux-2.6.18-orig/drivers/media/video/ir-kbd-i2c.c	2006-09-21 22:05:16.000000000 +0200
+++ linux-2.6.18/drivers/media/video/ir-kbd-i2c.c	2006-09-21 22:25:40.000000000 +0200
@@ -64,23 +64,32 @@
 static int get_key_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
 {
 	unsigned char buf[3];
-	int start, toggle, dev, code;
+	int start, range, toggle, dev, code;
 
 	/* poll IR chip */
 	if (3 != i2c_master_recv(&ir->c,buf,3))
 		return -EIO;
 
 	/* split rc5 data block ... */
-	start  = (buf[0] >> 6) &    3;
+	start  = (buf[0] >> 7) &    1;
+	range  = (buf[0] >> 6) &    1;
 	toggle = (buf[0] >> 5) &    1;
 	dev    =  buf[0]       & 0x1f;
 	code   = (buf[1] >> 2) & 0x3f;
 
-	if (3 != start)
+	/* rc5 has two start bits
+	 * the first bit must be one
+	 * the second bit defines the command range (1 = 0-63, 0 = 64 - 127)
+	 */
+	if (!start)
 		/* no key pressed */
 		return 0;
-	dprintk(1,"ir hauppauge (rc5): s%d t%d dev=%d code=%d\n",
-		start, toggle, dev, code);
+
+	if (!range)
+		code += 64;
+
+	dprintk(1,"ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n",
+		start, range, toggle, dev, code);
 
 	/* return key */
 	*ir_key = code;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] Allow RC5 codes 64 - 127 in ir-kbd-i2c.c
  2006-09-21 20:37 [PATCH] Allow RC5 codes 64 - 127 in ir-kbd-i2c.c David Härdeman
@ 2006-09-21 21:17 ` David Härdeman
  0 siblings, 0 replies; 2+ messages in thread
From: David Härdeman @ 2006-09-21 21:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: kraxel

[-- Attachment #1: Type: text/plain, Size: 478 bytes --]

The RC5 coding has for a long time supported commands 64-127 in addition 
to 0-63. This is controlled by the second bit of the RC5 packet (see  
http://www.armory.com/~spcecdt/remote/RC5codes.html for details).

The attached patch modifies ir-kbd-i2c.c to allow for commands 64-127, 
tested with a PVR350 card in combination with a programmable remote.

This time, attached inline so that it won't be line-wrapped :)

Signed-off-by: David Härdeman <david@hardeman.nu>

[-- Attachment #2: ir-kbd-i2c-use-all-rc5-codes --]
[-- Type: text/plain, Size: 1255 bytes --]

diff -ur linux-2.6.18-orig/drivers/media/video/ir-kbd-i2c.c linux-2.6.18/drivers/media/video/ir-kbd-i2c.c
--- linux-2.6.18-orig/drivers/media/video/ir-kbd-i2c.c	2006-09-21 22:05:16.000000000 +0200
+++ linux-2.6.18/drivers/media/video/ir-kbd-i2c.c	2006-09-21 22:25:40.000000000 +0200
@@ -64,23 +64,32 @@
 static int get_key_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
 {
 	unsigned char buf[3];
-	int start, toggle, dev, code;
+	int start, range, toggle, dev, code;
 
 	/* poll IR chip */
 	if (3 != i2c_master_recv(&ir->c,buf,3))
 		return -EIO;
 
 	/* split rc5 data block ... */
-	start  = (buf[0] >> 6) &    3;
+	start  = (buf[0] >> 7) &    1;
+	range  = (buf[0] >> 6) &    1;
 	toggle = (buf[0] >> 5) &    1;
 	dev    =  buf[0]       & 0x1f;
 	code   = (buf[1] >> 2) & 0x3f;
 
-	if (3 != start)
+	/* rc5 has two start bits
+	 * the first bit must be one
+	 * the second bit defines the command range (1 = 0-63, 0 = 64 - 127)
+	 */
+	if (!start)
 		/* no key pressed */
 		return 0;
-	dprintk(1,"ir hauppauge (rc5): s%d t%d dev=%d code=%d\n",
-		start, toggle, dev, code);
+
+	if (!range)
+		code += 64;
+
+	dprintk(1,"ir hauppauge (rc5): s%d r%d t%d dev=%d code=%d\n",
+		start, range, toggle, dev, code);
 
 	/* return key */
 	*ir_key = code;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-09-21 21:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-21 20:37 [PATCH] Allow RC5 codes 64 - 127 in ir-kbd-i2c.c David Härdeman
2006-09-21 21:17 ` David Härdeman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox