diff mbox

[RFC,1/2] ir-nec-decoder: decode Apple's NEC remote variant

Message ID 20101029031319.GF17238@redhat.com (mailing list archive)
State RFC
Headers show

Commit Message

Jarod Wilson Oct. 29, 2010, 3:13 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/media/IR/ir-nec-decoder.c b/drivers/media/IR/ir-nec-decoder.c
index 70993f7..6dcddd2 100644
--- a/drivers/media/IR/ir-nec-decoder.c
+++ b/drivers/media/IR/ir-nec-decoder.c
@@ -50,6 +50,7 @@  static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 	struct nec_dec *data = &ir_dev->raw->nec;
 	u32 scancode;
 	u8 address, not_address, command, not_command;
+	bool apple = false;
 
 	if (!(ir_dev->raw->enabled_protocols & IR_TYPE_NEC))
 		return 0;
@@ -158,7 +159,14 @@  static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev)
 		command	    = bitrev8((data->bits >>  8) & 0xff);
 		not_command = bitrev8((data->bits >>  0) & 0xff);
 
-		if ((command ^ not_command) != 0xff) {
+		/* Apple remotes use an NEC-like proto, but w/o a checksum */
+		if ((address == 0xee) && (not_address == 0x87)) {
+			apple = true;
+			IR_dprintk(1, "Apple remote, ID byte 0x%02x\n",
+				   not_command);
+		}
+
+		if (((command ^ not_command) != 0xff) && !apple) {
 			IR_dprintk(1, "NEC checksum error: received 0x%08x\n",
 				   data->bits);
 			break;