From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Daniel Mack <daniel@caiaq.de>
Cc: Richard Purdie <rpurdie@rpsys.net>,
linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
Constantin Baranov <const@mimas.ru>
Subject: Re: [PATCH] leds-alix2: add support for button connected to J15
Date: Sun, 18 Oct 2009 00:27:39 -0700 [thread overview]
Message-ID: <20091018072738.GF3935@core.coreip.homeip.net> (raw)
In-Reply-To: <20091016130315.GT28832@buzzloop.caiaq.de>
Hi Daniel,
On Fri, Oct 16, 2009 at 03:03:15PM +0200, Daniel Mack wrote:
>
> +#ifdef CONFIG_LEDS_ALIX2_BUTTON
> +static void alix_button_poll(struct input_polled_dev *ipdev)
> +{
> + unsigned int val = !(inl(gpio_base + 0x30) & (1 << 1));
> +
> + if (val == alix_button_last)
> + return;
You can probably let input core filter out duplicate events...
> +
> + input_report_key(ipdev->input, BTN_MISC, val);
BTN_MISC is expected to be used by joysticks or poniting devices, I'd
recomment KEY_PROG1 for a key.
> + input_sync(ipdev->input);
> + alix_button_last = val;
> +}
> +#endif
> +
> static int __init alix_led_probe(struct platform_device *pdev)
> {
> int i;
> @@ -89,6 +110,35 @@ static int __init alix_led_probe(struct platform_device *pdev)
> if (ret < 0)
> goto fail;
> }
> +
> +#ifdef CONFIG_LEDS_ALIX2_BUTTON
> + /* enable button input */
> + outl(1 << 1, gpio_base + 0x20);
> +
> + /* enable pullup on input pin */
> + outl(1 << 1, gpio_base + 0x18);
> +
> + alix_button_last = 0;
> + ipdev = input_allocate_polled_device();
> + if (!ipdev)
> + goto fail;
> +
> + ipdev->poll = alix_button_poll;
> + ipdev->poll_interval = POLL_INTERVAL_DEFAULT;
> + ipdev->input->name = "ALIX2 button";
> + ipdev->input->phys = "alix2/input0";
> + ipdev->input->id.bustype = BUS_HOST;
> +
> + set_bit(EV_KEY, ipdev->input->evbit);
> + ipdev->input->keybit[BIT_WORD(BTN_MISC)] = BIT_MASK(BTN_MISC);
> +
> + ret = input_register_polled_device(ipdev);
> + if (ret) {
> + input_free_polled_device(ipdev);
> + goto fail;
> + }
> +#endif
Fells like you want to make it a function (and a stub if not
configured)...
--
Dmitry
next prev parent reply other threads:[~2009-10-18 7:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-16 13:03 [PATCH] leds-alix2: add support for button connected to J15 Daniel Mack
2009-10-18 7:27 ` Dmitry Torokhov [this message]
2009-10-19 7:37 ` Daniel Mack
2009-10-20 1:38 ` Dmitry Torokhov
2009-10-20 10:13 ` Daniel Mack
2009-10-21 4:35 ` Dmitry Torokhov
2009-10-21 19:33 ` Daniel Mack
2009-10-21 20:21 ` Constantin Baranov
2009-10-21 20:41 ` Daniel Mack
2009-10-21 21:39 ` Constantin Baranov
2009-10-21 22:09 ` Constantin Baranov
2009-10-22 10:11 ` Daniel Mack
2009-10-18 10:56 ` Richard Purdie
2009-10-19 7:16 ` Daniel Mack
2009-10-22 10:29 ` Pavel Machek
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=20091018072738.GF3935@core.coreip.homeip.net \
--to=dmitry.torokhov@gmail.com \
--cc=const@mimas.ru \
--cc=daniel@caiaq.de \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rpurdie@rpsys.net \
/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).