LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Simon Budig <simon@budig.de>
To: vojtech@suse.cz
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2.6.19] USB HID: proper LED-mapping (support for SpaceNavigator)
Date: Mon, 15 Jan 2007 00:11:35 +0100	[thread overview]
Message-ID: <20070114231135.GA29966@budig.de> (raw)

From: Simon Budig <simon@budig.de>

This change introduces a mapping for LED indicators between the USB HID
specification and the Linux input subsystem. The previous code properly
mapped the LEDs relevant for Keyboards, but garbeled the remaining ones.
With this change all LED enums from the input system get mapped to more
or less equivalent LED numbers from the HID specification.

This patch also extends the debug output and ensures that the unused
bits in a HID report to the device are zeroed out. This makes the
3Dconnexion SpaceNavigator fully usable with the linux input system.

Signed-off-by: Simon Budig <simon@budig.de>

diff -uprN -X linux/Documentation/dontdiff linux/drivers/usb/input.orig/hid-core.c linux/drivers/usb/input/hid-core.c
--- linux/drivers/usb/input.orig/hid-core.c	2006-11-29 22:57:37.000000000 +0100
+++ linux/drivers/usb/input/hid-core.c	2007-01-15 00:01:25.000000000 +0100
@@ -1089,6 +1089,10 @@ static void hid_output_field(struct hid_
 	unsigned size = field->report_size;
 	unsigned n;
 
+	/* make sure the unused bits in the last byte are zeros */
+	if (count > 0 && size > 0)
+		data[(count*size-1)/8] = 0;
+
 	for (n = 0; n < count; n++) {
 		if (field->logical_minimum < 0)	/* signed values */
 			implement(data, offset + n * size, size, s32ton(field->value[n], size));
diff -uprN -X linux/Documentation/dontdiff linux/drivers/usb/input.orig/hid-debug.h linux/drivers/usb/input/hid-debug.h
--- linux/drivers/usb/input.orig/hid-debug.h	2006-11-29 22:57:37.000000000 +0100
+++ linux/drivers/usb/input/hid-debug.h	2007-01-08 15:36:51.000000000 +0100
@@ -700,9 +700,10 @@ static char *keys[KEY_MAX + 1] = {
 
 static char *relatives[REL_MAX + 1] = {
 	[REL_X] = "X",			[REL_Y] = "Y",
-	[REL_Z] = "Z",			[REL_HWHEEL] = "HWheel",
-	[REL_DIAL] = "Dial",		[REL_WHEEL] = "Wheel",
-	[REL_MISC] = "Misc",
+	[REL_Z] = "Z",			[REL_RX] = "Rx",
+	[REL_RY] = "Ry",		[REL_RZ] = "Rz",
+	[REL_HWHEEL] = "HWheel",	[REL_DIAL] = "Dial",
+	[REL_WHEEL] = "Wheel",		[REL_MISC] = "Misc",
 };
 
 static char *absolutes[ABS_MAX + 1] = {
diff -uprN -X linux/Documentation/dontdiff linux/drivers/usb/input.orig/hid-input.c linux/drivers/usb/input/hid-input.c
--- linux/drivers/usb/input.orig/hid-input.c	2006-11-29 22:57:37.000000000 +0100
+++ linux/drivers/usb/input/hid-input.c	2007-01-08 17:20:16.000000000 +0100
@@ -366,9 +366,22 @@ static void hidinput_configure_usage(str
 			break;
 
 		case HID_UP_LED:
-			if (((usage->hid - 1) & 0xffff) >= LED_MAX)
-				goto ignore;
-			map_led((usage->hid - 1) & 0xffff);
+
+			switch (usage->hid & 0xffff) {                        /* HID-Value: */
+				case 0x01:  map_led (LED_NUML);     break;    /* Num Lock */
+				case 0x02:  map_led (LED_CAPSL);    break;    /* Caps Lock */
+				case 0x03:  map_led (LED_SCROLLL);  break;    /* Scroll Lock */
+				case 0x04:  map_led (LED_COMPOSE);  break;    /* Compose */
+				case 0x05:  map_led (LED_KANA);     break;    /* Kana */
+				case 0x27:  map_led (LED_SLEEP);    break;    /* Stand-By */
+				case 0x4c:  map_led (LED_SUSPEND);  break;    /* System Suspend */
+				case 0x09:  map_led (LED_MUTE);     break;    /* Mute */
+				case 0x4b:  map_led (LED_MISC);     break;    /* Generic Indicator */
+				case 0x19:  map_led (LED_MAIL);     break;    /* Message Waiting */
+				case 0x4d:  map_led (LED_CHARGING); break;    /* External Power Connected */
+
+				default: goto ignore;
+			}
 			break;
 
 		case HID_UP_DIGITIZER:

             reply	other threads:[~2007-01-14 23:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-14 23:11 Simon Budig [this message]
2007-01-15  8:42 ` Jiri Kosina
2007-01-15 16:25   ` Simon Budig
2007-01-15 16:44     ` Jiri Kosina
2007-01-15 17:32       ` Simon Budig
2007-01-15 21:14         ` Jiri Kosina
2007-01-15 22:55           ` Simon Budig
2007-01-15 18:32       ` Vojtech Pavlik
2007-01-15 18:38         ` Marcel Holtmann
2007-01-15 18:56           ` Vojtech Pavlik
2007-01-15 16:28 ` [PATCH 2.6.20-rc5] " Simon Budig
2007-01-15 17:34   ` Simon Budig

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=20070114231135.GA29966@budig.de \
    --to=simon@budig.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vojtech@suse.cz \
    --subject='Re: [PATCH 2.6.19] USB HID: proper LED-mapping (support for SpaceNavigator)' \
    /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

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