From patchwork Fri Jul 30 11:38:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 115458 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6UBdA34029641 for ; Fri, 30 Jul 2010 11:39:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758408Ab0G3LjG (ORCPT ); Fri, 30 Jul 2010 07:39:06 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:41194 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758219Ab0G3LjE (ORCPT ); Fri, 30 Jul 2010 07:39:04 -0400 Received: by fxm14 with SMTP id 14so798201fxm.19 for ; Fri, 30 Jul 2010 04:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=djxJyHgjmotzwWMVesmIgjHiz/J9rzzLZ8ksJ8RVm3k=; b=XDnUXdqcrp3JKlaSKint9orDY36j3vmUSsW3EiRnZvR4cXyFvL7OlEM7Sk4i99qHjL 2OXIloI1eEBhfSHwIXI6EI+NuGcf6nnieRC22Nr4niDCXvRxkJNKrefQ+PWG9WDjvnRb DQGCyD6wC7mk8qcdbH8iLA6Q9n45MzPAURopQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=Ghqa40M8TG+adu5x4wdp0qpvRALYDNFV5GSVvI4wdrN9hEno0eHEHSrR1y7I/OUClw 9FTqNXCon4v5ikwpd1EtL/J4tL6OcYbxNy29o9vTaF/6NjDl/iDwHaftNV4NqFiKYUHO bp6nBC90YKnd0fqg+o6BSgxtTJgzVuDf5L5W4= Received: by 10.223.113.12 with SMTP id y12mr1893919fap.36.1280489943169; Fri, 30 Jul 2010 04:39:03 -0700 (PDT) Received: from localhost.localdomain (IGLD-84-228-19-51.inter.net.il [84.228.19.51]) by mx.google.com with ESMTPS id q17sm767482faa.21.2010.07.30.04.39.00 (version=SSLv3 cipher=RC4-MD5); Fri, 30 Jul 2010 04:39:01 -0700 (PDT) From: Maxim Levitsky To: lirc-list@lists.sourceforge.net Cc: Jarod Wilson , linux-input@vger.kernel.org, linux-media@vger.kernel.org, Mauro Carvalho Chehab , Christoph Bartelmus , Maxim Levitsky Subject: [PATCH 02/13] IR: minor fixes: Date: Fri, 30 Jul 2010 14:38:42 +0300 Message-Id: <1280489933-20865-3-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1280489933-20865-1-git-send-email-maximlevitsky@gmail.com> References: <1280489933-20865-1-git-send-email-maximlevitsky@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 30 Jul 2010 11:39:10 +0000 (UTC) diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h index babd520..dc26e2b 100644 --- a/drivers/media/IR/ir-core-priv.h +++ b/drivers/media/IR/ir-core-priv.h @@ -76,7 +76,6 @@ struct ir_raw_event_ctrl { struct lirc_codec { struct ir_input_dev *ir_dev; struct lirc_driver *drv; - int lircdata; } lirc; }; @@ -104,10 +103,9 @@ static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration) ev->duration -= duration; } -#define TO_US(duration) (((duration) + 500) / 1000) +#define TO_US(duration) DIV_ROUND_CLOSEST((duration), 1000) #define TO_STR(is_pulse) ((is_pulse) ? "pulse" : "space") #define IS_RESET(ev) (ev.duration == 0) - /* * Routines from ir-sysfs.c - Meant to be called only internally inside * ir-core diff --git a/drivers/media/IR/ir-lirc-codec.c b/drivers/media/IR/ir-lirc-codec.c index 3ba482d..8ca01fd 100644 --- a/drivers/media/IR/ir-lirc-codec.c +++ b/drivers/media/IR/ir-lirc-codec.c @@ -32,6 +32,7 @@ static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev) { struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); + int sample; if (!(ir_dev->raw->enabled_protocols & IR_TYPE_LIRC)) return 0; @@ -39,18 +40,21 @@ static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev) if (!ir_dev->raw->lirc.drv || !ir_dev->raw->lirc.drv->rbuf) return -EINVAL; + if (IS_RESET(ev)) + return 0; + IR_dprintk(2, "LIRC data transfer started (%uus %s)\n", TO_US(ev.duration), TO_STR(ev.pulse)); - ir_dev->raw->lirc.lircdata += ev.duration / 1000; + + sample = ev.duration / 1000; if (ev.pulse) - ir_dev->raw->lirc.lircdata |= PULSE_BIT; + sample |= PULSE_BIT; lirc_buffer_write(ir_dev->raw->lirc.drv->rbuf, - (unsigned char *) &ir_dev->raw->lirc.lircdata); + (unsigned char *) &sample); wake_up(&ir_dev->raw->lirc.drv->rbuf->wait_poll); - ir_dev->raw->lirc.lircdata = 0; return 0; } @@ -224,8 +228,6 @@ static int ir_lirc_register(struct input_dev *input_dev) ir_dev->raw->lirc.drv = drv; ir_dev->raw->lirc.ir_dev = ir_dev; - ir_dev->raw->lirc.lircdata = PULSE_MASK; - return 0; lirc_register_failed: diff --git a/drivers/media/IR/ir-raw-event.c b/drivers/media/IR/ir-raw-event.c index 6f192ef..51f65da 100644 --- a/drivers/media/IR/ir-raw-event.c +++ b/drivers/media/IR/ir-raw-event.c @@ -66,6 +66,9 @@ int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev) if (!ir->raw) return -EINVAL; + IR_dprintk(2, "sample: (05%dus %s)\n", + TO_US(ev->duration), TO_STR(ev->pulse)); + if (kfifo_in(&ir->raw->kfifo, ev, sizeof(*ev)) != sizeof(*ev)) return -ENOMEM;