diff options
author | Azael Avalos <coproscefalo@gmail.com> | 2015-03-20 18:55:17 -0400 |
---|---|---|
committer | Darren Hart <dvhart@linux.intel.com> | 2015-03-25 13:58:24 -0400 |
commit | a2b3471b5b13b81c5975d8f88db65694d7b69f56 (patch) | |
tree | 636e8d564a64941e5dbcfc270e9e0253231e885f | |
parent | 56e6b353396187a6e79acdbe3934fcd796a15e2e (diff) |
toshiba_acpi: Use the Hotkey Event Type function for keymap choosing
With the previous patch adding support to "Hotkey Event Type", we can
now use the type to distinguish which keymap to use.
This patch changes the toshiba_acpi_setup_keyboard function to make
use of the hotkey event type to choose the correct keymap without the
need to use the DMI matching list.
Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
-rw-r--r-- | drivers/platform/x86/toshiba_acpi.c | 70 |
1 files changed, 32 insertions, 38 deletions
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index 2a63ad043c4b..2781b149a95d 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include <linux/workqueue.h> | 49 | #include <linux/workqueue.h> |
50 | #include <linux/i8042.h> | 50 | #include <linux/i8042.h> |
51 | #include <linux/acpi.h> | 51 | #include <linux/acpi.h> |
52 | #include <linux/dmi.h> | ||
53 | #include <linux/uaccess.h> | 52 | #include <linux/uaccess.h> |
54 | 53 | ||
55 | MODULE_AUTHOR("John Belmonte"); | 54 | MODULE_AUTHOR("John Belmonte"); |
@@ -177,6 +176,7 @@ struct toshiba_acpi_dev { | |||
177 | int kbd_mode; | 176 | int kbd_mode; |
178 | int kbd_time; | 177 | int kbd_time; |
179 | int usbsc_bat_level; | 178 | int usbsc_bat_level; |
179 | int hotkey_event_type; | ||
180 | 180 | ||
181 | unsigned int illumination_supported:1; | 181 | unsigned int illumination_supported:1; |
182 | unsigned int video_supported:1; | 182 | unsigned int video_supported:1; |
@@ -246,29 +246,6 @@ static const struct key_entry toshiba_acpi_keymap[] = { | |||
246 | { KE_END, 0 }, | 246 | { KE_END, 0 }, |
247 | }; | 247 | }; |
248 | 248 | ||
249 | /* alternative keymap */ | ||
250 | static const struct dmi_system_id toshiba_alt_keymap_dmi[] = { | ||
251 | { | ||
252 | .matches = { | ||
253 | DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), | ||
254 | DMI_MATCH(DMI_PRODUCT_NAME, "Satellite M840"), | ||
255 | }, | ||
256 | }, | ||
257 | { | ||
258 | .matches = { | ||
259 | DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), | ||
260 | DMI_MATCH(DMI_PRODUCT_NAME, "Qosmio X75-A"), | ||
261 | }, | ||
262 | }, | ||
263 | { | ||
264 | .matches = { | ||
265 | DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), | ||
266 | DMI_MATCH(DMI_PRODUCT_NAME, "TECRA A50-A"), | ||
267 | }, | ||
268 | }, | ||
269 | {} | ||
270 | }; | ||
271 | |||
272 | static const struct key_entry toshiba_acpi_alt_keymap[] = { | 249 | static const struct key_entry toshiba_acpi_alt_keymap[] = { |
273 | { KE_KEY, 0x157, { KEY_MUTE } }, | 250 | { KE_KEY, 0x157, { KEY_MUTE } }, |
274 | { KE_KEY, 0x102, { KEY_ZOOMOUT } }, | 251 | { KE_KEY, 0x102, { KEY_ZOOMOUT } }, |
@@ -2459,10 +2436,22 @@ static void toshiba_acpi_process_hotkeys(struct toshiba_acpi_dev *dev) | |||
2459 | 2436 | ||
2460 | static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) | 2437 | static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) |
2461 | { | 2438 | { |
2439 | const struct key_entry *keymap = toshiba_acpi_keymap; | ||
2462 | acpi_handle ec_handle; | 2440 | acpi_handle ec_handle; |
2463 | int error; | 2441 | u32 events_type; |
2464 | u32 hci_result; | 2442 | u32 hci_result; |
2465 | const struct key_entry *keymap = toshiba_acpi_keymap; | 2443 | int error; |
2444 | |||
2445 | error = toshiba_acpi_enable_hotkeys(dev); | ||
2446 | if (error) | ||
2447 | return error; | ||
2448 | |||
2449 | error = toshiba_hotkey_event_type_get(dev, &events_type); | ||
2450 | if (error) { | ||
2451 | pr_err("Unable to query Hotkey Event Type\n"); | ||
2452 | return error; | ||
2453 | } | ||
2454 | dev->hotkey_event_type = events_type; | ||
2466 | 2455 | ||
2467 | dev->hotkey_dev = input_allocate_device(); | 2456 | dev->hotkey_dev = input_allocate_device(); |
2468 | if (!dev->hotkey_dev) | 2457 | if (!dev->hotkey_dev) |
@@ -2472,8 +2461,14 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) | |||
2472 | dev->hotkey_dev->phys = "toshiba_acpi/input0"; | 2461 | dev->hotkey_dev->phys = "toshiba_acpi/input0"; |
2473 | dev->hotkey_dev->id.bustype = BUS_HOST; | 2462 | dev->hotkey_dev->id.bustype = BUS_HOST; |
2474 | 2463 | ||
2475 | if (dmi_check_system(toshiba_alt_keymap_dmi)) | 2464 | if (events_type == HCI_SYSTEM_TYPE1 || |
2465 | !dev->kbd_function_keys_supported) | ||
2466 | keymap = toshiba_acpi_keymap; | ||
2467 | else if (events_type == HCI_SYSTEM_TYPE2 || | ||
2468 | dev->kbd_function_keys_supported) | ||
2476 | keymap = toshiba_acpi_alt_keymap; | 2469 | keymap = toshiba_acpi_alt_keymap; |
2470 | else | ||
2471 | pr_info("Unknown event type received %x\n", events_type); | ||
2477 | error = sparse_keymap_setup(dev->hotkey_dev, keymap, NULL); | 2472 | error = sparse_keymap_setup(dev->hotkey_dev, keymap, NULL); |
2478 | if (error) | 2473 | if (error) |
2479 | goto err_free_dev; | 2474 | goto err_free_dev; |
@@ -2515,12 +2510,6 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) | |||
2515 | goto err_remove_filter; | 2510 | goto err_remove_filter; |
2516 | } | 2511 | } |
2517 | 2512 | ||
2518 | error = toshiba_acpi_enable_hotkeys(dev); | ||
2519 | if (error) { | ||
2520 | pr_info("Unable to enable hotkeys\n"); | ||
2521 | goto err_remove_filter; | ||
2522 | } | ||
2523 | |||
2524 | error = input_register_device(dev->hotkey_dev); | 2513 | error = input_register_device(dev->hotkey_dev); |
2525 | if (error) { | 2514 | if (error) { |
2526 | pr_info("Unable to register input device\n"); | 2515 | pr_info("Unable to register input device\n"); |
@@ -2673,6 +2662,16 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) | |||
2673 | acpi_dev->driver_data = dev; | 2662 | acpi_dev->driver_data = dev; |
2674 | dev_set_drvdata(&acpi_dev->dev, dev); | 2663 | dev_set_drvdata(&acpi_dev->dev, dev); |
2675 | 2664 | ||
2665 | /* Query the BIOS for supported features */ | ||
2666 | |||
2667 | /* | ||
2668 | * The "Special Functions" are always supported by the laptops | ||
2669 | * with the new keyboard layout, query for its presence to help | ||
2670 | * determine the keymap layout to use. | ||
2671 | */ | ||
2672 | ret = toshiba_function_keys_get(dev, &dummy); | ||
2673 | dev->kbd_function_keys_supported = !ret; | ||
2674 | |||
2676 | if (toshiba_acpi_setup_keyboard(dev)) | 2675 | if (toshiba_acpi_setup_keyboard(dev)) |
2677 | pr_info("Unable to activate hotkeys\n"); | 2676 | pr_info("Unable to activate hotkeys\n"); |
2678 | 2677 | ||
@@ -2750,17 +2749,12 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) | |||
2750 | ret = toshiba_usb_sleep_music_get(dev, &dummy); | 2749 | ret = toshiba_usb_sleep_music_get(dev, &dummy); |
2751 | dev->usb_sleep_music_supported = !ret; | 2750 | dev->usb_sleep_music_supported = !ret; |
2752 | 2751 | ||
2753 | ret = toshiba_function_keys_get(dev, &dummy); | ||
2754 | dev->kbd_function_keys_supported = !ret; | ||
2755 | |||
2756 | ret = toshiba_panel_power_on_get(dev, &dummy); | 2752 | ret = toshiba_panel_power_on_get(dev, &dummy); |
2757 | dev->panel_power_on_supported = !ret; | 2753 | dev->panel_power_on_supported = !ret; |
2758 | 2754 | ||
2759 | ret = toshiba_usb_three_get(dev, &dummy); | 2755 | ret = toshiba_usb_three_get(dev, &dummy); |
2760 | dev->usb_three_supported = !ret; | 2756 | dev->usb_three_supported = !ret; |
2761 | 2757 | ||
2762 | /* Determine whether or not BIOS supports fan and video interfaces */ | ||
2763 | |||
2764 | ret = get_video_status(dev, &dummy); | 2758 | ret = get_video_status(dev, &dummy); |
2765 | dev->video_supported = !ret; | 2759 | dev->video_supported = !ret; |
2766 | 2760 | ||