From patchwork Fri May 28 19:59:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 3538 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Fri, 28 May 2010 19:59:50 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Fri, 28 May 2010 17:00:43 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1OI5if-0000lU-TL; Fri, 28 May 2010 19:59:50 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757382Ab0E1T7r (ORCPT + 1 other); Fri, 28 May 2010 15:59:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25918 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756802Ab0E1T7q (ORCPT ); Fri, 28 May 2010 15:59:46 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4SJxkae028656 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 28 May 2010 15:59:46 -0400 Received: from ihatethathostname.lab.bos.redhat.com (ihatethathostname.lab.bos.redhat.com [10.16.43.238]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4SJxjrH027473 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 28 May 2010 15:59:46 -0400 Received: from ihatethathostname.lab.bos.redhat.com (ihatethathostname.lab.bos.redhat.com [127.0.0.1]) by ihatethathostname.lab.bos.redhat.com (8.14.4/8.14.3) with ESMTP id o4SJxjDY007310 for ; Fri, 28 May 2010 15:59:45 -0400 Received: (from jarod@localhost) by ihatethathostname.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o4SJxjgb007308 for linux-media@vger.kernel.org; Fri, 28 May 2010 15:59:45 -0400 X-Authentication-Warning: ihatethathostname.lab.bos.redhat.com: jarod set sender to jarod@redhat.com using -f Date: Fri, 28 May 2010 15:59:45 -0400 From: Jarod Wilson To: linux-media@vger.kernel.org Subject: [PATCH] IR: let all protocol decoders have a go at raw data Message-ID: <20100528195945.GA7305@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The mceusb driver I'm about to submit handles just about any raw IR you can throw at it. The ir-core loads up all protocol decoders, starting with NEC, then RC5, then RC6. RUN_DECODER() was trying them in the same order, and exiting if any of the decoders didn't like the data. The default mceusb remote talks RC6(6A). Well, the RC6 decoder never gets a chance to run unless you move the RC6 decoder to the front of the list. What I believe to be correct is to have RUN_DECODER keep trying all of the decoders, even when one triggers an error. I don't think the errors matter so much as it matters that at least one was successful -- i.e., that _sumrc is > 0. The following works for me w/my mceusb driver and the default decoder ordering -- NEC and RC5 still fail, but RC6 still gets a crack at it, and successfully does its job. Signed-off-by: Jarod Wilson --- drivers/media/IR/ir-raw-event.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c index ea68a3f..44162db 100644 --- a/drivers/media/IR/ir-raw-event.c +++ b/drivers/media/IR/ir-raw-event.c @@ -36,14 +36,15 @@ static DEFINE_SPINLOCK(ir_raw_handler_lock); */ #define RUN_DECODER(ops, ...) ({ \ struct ir_raw_handler *_ir_raw_handler; \ - int _sumrc = 0, _rc; \ + int _sumrc = 0, _rc, _fail; \ spin_lock(&ir_raw_handler_lock); \ list_for_each_entry(_ir_raw_handler, &ir_raw_handler_list, list) { \ if (_ir_raw_handler->ops) { \ _rc = _ir_raw_handler->ops(__VA_ARGS__); \ if (_rc < 0) \ - break; \ - _sumrc += _rc; \ + _fail++; \ + else \ + _sumrc += _rc; \ } \ } \ spin_unlock(&ir_raw_handler_lock); \