From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE83613DDB8; Thu, 25 Jul 2024 14:44:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721918650; cv=none; b=dd6BCOtnjssqHepXlB0byuH7j7Th0Dr2gpAtUWKblJa4Jm3Y8DwDxRU54gHgWFHz4H2E8w1+YyiyAO0p80ekRoVgRWcmFsFmD5wN04S91HXCaDH1f7kpTAH61kctWJEaTyC7o4dSK8qv0DfNTocMOHDJ8p0uBNugEJCyQmFEKiA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721918650; c=relaxed/simple; bh=oJ6CUeDIMvfeEzok1mFB999Ir52WTgGVn4V9qbSVJmo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AVcn50zyWXg8woBkuHdwO0bAsSCKBEyQlb/HEumids4/1DWsP4Rg7UTexn0BIIaE0MnEmIcagLQHcIw6hJWmoQVOjM1ospo3LR4ABiyX5myCnKajEMxi6MrtRyeNQ1/XoW7J1j8VU0CKUO9rVhTifln9fV7k89De5ygeDh6BsrI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=utkQKEO2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="utkQKEO2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EE68C116B1; Thu, 25 Jul 2024 14:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1721918650; bh=oJ6CUeDIMvfeEzok1mFB999Ir52WTgGVn4V9qbSVJmo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=utkQKEO2iEko8AZeYjBWcbCyl4K+iHTMJ+67aAS/EquXA5FntOQQJ6yRgRYlx5pLZ iMgz7PH5+kkbkiLnBYK73t8yIYdYMODqJ4KknY2B25nHKQ9OpVeO7hhWJSgthfouqO EhEOoW9UCJjdnAir5Xq8aLUdioFppnCuz8F/h73w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jonathan Denose , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.4 18/43] Input: elantech - fix touchpad state on resume for Lenovo N24 Date: Thu, 25 Jul 2024 16:36:41 +0200 Message-ID: <20240725142731.162136419@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240725142730.471190017@linuxfoundation.org> References: <20240725142730.471190017@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jonathan Denose [ Upstream commit a69ce592cbe0417664bc5a075205aa75c2ec1273 ] The Lenovo N24 on resume becomes stuck in a state where it sends incorrect packets, causing elantech_packet_check_v4 to fail. The only way for the device to resume sending the correct packets is for it to be disabled and then re-enabled. This change adds a dmi check to trigger this behavior on resume. Signed-off-by: Jonathan Denose Link: https://lore.kernel.org/r/20240503155020.v2.1.Ifa0e25ebf968d8f307f58d678036944141ab17e6@changeid Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/mouse/elantech.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 9ff89bfda7a24..8e286e023916f 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -1476,16 +1476,47 @@ static void elantech_disconnect(struct psmouse *psmouse) psmouse->private = NULL; } +/* + * Some hw_version 4 models fail to properly activate absolute mode on + * resume without going through disable/enable cycle. + */ +static const struct dmi_system_id elantech_needs_reenable[] = { +#if defined(CONFIG_DMI) && defined(CONFIG_X86) + { + /* Lenovo N24 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_NAME, "81AF"), + }, + }, +#endif + { } +}; + /* * Put the touchpad back into absolute mode when reconnecting */ static int elantech_reconnect(struct psmouse *psmouse) { + int err; + psmouse_reset(psmouse); if (elantech_detect(psmouse, 0)) return -1; + if (dmi_check_system(elantech_needs_reenable)) { + err = ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_DISABLE); + if (err) + psmouse_warn(psmouse, "failed to deactivate mouse on %s: %d\n", + psmouse->ps2dev.serio->phys, err); + + err = ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_ENABLE); + if (err) + psmouse_warn(psmouse, "failed to reactivate mouse on %s: %d\n", + psmouse->ps2dev.serio->phys, err); + } + if (elantech_set_absolute_mode(psmouse)) { psmouse_err(psmouse, "failed to put touchpad back into absolute mode.\n"); -- 2.43.0