platform/x86: ideapad-laptop: Only toggle ps2 aux port on/off on select models

Recently there have been multiple patches to disable the ideapad-laptop's
touchpad control code, because it is causing issues on various laptops:

Commit d69cd7eea9 ("platform/x86: ideapad-laptop: Disable touchpad_switch for ELAN0634")
Commit a231224a60 ("platform/x86: ideapad-laptop: Disable touchpad_switch")

The turning on/off of the ps2 aux port was added specifically for
the IdeaPad Z570, where the EC does toggle the touchpad on/off LED and
toggles the value returned by reading VPCCMD_R_TOUCHPAD, but it does not
actually turn on/off the touchpad.

The ideapad-laptop code really should not be messing with the i8042
controller on all devices just for this special case.

Add a new ctrl_ps2_aux_port flag set based on a DMI based allow-list
for devices which need this workaround, populating it with just
the Ideapad Z570 for now.

This also adds a module parameter so that this behavior can easily
be enabled on other models which may need it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Tested-by: Maxim Mikityanskiy <maxtram95@gmail.com>
Link: https://lore.kernel.org/r/20221117110244.67811-4-hdegoede@redhat.com
This commit is contained in:
Hans de Goede 2022-11-17 12:02:41 +01:00
parent f4dd8c44bb
commit c69e7d843d
1 changed files with 28 additions and 1 deletions

View File

@ -143,6 +143,7 @@ struct ideapad_private {
bool hw_rfkill_switch : 1; bool hw_rfkill_switch : 1;
bool kbd_bl : 1; bool kbd_bl : 1;
bool touchpad_ctrl_via_ec : 1; bool touchpad_ctrl_via_ec : 1;
bool ctrl_ps2_aux_port : 1;
bool usb_charging : 1; bool usb_charging : 1;
} features; } features;
struct { struct {
@ -174,6 +175,12 @@ MODULE_PARM_DESC(set_fn_lock_led,
"Enable driver based updates of the fn-lock LED on fn-lock changes. " "Enable driver based updates of the fn-lock LED on fn-lock changes. "
"If you need this please report this to: platform-driver-x86@vger.kernel.org"); "If you need this please report this to: platform-driver-x86@vger.kernel.org");
static bool ctrl_ps2_aux_port;
module_param(ctrl_ps2_aux_port, bool, 0444);
MODULE_PARM_DESC(ctrl_ps2_aux_port,
"Enable driver based PS/2 aux port en-/dis-abling on touchpad on/off toggle. "
"If you need this please report this to: platform-driver-x86@vger.kernel.org");
/* /*
* shared data * shared data
*/ */
@ -1507,6 +1514,7 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv, bool send_
* touchpad off and on. We send KEY_TOUCHPAD_OFF and * touchpad off and on. We send KEY_TOUCHPAD_OFF and
* KEY_TOUCHPAD_ON to not to get out of sync with LED * KEY_TOUCHPAD_ON to not to get out of sync with LED
*/ */
if (priv->features.ctrl_ps2_aux_port)
i8042_command(&param, value ? I8042_CMD_AUX_ENABLE : I8042_CMD_AUX_DISABLE); i8042_command(&param, value ? I8042_CMD_AUX_ENABLE : I8042_CMD_AUX_DISABLE);
if (send_events) { if (send_events) {
@ -1615,6 +1623,23 @@ static const struct dmi_system_id hw_rfkill_list[] = {
{} {}
}; };
/*
* On some models the EC toggles the touchpad muted LED on touchpad toggle
* hotkey presses, but the EC does not actually disable the touchpad itself.
* On these models the driver needs to explicitly enable/disable the i8042
* (PS/2) aux port.
*/
static const struct dmi_system_id ctrl_ps2_aux_port_list[] = {
{
/* Lenovo Ideapad Z570 */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_VERSION, "Ideapad Z570"),
},
},
{}
};
static const struct dmi_system_id no_touchpad_switch_list[] = { static const struct dmi_system_id no_touchpad_switch_list[] = {
{ {
.ident = "Lenovo Yoga 3 Pro 1370", .ident = "Lenovo Yoga 3 Pro 1370",
@ -1642,6 +1667,8 @@ static void ideapad_check_features(struct ideapad_private *priv)
set_fn_lock_led || dmi_check_system(set_fn_lock_led_list); set_fn_lock_led || dmi_check_system(set_fn_lock_led_list);
priv->features.hw_rfkill_switch = priv->features.hw_rfkill_switch =
hw_rfkill_switch || dmi_check_system(hw_rfkill_list); hw_rfkill_switch || dmi_check_system(hw_rfkill_list);
priv->features.ctrl_ps2_aux_port =
ctrl_ps2_aux_port || dmi_check_system(ctrl_ps2_aux_port_list);
/* Most ideapads with ELAN0634 touchpad don't use EC touchpad switch */ /* Most ideapads with ELAN0634 touchpad don't use EC touchpad switch */
if (acpi_dev_present("ELAN0634", NULL, -1)) if (acpi_dev_present("ELAN0634", NULL, -1))