Commit fdcc0602 authored by Hans de Goede's avatar Hans de Goede

platform/x86: asus-wmi: Fix kbd_dock_devid tablet-switch reporting

Commit 1ea0d3b4 ("platform/x86: asus-wmi: Simplify tablet-mode-switch
handling") unified the asus-wmi tablet-switch handling, but it did not take
into account that the value returned for the kbd_dock_devid WMI method is
inverted where as the other ones are not inverted.

This causes asus-wmi to report an inverted tablet-switch state for devices
which use the kbd_dock_devid, which causes libinput to ignore touchpad
events while the affected T10x model 2-in-1s are docked.

Add inverting of the return value in the kbd_dock_devid case to fix this.

Fixes: 1ea0d3b4 ("platform/x86: asus-wmi: Simplify tablet-mode-switch handling")
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230120143441.527334-1-hdegoede@redhat.com
parent a410429a
...@@ -225,6 +225,7 @@ struct asus_wmi { ...@@ -225,6 +225,7 @@ struct asus_wmi {
int tablet_switch_event_code; int tablet_switch_event_code;
u32 tablet_switch_dev_id; u32 tablet_switch_dev_id;
bool tablet_switch_inverted;
enum fan_type fan_type; enum fan_type fan_type;
enum fan_type gpu_fan_type; enum fan_type gpu_fan_type;
...@@ -493,6 +494,13 @@ static bool asus_wmi_dev_is_present(struct asus_wmi *asus, u32 dev_id) ...@@ -493,6 +494,13 @@ static bool asus_wmi_dev_is_present(struct asus_wmi *asus, u32 dev_id)
} }
/* Input **********************************************************************/ /* Input **********************************************************************/
static void asus_wmi_tablet_sw_report(struct asus_wmi *asus, bool value)
{
input_report_switch(asus->inputdev, SW_TABLET_MODE,
asus->tablet_switch_inverted ? !value : value);
input_sync(asus->inputdev);
}
static void asus_wmi_tablet_sw_init(struct asus_wmi *asus, u32 dev_id, int event_code) static void asus_wmi_tablet_sw_init(struct asus_wmi *asus, u32 dev_id, int event_code)
{ {
struct device *dev = &asus->platform_device->dev; struct device *dev = &asus->platform_device->dev;
...@@ -501,7 +509,7 @@ static void asus_wmi_tablet_sw_init(struct asus_wmi *asus, u32 dev_id, int event ...@@ -501,7 +509,7 @@ static void asus_wmi_tablet_sw_init(struct asus_wmi *asus, u32 dev_id, int event
result = asus_wmi_get_devstate_simple(asus, dev_id); result = asus_wmi_get_devstate_simple(asus, dev_id);
if (result >= 0) { if (result >= 0) {
input_set_capability(asus->inputdev, EV_SW, SW_TABLET_MODE); input_set_capability(asus->inputdev, EV_SW, SW_TABLET_MODE);
input_report_switch(asus->inputdev, SW_TABLET_MODE, result); asus_wmi_tablet_sw_report(asus, result);
asus->tablet_switch_dev_id = dev_id; asus->tablet_switch_dev_id = dev_id;
asus->tablet_switch_event_code = event_code; asus->tablet_switch_event_code = event_code;
} else if (result == -ENODEV) { } else if (result == -ENODEV) {
...@@ -534,6 +542,7 @@ static int asus_wmi_input_init(struct asus_wmi *asus) ...@@ -534,6 +542,7 @@ static int asus_wmi_input_init(struct asus_wmi *asus)
case asus_wmi_no_tablet_switch: case asus_wmi_no_tablet_switch:
break; break;
case asus_wmi_kbd_dock_devid: case asus_wmi_kbd_dock_devid:
asus->tablet_switch_inverted = true;
asus_wmi_tablet_sw_init(asus, ASUS_WMI_DEVID_KBD_DOCK, NOTIFY_KBD_DOCK_CHANGE); asus_wmi_tablet_sw_init(asus, ASUS_WMI_DEVID_KBD_DOCK, NOTIFY_KBD_DOCK_CHANGE);
break; break;
case asus_wmi_lid_flip_devid: case asus_wmi_lid_flip_devid:
...@@ -573,10 +582,8 @@ static void asus_wmi_tablet_mode_get_state(struct asus_wmi *asus) ...@@ -573,10 +582,8 @@ static void asus_wmi_tablet_mode_get_state(struct asus_wmi *asus)
return; return;
result = asus_wmi_get_devstate_simple(asus, asus->tablet_switch_dev_id); result = asus_wmi_get_devstate_simple(asus, asus->tablet_switch_dev_id);
if (result >= 0) { if (result >= 0)
input_report_switch(asus->inputdev, SW_TABLET_MODE, result); asus_wmi_tablet_sw_report(asus, result);
input_sync(asus->inputdev);
}
} }
/* dGPU ********************************************************************/ /* dGPU ********************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment