linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] to fix scancodes returned by sony-laptop driver
@ 2011-11-16 18:51 John Hughes
  2011-11-17 19:16 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: John Hughes @ 2011-11-16 18:51 UTC (permalink / raw)
  To: Mattia Dongili; +Cc: platform-driver-x86, linux-kernel

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

Fix scancodes returned by driver to match scancodes used to remap keys.

(Before the patch FN/E returned scancode 0x1B, but to remap scancode 
0x14 had to be used).


[-- Attachment #2: sony-scancode.patch --]
[-- Type: text/x-patch, Size: 2682 bytes --]

The scancodes returned by the sony-laptop driver for function keys did not
match the scancodes used to remap keys.  Also, since the scancode was sent
to the input subsystem after the mapped keysym the /lib/udev/keymap
utility was confused about which scancode to report for which keysym.

This patch fixes the driver so the correct scancode is shown for each
key.  It also adds to the documentation a description of where to find
the scancodes.

Signed-off-by: John Hughes <john@calva.com>

diff --git a/Documentation/laptops/sony-laptop.txt b/Documentation/laptops/sony-laptop.txt
index 2bd4e82..0d5ac7f 100644
--- a/Documentation/laptops/sony-laptop.txt
+++ b/Documentation/laptops/sony-laptop.txt
@@ -17,6 +17,11 @@ subsystem. See the logs of acpid or /proc/acpi/event and
 devices are created by the driver. Additionally, loading the driver with the
 debug option will report all events in the kernel log.
 
+The "scancodes" passed to the input system (that can be remapped with udev)
+are indexes to the table "sony_laptop_input_keycode_map" in the sony-laptop.c
+module.  For example the "FN/E" key combination (EJECTCD on some models)
+generates the scancode 20 (0x14).
+
 Backlight control:
 ------------------
 If your laptop model supports it, you will find sysfs files in the
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index bbd182e..f148459 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -347,6 +347,7 @@ static void sony_laptop_report_input_event(u8 event)
 	struct input_dev *jog_dev = sony_laptop_input.jog_dev;
 	struct input_dev *key_dev = sony_laptop_input.key_dev;
 	struct sony_laptop_keypress kp = { NULL };
+	int scancode;
 
 	if (event == SONYPI_EVENT_FNKEY_RELEASED ||
 			event == SONYPI_EVENT_ANYBUTTON_RELEASED) {
@@ -380,8 +381,8 @@ static void sony_laptop_report_input_event(u8 event)
 			dprintk("sony_laptop_report_input_event, event not known: %d\n", event);
 			break;
 		}
-		if (sony_laptop_input_index[event] != -1) {
-			kp.key = sony_laptop_input_keycode_map[sony_laptop_input_index[event]];
+		if ((scancode = sony_laptop_input_index[event]) != -1) {
+			kp.key = sony_laptop_input_keycode_map[scancode];
 			if (kp.key != KEY_UNKNOWN)
 				kp.dev = key_dev;
 		}
@@ -389,9 +390,9 @@ static void sony_laptop_report_input_event(u8 event)
 	}
 
 	if (kp.dev) {
-		input_report_key(kp.dev, kp.key, 1);
 		/* we emit the scancode so we can always remap the key */
-		input_event(kp.dev, EV_MSC, MSC_SCAN, event);
+		input_event(kp.dev, EV_MSC, MSC_SCAN, scancode);
+		input_report_key(kp.dev, kp.key, 1);
 		input_sync(kp.dev);
 
 		/* schedule key release */

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

* Re: [PATCH] to fix scancodes returned by sony-laptop driver
  2011-11-16 18:51 [PATCH] to fix scancodes returned by sony-laptop driver John Hughes
@ 2011-11-17 19:16 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2011-11-17 19:16 UTC (permalink / raw)
  To: John Hughes; +Cc: Mattia Dongili, platform-driver-x86, linux-kernel

On Wed, Nov 16, 2011 at 07:51:57PM +0100, John Hughes wrote:
> Fix scancodes returned by driver to match scancodes used to remap keys.
> 
> (Before the patch FN/E returned scancode 0x1B, but to remap scancode
> 0x14 had to be used).
> 

> The scancodes returned by the sony-laptop driver for function keys did not
> match the scancodes used to remap keys.  Also, since the scancode was sent
> to the input subsystem after the mapped keysym the /lib/udev/keymap
> utility was confused about which scancode to report for which keysym.
> 
> This patch fixes the driver so the correct scancode is shown for each
> key.  It also adds to the documentation a description of where to find
> the scancodes.
> 
> Signed-off-by: John Hughes <john@calva.com>

Acked-by: Dmitry Torokhov <dtor@mail.ru>

> 
> diff --git a/Documentation/laptops/sony-laptop.txt b/Documentation/laptops/sony-laptop.txt
> index 2bd4e82..0d5ac7f 100644
> --- a/Documentation/laptops/sony-laptop.txt
> +++ b/Documentation/laptops/sony-laptop.txt
> @@ -17,6 +17,11 @@ subsystem. See the logs of acpid or /proc/acpi/event and
>  devices are created by the driver. Additionally, loading the driver with the
>  debug option will report all events in the kernel log.
>  
> +The "scancodes" passed to the input system (that can be remapped with udev)
> +are indexes to the table "sony_laptop_input_keycode_map" in the sony-laptop.c
> +module.  For example the "FN/E" key combination (EJECTCD on some models)
> +generates the scancode 20 (0x14).
> +
>  Backlight control:
>  ------------------
>  If your laptop model supports it, you will find sysfs files in the
> diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
> index bbd182e..f148459 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -347,6 +347,7 @@ static void sony_laptop_report_input_event(u8 event)
>  	struct input_dev *jog_dev = sony_laptop_input.jog_dev;
>  	struct input_dev *key_dev = sony_laptop_input.key_dev;
>  	struct sony_laptop_keypress kp = { NULL };
> +	int scancode;
>  
>  	if (event == SONYPI_EVENT_FNKEY_RELEASED ||
>  			event == SONYPI_EVENT_ANYBUTTON_RELEASED) {
> @@ -380,8 +381,8 @@ static void sony_laptop_report_input_event(u8 event)
>  			dprintk("sony_laptop_report_input_event, event not known: %d\n", event);
>  			break;
>  		}
> -		if (sony_laptop_input_index[event] != -1) {
> -			kp.key = sony_laptop_input_keycode_map[sony_laptop_input_index[event]];
> +		if ((scancode = sony_laptop_input_index[event]) != -1) {
> +			kp.key = sony_laptop_input_keycode_map[scancode];
>  			if (kp.key != KEY_UNKNOWN)
>  				kp.dev = key_dev;
>  		}
> @@ -389,9 +390,9 @@ static void sony_laptop_report_input_event(u8 event)
>  	}
>  
>  	if (kp.dev) {
> -		input_report_key(kp.dev, kp.key, 1);
>  		/* we emit the scancode so we can always remap the key */
> -		input_event(kp.dev, EV_MSC, MSC_SCAN, event);
> +		input_event(kp.dev, EV_MSC, MSC_SCAN, scancode);
> +		input_report_key(kp.dev, kp.key, 1);
>  		input_sync(kp.dev);
>  
>  		/* schedule key release */

-- 
Dmitry

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

end of thread, other threads:[~2011-11-17 19:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-16 18:51 [PATCH] to fix scancodes returned by sony-laptop driver John Hughes
2011-11-17 19:16 ` Dmitry Torokhov

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