All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darius <augulis.darius@gmail.com>
To: linux-input@vger.kernel.org
Subject: [PATCH] gpio keys single egde
Date: Fri, 20 Feb 2009 16:02:11 +0200	[thread overview]
Message-ID: <gnmd97$g5d$1@ger.gmane.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: patch-gpio_keys-single_edge --]
[-- Type: text/plain, Size: 2235 bytes --]

From: Darius Augulis <augulis.darius@gmail.com>

Support for such GPIO controllers, which can't trigger on both edges at once.

Signed-off-by: Darius Augulis <augulis.darius@gmail.com>

Index: linux-2.6.29-rc5/drivers/input/keyboard/gpio_keys.c
===================================================================
--- linux-2.6.29-rc5.orig/drivers/input/keyboard/gpio_keys.c
+++ linux-2.6.29-rc5/drivers/input/keyboard/gpio_keys.c
@@ -43,8 +43,15 @@ static void gpio_keys_report_event(struc
 	unsigned int type = button->type ?: EV_KEY;
 	int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low;
 
+	printk("GPIO=%d\n", state);
+
 	input_event(input, type, button->code, !!state);
 	input_sync(input);
+
+	if (button->single_edge) {
+		input_event(input, type, button->code, !state);
+		input_sync(input);
+	}
 }
 
 static void gpio_check_button(unsigned long _data)
@@ -77,6 +84,7 @@ static int __devinit gpio_keys_probe(str
 	struct input_dev *input;
 	int i, error;
 	int wakeup = 0;
+	unsigned long irq_flags;
 
 	ddata = kzalloc(sizeof(struct gpio_keys_drvdata) +
 			pdata->nbuttons * sizeof(struct gpio_button_data),
@@ -141,9 +149,13 @@ static int __devinit gpio_keys_probe(str
 			goto fail2;
 		}
 
-		error = request_irq(irq, gpio_keys_isr,
-				    IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING |
-					IRQF_TRIGGER_FALLING,
+		irq_flags = IRQF_SAMPLE_RANDOM;
+		if (button->single_edge)
+			irq_flags |= (button->active_low ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING);
+		else
+			irq_flags |= IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
+
+		error = request_irq(irq, gpio_keys_isr, irq_flags,
 				    button->desc ? button->desc : "gpio_keys",
 				    bdata);
 		if (error) {
Index: linux-2.6.29-rc5/include/linux/gpio_keys.h
===================================================================
--- linux-2.6.29-rc5.orig/include/linux/gpio_keys.h
+++ linux-2.6.29-rc5/include/linux/gpio_keys.h
@@ -6,6 +6,7 @@ struct gpio_keys_button {
 	int code;		/* input event code (KEY_*, SW_*) */
 	int gpio;
 	int active_low;
+	int single_edge;	/* Trigger only single egde (0-no, 1-yes) */
 	char *desc;
 	int type;		/* input event type (EV_KEY, EV_SW) */
 	int wakeup;		/* configure the button as a wake-up source */

                 reply	other threads:[~2009-02-20 14:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='gnmd97$g5d$1@ger.gmane.org' \
    --to=augulis.darius@gmail.com \
    --cc=linux-input@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 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.