linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] sparse-keymap: Emit events useful for key debugging
@ 2011-03-23 21:13 Seth Forshee
  2011-03-23 21:13 ` [PATCH 1/2] Input: sparse-keymap - report scancodes with key events Seth Forshee
  2011-03-23 21:13 ` [PATCH 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes Seth Forshee
  0 siblings, 2 replies; 7+ messages in thread
From: Seth Forshee @ 2011-03-23 21:13 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel

A number of ACPI/WMI drivers use sparse-keymap for hotkeys. Some of the
most common hotkey problems are new keys with perviously unused scan
codes and keys that reuse scan codes for different functions than in
previous models. Diagnosis of these key problems can be done easily
from userspace as long as the drivers emit MSC_SCAN events for all keys
and KEY_UNKNOWN key events for unknown scan codes. sparse-keymap does
neither.

The following patches modify sparse-keymap to emit these events,
facilitating easier debugging of malfunctioning keys from userspace.

Thanks,
Seth


Seth Forshee (2):
  Input: sparse-keymap - report scancodes with key events
  Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes

 drivers/input/sparse-keymap.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] Input: sparse-keymap - report scancodes with key events
  2011-03-23 21:13 [PATCH 0/2] sparse-keymap: Emit events useful for key debugging Seth Forshee
@ 2011-03-23 21:13 ` Seth Forshee
  2011-03-23 21:13 ` [PATCH 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes Seth Forshee
  1 sibling, 0 replies; 7+ messages in thread
From: Seth Forshee @ 2011-03-23 21:13 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel

Scancodes are useful debugging aids when incorrect keycodes
are being sent, as is common with laptop hotkeys.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 drivers/input/sparse-keymap.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index 337bf51..74bca5d 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -208,6 +208,11 @@ int sparse_keymap_setup(struct input_dev *dev,
 		}
 	}
 
+	if (test_bit(EV_KEY, dev->evbit)) {
+		__set_bit(EV_MSC, dev->evbit);
+		__set_bit(MSC_SCAN, dev->mscbit);
+	}
+
 	dev->keycode = map;
 	dev->keycodemax = map_size;
 	dev->getkeycode = sparse_keymap_getkeycode;
@@ -268,6 +273,7 @@ void sparse_keymap_report_entry(struct input_dev *dev, const struct key_entry *k
 {
 	switch (ke->type) {
 	case KE_KEY:
+		input_event(dev, EV_MSC, MSC_SCAN, ke->code);
 		input_report_key(dev, ke->keycode, value);
 		input_sync(dev);
 		if (value && autorelease) {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes
  2011-03-23 21:13 [PATCH 0/2] sparse-keymap: Emit events useful for key debugging Seth Forshee
  2011-03-23 21:13 ` [PATCH 1/2] Input: sparse-keymap - report scancodes with key events Seth Forshee
@ 2011-03-23 21:13 ` Seth Forshee
  2011-03-25  7:35   ` Dmitry Torokhov
  1 sibling, 1 reply; 7+ messages in thread
From: Seth Forshee @ 2011-03-23 21:13 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel

This allows for debugging non-functional keys easily from
userspace.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 drivers/input/sparse-keymap.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index 74bca5d..744980e 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -209,6 +209,7 @@ int sparse_keymap_setup(struct input_dev *dev,
 	}
 
 	if (test_bit(EV_KEY, dev->evbit)) {
+		__set_bit(KEY_UNKNOWN, dev->keybit);
 		__set_bit(EV_MSC, dev->evbit);
 		__set_bit(MSC_SCAN, dev->mscbit);
 	}
@@ -311,12 +312,19 @@ bool sparse_keymap_report_event(struct input_dev *dev, unsigned int code,
 {
 	const struct key_entry *ke =
 		sparse_keymap_entry_from_scancode(dev, code);
+	struct key_entry unknown_ke;
 
 	if (ke) {
 		sparse_keymap_report_entry(dev, ke, value, autorelease);
 		return true;
 	}
 
+	/* Report an unknown key event as a debugging aid */
+	unknown_ke.type = KE_KEY;
+	unknown_ke.code = code;
+	unknown_ke.keycode = KEY_UNKNOWN;
+	sparse_keymap_report_entry(dev, &unknown_ke, value, autorelease);
+
 	return false;
 }
 EXPORT_SYMBOL(sparse_keymap_report_event);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes
  2011-03-23 21:13 ` [PATCH 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes Seth Forshee
@ 2011-03-25  7:35   ` Dmitry Torokhov
  2011-03-25 13:40     ` Seth Forshee
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Torokhov @ 2011-03-25  7:35 UTC (permalink / raw)
  To: Seth Forshee; +Cc: linux-input, linux-kernel

Hi Seth,

On Wed, Mar 23, 2011 at 04:13:43PM -0500, Seth Forshee wrote:
>  
> +	/* Report an unknown key event as a debugging aid */
> +	unknown_ke.type = KE_KEY;
> +	unknown_ke.code = code;
> +	unknown_ke.keycode = KEY_UNKNOWN;
> +	sparse_keymap_report_entry(dev, &unknown_ke, value, autorelease);

I think it should not depend on autorelease but always automatically
release KEY_UNKNOWN.

Otherwise I think I'll apply both patches.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes
  2011-03-25  7:35   ` Dmitry Torokhov
@ 2011-03-25 13:40     ` Seth Forshee
  2011-03-25 13:40       ` [PATCH v2 1/2] Input: sparse-keymap - report scancodes with key events Seth Forshee
  2011-03-25 13:40       ` [PATCH v2 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes Seth Forshee
  0 siblings, 2 replies; 7+ messages in thread
From: Seth Forshee @ 2011-03-25 13:40 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel

On Fri, Mar 25, 2011 at 12:35:54AM -0700, Dmitry Torokhov wrote:
> Hi Seth,
> 
> On Wed, Mar 23, 2011 at 04:13:43PM -0500, Seth Forshee wrote:
> >  
> > +	/* Report an unknown key event as a debugging aid */
> > +	unknown_ke.type = KE_KEY;
> > +	unknown_ke.code = code;
> > +	unknown_ke.keycode = KEY_UNKNOWN;
> > +	sparse_keymap_report_entry(dev, &unknown_ke, value, autorelease);
> 
> I think it should not depend on autorelease but always automatically
> release KEY_UNKNOWN.
> 
> Otherwise I think I'll apply both patches.

Great! Here are the patches with that changed.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] Input: sparse-keymap - report scancodes with key events
  2011-03-25 13:40     ` Seth Forshee
@ 2011-03-25 13:40       ` Seth Forshee
  2011-03-25 13:40       ` [PATCH v2 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes Seth Forshee
  1 sibling, 0 replies; 7+ messages in thread
From: Seth Forshee @ 2011-03-25 13:40 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel

Scancodes are useful debugging aids when incorrect keycodes
are being sent, as is common with laptop hotkeys.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 drivers/input/sparse-keymap.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index 337bf51..74bca5d 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -208,6 +208,11 @@ int sparse_keymap_setup(struct input_dev *dev,
 		}
 	}
 
+	if (test_bit(EV_KEY, dev->evbit)) {
+		__set_bit(EV_MSC, dev->evbit);
+		__set_bit(MSC_SCAN, dev->mscbit);
+	}
+
 	dev->keycode = map;
 	dev->keycodemax = map_size;
 	dev->getkeycode = sparse_keymap_getkeycode;
@@ -268,6 +273,7 @@ void sparse_keymap_report_entry(struct input_dev *dev, const struct key_entry *k
 {
 	switch (ke->type) {
 	case KE_KEY:
+		input_event(dev, EV_MSC, MSC_SCAN, ke->code);
 		input_report_key(dev, ke->keycode, value);
 		input_sync(dev);
 		if (value && autorelease) {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes
  2011-03-25 13:40     ` Seth Forshee
  2011-03-25 13:40       ` [PATCH v2 1/2] Input: sparse-keymap - report scancodes with key events Seth Forshee
@ 2011-03-25 13:40       ` Seth Forshee
  1 sibling, 0 replies; 7+ messages in thread
From: Seth Forshee @ 2011-03-25 13:40 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel

This allows for debugging non-functional keys easily from
userspace.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
 drivers/input/sparse-keymap.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index 74bca5d..fdb6a39 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -209,6 +209,7 @@ int sparse_keymap_setup(struct input_dev *dev,
 	}
 
 	if (test_bit(EV_KEY, dev->evbit)) {
+		__set_bit(KEY_UNKNOWN, dev->keybit);
 		__set_bit(EV_MSC, dev->evbit);
 		__set_bit(MSC_SCAN, dev->mscbit);
 	}
@@ -311,12 +312,19 @@ bool sparse_keymap_report_event(struct input_dev *dev, unsigned int code,
 {
 	const struct key_entry *ke =
 		sparse_keymap_entry_from_scancode(dev, code);
+	struct key_entry unknown_ke;
 
 	if (ke) {
 		sparse_keymap_report_entry(dev, ke, value, autorelease);
 		return true;
 	}
 
+	/* Report an unknown key event as a debugging aid */
+	unknown_ke.type = KE_KEY;
+	unknown_ke.code = code;
+	unknown_ke.keycode = KEY_UNKNOWN;
+	sparse_keymap_report_entry(dev, &unknown_ke, value, true);
+
 	return false;
 }
 EXPORT_SYMBOL(sparse_keymap_report_event);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-03-25 13:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-23 21:13 [PATCH 0/2] sparse-keymap: Emit events useful for key debugging Seth Forshee
2011-03-23 21:13 ` [PATCH 1/2] Input: sparse-keymap - report scancodes with key events Seth Forshee
2011-03-23 21:13 ` [PATCH 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes Seth Forshee
2011-03-25  7:35   ` Dmitry Torokhov
2011-03-25 13:40     ` Seth Forshee
2011-03-25 13:40       ` [PATCH v2 1/2] Input: sparse-keymap - report scancodes with key events Seth Forshee
2011-03-25 13:40       ` [PATCH v2 2/2] Input: sparse-keymap - report KEY_UNKNOWN for unknown scan codes Seth Forshee

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).