platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ideapad-laptop: Fix Legion 5 Fn lock LED
@ 2021-08-17 17:12 Meng Dong
  2021-08-18  7:44 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Meng Dong @ 2021-08-17 17:12 UTC (permalink / raw)
  To: Ike Panhc, Hans de Goede, Mark Gross, platform-driver-x86; +Cc: Meng Dong

This patch fixes the bug 212671.
Althrough the Fn lock (Fn + Esc) works on Legion 5 (R7000P), its LED
light does not change with the state. This modification sets the Fn lock
state to its current value on receiving the wmi event
8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 to update the LED state.

Signed-off-by: Meng Dong <whenov@gmail.com>
---
Another possible approach is to call `ideapad_input_report(priv, value)`
to send a keycode and let the user handle the LED by echoing the current
value of /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/fn_lock back
into itself. But the problem with this approach is Fn+F9 and Fn+Esc
trigger the same WMI GUID and event value and I have no idea how to
distinguish them.

 drivers/platform/x86/ideapad-laptop.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 784326bd72f0..48561b666547 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -41,6 +41,7 @@
 static const char *const ideapad_wmi_fnesc_events[] = {
 	"26CAB2E5-5CF1-46AE-AAC3-4A12B6BA50E6", /* Yoga 3 */
 	"56322276-8493-4CE8-A783-98C991274F5E", /* Yoga 700 */
+	"8FC0DE0C-B4E4-43FD-B0F3-8871711C1294", /* Legion 5 */
 };
 #endif
 
@@ -1464,6 +1465,15 @@ static void ideapad_wmi_notify(u32 value, void *context)
 	case 128:
 		ideapad_input_report(priv, value);
 		break;
+	case 208:
+		unsigned long result;
+
+		if (!eval_hals(priv->adev->handle, &result)) {
+			bool state = test_bit(HALS_FNLOCK_STATE_BIT, &result);
+
+			exec_sals(priv->adev->handle, state ? SALS_FNLOCK_ON : SALS_FNLOCK_OFF);
+		}
+		break;
 	default:
 		dev_info(&priv->platform_device->dev,
 			 "Unknown WMI event: %u\n", value);
-- 
2.32.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ideapad-laptop: Fix Legion 5 Fn lock LED
  2021-08-17 17:12 [PATCH] ideapad-laptop: Fix Legion 5 Fn lock LED Meng Dong
@ 2021-08-18  7:44 ` Hans de Goede
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2021-08-18  7:44 UTC (permalink / raw)
  To: Meng Dong, Ike Panhc, Mark Gross, platform-driver-x86

Hi,

On 8/17/21 7:12 PM, Meng Dong wrote:
> This patch fixes the bug 212671.
> Althrough the Fn lock (Fn + Esc) works on Legion 5 (R7000P), its LED
> light does not change with the state. This modification sets the Fn lock
> state to its current value on receiving the wmi event
> 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 to update the LED state.
> 
> Signed-off-by: Meng Dong <whenov@gmail.com>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans


> ---
> Another possible approach is to call `ideapad_input_report(priv, value)`
> to send a keycode and let the user handle the LED by echoing the current
> value of /sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/fn_lock back
> into itself. But the problem with this approach is Fn+F9 and Fn+Esc
> trigger the same WMI GUID and event value and I have no idea how to
> distinguish them.
> 
>  drivers/platform/x86/ideapad-laptop.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
> index 784326bd72f0..48561b666547 100644
> --- a/drivers/platform/x86/ideapad-laptop.c
> +++ b/drivers/platform/x86/ideapad-laptop.c
> @@ -41,6 +41,7 @@
>  static const char *const ideapad_wmi_fnesc_events[] = {
>  	"26CAB2E5-5CF1-46AE-AAC3-4A12B6BA50E6", /* Yoga 3 */
>  	"56322276-8493-4CE8-A783-98C991274F5E", /* Yoga 700 */
> +	"8FC0DE0C-B4E4-43FD-B0F3-8871711C1294", /* Legion 5 */
>  };
>  #endif
>  
> @@ -1464,6 +1465,15 @@ static void ideapad_wmi_notify(u32 value, void *context)
>  	case 128:
>  		ideapad_input_report(priv, value);
>  		break;
> +	case 208:
> +		unsigned long result;
> +
> +		if (!eval_hals(priv->adev->handle, &result)) {
> +			bool state = test_bit(HALS_FNLOCK_STATE_BIT, &result);
> +
> +			exec_sals(priv->adev->handle, state ? SALS_FNLOCK_ON : SALS_FNLOCK_OFF);
> +		}
> +		break;
>  	default:
>  		dev_info(&priv->platform_device->dev,
>  			 "Unknown WMI event: %u\n", value);
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-18  7:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17 17:12 [PATCH] ideapad-laptop: Fix Legion 5 Fn lock LED Meng Dong
2021-08-18  7:44 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).