From d618651b0f112d9715d0ca6f9dbea87761be15d7 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Wed, 21 Oct 2015 12:46:10 +0200 Subject: thinkpad_acpi: Don't yell on unsupported brightness interfaces The thinkpad_acpi driver currently emits error messages on unsupported brightness interfaces, giving the impression that someone will implement those. However, this error is spit out on nearly every thinkpad in production since 2 years now. Furthermore, the backlight interfaces on those devices are supported by the i915 driver just fine. Downgrade the error message to a normal pr_info() and stop telling people to report it to IBM. Signed-off-by: David Herrmann Acked-by: Henrique de Moraes Holschuh Signed-off-by: Darren Hart --- drivers/platform/x86/thinkpad_acpi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 131dd7464183..0bed4733c4f0 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -6459,8 +6459,7 @@ static void __init tpacpi_detect_brightness_capabilities(void) pr_info("detected a 8-level brightness capable ThinkPad\n"); break; default: - pr_err("Unsupported brightness interface, " - "please contact %s\n", TPACPI_MAIL); + pr_info("Unsupported brightness interface\n"); tp_features.bright_unkfw = 1; bright_maxlvl = b - 1; } -- cgit v1.2.3 From 74caab996c68393c0a985dccfd0ee6b33fb016e6 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 6 Nov 2015 22:28:49 +0100 Subject: ideapad-laptop: add support for Yoga 3 ESC key The ideapad-laptop handles most special keys on various Lenovo Laptops including the Yoga line. Unfortunately, the Yoga 3 11/13/14 models have one important exception, which is the Fn-ESC combination. On other Lenovo Laptops, this is FnLock, which switches the function keys between the primary (Mute, Vol down, Vol up, ...) and the secondary (F1, F2, F3, ...) behavior. On the new machines, FnLock is only available through BIOS setup (possibly through a yet-to-be-implemented feature in this driver) but not through Fn-ESC, but instead the ESC key itself switched between ESC and a "Paper Display" app for Windows. Unfortunately, that means that you can never have both ESC *and* the function keys working at the same time without needing to press Fn on one of them. As pointed out in the official Lenovo Forum by dozens of users, this makes the machine rather useless for any serious work [1]. I have now studied the ACPI DSDT one more time and found the event that is generated for the ESC key. Unlike all other key events on this machine, it is actually a WMI, while the other ones are read from the embedded controller. I am now installing a WMI notifier that uses the event number from the WMI subsystem as the scancode. The only event number generated here is '128', and that fits in nicely with the two existing ranges of scancodes used by the EC: 0-15 for the 16-bit VPCCMD_R_VPC register, 16-17 for the VPCCMD_R_NOVO register and 64-67 for VPCCMD_R_SPECIAL_BUTTONS. The only sane way to handle this button (in absence of the Windows Paper Display driver) seems to be to have it emit KEY_ESC, so that is what I use as the default. Should any user ever want to overwrite the default, they can install their own keymap. To ensure that we can still build the driver without adding a CONFIG_WMI dependency, all new code is enclosed in #ifdef. Signed-off-by: Arnd Bergmann [1] https://forums.lenovo.com/t5/Lenovo-Yoga-Series-Notebooks/YOGA-3-14-How-to-reclaim-my-Esc-key-and-permanently-disable/td-p/2070816 Signed-off-by: Darren Hart --- drivers/platform/x86/Kconfig | 1 + drivers/platform/x86/ideapad-laptop.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 7b492d9b3ec4..ecc8adf35b00 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -345,6 +345,7 @@ config IDEAPAD_LAPTOP depends on SERIO_I8042 depends on BACKLIGHT_CLASS_DEVICE depends on ACPI_VIDEO || ACPI_VIDEO = n + depends on ACPI_WMI || ACPI_WMI = n select INPUT_SPARSEKMAP help This is a driver for Lenovo IdeaPad netbooks contains drivers for diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index fce49f3c6ed6..db76d011bedd 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -47,6 +47,10 @@ #define CFG_WIFI_BIT (18) #define CFG_CAMERA_BIT (19) +#if IS_ENABLED(CONFIG_ACPI_WMI) +static const char ideapad_wmi_fnesc_event[] = "26CAB2E5-5CF1-46AE-AAC3-4A12B6BA50E6"; +#endif + enum { VPCCMD_R_VPC1 = 0x10, VPCCMD_R_BL_MAX, @@ -567,6 +571,8 @@ static const struct key_entry ideapad_keymap[] = { { KE_KEY, 65, { KEY_PROG4 } }, { KE_KEY, 66, { KEY_TOUCHPAD_OFF } }, { KE_KEY, 67, { KEY_TOUCHPAD_ON } }, + { KE_KEY, 128, { KEY_ESC } }, + { KE_END, 0 }, }; @@ -825,6 +831,19 @@ static void ideapad_acpi_notify(acpi_handle handle, u32 event, void *data) } } +#if IS_ENABLED(CONFIG_ACPI_WMI) +static void ideapad_wmi_notify(u32 value, void *context) +{ + switch (value) { + case 128: + ideapad_input_report(context, value); + break; + default: + pr_info("Unknown WMI event %u\n", value); + } +} +#endif + /* * Some ideapads don't have a hardware rfkill switch, reading VPCCMD_R_RF * always results in 0 on these models, causing ideapad_laptop to wrongly @@ -935,8 +954,18 @@ static int ideapad_acpi_add(struct platform_device *pdev) ACPI_DEVICE_NOTIFY, ideapad_acpi_notify, priv); if (ret) goto notification_failed; +#if IS_ENABLED(CONFIG_ACPI_WMI) + ret = wmi_install_notify_handler(ideapad_wmi_fnesc_event, ideapad_wmi_notify, priv); + if (ret != AE_OK && ret != AE_NOT_EXIST) + goto notification_failed_wmi; +#endif return 0; +#if IS_ENABLED(CONFIG_ACPI_WMI) +notification_failed_wmi: + acpi_remove_notify_handler(priv->adev->handle, + ACPI_DEVICE_NOTIFY, ideapad_acpi_notify); +#endif notification_failed: ideapad_backlight_exit(priv); backlight_failed: @@ -955,6 +984,9 @@ static int ideapad_acpi_remove(struct platform_device *pdev) struct ideapad_private *priv = dev_get_drvdata(&pdev->dev); int i; +#if IS_ENABLED(CONFIG_ACPI_WMI) + wmi_remove_notify_handler(ideapad_wmi_fnesc_event); +#endif acpi_remove_notify_handler(priv->adev->handle, ACPI_DEVICE_NOTIFY, ideapad_acpi_notify); ideapad_backlight_exit(priv); -- cgit v1.2.3 From c789fffc56a1a6c4bd9cbd15269d86089d757214 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 6 Nov 2015 23:26:59 +0100 Subject: ideapad-laptop: include Yoga 3 1170 in add rfkill whitelist This changes the entry to the whitelist of machines that do not have a physical rfkill switch. Unfortunately, the Yoga 3 generation seems to use upper-case letters for the YOGA 3 Pro-1370, while it uses normal capitalization for its Yoga 3 1170 and 1470 siblings. In order to catch all variants of the Yoga 3, I'm changing both the entry for the 1470 (using "Yoga" as the name) and the entry for the Pro 1370 (using all-caps "YOGA") to not match the exact model number but only the generation. This way, the 1170 and 1470 models share one entry, but if the firmware changes from one format to the other, it will still work. The second entry for Yoga 2 Pro that was recently added for some reason ended up not being added in alphanumeric order, and I'm moving the Yoga 3 1470 entry down while making the change, so they are sorted more logically. Signed-off-by: Arnd Bergmann Signed-off-by: Darren Hart --- drivers/platform/x86/ideapad-laptop.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index db76d011bedd..c11f40f37bd0 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -872,24 +872,24 @@ static const struct dmi_system_id no_hw_rfkill_list[] = { }, }, { - .ident = "Lenovo Yoga 3 14", + .ident = "Lenovo Yoga 2 11 / 13 / Pro", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), - DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Yoga 3 14"), + DMI_MATCH(DMI_BOARD_NAME, "Yoga2"), }, }, { - .ident = "Lenovo Yoga 2 11 / 13 / Pro", + .ident = "Lenovo Yoga 3 1170 / 1470", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), - DMI_MATCH(DMI_BOARD_NAME, "Yoga2"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Yoga 3"), }, }, { .ident = "Lenovo Yoga 3 Pro 1370", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), - DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo YOGA 3 Pro-1370"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo YOGA 3"), }, }, {} -- cgit v1.2.3 From f71c882dd4cfe4aa88ea07b1402ddd43605d4aef Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 9 Nov 2015 17:09:05 +0100 Subject: ideapad-laptop: Add Lenovo Yoga 900 to no_hw_rfkill dmi list Like some of the other Yoga models the Lenovo Yoga 900 does not have a hw rfkill switch, and trying to read the hw rfkill switch through the ideapad module causes it to always reported blocking breaking wifi. This commit adds the Lenovo Yoga 900 to the no_hw_rfkill dmi list, fixing the wifi breakage. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1275490 Cc: stable@vger.kernel.org Reported-and-tested-by: Kevin Fenzi Signed-off-by: Hans de Goede Signed-off-by: Darren Hart --- drivers/platform/x86/ideapad-laptop.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index c11f40f37bd0..a313dfc0245f 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -892,6 +892,13 @@ static const struct dmi_system_id no_hw_rfkill_list[] = { DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo YOGA 3"), }, }, + { + .ident = "Lenovo Yoga 900", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo YOGA 900"), + }, + }, {} }; -- cgit v1.2.3 From b82983401684ba06fcf3fbafa63edf371c0d4775 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 11 Nov 2015 01:18:16 +0300 Subject: asus-wmi: fix error handling in store_sys_wmi() The asus_wmi_get_devstate_simple() returns 0-1 on success. In theory according to static checkers, it can return either -EIO or -ENODEV on failure. Currently the error handling code only handles -ENODEV and -EIO is treated as success. Let's make it handle the -EIO error as well. It's possible that it can't actually return -EIO and this patch is not needed but in that case this patch is harmless and silences a static checker warning so it's still worth it. Signed-off-by: Dan Carpenter Signed-off-by: Darren Hart --- drivers/platform/x86/asus-wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 1f7d80ff8cb4..179eeee227b4 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -1682,7 +1682,7 @@ static ssize_t store_sys_wmi(struct asus_wmi *asus, int devid, int rv, err, value; value = asus_wmi_get_devstate_simple(asus, devid); - if (value == -ENODEV) /* Check device presence */ + if (value < 0) return value; rv = parse_arg(buf, count, &value); -- cgit v1.2.3