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 DFCC819E2DB; Tue, 9 Jul 2024 16:27:28 +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=1720542449; cv=none; b=b3SVhdtjTjCiyALDsufOEk8jS198bq50fvLPKNVMn+ECdEgBU1iWBKxpkcr232EhAsik8N+aOmpFKLPH5c689Py+T9grph0HknHgFV98ObMxwbYUysX3y/8ujJdm3U2KMH2VtQw/M5AIxFccIcr3UBUf4/leEUgCOIIy92Leylo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720542449; c=relaxed/simple; bh=imYIFxwQm9Tpqt9qP5Rzt36q+eNgduHDNVlWjY4Y8B8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=I8VNksO9tApXI+pISppPsKJ8IUaVIF7QbekbVCY++NfIqgKRxuXTKdTL1Or2D+cWQiSwYyOf4srt8+LWwKoHEcpR6n86jCIJHVxSKrtptTZS9lCViW3Wkm8511AgI92m3rGw3sQT6bJUQeA8v2gbF/FtovBeDnEes941cpADsMk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h1koOL3P; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h1koOL3P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4DE6C3277B; Tue, 9 Jul 2024 16:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720542448; bh=imYIFxwQm9Tpqt9qP5Rzt36q+eNgduHDNVlWjY4Y8B8=; h=From:To:Cc:Subject:Date:From; b=h1koOL3PQE07powVZFfrkSE2LTR7D8Nwkd8oD9su6rRxDUKRBkT6n66EfHd+eG5c6 GrFd7c3h/cdvQ9A+D79fIA8uYm3+pQjiLpkqxMqVQvA+owxmTd6VEVTRcw/Fis0TGC 3U0sF6l6m7e/i1aJcRET6MT8EvvE9V5UDGH5Z48nlknpcLW2hQwrE3THb/2qB/RLKN WqQ7BcFUcupkOYaPm2YPsMLUXDkG9b4nqKH9UMFZL7N3NuAiCuoVH3LEE2amyOmMGz RNlS+zioUOl4ACEFodZPQVOyp1pUJpnh5qHBdOYPvwbZxMCiDfhAVA/JSJyUov1pM6 XxzN8OVWuZ3YQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jonathan Denose , Dmitry Torokhov , Sasha Levin , jefferymiller@google.com, linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 1/7] Input: elantech - fix touchpad state on resume for Lenovo N24 Date: Tue, 9 Jul 2024 12:27:12 -0400 Message-ID: <20240709162726.33610-1-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 4.19.317 Content-Transfer-Encoding: 8bit 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 6759cab82a723..6f747c59cd652 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -1527,16 +1527,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