Re: [PATCH v2 2/2] platform/x86: asus-wmi: accept either lid-flip notify code

Hans de Goede <[email protected]>
Newsgroups org.kernel.vger.platform-driver-x86,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Hi Robin,

On 5-Aug-26 4:11 PM, Robin Everaars wrote:
> asus-wmi pairs the devid it polls for the tablet switch with the single
> notify code it listens for, and tablet_mode_sw only offers those fixed
> pairings. Some convertibles read the hinge at one lid-flip devid but
> notify with the other, which no value covers.
> 
> The ASUS ProArt PX13 (HN7306EAC) is one. ASUS_WMI_DEVID_LID_FLIP is frozen
> at 1 in every pose while ASUS_WMI_DEVID_LID_FLIP_ROG tracks the hinge, yet
> folding notifies with NOTIFY_LID_FLIP rather than NOTIFY_LID_FLIP_ROG. So
> tablet_mode_sw=2 pins the switch on and suspends the internal keyboard for
> good, and tablet_mode_sw=3 reads the right devid but never hears the event.
> 
> Accept either lid-flip code once a lid-flip switch is registered. Both are
> the same "lid flip action" event and both already map to KEY_PROG2 in the
> sparse keymap. Machines with a keyboard-dock switch notify with 0x75 and
> are unaffected, and with no switch registered the event code is 0 and the
> old equality test still runs.
> 
> Signed-off-by: Robin 
> Everaars <[email protected]>

nitpick: Something went wrong with the S-o-b line here

> ---
>  drivers/platform/x86/asus-wmi.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index dce4d07..8b63fb4 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -820,6 +820,27 @@ static void asus_wmi_tablet_mode_get_state(struct asus_wmi *asus)
>  		asus_wmi_tablet_sw_report(asus, result);
>  }
>  
> +/*
> + * Some convertibles report the hinge at one lid-flip devid while their firmware
> + * notifies with the other lid-flip code, a pairing no tablet_mode_sw value
> + * covers. The ASUS ProArt PX13 (HN7306EAC) is one: ASUS_WMI_DEVID_LID_FLIP is
> + * frozen at 1 in every pose while ASUS_WMI_DEVID_LID_FLIP_ROG tracks the hinge,
> + * yet the fold notifies with NOTIFY_LID_FLIP rather than NOTIFY_LID_FLIP_ROG.
> + * Accept either code once a lid-flip switch is registered; both are the same
> + * "lid flip action" event 
> and both already map to KEY_PROG2 in the sparse keymap.
> + */
> +static bool asus_wmi_is_tablet_switch_code(struct asus_wmi *asus, int code)
> +{
> +	if (code == asus->tablet_switch_event_code)
> +		return true;
> +
> +	if (asus->tablet_switch_event_code == NOTIFY_LID_FLIP ||
> +	    asus->tablet_switch_event_code == NOTIFY_LID_FLIP_ROG)
> +		return code == NOTIFY_LID_FLIP || code == NOTIFY_LID_FLIP_ROG;
> +
> +	return false;
> +}
This seems rather complicated, instead if adding this function please dropall usage of tablet_switch_event_code and ...

> @@ -4675,7 +4696,7 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus)
>  		return;
>  	}
>  
> -	if (code == asus->tablet_switch_event_code) {
> +	if (asus_wmi_is_tablet_switch_code(asus, code)) {
>  		asus_wmi_tablet_mode_get_state(asus);
>  		return;
>  	}

Replace the code check if condition with:

        if (code == NOTIFY_KBD_DOCK_CHANGE ||
            code == NOTIFY_LID_FLIP ||
            code == NOTIFY_LID_FLIP_ROG) {

and update the commit message to match.

Regards,

Hans
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.