sony-laptop driver: Volume keys on Sony Vaio TX3 don't work
Subsystems (2)
Even though sony-laptop has code to handle the volume-up/volume-down keys they don't work. Pressing volume-down gets treated as SONYPI_EVENT_PKEY_P1 and volume-up as SONYPI_EVENT_PKEY_P2.
This is because volume-down generates event 0x01 with data mask 0x05 and although the sonypi_volumeev table exists to handle this the table sonypi_pkeyev steals the event before it gets handled.
Re-ordering the entries in the table type3_events and fixing the bug in sonypi_volumeev (up and down were inverted) makes the volume keys work.
See attached patch.
The two remaining problems are:
1. the EJECT key is mapped to FN_E
2. the MUTE key (event 5f, 31) is mapped to nothing. (Not to important as it turns the speaker off in hardware).
platform/x86/sony-laptop.c renamed from platform/x86/sony-laptop.c.orig +3 -3
@@ -1576,8 +1576,8 @@/* The set of possible volume events */ static struct sonypi_event sonypi_volumeev[] = { - {0x01 ,SONYPI_EVENT_VOLUME_INC_PRESSED }, - {0x02 ,SONYPI_EVENT_VOLUME_DEC_PRESSED }, + {0x01 ,SONYPI_EVENT_VOLUME_DEC_PRESSED }, + {0x02 ,SONYPI_EVENT_VOLUME_INC_PRESSED }, {0 ,0 } };
@@ -1624,10 +1624,10 @@ { 0x31, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev }, { 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev }, { 0x31, SONYPI_PKEY_MASK, sonypi_pkeyev }, + { 0x05, SONYPI_PKEY_MASK, sonypi_volumeev }, { 0x05, SONYPI_PKEY_MASK, sonypi_pkeyev }, { 0x05, SONYPI_ZOOM_MASK, sonypi_zoomev }, { 0x05, SONYPI_CAPTURE_MASK, sonypi_captureev }, - { 0x05, SONYPI_PKEY_MASK, sonypi_volumeev }, { 0x05, SONYPI_PKEY_MASK, sonypi_brightnessev }, { 0 }, };
Bug: changing keycodes generated by sony-laptop doesn't work
Something about the way sony-laptop sends scancodes and keycodes to the input subsystem doesn't work.
1. using the /lib/udev/keymap utility to show the scancodes and keycodes generated by the Sony Vaio keys device shows them out-of sync:
start keymap, press EJECT (mapped by sony-laptop to FN_E) twice, then AV MODE (mapped to PROG1) twice:
# /lib/udev/keymap -i input/event5
Press ESC to finish
scan code: 0x00 key code: fn_e
scan code: 0x1B key code: fn_e
scan code: 0x1B key code: prog1
scan code: 0x20 key code: prog1
^C
Notice that each time a key is pressed the scancode shown is the scancode of the previous key.
2. Changing the keycode for a given scancode has no effect:
# /lib/udev/keymap input/event5 0x1B ejectcd
setting scancode 0x1B to key code 161
# /lib/udev/keymap -i input/event5
Press ESC to finish
scan code: 0x00 key code: fn_e
scan code: 0x1B key code: fn_e
^C
Quoted 1 line · John Hughes
Even though sony-laptop has code to handle the volume-up/volume-down keys they don't work. Pressing volume-down gets treated as
SONYPI_EVENT_PKEY_P1and volume-up asSONYPI_EVENT_PKEY_P2.
And of course this bug has already been fixed. Was looking at an old version, 2.6.32, sorry.
Quoted 1 line
Re-ordering the entries in the table
type3_eventsand fixing the bug insonypi_volumeev(up and down were inverted) makes the volume keys work.
But the current head version still has the bug where volume up/volume down are switched.
Re: Bug: changing keycodes generated by sony-laptop doesn't work
In reply to John HughesQuoted 1 line · John Hughes
Something about the way sony-laptop sends scancodes and keycodes to the input subsystem doesn't work.
I forgot to say that this is in 2.6.32.
Further testing shows that it is possible to change the keycode generated for a particular scancode but that the mapping is wrong.
For example:
# /lib/udev/keymap -i input/event6 Press ESC to finish scan code: 0x00 key code: fn_e scan code: 0x1B key code: fn_e ^C # /lib/udev/keymap input/event6 0x14 ejectcd setting scancode 0x14 to key code 161 # /lib/udev/keymap -i input/event6 Press ESC to finish scan code: 0x00 key code: ejectcd scan code: 0x1B key code: ejectcd scan code: 0x1B key code: ejectcd scan code: 0x1B key code: ejectcd ^C
All the scancodes are 7 off, setting the mapping for scancode 0x14 changes the mapping for what the driver claims is scancode 0x1B.
I guess this has something to do with a confusion between the jog-dial scancodes and the Vaio keys scancodes.
Quoted 4 lines · John Hughes
Quoted 1 line · John Hughes
Even though sony-laptop has code to handle the volume-up/volume-down keys they don't work. Pressing volume-down gets treated as
SONYPI_EVENT_PKEY_P1and volume-up asSONYPI_EVENT_PKEY_P2.And of course this bug has already been fixed. Was looking at an old version, 2.6.32, sorry.
Must learn to check before writing.
No, the problem has not been fixed in head.
Here's a patch that makes the volume keys work for me. Tested on current git
# uname -a Linux carbon 3.1.0-rc9+ #2 SMP Sun Oct 16 19:14:15 CEST 2011 i686 GNU/Linux
drivers/platform/x86/sony-laptop.c +3 -3
@@ -2065,8 +2065,8 @@ static struct sonypi_event sonypi_batteryev[] = {/* The set of possible volume events */ static struct sonypi_event sonypi_volumeev[] = { - {0x01 ,SONYPI_EVENT_VOLUME_INC_PRESSED }, - {0x02 ,SONYPI_EVENT_VOLUME_DEC_PRESSED }, + {0x01 ,SONYPI_EVENT_VOLUME_DEC_PRESSED }, + {0x02 ,SONYPI_EVENT_VOLUME_INC_PRESSED }, {0 ,0 } };
@@ -2113,10 +2113,10 @@ static struct sonypi_eventtypes type3_events[] = { { 0x31, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev }, { 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev }, { 0x31, SONYPI_PKEY_MASK, sonypi_pkeyev }, + { 0x05, SONYPI_PKEY_MASK, sonypi_volumeev }, { 0x05, SONYPI_PKEY_MASK, sonypi_pkeyev }, { 0x05, SONYPI_ZOOM_MASK, sonypi_zoomev }, { 0x05, SONYPI_CAPTURE_MASK, sonypi_captureev }, - { 0x05, SONYPI_PKEY_MASK, sonypi_volumeev }, { 0x05, SONYPI_PKEY_MASK, sonypi_brightnessev }, { 0 }, };
drivers/platform/x86/sony-laptop.c
Quoted 8 lines · John Hughes
Quoted 3 lines
Quoted 3 lines
Even though sony-laptop has code to handle the volume-up/volume-down keys they don't work. Pressing volume-down gets treated as
SONYPI_EVENT_PKEY_P1and volume-up asSONYPI_EVENT_PKEY_P2.Here's a patch that makes the volume keys work for me. Tested on current git
drivers/platform/x86/sony-laptop.c +0
-0
Do we know if this is applicable to all Sony laptops, or only a few busticated models?
Mattia Dongili
maintainerQuoted 5 lines · On Sun, Oct 16, 2011 at 02:20:18PM -0400, [email protected] wrote:
Quoted 3 lines · John Hughes
Quoted 3 lines
Quoted 3 lines
Even though sony-laptop has code to handle the volume-up/volume-down keys they don't work. Pressing volume-down gets treated as
SONYPI_EVENT_PKEY_P1and volume-up asSONYPI_EVENT_PKEY_P2.
Quoted 7 lines
drivers/platform/x86/sony-laptop.c
Quoted 4 lines
Here's a patch that makes the volume keys work for me. Tested on current git
drivers/platform/x86/sony-laptop.c +0
-0Do we know if this is applicable to all Sony laptops, or only a few busticated models?
I believe the latter is the case, the old A series also had this problem. Of course applying the patch will break other models (SZ is one I'm sure about) so there is no actual winner here unless we figure out how to properly decode keys on sonypi models (this problem is specifically related to two phase hotkey decoding, see the irq handler). ...I don't have any such old laptop anymore with me.
Signature · 2 lines
mattia :wq!
Quoted 9 lines · Mattia Dongili
Quoted 2 lines · On Sun, Oct 16, 2011 at 02:20:18PM -0400, [email protected] wrote:
Do we know if this is applicable to all Sony laptops, or only a few busticated models?
I believe the latter is the case, the old A series also had this problem. Of course applying the patch will break other models (SZ is one I'm sure about) so there is no actual winner here unless we figure out how to properly decode keys on sonypi models (this problem is specifically related to two phase hotkey decoding, see the irq handler).
And let me guess - two phase hotkey decoding is sufficiently weird that nobody wants to actually fix *that* code, right? (Rhetorical question, I already know the answer to that one).
If that's not an option, perhaps we need a per-model quirk that patches up the tables at boot time? If we do that, we may want to re-arrange the table so the affected entries are at the front or something to help insure we don't patch the wrong entries if somebody else inserts new lines.
Quoted 11 lines · On 10/16/2011 08:20 PM, [email protected] wrote:
Quoted 3 lines · John Hughes
Here's a patch that makes the volume keys work for me. Tested on current git
Do we know if this is applicable to all Sony laptops, or only a few busticated models?
The current code is simply wrong. It might work by accident on some models, but.,..
(Why wrong? it says event (0x01,0x05) is PROG1, but event (0x01, 0x05) is Volume up, Make up your mind please. PS it's volume DOWN not up).
Wouldn't it be easier just to leave the decision for user mode? Make the different events generate different "scancodes" and let udev sort them out?
Quoted 5 lines · On 10/16/2011 11:50 PM, [email protected] wrote:
And let me guess - two phase hotkey decoding is sufficiently weird that nobody wants to actually fix *that* code, right? (Rhetorical question, I already know the answer to that one).
Ok, what is "two phase hotkey decoding?"
Re: Bug: changing keycodes generated by sony-laptop doesn't work
In reply to John HughesQuoted 2 lines · John Hughes
All the scancodes are 7 off, setting the mapping for scancode
0x14changes the mapping for what the driver claims is scancode0x1B.
Actually it's a bit worse than that.
The "scancodes" used by the sony-laptop driver are the indexes into sony_laptop_input_keycode_map and not the "event" codes at all.
This patch (not yet tested) should fix the scancodes reported by /lib/udev/keymap.
This just leaves a bug in the keymap files included with udev. I guess the sony-laptop file in Documentation needs to say where to find the scancodes.
drivers/platform/x86/sony-laptop.c +5 -4
@@ -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 */
Mattia Dongili
maintainerQuoted 6 lines · John Hughes
Quoted 4 lines · On 10/16/2011 11:50 PM, [email protected] wrote:
And let me guess - two phase hotkey decoding is sufficiently weird that nobody wants to actually fix *that* code, right? (Rhetorical question, I already know the answer to that one).
Ok, what is "two phase hotkey decoding?"
basically the driver receives in IRQ, reads from the IO port a value that turns out to be a generic value that means "got a hotkey" and needs to write one more command to the IO port and wait for another IRQ that potentially has the information about what hotkey was pressed.
The part we're currently missing is what to write to the IO port for some models.
See type3_handle_irq in the source and type3_events: most of those with data=0x05 require extra handling that we are not doing.
On the second IRQ you get some data=0x31 and the actual event.
Hope it's clearer.
Signature · 2 lines
mattia :wq!
Mattia Dongili
maintainerQuoted 11 lines · On Sun, Oct 16, 2011 at 05:50:13PM -0400, [email protected] wrote:
Quoted 9 lines · Mattia Dongili
Quoted 2 lines · On Sun, Oct 16, 2011 at 02:20:18PM -0400, [email protected] wrote:
Do we know if this is applicable to all Sony laptops, or only a few busticated models?
I believe the latter is the case, the old A series also had this problem. Of course applying the patch will break other models (SZ is one I'm sure about) so there is no actual winner here unless we figure out how to properly decode keys on sonypi models (this problem is specifically related to two phase hotkey decoding, see the irq handler).
Quoted 8 lines
And let me guess - two phase hotkey decoding is sufficiently weird that nobody wants to actually fix *that* code, right? (Rhetorical question, I already know the answer to that one).
If that's not an option, perhaps we need a per-model quirk that patches up the tables at boot time? If we do that, we may want to re-arrange the table so the affected entries are at the front or something to help insure we don't patch the wrong entries if somebody else inserts new lines.
Wouldn't udev do that already?
We may actually want to remove those events that never get looked up in the tables instead.
Signature · 2 lines
mattia :wq!
Quoted 9 lines · Mattia Dongili
Quoted 2 lines · John Hughes
Ok, what is "two phase hotkey decoding?"
basically the driver receives in IRQ, reads from the IO port a value that turns out to be a generic value that means "got a hotkey" and needs to write one more command to the IO port and wait for another IRQ that potentially has the information about what hotkey was pressed.
Quoted 8 lines
The part we're currently missing is what to write to the IO port for some models.
See
type3_handle_irqin the source andtype3_events: most of those with data=0x05 require extra handling that we are not doing.
On the second IRQ you get some data=0x31 and the actual event.
Oh, I see.
Poking around in the dark. What fun.
I'll see if I can think of any useful experiments.
Quoted 4 lines · Mattia Dongili
Quoted 2 lines · On Sun, Oct 16, 2011 at 05:50:13PM -0400, [email protected] wrote:
On Mon, 17 Oct 2011 06:38:01 +0900, Mattia Dongili said:
Quoted 10 lines
Quoted 5 lines
If that's not an option, perhaps we need a per-model quirk that patches up the tables at boot time? If we do that, we may want to re-arrange the table so the affected entries are at the front or something to help insure we don't patch the wrong entries if somebody else inserts new lines.
Wouldn't udev do that already?
We may actually want to remove those events that never get looked up in the tables instead.
udev does have some per-model stuff for the Vaio's.
Doesn't work right because the scancodes reported the sony-laptop driver are not the right ones.
(sony-laptop sends its "event" code as the scancode, but to change the keymap you have to use the index in the sony_laptop_input_keycode_map table. I have posted one patch for this which makes the scancodes at least consistent but I think I'll do another that makes them be the same as what current udev thinks they should be. I'll have that ready this evening I thing - have to work now :-( )
Quoted 6 lines · John Hughes
udev does have some per-model stuff for the Vaio's.
Doesn't work right because the scancodes reported the sony-laptop driver are not the right ones.
(sony-laptop sends its "event" code as the scancode, but to change the keymap you have to use the index in the
sony_laptop_input_keycode_maptable. I have posted one patch for this which makes the scancodes at least consistent but I think I'll do another that makes them be the same as what current udev thinks they should be. I'll have that ready this evening I thing - have to work now :-( )
Ok, here is a patch that makes the scancodes reported by sony-laptop be the same as the SONY_EVENT defines.
Unfortunately this doesn't work terribly well because the scancodes used by udev seem to be chosen randomly:
$ cat /lib/udev/keymaps/module-sony 0x06 mute # Fn+F2 0x07 volumedown # Fn+F3 0x08 volumeup # Fn+F4 0x09 brightnessdown # Fn+F5 0x0A brightnessup # Fn+F6 0x0B switchvideomode # Fn+F7 0x0E zoom # Fn+F10 0x10 suspend # Fn+F12
and
$ cat /lib/udev/keymaps/module-sony-vgn 0x00 brightnessdown # Fn+F5 0x10 brightnessup # Fn+F6 0x11 switchvideomode # Fn+F7 0x12 zoomout 0x14 zoomin 0x15 suspend # Fn+F12 0x17 prog1
So the different ideas are:
key module-sony module-sony-vgn orig code(*) event(*) fn_f1 0x05 0x0c fn_f2 0x06 0x06 0x0d fn_f3 0x07 0x07 0x0e fn_f4 0x08 0x08 0x0f fn_f5 0x09 0x00 (!) 0x09 0x10 fn_f6 0x0a 0x10 0x0a 0x11 fn_f7 0x0b 0x11 0x0b 0x12 fn_f8 0x0c 0x13 fn_f9 0x0d 0x14 fn_f10 0x0e 0x0e 0x15 fn_f11 0x0f 0x16 fn_f12 0x10 0x15 0x10 0x17
(*) Orig code - the scancodes that map for the original code, and the scancodes returned by my first patch (*) event - the scancodes from the patch included here.
So, it seems to me that:
1. my original patch is the smaller change, and works with the udev "module-sony" keymap file
2. this patch is prettier but doesn't work with existing userspace.
3. the poor sod who wrote the module-sony-vgn file was terribly confused by the scancodes returned by the original code.
My recommendation would be to use my first patch - it makes the driver return scancodes that correspond to the scancodes that you need to map.
OK?
Want me to do the whole formal "blablabla-by" stuff now?
drivers/platform/x86/sony-laptop.c +80 -145
@@ -177,146 +177,83 @@ struct sony_laptop_keypress { };/* Correspondance table between sonypi events -* and input layer indexes in the keymap +* and keycodes */ -static int sony_laptop_input_index[] = { --1 ,/* 0 no event */ --1 ,/* 1 SONYPI_EVENT_JOGDIAL_DOWN */ --1 ,/* 2 SONYPI_EVENT_JOGDIAL_UP */ --1 ,/* 3 SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */ --1 ,/* 4 SONYPI_EVENT_JOGDIAL_UP_PRESSED */ --1 ,/* 5 SONYPI_EVENT_JOGDIAL_PRESSED */ --1 ,/* 6 SONYPI_EVENT_JOGDIAL_RELEASED */ -0 ,/* 7 SONYPI_EVENT_CAPTURE_PRESSED */ -1 ,/* 8 SONYPI_EVENT_CAPTURE_RELEASED */ -2 ,/* 9 SONYPI_EVENT_CAPTURE_PARTIALPRESSED */ -3 ,/* 10 SONYPI_EVENT_CAPTURE_PARTIALRELEASED */ -4 ,/* 11 SONYPI_EVENT_FNKEY_ESC */ -5 ,/* 12 SONYPI_EVENT_FNKEY_F1 */ -6 ,/* 13 SONYPI_EVENT_FNKEY_F2 */ -7 ,/* 14 SONYPI_EVENT_FNKEY_F3 */ -8 ,/* 15 SONYPI_EVENT_FNKEY_F4 */ -9 ,/* 16 SONYPI_EVENT_FNKEY_F5 */ -10 ,/* 17 SONYPI_EVENT_FNKEY_F6 */ -11 ,/* 18 SONYPI_EVENT_FNKEY_F7 */ -12 ,/* 19 SONYPI_EVENT_FNKEY_F8 */ -13 ,/* 20 SONYPI_EVENT_FNKEY_F9 */ -14 ,/* 21 SONYPI_EVENT_FNKEY_F10 */ -15 ,/* 22 SONYPI_EVENT_FNKEY_F11 */ -16 ,/* 23 SONYPI_EVENT_FNKEY_F12 */ -17 ,/* 24 SONYPI_EVENT_FNKEY_1 */ -18 ,/* 25 SONYPI_EVENT_FNKEY_2 */ -19 ,/* 26 SONYPI_EVENT_FNKEY_D */ -20 ,/* 27 SONYPI_EVENT_FNKEY_E */ -21 ,/* 28 SONYPI_EVENT_FNKEY_F */ -22 ,/* 29 SONYPI_EVENT_FNKEY_S */ -23 ,/* 30 SONYPI_EVENT_FNKEY_B */ -24 ,/* 31 SONYPI_EVENT_BLUETOOTH_PRESSED */ -25 ,/* 32 SONYPI_EVENT_PKEY_P1 */ -26 ,/* 33 SONYPI_EVENT_PKEY_P2 */ -27 ,/* 34 SONYPI_EVENT_PKEY_P3 */ -28 ,/* 35 SONYPI_EVENT_BACK_PRESSED */ --1 ,/* 36 SONYPI_EVENT_LID_CLOSED */ --1 ,/* 37 SONYPI_EVENT_LID_OPENED */ -29 ,/* 38 SONYPI_EVENT_BLUETOOTH_ON */ -30 ,/* 39 SONYPI_EVENT_BLUETOOTH_OFF */ -31 ,/* 40 SONYPI_EVENT_HELP_PRESSED */ -32 ,/* 41 SONYPI_EVENT_FNKEY_ONLY */ -33 ,/* 42 SONYPI_EVENT_JOGDIAL_FAST_DOWN */ -34 ,/* 43 SONYPI_EVENT_JOGDIAL_FAST_UP */ -35 ,/* 44 SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */ -36 ,/* 45 SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */ -37 ,/* 46 SONYPI_EVENT_JOGDIAL_VFAST_DOWN */ -38 ,/* 47 SONYPI_EVENT_JOGDIAL_VFAST_UP */ -39 ,/* 48 SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */ -40 ,/* 49 SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */ -41 ,/* 50 SONYPI_EVENT_ZOOM_PRESSED */ -42 ,/* 51 SONYPI_EVENT_THUMBPHRASE_PRESSED */ -43 ,/* 52 SONYPI_EVENT_MEYE_FACE */ -44 ,/* 53 SONYPI_EVENT_MEYE_OPPOSITE */ -45 ,/* 54 SONYPI_EVENT_MEMORYSTICK_INSERT */ -46 ,/* 55 SONYPI_EVENT_MEMORYSTICK_EJECT */ --1 ,/* 56 SONYPI_EVENT_ANYBUTTON_RELEASED */ --1 ,/* 57 SONYPI_EVENT_BATTERY_INSERT */ --1 ,/* 58 SONYPI_EVENT_BATTERY_REMOVE */ --1 ,/* 59 SONYPI_EVENT_FNKEY_RELEASED */ -47 ,/* 60 SONYPI_EVENT_WIRELESS_ON */ -48 ,/* 61 SONYPI_EVENT_WIRELESS_OFF */ -49 ,/* 62 SONYPI_EVENT_ZOOM_IN_PRESSED */ -50 ,/* 63 SONYPI_EVENT_ZOOM_OUT_PRESSED */ -51 ,/* 64 SONYPI_EVENT_CD_EJECT_PRESSED */ -52 ,/* 65 SONYPI_EVENT_MODEKEY_PRESSED */ -53 ,/* 66 SONYPI_EVENT_PKEY_P4 */ -54 ,/* 67 SONYPI_EVENT_PKEY_P5 */ -55 ,/* 68 SONYPI_EVENT_SETTINGKEY_PRESSED */ -56 ,/* 69 SONYPI_EVENT_VOLUME_INC_PRESSED */ -57 ,/* 70 SONYPI_EVENT_VOLUME_DEC_PRESSED */ --1 ,/* 71 SONYPI_EVENT_BRIGHTNESS_PRESSED */ -58 ,/* 72 SONYPI_EVENT_MEDIA_PRESSED */ -59 ,/* 72 SONYPI_EVENT_VENDOR_PRESSED */ -}; -static int sony_laptop_input_keycode_map[] = { -KEY_CAMERA ,/* 0 SONYPI_EVENT_CAPTURE_PRESSED */ -KEY_RESERVED ,/* 1 SONYPI_EVENT_CAPTURE_RELEASED */ -KEY_RESERVED ,/* 2 SONYPI_EVENT_CAPTURE_PARTIALPRESSED */ -KEY_RESERVED ,/* 3 SONYPI_EVENT_CAPTURE_PARTIALRELEASED */ -KEY_FN_ESC ,/* 4 SONYPI_EVENT_FNKEY_ESC */ -KEY_FN_F1 ,/* 5 SONYPI_EVENT_FNKEY_F1 */ -KEY_FN_F2 ,/* 6 SONYPI_EVENT_FNKEY_F2 */ -KEY_FN_F3 ,/* 7 SONYPI_EVENT_FNKEY_F3 */ -KEY_FN_F4 ,/* 8 SONYPI_EVENT_FNKEY_F4 */ -KEY_FN_F5 ,/* 9 SONYPI_EVENT_FNKEY_F5 */ -KEY_FN_F6 ,/* 10 SONYPI_EVENT_FNKEY_F6 */ -KEY_FN_F7 ,/* 11 SONYPI_EVENT_FNKEY_F7 */ -KEY_FN_F8 ,/* 12 SONYPI_EVENT_FNKEY_F8 */ -KEY_FN_F9 ,/* 13 SONYPI_EVENT_FNKEY_F9 */ -KEY_FN_F10 ,/* 14 SONYPI_EVENT_FNKEY_F10 */ -KEY_FN_F11 ,/* 15 SONYPI_EVENT_FNKEY_F11 */ -KEY_FN_F12 ,/* 16 SONYPI_EVENT_FNKEY_F12 */ -KEY_FN_F1 ,/* 17 SONYPI_EVENT_FNKEY_1 */ -KEY_FN_F2 ,/* 18 SONYPI_EVENT_FNKEY_2 */ -KEY_FN_D ,/* 19 SONYPI_EVENT_FNKEY_D */ -KEY_FN_E ,/* 20 SONYPI_EVENT_FNKEY_E */ -KEY_FN_F ,/* 21 SONYPI_EVENT_FNKEY_F */ -KEY_FN_S ,/* 22 SONYPI_EVENT_FNKEY_S */ -KEY_FN_B ,/* 23 SONYPI_EVENT_FNKEY_B */ -KEY_BLUETOOTH ,/* 24 SONYPI_EVENT_BLUETOOTH_PRESSED */ -KEY_PROG1 ,/* 25 SONYPI_EVENT_PKEY_P1 */ -KEY_PROG2 ,/* 26 SONYPI_EVENT_PKEY_P2 */ -KEY_PROG3 ,/* 27 SONYPI_EVENT_PKEY_P3 */ -KEY_BACK ,/* 28 SONYPI_EVENT_BACK_PRESSED */ -KEY_BLUETOOTH ,/* 29 SONYPI_EVENT_BLUETOOTH_ON */ -KEY_BLUETOOTH ,/* 30 SONYPI_EVENT_BLUETOOTH_OFF */ -KEY_HELP ,/* 31 SONYPI_EVENT_HELP_PRESSED */ -KEY_FN ,/* 32 SONYPI_EVENT_FNKEY_ONLY */ -KEY_RESERVED ,/* 33 SONYPI_EVENT_JOGDIAL_FAST_DOWN */ -KEY_RESERVED ,/* 34 SONYPI_EVENT_JOGDIAL_FAST_UP */ -KEY_RESERVED ,/* 35 SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */ -KEY_RESERVED ,/* 36 SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */ -KEY_RESERVED ,/* 37 SONYPI_EVENT_JOGDIAL_VFAST_DOWN */ -KEY_RESERVED ,/* 38 SONYPI_EVENT_JOGDIAL_VFAST_UP */ -KEY_RESERVED ,/* 39 SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */ -KEY_RESERVED ,/* 40 SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */ -KEY_ZOOM ,/* 41 SONYPI_EVENT_ZOOM_PRESSED */ -BTN_THUMB ,/* 42 SONYPI_EVENT_THUMBPHRASE_PRESSED */ -KEY_RESERVED ,/* 43 SONYPI_EVENT_MEYE_FACE */ -KEY_RESERVED ,/* 44 SONYPI_EVENT_MEYE_OPPOSITE */ -KEY_RESERVED ,/* 45 SONYPI_EVENT_MEMORYSTICK_INSERT */ -KEY_RESERVED ,/* 46 SONYPI_EVENT_MEMORYSTICK_EJECT */ -KEY_WLAN ,/* 47 SONYPI_EVENT_WIRELESS_ON */ -KEY_WLAN ,/* 48 SONYPI_EVENT_WIRELESS_OFF */ -KEY_ZOOMIN ,/* 49 SONYPI_EVENT_ZOOM_IN_PRESSED */ -KEY_ZOOMOUT ,/* 50 SONYPI_EVENT_ZOOM_OUT_PRESSED */ -KEY_EJECTCD ,/* 51 SONYPI_EVENT_CD_EJECT_PRESSED */ -KEY_F13 ,/* 52 SONYPI_EVENT_MODEKEY_PRESSED */ -KEY_PROG4 ,/* 53 SONYPI_EVENT_PKEY_P4 */ -KEY_F14 ,/* 54 SONYPI_EVENT_PKEY_P5 */ -KEY_F15 ,/* 55 SONYPI_EVENT_SETTINGKEY_PRESSED */ -KEY_VOLUMEUP ,/* 56 SONYPI_EVENT_VOLUME_INC_PRESSED */ -KEY_VOLUMEDOWN ,/* 57 SONYPI_EVENT_VOLUME_DEC_PRESSED */ -KEY_MEDIA ,/* 58 SONYPI_EVENT_MEDIA_PRESSED */ -KEY_VENDOR ,/* 59 SONYPI_EVENT_VENDOR_PRESSED */ +KEY_UNKNOWN ,/* 0 no event */ +KEY_UNKNOWN ,/* 1 SONYPI_EVENT_JOGDIAL_DOWN */ +KEY_UNKNOWN ,/* 2 SONYPI_EVENT_JOGDIAL_UP */ +KEY_UNKNOWN ,/* 3 SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */ +KEY_UNKNOWN ,/* 4 SONYPI_EVENT_JOGDIAL_UP_PRESSED */ +KEY_UNKNOWN ,/* 5 SONYPI_EVENT_JOGDIAL_PRESSED */ +KEY_UNKNOWN ,/* 6 SONYPI_EVENT_JOGDIAL_RELEASED */ +KEY_CAMERA ,/* 7 SONYPI_EVENT_CAPTURE_PRESSED */ +KEY_RESERVED ,/* 8 SONYPI_EVENT_CAPTURE_RELEASED */ +KEY_RESERVED ,/* 9 SONYPI_EVENT_CAPTURE_PARTIALPRESSED */ +KEY_RESERVED ,/* 10 SONYPI_EVENT_CAPTURE_PARTIALRELEASED */ +KEY_FN_ESC ,/* 11 SONYPI_EVENT_FNKEY_ESC */ +KEY_FN_F1 ,/* 12 SONYPI_EVENT_FNKEY_F1 */ +KEY_FN_F2 ,/* 13 SONYPI_EVENT_FNKEY_F2 */ +KEY_FN_F3 ,/* 14 SONYPI_EVENT_FNKEY_F3 */ +KEY_FN_F4 ,/* 15 SONYPI_EVENT_FNKEY_F4 */ +KEY_FN_F5 ,/* 16 SONYPI_EVENT_FNKEY_F5 */ +KEY_FN_F6 ,/* 17 SONYPI_EVENT_FNKEY_F6 */ +KEY_FN_F7 ,/* 18 SONYPI_EVENT_FNKEY_F7 */ +KEY_FN_F8 ,/* 19 SONYPI_EVENT_FNKEY_F8 */ +KEY_FN_F9 ,/* 20 SONYPI_EVENT_FNKEY_F9 */ +KEY_FN_F10 ,/* 21 SONYPI_EVENT_FNKEY_F10 */ +KEY_FN_F11 ,/* 22 SONYPI_EVENT_FNKEY_F11 */ +KEY_FN_F12 ,/* 23 SONYPI_EVENT_FNKEY_F12 */ +KEY_FN_F1 ,/* 24 SONYPI_EVENT_FNKEY_1 */ +KEY_FN_F2 ,/* 25 SONYPI_EVENT_FNKEY_2 */ +KEY_FN_D ,/* 26 SONYPI_EVENT_FNKEY_D */ +KEY_FN_E ,/* 27 SONYPI_EVENT_FNKEY_E */ +KEY_FN_F ,/* 28 SONYPI_EVENT_FNKEY_F */ +KEY_FN_S ,/* 29 SONYPI_EVENT_FNKEY_S */ +KEY_FN_B ,/* 30 SONYPI_EVENT_FNKEY_B */ +KEY_BLUETOOTH ,/* 31 SONYPI_EVENT_BLUETOOTH_PRESSED */ +KEY_PROG1 ,/* 32 SONYPI_EVENT_PKEY_P1 */ +KEY_PROG2 ,/* 33 SONYPI_EVENT_PKEY_P2 */ +KEY_PROG3 ,/* 34 SONYPI_EVENT_PKEY_P3 */ +KEY_BACK ,/* 35 SONYPI_EVENT_BACK_PRESSED */ +KEY_UNKNOWN ,/* 36 SONYPI_EVENT_LID_CLOSED */ +KEY_UNKNOWN ,/* 37 SONYPI_EVENT_LID_OPENED */ +KEY_BLUETOOTH ,/* 38 SONYPI_EVENT_BLUETOOTH_ON */ +KEY_BLUETOOTH ,/* 39 SONYPI_EVENT_BLUETOOTH_OFF */ +KEY_HELP ,/* 40 SONYPI_EVENT_HELP_PRESSED */ +KEY_FN ,/* 41 SONYPI_EVENT_FNKEY_ONLY */ +KEY_RESERVED ,/* 42 SONYPI_EVENT_JOGDIAL_FAST_DOWN */ +KEY_RESERVED ,/* 43 SONYPI_EVENT_JOGDIAL_FAST_UP */ +KEY_RESERVED ,/* 44 SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */ +KEY_RESERVED ,/* 45 SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */ +KEY_RESERVED ,/* 46 SONYPI_EVENT_JOGDIAL_VFAST_DOWN */ +KEY_RESERVED ,/* 47 SONYPI_EVENT_JOGDIAL_VFAST_UP */ +KEY_RESERVED ,/* 48 SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */ +KEY_RESERVED ,/* 49 SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */ +KEY_ZOOM ,/* 50 SONYPI_EVENT_ZOOM_PRESSED */ +BTN_THUMB ,/* 51 SONYPI_EVENT_THUMBPHRASE_PRESSED */ +KEY_RESERVED ,/* 52 SONYPI_EVENT_MEYE_FACE */ +KEY_RESERVED ,/* 53 SONYPI_EVENT_MEYE_OPPOSITE */ +KEY_RESERVED ,/* 54 SONYPI_EVENT_MEMORYSTICK_INSERT */ +KEY_RESERVED ,/* 55 SONYPI_EVENT_MEMORYSTICK_EJECT */ +KEY_UNKNOWN ,/* 56 SONYPI_EVENT_ANYBUTTON_RELEASED */ +KEY_UNKNOWN ,/* 57 SONYPI_EVENT_BATTERY_INSERT */ +KEY_UNKNOWN ,/* 58 SONYPI_EVENT_BATTERY_REMOVE */ +KEY_UNKNOWN ,/* 59 SONYPI_EVENT_FNKEY_RELEASED */ +KEY_WLAN ,/* 60 SONYPI_EVENT_WIRELESS_ON */ +KEY_WLAN ,/* 61 SONYPI_EVENT_WIRELESS_OFF */ +KEY_ZOOMIN ,/* 62 SONYPI_EVENT_ZOOM_IN_PRESSED */ +KEY_ZOOMOUT ,/* 63 SONYPI_EVENT_ZOOM_OUT_PRESSED */ +KEY_EJECTCD ,/* 64 SONYPI_EVENT_CD_EJECT_PRESSED */ +KEY_F13 ,/* 65 SONYPI_EVENT_MODEKEY_PRESSED */ +KEY_PROG4 ,/* 66 SONYPI_EVENT_PKEY_P4 */ +KEY_F14 ,/* 67 SONYPI_EVENT_PKEY_P5 */ +KEY_F15 ,/* 68 SONYPI_EVENT_SETTINGKEY_PRESSED */ +KEY_VOLUMEUP ,/* 69 SONYPI_EVENT_VOLUME_INC_PRESSED */ +KEY_VOLUMEDOWN ,/* 70 SONYPI_EVENT_VOLUME_DEC_PRESSED */ +KEY_UNKNOWN ,/* 71 SONYPI_EVENT_BRIGHTNESS_PRESSED */ +KEY_MEDIA ,/* 72 SONYPI_EVENT_MEDIA_PRESSED */ +KEY_VENDOR ,/* 72 SONYPI_EVENT_VENDOR_PRESSED */ };/* release buttons after a short delay if pressed */
@@ -376,22 +313,20 @@ static void sony_laptop_report_input_event(u8 event)break ;default : -if (event >=ARRAY_SIZE (sony_laptop_input_index)) { +if (event >=ARRAY_SIZE (sony_laptop_input_keycode_map)) {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 (kp.key !=KEY_UNKNOWN ) - kp.dev = key_dev; - } + kp.key = sony_laptop_input_keycode_map[event]; +if (kp.key !=KEY_UNKNOWN && kp.key !=KEY_RESERVED ) + kp.dev = key_dev;break ; }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_report_key (kp.dev, kp.key,1 );input_sync (kp.dev);/* schedule key release */