Skip to contentSkip to conversation

toshiba_acpi: Add hotkeys support for Toshiba Satellite U940

PATCH In review Jose Ignacio Naranjo 2 participants 4 messages Nov 22, 2013 – Jan 21, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toshiba_acpi: Add hotkeys support for Toshiba Satellite U940

---
 drivers/platform/x86/toshiba_acpi.c | 41 +++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)
drivers/platform/x86/toshiba_acpi.c +39 -2
index 0cfadb6..ff711d5 100644
@@ -54,6 +54,7 @@
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/i8042.h>
+#include <linux/dmi.h>
 
 #include <asm/uaccess.h>
 
@@ -150,7 +151,7 @@ static const struct acpi_device_id toshiba_device_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, toshiba_device_ids);
 
-static const struct key_entry toshiba_acpi_keymap[] = {
+static const struct key_entry toshiba_acpi_default_keymap[] = {
 	{ KE_KEY, 0x101, { KEY_MUTE } },
 	{ KE_KEY, 0x102, { KEY_ZOOMOUT } },
 	{ KE_KEY, 0x103, { KEY_ZOOMIN } },
@@ -178,6 +179,41 @@ static const struct key_entry toshiba_acpi_keymap[] = {
 	{ KE_END, 0 },
 };
 
+static const struct key_entry *keymap = toshiba_acpi_default_keymap;
+
+static struct key_entry keymap_satellite_u940[] = {
+	{ KE_KEY, 0x13c, { KEY_BRIGHTNESSDOWN } },
+	{ KE_KEY, 0x13d, { KEY_BRIGHTNESSUP } },
+	{ KE_KEY, 0x13e, { KEY_SWITCHVIDEOMODE } },
+	{ KE_KEY, 0x13f, { KEY_TOUCHPAD_TOGGLE } },
+	{ KE_KEY, 0x157, { KEY_MUTE} },
+	{ KE_KEY, 0x158, { KEY_WLAN } },
+	{ KE_KEY, 0x12c, { KEY_KBDILLUMTOGGLE } },
+	{ KE_KEY, 0x102, { KEY_ZOOMOUT } },
+	{ KE_KEY, 0x103, { KEY_ZOOMIN } },
+	{ KE_KEY, 0x139, { KEY_ZOOMRESET } },
+	{ KE_END, 0 }
+};
+
+static int dmi_matched(const struct dmi_system_id *dmi)
+{
+	keymap = dmi->driver_data;
+	return 1;
+}
+
+static const struct dmi_system_id dmi_ids[] = {
+	{
+		/* Toshiba Satellite U940 */
+		.callback = dmi_matched,
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE U940"),
+		},
+		.driver_data = keymap_satellite_u940
+	},
+	{ NULL, }
+};
+
 /* utility
  */
 
@@ -984,7 +1020,8 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
 	dev->hotkey_dev->phys = "toshiba_acpi/input0";
 	dev->hotkey_dev->id.bustype = BUS_HOST;
 
-	error = sparse_keymap_setup(dev->hotkey_dev, toshiba_acpi_keymap, NULL);
+	dmi_check_system(dmi_ids);
+	error = sparse_keymap_setup(dev->hotkey_dev, keymap, NULL);
 	if (error)
 		goto err_free_dev;
 
Signature · 1 line
1.8.3.2
#1 lore raw

Hello Matthew and list,

I didn't receive any feedback about this patch. Is there any problem? I had to do it because I was lacking of a few scancodes and I couldn't remap all the keys using udev

Regards,
JI

Quoted 80 lines · Jose Ignacio Naranjo
---
 drivers/platform/x86/toshiba_acpi.c | 41 +++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)
drivers/platform/x86/toshiba_acpi.c +39 -3
index 0cfadb6..ff711d5 100644
@@ -54,6 +54,7 @@
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/i8042.h>
+#include <linux/dmi.h>
 
 #include <asm/uaccess.h>
 
@@ -150,7 +151,7 @@ static const struct acpi_device_id toshiba_device_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, toshiba_device_ids);
 
-static const struct key_entry toshiba_acpi_keymap[] = {
+static const struct key_entry toshiba_acpi_default_keymap[] = {
        { KE_KEY, 0x101, { KEY_MUTE } },
        { KE_KEY, 0x102, { KEY_ZOOMOUT } },
        { KE_KEY, 0x103, { KEY_ZOOMIN } },
@@ -178,6 +179,41 @@ static const struct key_entry toshiba_acpi_keymap[] = {
        { KE_END, 0 },
 };
 
+static const struct key_entry *keymap = toshiba_acpi_default_keymap;
+
+static struct key_entry keymap_satellite_u940[] = {
+       { KE_KEY, 0x13c, { KEY_BRIGHTNESSDOWN } },
+       { KE_KEY, 0x13d, { KEY_BRIGHTNESSUP } },
+       { KE_KEY, 0x13e, { KEY_SWITCHVIDEOMODE } },
+       { KE_KEY, 0x13f, { KEY_TOUCHPAD_TOGGLE } },
+       { KE_KEY, 0x157, { KEY_MUTE} },
+       { KE_KEY, 0x158, { KEY_WLAN } },
+       { KE_KEY, 0x12c, { KEY_KBDILLUMTOGGLE } },
+       { KE_KEY, 0x102, { KEY_ZOOMOUT } },
+       { KE_KEY, 0x103, { KEY_ZOOMIN } },
+       { KE_KEY, 0x139, { KEY_ZOOMRESET } },
+       { KE_END, 0 }
+};
+
+static int dmi_matched(const struct dmi_system_id *dmi)
+{
+       keymap = dmi->driver_data;
+       return 1;
+}
+
+static const struct dmi_system_id dmi_ids[] = {
+       {
+               /* Toshiba Satellite U940 */
+               .callback = dmi_matched,
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE U940"),
+               },
+               .driver_data = keymap_satellite_u940
+       },
+       { NULL, }
+};
+
 /* utility
  */
 
@@ -984,7 +1020,8 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
        dev->hotkey_dev->phys = "toshiba_acpi/input0";
        dev->hotkey_dev->id.bustype = BUS_HOST;
 
-       error = sparse_keymap_setup(dev->hotkey_dev, toshiba_acpi_keymap, NULL);
+       dmi_check_system(dmi_ids);
+       error = sparse_keymap_setup(dev->hotkey_dev, keymap, NULL);
        if (error)
                goto err_free_dev;
 
--

1.8.3.2

#2 lore raw
Quoted 5 lines · Jose Ignacio Naranjo

Hello Matthew and list,

I didn't receive any feedback about this patch. Is there any problem? I had to do it because I was lacking of a few scancodes and I couldn't remap all the keys using udev

I just haven't had a chance to review it yet. I'll take a look in the next couple of days. Thanks for your patience!

Signature · 1 line
Matthew Garrett | [email protected]
#3 lore raw
In reply to Jose Ignacio Naranjo

On Sat, 2013-11-23 at 00:02 +0100, Jose Ignacio Naranjo wrote:

First, I'm really sorry that it's taken me so long to get around to reviewing this.

drivers/platform/x86/toshiba_acpi.c static const struct key_entry toshiba_acpi_keymap[] = { · line 195

Quoted 12 lines
drivers/platform/x86/toshiba_acpi.c +12 -0
+static struct key_entry keymap_satellite_u940[] = {
+	{ KE_KEY, 0x13c, { KEY_BRIGHTNESSDOWN } },
+	{ KE_KEY, 0x13d, { KEY_BRIGHTNESSUP } },
+	{ KE_KEY, 0x13e, { KEY_SWITCHVIDEOMODE } },
+	{ KE_KEY, 0x13f, { KEY_TOUCHPAD_TOGGLE } },
+	{ KE_KEY, 0x157, { KEY_MUTE} },
+	{ KE_KEY, 0x158, { KEY_WLAN } },
+	{ KE_KEY, 0x12c, { KEY_KBDILLUMTOGGLE } },
+	{ KE_KEY, 0x102, { KEY_ZOOMOUT } },
+	{ KE_KEY, 0x103, { KEY_ZOOMIN } },
+	{ KE_KEY, 0x139, { KEY_ZOOMRESET } },
+	{ KE_END, 0 }

Yeah, that's pretty distinct from the original map. Boo.

drivers/platform/x86/toshiba_acpi.c static const struct key_entry toshiba_acpi_keymap[] = { · line 202

Quoted 6 lines
drivers/platform/x86/toshiba_acpi.c +6 -0
+
+static int dmi_matched(const struct dmi_system_id *dmi)
+{
+	keymap = dmi->driver_data;
+	return 1;
+}

But I'm not a fan of doing this with DMI - if Toshiba are doing this for some newer machines then it's possible that the map's changed for all of them. Things that spring to mind:

1) The map may be different on all systems that support Windows 8?
2) There's some ACPI call that distinguishes between them?

Can you send me the output of acpidump for this system?

Thanks,

Signature · 1 line
Matthew Garrett <[email protected]>