diff options
author | Bastien Nocera <hadess@hadess.net> | 2015-03-02 08:45:16 -0500 |
---|---|---|
committer | Darren Hart <dvhart@linux.intel.com> | 2015-03-03 11:58:54 -0500 |
commit | f23a5bcb70586231b5130a08de965592afdcf9cd (patch) | |
tree | 2b1609cd10259d6e346fb498a546bb5a26b4f848 /drivers/platform/x86/thinkpad_acpi.c | |
parent | c517d838eb7d07bbe9507871fab3931deccff539 (diff) |
thinkpad_acpi: Remember adaptive kbd presence
Rather than checking on each suspend and resume whether the laptop
has an adaptive keyboard, check when the driver is initialised.
Signed-off-by: Bastien Nocera <hadess@hadess.net>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Diffstat (limited to 'drivers/platform/x86/thinkpad_acpi.c')
-rw-r--r-- | drivers/platform/x86/thinkpad_acpi.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 3b8ceee7c5cb..763aef0e7764 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c | |||
@@ -319,6 +319,7 @@ static struct { | |||
319 | u32 sensors_pdrv_attrs_registered:1; | 319 | u32 sensors_pdrv_attrs_registered:1; |
320 | u32 sensors_pdev_attrs_registered:1; | 320 | u32 sensors_pdev_attrs_registered:1; |
321 | u32 hotkey_poll_active:1; | 321 | u32 hotkey_poll_active:1; |
322 | u32 has_adaptive_kbd:1; | ||
322 | } tp_features; | 323 | } tp_features; |
323 | 324 | ||
324 | static struct { | 325 | static struct { |
@@ -3227,6 +3228,15 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
3227 | if (!tp_features.hotkey) | 3228 | if (!tp_features.hotkey) |
3228 | return 1; | 3229 | return 1; |
3229 | 3230 | ||
3231 | /* | ||
3232 | * Check if we have an adaptive keyboard, like on the | ||
3233 | * Lenovo Carbon X1 2014 (2nd Gen). | ||
3234 | */ | ||
3235 | if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) { | ||
3236 | if ((hkeyv >> 8) == 2) | ||
3237 | tp_features.has_adaptive_kbd = true; | ||
3238 | } | ||
3239 | |||
3230 | quirks = tpacpi_check_quirks(tpacpi_hotkey_qtable, | 3240 | quirks = tpacpi_check_quirks(tpacpi_hotkey_qtable, |
3231 | ARRAY_SIZE(tpacpi_hotkey_qtable)); | 3241 | ARRAY_SIZE(tpacpi_hotkey_qtable)); |
3232 | 3242 | ||
@@ -3836,28 +3846,21 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) | |||
3836 | 3846 | ||
3837 | static void hotkey_suspend(void) | 3847 | static void hotkey_suspend(void) |
3838 | { | 3848 | { |
3839 | int hkeyv; | ||
3840 | |||
3841 | /* Do these on suspend, we get the events on early resume! */ | 3849 | /* Do these on suspend, we get the events on early resume! */ |
3842 | hotkey_wakeup_reason = TP_ACPI_WAKEUP_NONE; | 3850 | hotkey_wakeup_reason = TP_ACPI_WAKEUP_NONE; |
3843 | hotkey_autosleep_ack = 0; | 3851 | hotkey_autosleep_ack = 0; |
3844 | 3852 | ||
3845 | /* save previous mode of adaptive keyboard of X1 Carbon */ | 3853 | /* save previous mode of adaptive keyboard of X1 Carbon */ |
3846 | if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) { | 3854 | if (tp_features.has_adaptive_kbd) { |
3847 | if ((hkeyv >> 8) == 2) { | 3855 | if (!acpi_evalf(hkey_handle, &adaptive_keyboard_prev_mode, |
3848 | if (!acpi_evalf(hkey_handle, | 3856 | "GTRW", "dd", 0)) { |
3849 | &adaptive_keyboard_prev_mode, | 3857 | pr_err("Cannot read adaptive keyboard mode.\n"); |
3850 | "GTRW", "dd", 0)) { | ||
3851 | pr_err("Cannot read adaptive keyboard mode.\n"); | ||
3852 | } | ||
3853 | } | 3858 | } |
3854 | } | 3859 | } |
3855 | } | 3860 | } |
3856 | 3861 | ||
3857 | static void hotkey_resume(void) | 3862 | static void hotkey_resume(void) |
3858 | { | 3863 | { |
3859 | int hkeyv; | ||
3860 | |||
3861 | tpacpi_disable_brightness_delay(); | 3864 | tpacpi_disable_brightness_delay(); |
3862 | 3865 | ||
3863 | if (hotkey_status_set(true) < 0 || | 3866 | if (hotkey_status_set(true) < 0 || |
@@ -3872,14 +3875,10 @@ static void hotkey_resume(void) | |||
3872 | hotkey_poll_setup_safe(false); | 3875 | hotkey_poll_setup_safe(false); |
3873 | 3876 | ||
3874 | /* restore previous mode of adapive keyboard of X1 Carbon */ | 3877 | /* restore previous mode of adapive keyboard of X1 Carbon */ |
3875 | if (acpi_evalf(hkey_handle, &hkeyv, "MHKV", "qd")) { | 3878 | if (tp_features.has_adaptive_kbd) { |
3876 | if ((hkeyv >> 8) == 2) { | 3879 | if (!acpi_evalf(hkey_handle, NULL, "STRW", "vd", |
3877 | if (!acpi_evalf(hkey_handle, | 3880 | adaptive_keyboard_prev_mode)) { |
3878 | NULL, | 3881 | pr_err("Cannot set adaptive keyboard mode.\n"); |
3879 | "STRW", "vd", | ||
3880 | adaptive_keyboard_prev_mode)) { | ||
3881 | pr_err("Cannot set adaptive keyboard mode.\n"); | ||
3882 | } | ||
3883 | } | 3882 | } |
3884 | } | 3883 | } |
3885 | } | 3884 | } |