From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.arm.linux.org.uk, linux-input@vger.kernel.org
Subject: Re: [PATCH 3/5] [ARM] pxa: lx: add keyboard driver
Date: Sat, 18 Apr 2009 16:10:28 -0700 [thread overview]
Message-ID: <20090418231018.GA32346@dtor-d630.eng.vmware.com> (raw)
In-Reply-To: <1240064452-14691-3-git-send-email-linux@arm.linux.org.uk>
Hi Russell,
On Sat, Apr 18, 2009 at 03:20:50PM +0100, Russell King wrote:
> This adds support for the keyboard support on the LX platform.
> We aren't directly connected to the keyboard itself, but the
> keyboard is managed by PCON via the system I2C bus.
>
Very nice driver. I prefer input devices having a private copy of keymap
but I suppose there is just such device in the system anyways...
>
> +config KEYBOARD_LX
> + tristate "LX Keyboard support"
> + depends on MACH_NETBOOKPRO && INPUT && INPUT_KEYBOARD
Dependancy on INPUT_KEYBOARD is not needed, strictly speaking.
INPUT_KEYBOARD is only [menu]config syntactic sugar, there is no meat
behind the option.
> +
> + /*
> + * Some keys have additional operations after we have
> + * decoded them. We don't report these "special" keys
> + * to the input layer.
> + */
> + switch (key) {
> + case KEY_BRIGHTNESSUP:
> + case KEY_BRIGHTNESSDOWN:
> + input_event(kbd, EV_PWR, key, !up);
Umm... some userspace apps might still want to get these. Strictly
speaking KEY_* codes belong to EV_KEY namespace.
> + break;
> +
> + case KEY_SUSPEND:
> + input_event(kbd, EV_PWR, key, !up);
> +#if defined(CONFIG_APM_EMULATION) && !defined(CONFIG_INPUT_APMPOWER)
> + if (!up)
> + apm_queue_event(APM_SYS_SUSPEND);
> +#endif
> + break;
> +
> + default:
> + input_report_key(kbd, key, !up);
> + break;
> + }
> +}
> +
> +static void lx_keyb_reset(struct input_dev *kbd)
> +{
> + unsigned char *map;
> + int key;
> +
> + for (key = 0; key < LX_NUMKEYCODES; key++)
> + if (keystate[key] & KP_DOWN) {
> + map = normal_map;
> + if (keystate[key] & KP_FN)
> + map = fn_map;
> + else if (keystate[key] & KP_NUMLCK)
> + map = numlck_map;
> + keystate[key] = KP_NONE;
> + input_report_key(kbd, map[key], 0);
> + }
Why don't you just send 'up' event for all known keys? Input core will
filter out the ones that have not been 'down'ed... Better yet, don't do
anything here, I should finish adding forced release at suspend/resume
to the input core shortly.
> +
> + num_lck = 0;
> +}
> +
> +static void lx_keyb_write(void *data, unsigned int addr, unsigned char val)
> +{
> + struct input_dev *kbd = data;
Blank line between variables and the code is always appreciated ;)
> + pcon_kbd_ack();
> + lx_keyb_process_key(kbd, val);
> +}
> +
> +static struct lx_i2cslave_watcher lx_keyb_watcher = {
> + .start = PHST_KEYBOARD_START,
> + .size = PHST_KEYBOARD_SIZE,
> + .write = lx_keyb_write,
> +};
> +
> +static int lx_keyb_probe(struct platform_device *dev)
> +{
> + struct input_dev *kbd;
> + int i, ret;
> +
> + kbd = input_allocate_device();
> + if (!kbd)
> + return -ENOMEM;
> +
> + kbd->name = "LX Keyboard";
> + kbd->phys = "pcon/input0";
> + kbd->dev.parent = &dev->dev;
> + kbd->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
> + BIT_MASK(EV_PWR);
> + kbd->keycode = normal_map;
> + kbd->keycodesize = sizeof(unsigned char);
> + kbd->keycodemax = ARRAY_SIZE(normal_map);
> +
So we have 3 keymaps but only one can be changed form userspace... I
suppose it is OK given how special the other 2 keymaps are. Or we could
provide an alternative {get,set}keycode methods.
> + for (i = 0; i < ARRAY_SIZE(normal_map); i++) {
> + if (normal_map[i])
> + __set_bit(normal_map[i], kbd->keybit);
> + }
> + for (i = 0; i < ARRAY_SIZE(numlck_map); i++) {
> + if (numlck_map[i])
> + __set_bit(numlck_map[i], kbd->keybit);
> + }
> + for (i = 0; i < ARRAY_SIZE(fn_map); i++) {
> + if (fn_map[i])
> + __set_bit(fn_map[i], kbd->keybit);
> + }
> +
> + ret = input_register_device(kbd);
> + if (ret == 0) {
> + platform_set_drvdata(dev, kbd);
> + lx_i2cslave_addwatcher(&lx_keyb_watcher, kbd);
> + } else {
> + input_free_device(kbd);
> + }
> + return ret;
> +}
> +
> +static int __devexit lx_keyb_remove(struct platform_device *dev)
> +{
> + struct input_dev *kbd = platform_get_drvdata(dev);
> + platform_set_drvdata(dev, NULL);
> + lx_i2cslave_delwatcher(&lx_keyb_watcher, kbd);
> + input_unregister_device(kbd);
> + return 0;
> +}
> +
> +static int lx_keyb_resume(struct platform_device *dev)
> +{
> + struct input_dev *kbd = platform_get_drvdata(dev);
> + lx_keyb_reset(kbd);
> + return 0;
> +}
> +
> +static struct platform_driver lx_kbd = {
> + .driver = {
> + .name = "lx-kbd",
> + .owner = THIS_MODULE,
> + },
> + .probe = lx_keyb_probe,
> + .remove = __devexit_p(lx_keyb_remove),
> + .resume = lx_keyb_resume,
> +};
> +
> +static int __init lx_keyb_init(void)
> +{
> + printk(KERN_INFO "LX Keyboard Driver, (c) 2004 Simtec Electronics\n");
Is this needed? Input core will already add printk when input device is
added and our boot is already chatty enough...
Thanks!
--
Dmitry
next prev parent reply other threads:[~2009-04-18 23:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-18 14:19 [PATCH 0/5] PXA LX platform support Russell King - ARM Linux
2009-04-18 14:20 ` [PATCH 3/5] [ARM] pxa: lx: add keyboard driver Russell King
2009-04-18 23:10 ` Dmitry Torokhov [this message]
2009-04-20 8:25 ` Russell King - ARM Linux
2009-04-20 9:04 ` Dmitry Torokhov
2009-04-20 10:56 ` Russell King - ARM Linux
2009-04-20 11:06 ` Russell King - ARM Linux
2009-04-20 11:13 ` [PATCH 3/5 UPDATED] " Russell King - ARM Linux
2009-04-21 2:16 ` Dmitry Torokhov
2009-04-22 18:56 ` Russell King - ARM Linux
2009-04-21 2:15 ` [PATCH 3/5] " Dmitry Torokhov
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=20090418231018.GA32346@dtor-d630.eng.vmware.com \
--to=dmitry.torokhov@gmail.com \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-input@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
/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).