From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: "Bruno Prémont" <bonbons@linux-vserver.org>
Cc: Jiri Kosina <jkosina@suse.cz>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org
Subject: Re: [PATCH 3/6] HID: picoLCD: Add support for CIR
Date: Fri, 14 Sep 2012 11:15:37 -0300 [thread overview]
Message-ID: <50533C09.1020809@redhat.com> (raw)
In-Reply-To: <20120819193254.6a48348d@neptune.home>
Em 19-08-2012 14:32, Bruno Prémont escreveu:
> Implement support for picoLCD's CIR header using RC_CORE for decoding
> the IR event stream.
>
> Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org>
Sorry for a late answer. I'm with a huge backlog due to KS/2012 workshop.
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> ---
> drivers/hid/hid-picolcd.h | 5 ++-
> drivers/hid/hid-picolcd_cir.c | 95 +++++++++++++++++++++++++++++++++++++++-
> drivers/hid/hid-picolcd_core.c | 3 +-
> 3 files changed, 98 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hid/hid-picolcd.h b/drivers/hid/hid-picolcd.h
> index dc4c795..240eb1c 100644
> --- a/drivers/hid/hid-picolcd.h
> +++ b/drivers/hid/hid-picolcd.h
> @@ -85,7 +85,9 @@ struct picolcd_data {
> /* input stuff */
> u8 pressed_keys[2];
> struct input_dev *input_keys;
> - struct input_dev *input_cir;
> +#ifdef CONFIG_HID_PICOLCD_CIR
> + struct rc_dev *rc_dev;
> +#endif
> unsigned short keycode[PICOLCD_KEYS];
>
> #ifdef CONFIG_HID_PICOLCD_FB
> @@ -114,6 +116,7 @@ struct picolcd_data {
> int status;
> #define PICOLCD_BOOTLOADER 1
> #define PICOLCD_FAILED 2
> +#define PICOLCD_CIR_SHUN 4
> };
>
> #ifdef CONFIG_HID_PICOLCD_FB
> diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
> index dc632c3..f38af30 100644
> --- a/drivers/hid/hid-picolcd_cir.c
> +++ b/drivers/hid/hid-picolcd_cir.c
> @@ -37,6 +37,7 @@
> #include <linux/completion.h>
> #include <linux/uaccess.h>
> #include <linux/module.h>
> +#include <media/rc-core.h>
>
> #include "hid-picolcd.h"
>
> @@ -44,18 +45,108 @@
> int picolcd_raw_cir(struct picolcd_data *data,
> struct hid_report *report, u8 *raw_data, int size)
> {
> - /* Need understanding of CIR data format to implement ... */
> + unsigned long flags;
> + int i, w, sz;
> + DEFINE_IR_RAW_EVENT(rawir);
> +
> + /* ignore if rc_dev is NULL or status is shunned */
> + spin_lock_irqsave(&data->lock, flags);
> + if (data->rc_dev && (data->status & PICOLCD_CIR_SHUN)) {
> + spin_unlock_irqrestore(&data->lock, flags);
> + return 1;
> + }
> + spin_unlock_irqrestore(&data->lock, flags);
> +
> + /* PicoLCD USB packets contain 16-bit intervals in network order,
> + * with value negated for pulse. Intervals are in microseconds.
> + *
> + * Note: some userspace LIRC code for PicoLCD says negated values
> + * for space - is it a matter of IR chip? (pulse for my TSOP2236)
> + *
> + * In addition, the first interval seems to be around 15000 + base
> + * interval for non-first report of IR data - thus the quirk below
> + * to get RC_CODE to understand Sony and JVC remotes I have at hand
> + */
> + sz = size > 0 ? min((int)raw_data[0], size-1) : 0;
> + for (i = 0; i+1 < sz; i += 2) {
> + init_ir_raw_event(&rawir);
> + w = (raw_data[i] << 8) | (raw_data[i+1]);
> + rawir.pulse = !!(w & 0x8000);
> + rawir.duration = US_TO_NS(rawir.pulse ? (65536 - w) : w);
> + /* Quirk!! - see above */
> + if (i == 0 && rawir.duration > 15000000)
> + rawir.duration -= 15000000;
> + ir_raw_event_store(data->rc_dev, &rawir);
> + }
> + ir_raw_event_handle(data->rc_dev);
> +
> return 1;
> }
>
> +static int picolcd_cir_open(struct rc_dev *dev)
> +{
> + struct picolcd_data *data = dev->priv;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&data->lock, flags);
> + data->status &= ~PICOLCD_CIR_SHUN;
> + spin_unlock_irqrestore(&data->lock, flags);
> + return 0;
> +}
> +
> +static void picolcd_cir_close(struct rc_dev *dev)
> +{
> + struct picolcd_data *data = dev->priv;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&data->lock, flags);
> + data->status |= PICOLCD_CIR_SHUN;
> + spin_unlock_irqrestore(&data->lock, flags);
> +}
> +
> /* initialize CIR input device */
> int picolcd_init_cir(struct picolcd_data *data, struct hid_report *report)
> {
> - /* support not implemented yet */
> + struct rc_dev *rdev;
> + int ret = 0;
> +
> + rdev = rc_allocate_device();
> + if (!rdev)
> + return -ENOMEM;
> +
> + rdev->priv = data;
> + rdev->driver_type = RC_DRIVER_IR_RAW;
> + rdev->allowed_protos = RC_TYPE_ALL;
> + rdev->open = picolcd_cir_open;
> + rdev->close = picolcd_cir_close;
> + rdev->input_name = data->hdev->name;
> + rdev->input_phys = data->hdev->phys;
> + rdev->input_id.bustype = data->hdev->bus;
> + rdev->input_id.vendor = data->hdev->vendor;
> + rdev->input_id.product = data->hdev->product;
> + rdev->input_id.version = data->hdev->version;
> + rdev->dev.parent = &data->hdev->dev;
> + rdev->driver_name = PICOLCD_NAME;
> + rdev->map_name = RC_MAP_RC6_MCE;
> + rdev->timeout = MS_TO_NS(100);
> + rdev->rx_resolution = US_TO_NS(1);
> +
> + ret = rc_register_device(rdev);
> + if (ret)
> + goto err;
> + data->rc_dev = rdev;
> return 0;
> +
> +err:
> + rc_free_device(rdev);
> + return ret;
> }
>
> void picolcd_exit_cir(struct picolcd_data *data)
> {
> + struct rc_dev *rdev = data->rc_dev;
> +
> + data->rc_dev = NULL;
> + rc_unregister_device(rdev);
> }
>
> diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
> index 76ab173..580269b 100644
> --- a/drivers/hid/hid-picolcd_core.c
> +++ b/drivers/hid/hid-picolcd_core.c
> @@ -356,8 +356,7 @@ static int picolcd_raw_event(struct hid_device *hdev,
> if (data->input_keys)
> ret = picolcd_raw_keypad(data, report, raw_data+1, size-1);
> } else if (report->id == REPORT_IR_DATA) {
> - if (data->input_cir)
> - ret = picolcd_raw_cir(data, report, raw_data+1, size-1);
> + ret = picolcd_raw_cir(data, report, raw_data+1, size-1);
> } else {
> spin_lock_irqsave(&data->lock, flags);
> /*
>
next prev parent reply other threads:[~2012-09-14 14:15 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-30 19:36 [PATCH 0/7] HID: picoLCD updates Bruno Prémont
2012-07-30 19:38 ` [PATCH 1/7] HID: picoLCD: split driver code Bruno Prémont
2012-07-30 19:59 ` Bruno Prémont
2012-07-30 19:38 ` [PATCH 2/7] HID: picoLCD: Replace own refcounting with fbdev's Bruno Prémont
2012-07-30 19:38 ` [PATCH 3/7] HID: picoLCD: prevent NULL pointer dereference on unplug Bruno Prémont
2012-07-30 19:38 ` [PATCH 4/7] HID: picoLCD: satify some checkpatch warnings Bruno Prémont
2012-07-30 19:38 ` [PATCH 5/7] HID: picoLCD: Improve unplug handling Bruno Prémont
2012-07-30 19:38 ` [PATCH 6/7] HID: picoLCD: disable version check during probe Bruno Prémont
2012-08-15 8:15 ` Jiri Kosina
2012-08-19 16:56 ` [PATCH 6/7 v2] HID: picoLCD: drop " Bruno Prémont
2012-09-17 18:21 ` Bruno Prémont
2012-09-19 11:45 ` Jiri Kosina
2012-07-30 19:39 ` [PATCH 7/7] HID: picoLCD: add myself to MAINTAINERS Bruno Prémont
2012-07-31 7:26 ` [PATCH 0/7] HID: picoLCD updates David Herrmann
2012-07-31 7:59 ` Bruno Prémont
2012-08-09 18:09 ` Bruno Prémont
2012-08-13 23:27 ` Tejun Heo
2012-08-14 6:30 ` Bruno Prémont
2012-08-14 17:31 ` Tejun Heo
2012-08-15 8:27 ` Jiri Kosina
2012-08-15 9:42 ` Bruno Prémont
2012-08-15 12:11 ` Jiri Kosina
2012-08-15 15:16 ` Bruno Prémont
2012-08-15 21:32 ` Jiri Kosina
2012-08-16 16:30 ` Bruno Prémont
2012-08-16 16:47 ` Jiri Kosina
2012-08-18 12:40 ` Bruno Prémont
2012-08-18 13:19 ` Alan Stern
2012-08-18 13:48 ` Bruno Prémont
2012-08-18 18:49 ` Bruno Prémont
2012-08-19 0:11 ` Alan Stern
2012-08-19 16:23 ` Bruno Prémont
2012-08-19 19:56 ` Alan Stern
2012-08-19 17:28 ` [PATCH 0/6] HID: picoLCD additional fixes + CIR support Bruno Prémont
2012-08-19 17:31 ` [PATCH 1/6] HID: picoLCD: prevent NULL pointer dereferences Bruno Prémont
2012-08-19 17:32 ` [PATCH 2/6] HID: picoLCD: rework hid-fbdev interaction Bruno Prémont
2012-08-19 17:32 ` [PATCH 3/6] HID: picoLCD: Add support for CIR Bruno Prémont
2012-09-14 14:15 ` Mauro Carvalho Chehab [this message]
2012-08-19 17:33 ` [PATCH 4/6] HID: picoLCD: optimize for inactive debugfs Bruno Prémont
2012-08-19 17:33 ` [PATCH 5/6] HID: picoLCD: fix dumping of IR_DATA report Bruno Prémont
2012-08-19 17:33 ` [PATCH 6/6] HID: picoLCD: use proper device as input_dev parent Bruno Prémont
2012-09-05 9:50 ` [PATCH 0/6] HID: picoLCD additional fixes + CIR support Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50533C09.1020809@redhat.com \
--to=mchehab@redhat.com \
--cc=bonbons@linux-vserver.org \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).