From patchwork Fri Jul 30 02:17:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 115362 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 o6U2Hdi1006482 for ; Fri, 30 Jul 2010 02:17:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758359Ab0G3CRh (ORCPT ); Thu, 29 Jul 2010 22:17:37 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:53717 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758347Ab0G3CRg (ORCPT ); Thu, 29 Jul 2010 22:17:36 -0400 Received: by mail-bw0-f46.google.com with SMTP id 1so202286bwz.19 for ; Thu, 29 Jul 2010 19:17:35 -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=uNz7Sq+n3E2ss+n9dw4rGflbKtxiV5Khy2sJuNWdYLweJqpDDG2+vxYBfqia/gmIBf ut95p29Skmr5MnP0XkQUBoze+h6cJTlUXD85m/6zOovmADvu4sLR+8YweSGBSpQ1ik98 MGCdM9bfs56JL+Vanm/tsqCnFsN7pu10J1yvo= 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=VEroLGQCb10mq3AlXwoNfuJOjX3KkqLxcTBo8yWdgOB/BuETPc8XwlJ/IW7augAl0E gqJr56ffe6jLNFI1GgU00k0L9BVeO0BDIGL8fQpfSwbbpInxeR2jY8vMk9ScngS2AvZh hHO/j58y168/X5cGkNo4JlVyb2LCepsv63Hc0= Received: by 10.204.128.130 with SMTP id k2mr623083bks.159.1280456255784; Thu, 29 Jul 2010 19:17:35 -0700 (PDT) Received: from localhost.localdomain (IGLD-84-228-148-137.inter.net.il [84.228.148.137]) by mx.google.com with ESMTPS id f10sm1110122bkl.17.2010.07.29.19.17.33 (version=SSLv3 cipher=RC4-MD5); Thu, 29 Jul 2010 19:17:34 -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 05:17:04 +0300 Message-Id: <1280456235-2024-3-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1280456235-2024-1-git-send-email-maximlevitsky@gmail.com> References: <1280456235-2024-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 02:17:40 +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;