From: Dmitry Torokhov <dtor@insightbb.com>
To: Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
Cc: linux-input@atrey.karlin.mff.cuni.cz
Subject: Re: [PATCH] Add Cobalt button interface driver support
Date: Tue, 18 Sep 2007 00:59:39 -0400 [thread overview]
Message-ID: <200709180059.40257.dtor@insightbb.com> (raw)
In-Reply-To: <200704260640.l3Q6eP6R020764@mbox32.po.2iij.net>
Hi Yoichi,
I tried adding loadable keymap support to the cobalt buttons driver so
that users can adjust keycodes if they are not satisfied with the default
selection. I would like to ask you to give this patch a spin when you
have a minute to spare as I do not own the hardware and terefore is unable
to test the patch myself.
The easies way to test I believe with the keyfuzz utility:
http://0pointer.de/lennart/projects/keyfuzz/
Cobalt_btns uses 0-7 range of "scancodes".
Thank you in advance.
--
Dmitry
Input: cobalt_btns - add support for loadable keymaps
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---
drivers/input/misc/cobalt_btns.c | 73 +++++++++++++++++++--------------------
1 file changed, 36 insertions(+), 37 deletions(-)
Index: linux/drivers/input/misc/cobalt_btns.c
===================================================================
--- linux.orig/drivers/input/misc/cobalt_btns.c
+++ linux/drivers/input/misc/cobalt_btns.c
@@ -27,55 +27,48 @@
#define BUTTONS_COUNT_THRESHOLD 3
#define BUTTONS_STATUS_MASK 0xfe000000
+static const unsigned short cobalt_map[] = {
+ KEY_RESERVED,
+ KEY_RESTART,
+ KEY_LEFT,
+ KEY_UP,
+ KEY_DOWN,
+ KEY_RIGHT,
+ KEY_ENTER,
+ KEY_SELECT
+};
+
struct buttons_dev {
struct input_polled_dev *poll_dev;
+ unsigned short keymap[ARRAY_SIZE(cobalt_map)];
+ int count[ARRAY_SIZE(cobalt_map)];
void __iomem *reg;
};
-struct buttons_map {
- uint32_t mask;
- int keycode;
- int count;
-};
-
-static struct buttons_map buttons_map[] = {
- { 0x02000000, KEY_RESTART, },
- { 0x04000000, KEY_LEFT, },
- { 0x08000000, KEY_UP, },
- { 0x10000000, KEY_DOWN, },
- { 0x20000000, KEY_RIGHT, },
- { 0x40000000, KEY_ENTER, },
- { 0x80000000, KEY_SELECT, },
-};
-
static void handle_buttons(struct input_polled_dev *dev)
{
- struct buttons_map *button = buttons_map;
struct buttons_dev *bdev = dev->private;
struct input_dev *input = dev->input;
uint32_t status;
int i;
- status = readl(bdev->reg);
- status = ~status & BUTTONS_STATUS_MASK;
+ status = ~readl(bdev->reg) >> 24;
- for (i = 0; i < ARRAY_SIZE(buttons_map); i++) {
- if (status & button->mask) {
- button->count++;
+ for (i = 0; i < ARRAY_SIZE(bdev->keymap); i++) {
+ if (status & (1UL << i)) {
+ if (++bdev->count[i] == BUTTONS_COUNT_THRESHOLD) {
+ input_event(input, EV_MSC, MSC_SCAN, i);
+ input_report_key(input, bdev->keymap[i], 1);
+ input_sync(input);
+ }
} else {
- if (button->count >= BUTTONS_COUNT_THRESHOLD) {
- input_report_key(input, button->keycode, 0);
+ if (bdev->count[i] >= BUTTONS_COUNT_THRESHOLD) {
+ input_event(input, EV_MSC, MSC_SCAN, i);
+ input_report_key(input, bdev->keymap[i], 0);
input_sync(input);
}
- button->count = 0;
- }
-
- if (button->count == BUTTONS_COUNT_THRESHOLD) {
- input_report_key(input, button->keycode, 1);
- input_sync(input);
+ bdev->count[i] = 0;
}
-
- button++;
}
}
@@ -94,6 +87,8 @@ static int __devinit cobalt_buttons_prob
goto err_free_mem;
}
+ memcpy(bdev->keymap, cobalt_map, sizeof(bdev->keymap));
+
poll_dev->private = bdev;
poll_dev->poll = handle_buttons;
poll_dev->poll_interval = BUTTONS_POLL_INTERVAL;
@@ -104,11 +99,15 @@ static int __devinit cobalt_buttons_prob
input->id.bustype = BUS_HOST;
input->cdev.dev = &pdev->dev;
- input->evbit[0] = BIT(EV_KEY);
- for (i = 0; i < ARRAY_SIZE(buttons_map); i++) {
- set_bit(buttons_map[i].keycode, input->keybit);
- buttons_map[i].count = 0;
- }
+ input->keycode = pdev->keymap;
+ input->keycodemax = ARRAY_SIZE(pdev->keymap);
+ input->keycodesize = sizeof(unsigned short);
+
+ input_set_capability(input, EV_MSC, MSC_SCAN);
+ __set_bit(EV_KEY, input->evbit);
+ for (i = 0; i < ARRAY_SIZE(buttons_map); i++)
+ __set_bit(input->keycode[i], input->keybit);
+ __clear_bit(KEY_RESERVED, input->keybit);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
prev parent reply other threads:[~2007-09-18 4:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-16 3:36 [PATCH] Add Cobalt button interface driver support Yoichi Yuasa
2007-02-16 4:09 ` Dmitry Torokhov
2007-02-16 8:15 ` Yoichi Yuasa
2007-02-16 15:15 ` Dmitry Torokhov
2007-02-16 16:22 ` Yoichi Yuasa
2007-04-04 4:01 ` Dmitry Torokhov
2007-04-05 5:02 ` Yoichi Yuasa
2007-04-25 5:34 ` Dmitry Torokhov
2007-04-26 6:40 ` Yoichi Yuasa
2007-04-26 12:29 ` Dmitry Torokhov
2007-09-18 4:59 ` Dmitry Torokhov [this message]
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=200709180059.40257.dtor@insightbb.com \
--to=dtor@insightbb.com \
--cc=linux-input@atrey.karlin.mff.cuni.cz \
--cc=yoichi_yuasa@tripeaks.co.jp \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.