From patchwork Fri Oct 29 03:13:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 4751 Return-path: Envelope-to: mchehab@pedra Delivery-date: Fri, 29 Oct 2010 09:11:42 -0200 Received: from mchehab by pedra with local (Exim 4.72) (envelope-from ) id 1PBms1-0001Gw-JC for mchehab@pedra; Fri, 29 Oct 2010 09:11:42 -0200 Received: from casper.infradead.org [85.118.1.10] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Fri, 29 Oct 2010 09:11:41 -0200 (BRST) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1PBfP8-0006tx-Tf; Fri, 29 Oct 2010 03:13:23 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760425Ab0J2DNU (ORCPT + 1 other); Thu, 28 Oct 2010 23:13:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5646 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760300Ab0J2DNU (ORCPT ); Thu, 28 Oct 2010 23:13:20 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9T3DJN4029072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Oct 2010 23:13:19 -0400 Received: from xavier.bos.redhat.com (xavier.bos.redhat.com [10.16.16.50]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9T3DJ6A024398 for ; Thu, 28 Oct 2010 23:13:19 -0400 Received: by xavier.bos.redhat.com (Postfix, from userid 500) id 4AE34815D6; Thu, 28 Oct 2010 23:13:19 -0400 (EDT) Date: Thu, 28 Oct 2010 23:13:19 -0400 From: Jarod Wilson To: linux-media@vger.kernel.org Subject: [RFC PATCH 1/2] ir-nec-decoder: decode Apple's NEC remote variant Message-ID: <20101029031319.GF17238@redhat.com> References: <20101029031131.GE17238@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20101029031131.GE17238@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sender: Apple's remotes use an NEC-like protocol, but without checksumming. See http://en.wikipedia.org/wiki/Apple_Remote for details. Since they always send a specific vendor code, check for that, and bypass the checksum check. Signed-off-by: Jarod Wilson --- drivers/media/IR/ir-nec-decoder.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) 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;