Bug 69761 - Toshiba Satellite M840 - Wrong Key Mapping
Summary: Toshiba Satellite M840 - Wrong Key Mapping
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Platform_x86 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_platform_x86@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-31 13:14 UTC by Fede
Modified: 2017-09-19 01:04 UTC (History)
3 users (show)

See Also:
Kernel Version: 3.13.0-9
Subsystem:
Regression: No
Bisected commit-id:


Attachments
dmidecode output (18.63 KB, application/octet-stream)
2014-04-15 23:31 UTC, Fede
Details
Fix patch (2.75 KB, patch)
2014-04-16 06:21 UTC, Takashi Iwai
Details | Diff

Description Fede 2014-01-31 13:14:58 UTC
I have a Toshiba M840 and a few (not all) the FN+FX key mappings are wrong. Here below is a table showing how the key mapping should be and what is actually happening when you press the key combination:

Key combination|What should be        |What it does
FN+F2          |lower brightness      |Battery
FN+F3          |increases brightness  |Sleep
FN+F4          |switch video output   |Suspend
FN+F5          |touchpad ON/OFF       |Display
FN+F6          |Audio Previous        |Audio Previous
FN+F7          |Audio Play            |Audio Play
FN+F8          |Audio Next            |Audio Next
FN+F9          |Audio Lower Volume    |Audio Lower Volume
FN+F10         |Audio Raise Volume    |Audio Raise Volume
FN+F11         |Audio Mute ON/OFF     |0xf8
FN+F12         |Wireless ON/OFF Switch|0xf8


=============
01: None 00.0: 10105 BIOS                                       
  [Created at bios.186]
  Unique ID: rdCR.lZF+r4EgHp4
  Hardware Class: bios
  BIOS Keyboard LED Status:
    Scroll Lock: off
    Num Lock: off
    Caps Lock: off
  Config Status: cfg=no, avail=yes, need=no, active=unknown
=============

If you need other hardware details please do let me know.

Thanks

Federico
Comment 1 Fede 2014-01-31 13:17:09 UTC
I was requested to create this bug at:

https://bugzilla.novell.com/show_bug.cgi?id=812209

Here is more information:

hwinfo --keyboard
25: PS/2 00.0: 10800 Keyboard                                   
  [Created at input.226]
  Unique ID: nLyy.+49ps10DtUF
  Hardware Class: keyboard
  Model: "AT Translated Set 2 keyboard"
  Vendor: 0x0001 
  Device: 0x0001 "AT Translated Set 2 keyboard"
  Compatible to: int 0x0211 0x0001
  Device File: /dev/input/event0
  Device Files: /dev/input/event0, /dev/input/by-path/platform-i8042-serio-0-event-kbd
  Device Number: char 13:64
  Driver Info #0:
    XkbRules: xfree86
    XkbModel: pc104
  Config Status: cfg=no, avail=yes, need=no, active=unknown
Comment 2 Dmitry Torokhov 2014-01-31 17:07:10 UTC
They were wrong to request it - such keyboard mapping tweaks should be applied from userspace by udev, not in kernel.
Comment 3 Fede 2014-02-01 04:06:47 UTC
Ok, I'll get back to them. Thanks.
Comment 4 Takashi Iwai 2014-04-07 08:07:38 UTC
This looks like an incorrect keymap in toshiba_acpi, judging from the output seen in the bugzilla entry above.  The evtest shows that the driver already provides the key codes but just gives a wrong value.  If so, the kernel should be fixed instead of udev hwdb.

Federico, could you give the whole list of scancode <-> keycode mapping on your machine for the keys defined in drivers/platform/x86/toshiba_acpi.c?
Also check which ACPI device ID corresponds to ("TOS6200", "TOS6208", "TOS1900").  It appears in sysfs, /sys/bus/acpi/devices/*.
Comment 5 Dmitry Torokhov 2014-04-07 22:38:36 UTC
OK, if the keys in question are handled by toshiba_acpi then we need to bounce this bug to platform devices guys.
Comment 6 Fede 2014-04-08 03:27:24 UTC
I believe below is the info you need, if I have missed something or got something wrong please let me know:

1. Just for your reference, since this might be a new Toshiba keyboard layout, this is how it looks like:
http://www.acompatible.com/2204-7866-thickbox/toshiba-satellite-m840-keyboard-protector-skin-cover-us-layout.jpg


2. This is the list of ACPI devices under /sys/bus/acpi/devices/ matching TOS*.

lrwxrwxrwx 1 root root 0 Apr  8 09:23 TOS0310:00 -> ../../../devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/TOS0310:00/
lrwxrwxrwx 1 root root 0 Apr  8 09:23 TOS1102:00 -> ../../../devices/LNXSYSTM:00/device:00/PNP0A08:00/device:02/TOS1102:00/
lrwxrwxrwx 1 root root 0 Apr  8 09:23 TOS1900:00 -> ../../../devices/LNXSYSTM:00/device:00/TOS1900:00/
lrwxrwxrwx 1 root root 0 Apr  8 09:23 TOS6205:00 -> ../../../devices/LNXSYSTM:00/device:00/TOS6205:00/

3. A few FN+<Key> combination show under event0 and a few under event7, here is the output of evtest for both inputs:

a. evtest /dev/input/event0

Input driver version is 1.0.1
Input device ID: bus 0x11 vendor 0x1 product 0x1 version 0xab41
Input device name: "AT Translated Set 2 keyboard"
Supported events:
  Event type 0 (Sync)
  Event type 1 (Key)
    Event code 1 (Esc)
    Event code 2 (1)
    Event code 3 (2)
    Event code 4 (3)
    Event code 5 (4)
    Event code 6 (5)
    Event code 7 (6)
    Event code 8 (7)
    Event code 9 (8)
    Event code 10 (9)
    Event code 11 (0)
    Event code 12 (Minus)
    Event code 13 (Equal)
    Event code 14 (Backspace)
    Event code 15 (Tab)
    Event code 16 (Q)
    Event code 17 (W)
    Event code 18 (E)
    Event code 19 (R)
    Event code 20 (T)
    Event code 21 (Y)
    Event code 22 (U)
    Event code 23 (I)
    Event code 24 (O)
    Event code 25 (P)
    Event code 26 (LeftBrace)
    Event code 27 (RightBrace)
    Event code 28 (Enter)
    Event code 29 (LeftControl)
    Event code 30 (A)
    Event code 31 (S)
    Event code 32 (D)
    Event code 33 (F)
    Event code 34 (G)
    Event code 35 (H)
    Event code 36 (J)
    Event code 37 (K)
    Event code 38 (L)
    Event code 39 (Semicolon)
    Event code 40 (Apostrophe)
    Event code 41 (Grave)
    Event code 42 (LeftShift)
    Event code 43 (BackSlash)
    Event code 44 (Z)
    Event code 45 (X)
    Event code 46 (C)
    Event code 47 (V)
    Event code 48 (B)
    Event code 49 (N)
    Event code 50 (M)
    Event code 51 (Comma)
    Event code 52 (Dot)
    Event code 53 (Slash)
    Event code 54 (RightShift)
    Event code 55 (KPAsterisk)
    Event code 56 (LeftAlt)
    Event code 57 (Space)
    Event code 58 (CapsLock)
    Event code 59 (F1)
    Event code 60 (F2)
    Event code 61 (F3)
    Event code 62 (F4)
    Event code 63 (F5)
    Event code 64 (F6)
    Event code 65 (F7)
    Event code 66 (F8)
    Event code 67 (F9)
    Event code 68 (F10)
    Event code 69 (NumLock)
    Event code 70 (ScrollLock)
    Event code 71 (KP7)
    Event code 72 (KP8)
    Event code 73 (KP9)
    Event code 74 (KPMinus)
    Event code 75 (KP4)
    Event code 76 (KP5)
    Event code 77 (KP6)
    Event code 78 (KPPlus)
    Event code 79 (KP1)
    Event code 80 (KP2)
    Event code 81 (KP3)
    Event code 82 (KP0)
    Event code 83 (KPDot)
    Event code 85 (Zenkaku/Hankaku)
    Event code 86 (102nd)
    Event code 87 (F11)
    Event code 88 (F12)
    Event code 89 (RO)
    Event code 90 (Katakana)
    Event code 91 (HIRAGANA)
    Event code 92 (Henkan)
    Event code 93 (Katakana/Hiragana)
    Event code 94 (Muhenkan)
    Event code 95 (KPJpComma)
    Event code 96 (KPEnter)
    Event code 97 (RightCtrl)
    Event code 98 (KPSlash)
    Event code 99 (SysRq)
    Event code 100 (RightAlt)
    Event code 102 (Home)
    Event code 103 (Up)
    Event code 104 (PageUp)
    Event code 105 (Left)
    Event code 106 (Right)
    Event code 107 (End)
    Event code 108 (Down)
    Event code 109 (PageDown)
    Event code 110 (Insert)
    Event code 111 (Delete)
    Event code 112 (Macro)
    Event code 113 (Mute)
    Event code 114 (VolumeDown)
    Event code 115 (VolumeUp)
    Event code 116 (Power)
    Event code 117 (KPEqual)
    Event code 118 (KPPlusMinus)
    Event code 119 (Pause)
    Event code 121 (KPComma)
    Event code 122 (Hanguel)
    Event code 123 (Hanja)
    Event code 124 (Yen)
    Event code 125 (LeftMeta)
    Event code 126 (RightMeta)
    Event code 127 (Compose)
    Event code 128 (Stop)
    Event code 140 (Calc)
    Event code 142 (Sleep)
    Event code 143 (WakeUp)
    Event code 155 (Mail)
    Event code 156 (Bookmarks)
    Event code 157 (Computer)
    Event code 158 (Back)
    Event code 159 (Forward)
    Event code 163 (NextSong)
    Event code 164 (PlayPause)
    Event code 165 (PreviousSong)
    Event code 166 (StopCD)
    Event code 172 (HomePage)
    Event code 173 (Refresh)
    Event code 183 (F13)
    Event code 184 (F14)
    Event code 185 (F15)
    Event code 191 (F21)
    Event code 217 (Search)
    Event code 224 (Brightness down)
    Event code 225 (Brightness up)
    Event code 226 (Media)
    Event code 227 (?)
    Event code 238 (?)
  Event type 4 (Misc)
    Event code 4 (ScanCode)
  Event type 17 (LED)
    Event code 0 (NumLock)
    Event code 1 (CapsLock)
    Event code 2 (ScrollLock)
  Event type 20 (Repeat)
Testing ... (interrupt to exit)


b. evtest /dev/input/event7
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0
Input device name: "Toshiba input device"
Supported events:
  Event type 0 (Sync)
  Event type 1 (Key)
    Event code 113 (Mute)
    Event code 128 (Stop)
    Event code 142 (Sleep)
    Event code 149 (Prog2)
    Event code 150 (WWW)
    Event code 152 (Coffee)
    Event code 155 (Mail)
    Event code 163 (NextSong)
    Event code 164 (PlayPause)
    Event code 165 (PreviousSong)
    Event code 205 (Suspend)
    Event code 224 (Brightness down)
    Event code 225 (Brightness up)
    Event code 226 (Media)
    Event code 227 (?)
    Event code 228 (?)
    Event code 236 (?)
    Event code 238 (?)
    Event code 240 (Unknown)
    Event code 418 (?)
    Event code 419 (?)
    Event code 420 (?)
    Event code 464 (?)
    Event code 530 (?)
  Event type 4 (Misc)
    Event code 4 (ScanCode)
Testing ... (interrupt to exit)


4. Here below is the list I was able to match from the list shown in toshiba_acpi.c by using evtest. I have placed a remark when the key combination was triggered on event0 or event7. If this is not what you wanted, please let me know.

Here is the list of matches from toshiba_acpi.c to my laptop:

KEY_MUTE (event7):	 	type 4 (Misc), code 4 (ScanCode), value 157
				type 1 (Key), code 240 (Unknown), value 1
KEY_ZOOMOUT (event7):		type 4 (Misc), code 4 (ScanCode), value 102
				type 1 (Key), code 419 (?), value 1
KEY_ZOOMIN (event7):		type 4 (Misc), code 4 (ScanCode), value 103
				type 1 (Key), code 418 (?), value 1
KEY_KBDILLUMTOGGLE: I do not have this key
KEY_ZOOMRESET (event7, not really a key for this but FN+Space is supposed to change the screen resolution. Since we don't have a function for that, I guess it could be assigned for zoom reset, up to you):
				type 4 (Misc), code 4 (ScanCode), value 139
				type 1 (Key), code 420 (?), value 1
KEY_COFFEE: I do not have this key 
KEY_BATTERY: I do not have this key
KEY_SLEEP: I do not have this key
KEY_SUSPEND: I do not have this key
KEY_SWITCHVIDEOMODE (event7):	type 4 (Misc), code 4 (ScanCode), value 13e
				type 1 (Key), code 205 (Suspend), value 1
KEY_BRIGHTNESSDOWN (event7):	type 4 (Misc), code 4 (ScanCode), value 13c
				type 1 (Key), code 236 (?), value 1
KEY_BRIGHTNESSUP (event7):	type 4 (Misc), code 4 (ScanCode), value 13d
				type 1 (Key), code 142 (Sleep), value 1
KEY_WLAN (event7):		type 4 (Misc), code 4 (ScanCode), value 158
				type 1 (Key), code 240 (Unknown), value 1
KEY_TOUCHPAD_TOGGLE (event7):	type 4 (Misc), code 4 (ScanCode), value 13f
				type 1 (Key), code 227 (?), value 1
KEY_FN:
KEY_PROG2: I do not have this key
KEY_WWW: I do not have this key
KEY_MAIL: I do not have this key
KEY_STOP: I do not have this key
KEY_PREVIOUSSONG (event0):	type 4 (Misc), code 4 (ScanCode), value 90
				type 1 (Key), code 165 (PreviousSong), value 1
KEY_NEXTSONG (event0):		type 4 (Misc), code 4 (ScanCode), value 99
				type 1 (Key), code 163 (NextSong), value 0
KEY_PLAYPAUSE (event0): 	type 4 (Misc), code 4 (ScanCode), value a2
				type 1 (Key), code 164 (PlayPause), value 0
KEY_MEDIA: I do not have this key
KEY_RESERVED:
KE_END:

I notice the volume keys are not mentioned in the list here they are anyway:

VolumeDown (event0):		type 4 (Misc), code 4 (ScanCode), value ae
				type 1 (Key), code 114 (VolumeDown), value 0

VolumeUP (event0):		type 4 (Misc), code 4 (ScanCode), value b0
				type 1 (Key), code 115 (VolumeUp), value 0
Comment 7 Takashi Iwai 2014-04-15 15:46:39 UTC
OK, so the key map is completely different from the defined one.
Providing the new keymap itself should be easy, but a remaining question is in which condition an alternative keymap has to be applied.  As TOS1900 has been added from the very beginning, even before year 2008, it's not specific to TOS1900 binding.

I guess a safer option at this moment is to apply the alternative keymap based on DMI string matches.  Could you give the output of dmidecode?  Then I can provide you a test patch in return.
Comment 8 Fede 2014-04-15 23:31:13 UTC
Created attachment 132401 [details]
dmidecode output
Comment 9 Fede 2014-04-15 23:33:20 UTC
Hi Takashi, I have attached the output of dmidecode to the case.
Comment 10 Takashi Iwai 2014-04-16 06:21:01 UTC
Could you try the patch below?
Comment 11 Takashi Iwai 2014-04-16 06:21:58 UTC
Created attachment 132431 [details]
Fix patch
Comment 12 Fede 2014-04-20 12:31:50 UTC
Thanks for the patch Takashi. Most of the keys are working except for Zoom (In/Out/Reset) and Touchpad Toggle. While I couldn't test the video output yet (will do so soon), Gnome does recognize the key as 'Display'.

In Gnome, the key shortcut tool does not receive any input for the keys which are not working yet (the others you fix are working and the tool does recognize them correctly).

I'm not really concerned about the Zoom keys (while it be great to have them working). The touchpad toggle on the other hand, would be useful to get it to work.

Here is the output from evtest, please let me know what else you may need:

# evtest /dev/input/event7
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0
Input device name: "Toshiba input device"
Supported events:
  Event type 0 (Sync)
  Event type 1 (Key)
    Event code 113 (Mute)
    Event code 224 (Brightness down)
    Event code 225 (Brightness up)
    Event code 227 (?)
    Event code 238 (?)
    Event code 240 (Unknown)
    Event code 418 (?)
    Event code 419 (?)
    Event code 420 (?)
    Event code 530 (?)
  Event type 4 (Misc)
    Event code 4 (ScanCode)
Testing ... (interrupt to exit)


Zoom Out:

Event: time 1397995790.766515, type 4 (Misc), code 4 (ScanCode), value 102
Event: time 1397995790.766515, type 1 (Key), code 419 (?), value 1
Event: time 1397995790.766515, -------------- Report Sync ------------
Event: time 1397995790.766532, type 1 (Key), code 419 (?), value 0
Event: time 1397995790.766532, -------------- Report Sync ------------


Zoom In:

Event: time 1397995824.466953, type 4 (Misc), code 4 (ScanCode), value 103
Event: time 1397995824.466953, type 1 (Key), code 418 (?), value 1
Event: time 1397995824.466953, -------------- Report Sync ------------
Event: time 1397995824.466969, type 1 (Key), code 418 (?), value 0
Event: time 1397995824.466969, -------------- Report Sync ------------

Zoom Reset:

Event: time 1397995965.861597, type 4 (Misc), code 4 (ScanCode), value 139
Event: time 1397995965.861597, type 1 (Key), code 420 (?), value 1
Event: time 1397995965.861597, -------------- Report Sync ------------
Event: time 1397995965.861615, type 1 (Key), code 420 (?), value 0
Event: time 1397995965.861615, -------------- Report Sync ------------

Touchpad Toggle:

Event: time 1397995855.833966, type 4 (Misc), code 4 (ScanCode), value 13f
Event: time 1397995855.833966, type 1 (Key), code 530 (?), value 1
Event: time 1397995855.833966, -------------- Report Sync ------------
Event: time 1397995855.833984, type 1 (Key), code 530 (?), value 0
Event: time 1397995855.833984, -------------- Report Sync ------------


If there is anything I can try in order to help, I'll be glad to do it (like changing something in the patch if you need me to.

You've been extremely helpful.
Comment 13 Takashi Iwai 2014-04-29 13:13:17 UTC
All generated keycodes (418 = 0x1a2, 419 = 0x1a3, 530 = 0x212) look correct, so the patch should be OK per se.  The rest is the issue of the desktop environment, how to interpret such a key code.  You may need to set up the desktop services (like some daemon) to react with a key like touchpad toggle.

I'm going to submit the patch now to upstream.
Comment 14 Fede 2014-04-29 18:34:23 UTC
Ok, please go ahead. Many will appreciate to have these keys working.
Comment 15 Lonnie Lee Best 2014-06-18 16:19:09 UTC
Azael Avalos suggested that this patch should also be applied for the Toshiba Qosmio X75-A7298 :
https://bugzilla.kernel.org/show_bug.cgi?id=72551


". . . your model should be added to the DMI matching list, the recently released kernel 3.16-rc1 now comes with the new keymap (commit fe808bfb59d693e07ee23c99542cd64e1f41b8c9)."

Note You need to log in before you can comment on or make changes to this bug.