Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2144941lqb; Mon, 27 May 2024 09:12:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWRKBv6eVRwuKGB9eMGfvPSueDQeyNdP4VaZlNIYBvqNEWUnZPrsQ1goHI2JRcQRK80uWhdYHKESN9SOvaBVbs6c88YsNhr+5hzNYGefg== X-Google-Smtp-Source: AGHT+IENqYU4Vvi3tXusfpG6GvzyxTcLnuuf5U4K1yZjOT2tvSWwneycPO/+a+q+QofR569T4zyk X-Received: by 2002:a17:902:e810:b0:1f4:467f:772e with SMTP id d9443c01a7336-1f4486b5dd0mr119754375ad.7.1716826325763; Mon, 27 May 2024 09:12:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716826325; cv=pass; d=google.com; s=arc-20160816; b=vjGY8WjgMEMnL1q2J4xmNqrsYmwNoeHRSPt515j64VogwPe+spodpJ8xHntGfajT0i 1b/NNfviCpCzkem96fzb8vNMimmP1OruHR4WIKyjgQ0FuHnHXsxuOlXgIAW6jRnxAJYX jrKV/LMv1pXDMqPg0M3Jqa82gYPuJTUxPSslAWLfR9N87EMGx2SDy6IrCscSwShwwQp8 yXTZjfg8W62iA1KOFz8535h9YrnNAjSAg+zRClLqY+FYVcal8arTSDF+4KNYOWhrQsmM ganSlJZ1bGCZOsD0X323TEoJCbAGCteTniE8eEARzq+eQR7gChVUYPX9j2orWZohfdz/ Iaqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=RRnqCSw6rL2Tzz0i0vScItyZ1wey8/5jFYAjFvSa/lw=; fh=Qw4MYKglmouv+FwJWT8+Xn9cUdyf2avgQ59aEMJ0BTQ=; b=z75UjOuMSRAkzC9eJMB3b8Osm1GAbkQHztV7eG/213Y9Qgn3RPzz5PVrJHVWjGV+Sr FxIvO8+r9mf6nr8jHsc45unaH6tXu4kq+kUFKuq4iPyqRbk0ZKT4BApswS5C3u4/Dvul hfuVFAf8vR9Xxz+sVeh+AwVR22sRJWfLfrpQDhp0v1PL8lKP8fVz5jR3+zEAEXY0oiCW b41QRbQLwX6TQ0kY9+NpeNg11I+mYmDGdtWyBZdbyWKfBPKgqNY3Wmr+b3O/rUV6FHZ2 LELoq1JaWlRHFGdLFnUhwMnkiKk1wm6EVbSCwmKLgixy8TVIakEQtKVVyYHL1xdts5GK pksg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AypJ7b7D; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191145-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c7c081bsi1986525ad.133.2024.05.27.09.12.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 09:12:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AypJ7b7D; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191145-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 699F9287648 for ; Mon, 27 May 2024 16:01:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2FEE161325; Mon, 27 May 2024 15:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AypJ7b7D" 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 F0D1D16088F; Mon, 27 May 2024 15:55:59 +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=1716825360; cv=none; b=GmeLvTlkgfgXWedk0N5CZumcEHgQAD9aXqasO+LML/zE2IVxCaXi1Nwj999z5Y6pHnyMAv4iwM1/Kxs5617cvaj6E63BWXlExM95yM1wSqPpwom1BnUlUkaN1BF0CpAiEnkDDAUyrsf6YU8kvVHwgSTovh6ivGQKr9nwZc6tvCo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716825360; c=relaxed/simple; bh=usPfH4pL6CzqFQBNmbw6aRWHYqXftvOZaHjenx3H2iE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tYzNNRSu0Q0xD5jJHTfS0PeZwN9cqd+qaSV+O4pD+BG/mnepRlkBdtM/z0uK7RhwGWhexcUTAEOUCvAkhDwfppWftGTigW56lFz4+OmVdYiuQmVJtT7EU7vgyhP3TE3+A/+LLGW4cndN/H5r2QCq5e0GGNXfqJtt3RWhl8qTTG4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AypJ7b7D; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C0EBC32789; Mon, 27 May 2024 15:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716825359; bh=usPfH4pL6CzqFQBNmbw6aRWHYqXftvOZaHjenx3H2iE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AypJ7b7DBJPxdjLTUGOl9fRc7gRDGqLSaF30Yo73Txp2jobLYGbAOUKuHB2EVWHSF 4miFuc9K5j4gTLXVe5zBTEOTKuvdMhTRltL1HK7dx/a9ffhmmrrL05THK8MbL68Hbt 7tPCGD+SwapyJYDbKch1DxbGU+aqVDW2dRwcnnV2hEPoxH+nCldpsMUudNY7kz0WCl ojSMivNtNoL2NKESDnewufies38BYFj6mG4NtoZBJMDCSrvja4BBLacpTprdTtI7L1 XTpWt5QDM/cShnRNzyJgizihiv/ATlraHo6aK7bOYC1gIHvzxtl2a2RydcVavTqHFS uDHAcCNOfWbCA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arvid Norlander , Hans de Goede , Sasha Levin , coproscefalo@gmail.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 03/16] platform/x86: toshiba_acpi: Add quirk for buttons on Z830 Date: Mon, 27 May 2024 11:54:54 -0400 Message-ID: <20240527155541.3865428-3-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527155541.3865428-1-sashal@kernel.org> References: <20240527155541.3865428-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Arvid Norlander [ Upstream commit 23f1d8b47d125dcd8c1ec62a91164e6bc5d691d0 ] The Z830 has some buttons that will only work properly as "quickstart" buttons. To enable them in that mode, a value between 1 and 7 must be used for HCI_HOTKEY_EVENT. Windows uses 0x5 on this laptop so use that for maximum predictability and compatibility. As there is not yet a known way of auto detection, this patch uses a DMI quirk table. A module parameter is exposed to allow setting this on other models for testing. Signed-off-by: Arvid Norlander Tested-by: Hans de Goede Reviewed-by: Hans de Goede Link: https://lore.kernel.org/r/20240131111641.4418-3-W_Armin@gmx.de Signed-off-by: Hans de Goede Signed-off-by: Sasha Levin --- drivers/platform/x86/toshiba_acpi.c | 36 ++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index 291f14ef67024..2a5a651235fe6 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c @@ -57,6 +57,11 @@ module_param(turn_on_panel_on_resume, int, 0644); MODULE_PARM_DESC(turn_on_panel_on_resume, "Call HCI_PANEL_POWER_ON on resume (-1 = auto, 0 = no, 1 = yes"); +static int hci_hotkey_quickstart = -1; +module_param(hci_hotkey_quickstart, int, 0644); +MODULE_PARM_DESC(hci_hotkey_quickstart, + "Call HCI_HOTKEY_EVENT with value 0x5 for quickstart button support (-1 = auto, 0 = no, 1 = yes"); + #define TOSHIBA_WMI_EVENT_GUID "59142400-C6A3-40FA-BADB-8A2652834100" /* Scan code for Fn key on TOS1900 models */ @@ -136,6 +141,7 @@ MODULE_PARM_DESC(turn_on_panel_on_resume, #define HCI_ACCEL_MASK 0x7fff #define HCI_ACCEL_DIRECTION_MASK 0x8000 #define HCI_HOTKEY_DISABLE 0x0b +#define HCI_HOTKEY_ENABLE_QUICKSTART 0x05 #define HCI_HOTKEY_ENABLE 0x09 #define HCI_HOTKEY_SPECIAL_FUNCTIONS 0x10 #define HCI_LCD_BRIGHTNESS_BITS 3 @@ -2730,10 +2736,15 @@ static int toshiba_acpi_enable_hotkeys(struct toshiba_acpi_dev *dev) return -ENODEV; /* + * Enable quickstart buttons if supported. + * * Enable the "Special Functions" mode only if they are * supported and if they are activated. */ - if (dev->kbd_function_keys_supported && dev->special_functions) + if (hci_hotkey_quickstart) + result = hci_write(dev, HCI_HOTKEY_EVENT, + HCI_HOTKEY_ENABLE_QUICKSTART); + else if (dev->kbd_function_keys_supported && dev->special_functions) result = hci_write(dev, HCI_HOTKEY_EVENT, HCI_HOTKEY_SPECIAL_FUNCTIONS); else @@ -3257,7 +3268,14 @@ static const char *find_hci_method(acpi_handle handle) * works. toshiba_acpi_resume() uses HCI_PANEL_POWER_ON to avoid changing * the configured brightness level. */ -static const struct dmi_system_id turn_on_panel_on_resume_dmi_ids[] = { +#define QUIRK_TURN_ON_PANEL_ON_RESUME BIT(0) +/* + * Some Toshibas use "quickstart" keys. On these, HCI_HOTKEY_EVENT must use + * the value HCI_HOTKEY_ENABLE_QUICKSTART. + */ +#define QUIRK_HCI_HOTKEY_QUICKSTART BIT(1) + +static const struct dmi_system_id toshiba_dmi_quirks[] = { { /* Toshiba Portégé R700 */ /* https://bugzilla.kernel.org/show_bug.cgi?id=21012 */ @@ -3265,6 +3283,7 @@ static const struct dmi_system_id turn_on_panel_on_resume_dmi_ids[] = { DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE R700"), }, + .driver_data = (void *)QUIRK_TURN_ON_PANEL_ON_RESUME, }, { /* Toshiba Satellite/Portégé R830 */ @@ -3274,6 +3293,7 @@ static const struct dmi_system_id turn_on_panel_on_resume_dmi_ids[] = { DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), DMI_MATCH(DMI_PRODUCT_NAME, "R830"), }, + .driver_data = (void *)QUIRK_TURN_ON_PANEL_ON_RESUME, }, { /* Toshiba Satellite/Portégé Z830 */ @@ -3281,6 +3301,7 @@ static const struct dmi_system_id turn_on_panel_on_resume_dmi_ids[] = { DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), DMI_MATCH(DMI_PRODUCT_NAME, "Z830"), }, + .driver_data = (void *)(QUIRK_TURN_ON_PANEL_ON_RESUME | QUIRK_HCI_HOTKEY_QUICKSTART), }, }; @@ -3289,6 +3310,8 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) struct toshiba_acpi_dev *dev; const char *hci_method; u32 dummy; + const struct dmi_system_id *dmi_id; + long quirks = 0; int ret = 0; if (toshiba_acpi) @@ -3441,8 +3464,15 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) } #endif + dmi_id = dmi_first_match(toshiba_dmi_quirks); + if (dmi_id) + quirks = (long)dmi_id->driver_data; + if (turn_on_panel_on_resume == -1) - turn_on_panel_on_resume = dmi_check_system(turn_on_panel_on_resume_dmi_ids); + turn_on_panel_on_resume = !!(quirks & QUIRK_TURN_ON_PANEL_ON_RESUME); + + if (hci_hotkey_quickstart == -1) + hci_hotkey_quickstart = !!(quirks & QUIRK_HCI_HOTKEY_QUICKSTART); toshiba_wwan_available(dev); if (dev->wwan_supported) -- 2.43.0