From patchwork Tue Aug 24 19:36:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Ringel X-Patchwork-Id: 4152 Return-path: Envelope-to: mchehab@pedra Delivery-date: Tue, 24 Aug 2010 16:37:08 -0300 Received: from mchehab by pedra with local (Exim 4.72) (envelope-from ) id 1OnzIx-00013k-Jm for mchehab@pedra; Tue, 24 Aug 2010 16:37:07 -0300 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Tue, 24 Aug 2010 16:37:07 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OnzIC-0008As-2g; Tue, 24 Aug 2010 19:36:20 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755075Ab0HXTgS (ORCPT + 1 other); Tue, 24 Aug 2010 15:36:18 -0400 Received: from mail-in-11.arcor-online.net ([151.189.21.51]:57075 "EHLO mail-in-11.arcor-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754422Ab0HXTgR (ORCPT ); Tue, 24 Aug 2010 15:36:17 -0400 Received: from mail-in-19-z2.arcor-online.net (mail-in-19-z2.arcor-online.net [151.189.8.36]) by mx.arcor.de (Postfix) with ESMTP id 2511C35A6C8; Tue, 24 Aug 2010 21:36:16 +0200 (CEST) Received: from mail-in-10.arcor-online.net (mail-in-10.arcor-online.net [151.189.21.50]) by mail-in-19-z2.arcor-online.net (Postfix) with ESMTP id 11F50D7964; Tue, 24 Aug 2010 21:36:16 +0200 (CEST) Received: from linux-rwzd.site (dslb-188-103-199-167.pools.arcor-ip.net [188.103.199.167]) (Authenticated sender: stefan.ringel@arcor.de) by mail-in-10.arcor-online.net (Postfix) with ESMTPA id 65E772D6412; Tue, 24 Aug 2010 21:36:15 +0200 (CEST) X-DKIM: Sendmail DKIM Filter v2.8.2 mail-in-10.arcor-online.net 65E772D6412 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arcor.de; s=mail-in; t=1282678576; bh=rrFxeOvyuaukTwwxYzshXRuRHHl1vYq1+yMFuKrYR/c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=aO20mby7Iva8rSRREMxJRd5AIRYs7w9EgrLaI1Pp5VELDocA4SYRp0AsWBPqweynY fDpGPSr9O/D9VsrpPOqkX/qcYB6Ix9pVyVdN6tMknP5CHiuLjB/w75BsMvzhwGegfS bppOJAn1uQEY/bD0sa3+uf8e/JFqRAVQLFol4ALQ= From: stefan.ringel@arcor.de To: linux-media@vger.kernel.org Cc: mchehab@redhat.com, Stefan Ringel Subject: [PATCH 2/2] tm6000: bugfix data handling Date: Tue, 24 Aug 2010 21:36:10 +0200 Message-Id: <1282678570-13462-2-git-send-email-stefan.ringel@arcor.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1282678570-13462-1-git-send-email-stefan.ringel@arcor.de> References: <1282678570-13462-1-git-send-email-stefan.ringel@arcor.de> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sender: Mauro Carvalho Chehab From: Stefan Ringel Signed-off-by: Stefan Ringel --- drivers/staging/tm6000/tm6000-input.c | 59 +++++++++++++++++++++------------ 1 files changed, 38 insertions(+), 21 deletions(-) diff --git a/drivers/staging/tm6000/tm6000-input.c b/drivers/staging/tm6000/tm6000-input.c index 7b07096..4fcd5ff 100644 --- a/drivers/staging/tm6000/tm6000-input.c +++ b/drivers/staging/tm6000/tm6000-input.c @@ -46,7 +46,7 @@ MODULE_PARM_DESC(enable_ir, "enable ir (default is enable)"); } struct tm6000_ir_poll_result { - u8 rc_data[4]; + u16 rc_data; }; struct tm6000_IR { @@ -60,9 +60,9 @@ struct tm6000_IR { int polling; struct delayed_work work; u8 wait:1; + u8 key:1; struct urb *int_urb; u8 *urb_data; - u8 key:1; int (*get_key) (struct tm6000_IR *, struct tm6000_ir_poll_result *); @@ -122,13 +122,14 @@ static void tm6000_ir_urb_received(struct urb *urb) if (urb->status != 0) printk(KERN_INFO "not ready\n"); - else if (urb->actual_length > 0) + else if (urb->actual_length > 0) { memcpy(ir->urb_data, urb->transfer_buffer, urb->actual_length); - dprintk("data %02x %02x %02x %02x\n", ir->urb_data[0], - ir->urb_data[1], ir->urb_data[2], ir->urb_data[3]); + dprintk("data %02x %02x %02x %02x\n", ir->urb_data[0], + ir->urb_data[1], ir->urb_data[2], ir->urb_data[3]); - ir->key = 1; + ir->key = 1; + } rc = usb_submit_urb(urb, GFP_ATOMIC); } @@ -140,30 +141,47 @@ static int default_polling_getkey(struct tm6000_IR *ir, int rc; u8 buf[2]; - if (ir->wait && !&dev->int_in) { - poll_result->rc_data[0] = 0xff; + if (ir->wait && !&dev->int_in) return 0; - } if (&dev->int_in) { - poll_result->rc_data[0] = ir->urb_data[0]; - poll_result->rc_data[1] = ir->urb_data[1]; + if (ir->ir.ir_type == IR_TYPE_RC5) + poll_result->rc_data = ir->urb_data[0]; + else + poll_result->rc_data = ir->urb_data[0] | ir->urb_data[1] << 8; } else { tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT, 2, 0); msleep(10); tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT, 2, 1); msleep(10); - rc = tm6000_read_write_usb(dev, USB_DIR_IN | USB_TYPE_VENDOR | - USB_RECIP_DEVICE, REQ_02_GET_IR_CODE, 0, 0, buf, 1); + if (ir->ir.ir_type == IR_TYPE_RC5) { + rc = tm6000_read_write_usb(dev, USB_DIR_IN | + USB_TYPE_VENDOR | USB_RECIP_DEVICE, + REQ_02_GET_IR_CODE, 0, 0, buf, 1); - msleep(10); + msleep(10); - dprintk("read data=%02x\n", buf[0]); - if (rc < 0) - return rc; + dprintk("read data=%02x\n", buf[0]); + if (rc < 0) + return rc; - poll_result->rc_data[0] = buf[0]; + poll_result->rc_data = buf[0]; + } else { + rc = tm6000_read_write_usb(dev, USB_DIR_IN | + USB_TYPE_VENDOR | USB_RECIP_DEVICE, + REQ_02_GET_IR_CODE, 0, 0, buf, 2); + + msleep(10); + + dprintk("read data=%04x\n", buf[0] | buf[1] << 8); + if (rc < 0) + return rc; + + poll_result->rc_data = buf[0] | buf[1] << 8; + } + if ((poll_result->rc_data & 0x00ff) != 0xff) + ir->key = 1; } return 0; } @@ -180,12 +198,11 @@ static void tm6000_ir_handle_key(struct tm6000_IR *ir) return; } - dprintk("ir->get_key result data=%02x %02x\n", - poll_result.rc_data[0], poll_result.rc_data[1]); + dprintk("ir->get_key result data=%02x %04x\n", poll_result.rc_data); if (poll_result.rc_data[0] != 0xff && ir->key == 1) { ir_input_keydown(ir->input->input_dev, &ir->ir, - poll_result.rc_data[0] | poll_result.rc_data[1] << 8); + (u32)poll_result.rc_data); ir_input_nokey(ir->input->input_dev, &ir->ir); ir->key = 0;