From nobody Sat May 30 09:52:25 2026 Received: from smtp-out1.simply.com (smtp-out1.simply.com [94.231.106.240]) (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 9D5BD332913; Wed, 6 May 2026 19:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.240 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778096021; cv=none; b=m7uGocVDCqbbyDRTy+IwWXVH4cXWYqxl86wCBdBqaVCPylMd85d3jQ+8jO1Yjh3hchDjOOilE6DnTDwAMmVKZ2cFl4ndRuKhgn8nm6SRZeqgWpe9PELCOeUfFBCYTHq+d13zpw7ilhzFgGhBsbSzk6J38akqNvxWUVoIY28LJ8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778096021; c=relaxed/simple; bh=0E0riaforsFpDADYdFU7wxSXkiaEjNYCmu26Yajw9S0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W926cFADP6pxkJ2TTWPZyi3oOPkJIalNQkx1tOY3wqNtZ6taOFVUbCoQeptGbvSjcPAXVPyBnHqQ9GMBE42jU4nbqZoUmOHjIcvL7blnjl7Xe3mQyP4SVLyD8BveTCkMVC+wgmeT/WHaHdRVsD/Ng+KtB84SLRhGOh2JhcsfN2U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grenangen.se; spf=pass smtp.mailfrom=grenangen.se; dkim=pass (2048-bit key) header.d=grenangen.se header.i=@grenangen.se header.b=hJkzk35k; arc=none smtp.client-ip=94.231.106.240 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grenangen.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=grenangen.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=grenangen.se header.i=@grenangen.se header.b="hJkzk35k" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4g9lsz6z7lz1DHbY; Wed, 6 May 2026 21:33:27 +0200 (CEST) Received: from localhost (h-217-27-171-125.A498.priv.bahnhof.se [217.27.171.125]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by smtp.simply.com (Simply.com) with ESMTPSA id 4g9lsz5bLmz1DHpS; Wed, 6 May 2026 21:33:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grenangen.se; s=simplycom2; t=1778096007; bh=5ziB+yeGoLE8bnmvg6gHy/PHSlDnMakEWu2jrT3ybss=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hJkzk35k6VxzY8T0TJFhlsSOXIlalXMQW3vSAMHI+IPKqM/AmYYmFDfEnJ3b7TYNM ffXWGrB2xixYAl8aOgXMpuRv3OeXxFXKSMgo8p80XVRwYhwTB1h+6ExDXLOCw6cEE1 EcIAysHDGWmsYbAahY3wskxiQHpOdglSdSL5y2v+3Q7TOon9BxMefh4K7OoUR+h734 nnw8stcqAtPcnI82iMGvgTyvdcKnpmZBd+Cispe1rJBAZui2Y3acZ91H2T2ChEwGR0 NNiFnvEtx0CDRxaM4mRPbspCzHvrRfkDxKWk+yPhXzRopXUYDFUv8dZqLdgCbR3+3p d1hD2vi1PMErQ== From: =?UTF-8?q?Marcus=20Gren=C3=A4ngen?= To: platform-driver-x86@vger.kernel.org, denis.benato@linux.dev Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, luke@ljones.dev, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, jikos@kernel.org, bentiss@kernel.org, corentin.chary@gmail.com, marcus@grenangen.se Subject: [PATCH v2 1/3] HID: asus: export asus_hid_fnlock_notify() for direct fn-lock control Date: Wed, 6 May 2026 21:33:24 +0200 Message-ID: <20260506193326.5862-2-marcus@grenangen.se> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260506193326.5862-1-marcus@grenangen.se> References: <458d9e6c-8702-4cbc-9c4f-33cbd1175e67@linux.dev> <20260506193326.5862-1-marcus@grenangen.se> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Some ASUS platforms cannot control fn-lock via WMI DEVS and must send a HID feature report directly to the N-Key keyboard device instead. Add a module-level fnlock_hdev pointer (protected by a mutex) that is set at probe time for devices with QUIRK_HID_FN_LOCK and cleared at remove. Export asus_hid_fnlock_notify(bool) so that asus-armoury can call into hid-asus without a circular dependency. Signed-off-by: Marcus Gren=C3=A4ngen --- drivers/hid/hid-asus.c | 43 +++++++++++++++++++++- include/linux/platform_data/x86/asus-wmi.h | 5 +++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index d34d74df3dc0..8a51dacf35eb 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -584,6 +584,38 @@ static void asus_sync_fn_lock(struct work_struct *work) asus_kbd_set_fn_lock(drvdata->hdev, drvdata->fn_lock); } =20 +/* + * Module-level reference to the HID device that handles fn-lock via featu= re + * report. Set at probe and cleared at remove for QUIRK_HID_FN_LOCK device= s. + * Protected by fnlock_hdev_lock. + */ +static DEFINE_MUTEX(fnlock_hdev_lock); +static struct hid_device *fnlock_hdev; + +/** + * asus_hid_fnlock_notify() - Set fn-lock state directly via HID feature r= eport. + * @enabled: true to lock fn (F1-F12 primary), false to unlock. + * + * Called by asus-armoury on platforms where the WMI DEVS path for fn-lock= is + * non-functional (e.g. ASUS ProArt P16, N-Key keyboard product ID 0x19B6). + * + * Returns 0 on success, -ENODEV if no fn-lock capable HID device is prese= nt. + */ +int asus_hid_fnlock_notify(bool enabled) +{ + int ret =3D -ENODEV; + + guard(mutex)(&fnlock_hdev_lock); + if (fnlock_hdev) { + ret =3D asus_kbd_set_fn_lock(fnlock_hdev, enabled); + /* hid_hw_raw_request returns byte count on success; normalise to 0 */ + if (ret > 0) + ret =3D 0; + } + return ret; +} +EXPORT_SYMBOL_GPL(asus_hid_fnlock_notify); + static void asus_schedule_work(struct asus_kbd_leds *led) { unsigned long flags; @@ -969,6 +1001,8 @@ static int asus_input_configured(struct hid_device *hd= ev, struct hid_input *hi) drvdata->fn_lock =3D true; INIT_WORK(&drvdata->fn_lock_sync_work, asus_sync_fn_lock); asus_kbd_set_fn_lock(hdev, true); + guard(mutex)(&fnlock_hdev_lock); + fnlock_hdev =3D hdev; } =20 if (drvdata->tp) { @@ -1008,6 +1042,8 @@ static int asus_input_configured(struct hid_device *h= dev, struct hid_input *hi) drvdata->fn_lock =3D true; INIT_WORK(&drvdata->fn_lock_sync_work, asus_sync_fn_lock); asus_kbd_set_fn_lock(hdev, true); + guard(mutex)(&fnlock_hdev_lock); + fnlock_hdev =3D hdev; } =20 return 0; @@ -1362,8 +1398,13 @@ static void asus_remove(struct hid_device *hdev) cancel_work_sync(&drvdata->kbd_backlight->work); } =20 - if (drvdata->quirks & QUIRK_HID_FN_LOCK) + if (drvdata->quirks & QUIRK_HID_FN_LOCK) { + scoped_guard(mutex, &fnlock_hdev_lock) { + if (fnlock_hdev =3D=3D hdev) + fnlock_hdev =3D NULL; + } cancel_work_sync(&drvdata->fn_lock_sync_work); + } =20 hid_hw_stop(hdev); } diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index 554f41b827e1..20facd5da74e 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -196,6 +196,7 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u= 32 arg1, u32 *retval); int asus_hid_register_listener(struct asus_hid_listener *cdev); void asus_hid_unregister_listener(struct asus_hid_listener *cdev); int asus_hid_event(enum asus_hid_event event); +int asus_hid_fnlock_notify(bool enabled); #else static inline void set_ally_mcu_hack(enum asus_ally_mcu_hack status) { @@ -227,6 +228,10 @@ static inline int asus_hid_event(enum asus_hid_event e= vent) { return -ENODEV; } +static inline int asus_hid_fnlock_notify(bool enabled) +{ + return -ENODEV; +} #endif =20 #endif /* __PLATFORM_DATA_X86_ASUS_WMI_H */ --=20 2.54.0 From nobody Sat May 30 09:52:25 2026 Received: from smtp-out1.simply.com (smtp-out1.simply.com [94.231.106.240]) (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 9D1F1332909; Wed, 6 May 2026 19:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.240 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778096019; cv=none; b=Lx/ruosKiB9eYVaMjBHD0P3REfAD8KPidp2Q8vRIGjHH9stnWEdd0M/hsh+tiWadOiYZMTmCmRGO78wv7nFTWSknxPud8RNLtRFMlhN65umOWP5mKeuB1zB/+77ernDW+31yekW8Gyc5uBHuRMbmTEJKewVXIGEwrmWvaBU+Kos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778096019; c=relaxed/simple; bh=acAqpCuG5vdbCm/VILd6zEIEiskYNw+niNY51lb9HLE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IQaFVHkSyWwDl8l+JWt1ZEaibNS4GegRvJRt4Lcggv/HX2i/ayatqSwLOrbaXV69zoZverpxxIXouVqoMLoLeB6iQfgO/gUR9IxW0W4BsUP0swaZNzPVxj+1HjlY4dCLZX7XMWlj518z6wgqKcc7CPYD0+YI/wit6Pus4HEvvKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grenangen.se; spf=pass smtp.mailfrom=grenangen.se; dkim=pass (2048-bit key) header.d=grenangen.se header.i=@grenangen.se header.b=cipZb7LY; arc=none smtp.client-ip=94.231.106.240 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grenangen.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=grenangen.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=grenangen.se header.i=@grenangen.se header.b="cipZb7LY" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4g9lt02nvMz1DHpT; Wed, 6 May 2026 21:33:28 +0200 (CEST) Received: from localhost (h-217-27-171-125.A498.priv.bahnhof.se [217.27.171.125]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by smtp.simply.com (Simply.com) with ESMTPSA id 4g9lt01Qypz1DDSy; Wed, 6 May 2026 21:33:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grenangen.se; s=simplycom2; t=1778096008; bh=5plDjFUkjm3z87K+GUhrRwUtHmmpSxf/2NvEC0qQWv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cipZb7LYQyNmlNGG0nCZgElGSFVJCvT1iXidzDonHvgqR5ihi2kcn+Aj9vzWEkwmW 3+TrDbUOUyYCjDtipc58R+EqUkV5JlkdAuZmJkagHWZL89LPDry5MeLGdknYp3Hlq4 q4hbfl6LuMQ6D2HZFPuv77bYNX7d9RF5jT6NN2A02CEoowzjPqbnGyxD3sJjk+DxLe ADO72R9+oq3G12LGU7wv58HTGf7jllrSLIvms46oVYS9vwUuu8+99qF6Nbc/Uw9+PX i7Pcf4NbGeVOdsd0gp8mepWGVsdldyM70sL2Bzrba1Q9c5Acy8RyrWKlGgcOGn/lkV 3T9AiFPGDPBrA== From: =?UTF-8?q?Marcus=20Gren=C3=A4ngen?= To: platform-driver-x86@vger.kernel.org, denis.benato@linux.dev Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, luke@ljones.dev, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, jikos@kernel.org, bentiss@kernel.org, corentin.chary@gmail.com, marcus@grenangen.se Subject: [PATCH v2 2/3] platform/x86: asus-nb-wmi: add fnlock_use_hid quirk for ProArt P16 Date: Wed, 6 May 2026 21:33:25 +0200 Message-ID: <20260506193326.5862-3-marcus@grenangen.se> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260506193326.5862-1-marcus@grenangen.se> References: <458d9e6c-8702-4cbc-9c4f-33cbd1175e67@linux.dev> <20260506193326.5862-1-marcus@grenangen.se> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The ASUS ProArt P16 (N-Key keyboard 0B05:19B6) advertises the WMI fn-lock DEVID (0x00100023) as present via DSTS, but the DEVS call has no effect. Fn-lock must instead be toggled via a HID feature report sent to the N-Key keyboard (handled by hid-asus). Add a fnlock_use_hid flag to struct quirk_entry and set it for the ProArt P16 via a DMI match on DMI_PRODUCT_FAMILY. This flag is consumed by asus-armoury to select the HID path instead of WMI DEVS. Signed-off-by: Marcus Gren=C3=A4ngen --- drivers/platform/x86/asus-nb-wmi.c | 13 +++++++++++++ drivers/platform/x86/asus-wmi.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus= -nb-wmi.c index b4677c5bba5b..44e4cf68ff70 100644 --- a/drivers/platform/x86/asus-nb-wmi.c +++ b/drivers/platform/x86/asus-nb-wmi.c @@ -155,6 +155,10 @@ static struct quirk_entry quirk_asus_z13 =3D { .tablet_switch_mode =3D asus_wmi_kbd_dock_devid, }; =20 +static struct quirk_entry quirk_asus_proart_p16 =3D { + .fnlock_use_hid =3D true, +}; + static int dmi_matched(const struct dmi_system_id *dmi) { pr_info("Identified laptop model '%s'\n", dmi->ident); @@ -553,6 +557,15 @@ static const struct dmi_system_id asus_quirks[] =3D { }, .driver_data =3D &quirk_asus_z13, }, + { + .callback =3D dmi_matched, + .ident =3D "ASUS ProArt P16", + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_FAMILY, "ProArt P16"), + }, + .driver_data =3D &quirk_asus_proart_p16, + }, {}, }; =20 diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wm= i.h index 5cd4392b964e..6c50b11860e8 100644 --- a/drivers/platform/x86/asus-wmi.h +++ b/drivers/platform/x86/asus-wmi.h @@ -52,6 +52,11 @@ struct quirk_entry { */ int no_display_toggle; u32 xusb2pr; + /* + * Some platforms report WMI DEVID_FNLOCK as present but the DEVS call + * is a no-op. Force the HID feature report path via hid-asus instead. + */ + bool fnlock_use_hid; }; =20 struct asus_wmi_driver { --=20 2.54.0 From nobody Sat May 30 09:52:25 2026 Received: from smtp-out1.simply.com (smtp-out1.simply.com [94.231.106.240]) (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 E0F30332EC8; Wed, 6 May 2026 19:33:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.240 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778096024; cv=none; b=TmDADFsJNpvZIya14iMEQETx1YkncGgXVrJU1Jw3NUKes0UT/Bcs8Y0IcJuwHVBx23/KjQ4b1jhETWxGTTeMiWdHeAD3urEO/69EPplczEsvyAIPd/xiAed8JH7/w8ksJv28iATM7vns1DBNXeeHRaWTVxaW0W25kK7zrskl+3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778096024; c=relaxed/simple; bh=8Hi7J7f3Jc7rM9ymARnR7xQY4X+5J79J7sltTqwI5KM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B5eOIi5Lds7NlhXApvYVijxymHU2j00z6gtAEZf4AMTtdeQgJ+mZBBEicyd5ManG1IX7ahPOWnkTU7omkqyfo0aWg3u6rAkuqEUUB+bkh9NwjigW8J7+K7dF/UfmZ3butaCMBWMSBkbVipitJN+zBgDUhl1m5rWcZLPkQNamDOg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grenangen.se; spf=pass smtp.mailfrom=grenangen.se; dkim=pass (2048-bit key) header.d=grenangen.se header.i=@grenangen.se header.b=DHFLEchz; arc=none smtp.client-ip=94.231.106.240 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grenangen.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=grenangen.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=grenangen.se header.i=@grenangen.se header.b="DHFLEchz" Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4g9lt06c3Cz1DHpW; Wed, 6 May 2026 21:33:28 +0200 (CEST) Received: from localhost (h-217-27-171-125.A498.priv.bahnhof.se [217.27.171.125]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by smtp.simply.com (Simply.com) with ESMTPSA id 4g9lt05F8Fz1DDSy; Wed, 6 May 2026 21:33:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grenangen.se; s=simplycom2; t=1778096008; bh=M3+Ob8zDodFfm/vUJ1ZC2GL/XQp5y9tvpEeAGHcwyvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DHFLEchzx5/TAxiUCmE/g9p8p7syVaQrVPUeaW0Njfv26DGPcU0bBXAL29GObYvqp g1kLq8oQ4AD9ldPhGH7W4S8s4RaS4D7fgHbM6cmEt1tof2VQDuLmXF/BKFlivqzxlB UwwiBRgUw+t24Z0elUbFkmvX60uKIuzBviKNIPXYxyWvKatUGom7KTKBU2Pr4jQf6V 2n2V/PiUv52ppuoXarH+FYclYB6tAzxyFEtnsi5FkFzj0p3U0+suN0kvCh3DbCK/VT MmvtvxpCwTzQHsP0iuCbmrRo5OI/8rV9U2mfvToAu7ktgEAgtkv1RtMjChQ4Jh26Dp 0YKgeOgXd3RwA== From: =?UTF-8?q?Marcus=20Gren=C3=A4ngen?= To: platform-driver-x86@vger.kernel.org, denis.benato@linux.dev Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, luke@ljones.dev, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, jikos@kernel.org, bentiss@kernel.org, corentin.chary@gmail.com, marcus@grenangen.se Subject: [PATCH v2 3/3] platform/x86: asus-armoury: add fn_lock firmware attribute Date: Wed, 6 May 2026 21:33:26 +0200 Message-ID: <20260506193326.5862-4-marcus@grenangen.se> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260506193326.5862-1-marcus@grenangen.se> References: <458d9e6c-8702-4cbc-9c4f-33cbd1175e67@linux.dev> <20260506193326.5862-1-marcus@grenangen.se> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add a fn_lock attribute to the asus-armoury firmware-attributes interface, allowing userspace to read and set the Fn-lock state (whether F1-F12 keys are primary or media/system keys are primary). On most ASUS laptops fn-lock is backed by WMI DEVID 0x00100023 and the attribute uses armoury_get/set_devstate() as normal. On platforms where the WMI DEVS call is a no-op (fnlock_use_hid quirk, e.g. ProArt P16), the store path calls asus_hid_fnlock_notify() to send the feature report directly to the N-Key keyboard via hid-asus. The show path returns -EOPNOTSUPP on such platforms as the hardware provides no readback. The fnlock_use_hid flag is detected at init time via dmi_match() on DMI_PRODUCT_FAMILY. A direct DMI check is used rather than reading the asus-nb-wmi quirk flag because asus-armoury and asus-nb-wmi are both loadable modules at the same init level, so the asus_ref pointer set by asus-wmi may not yet be valid when asus-armoury initialises. Signed-off-by: Marcus Gren=C3=A4ngen --- drivers/platform/x86/asus-armoury.c | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asu= s-armoury.c index 5b0987ccc270..9d7646eff944 100644 --- a/drivers/platform/x86/asus-armoury.c +++ b/drivers/platform/x86/asus-armoury.c @@ -93,6 +93,7 @@ struct asus_armoury_priv { =20 u32 mini_led_dev_id; u32 gpu_mux_dev_id; + bool fnlock_use_hid; }; =20 static struct asus_armoury_priv asus_armoury =3D { @@ -778,6 +779,58 @@ ASUS_ATTR_GROUP_ROG_TUNABLE(nv_tgp, "nv_tgp", ASUS_WMI= _DEVID_DGPU_SET_TGP, ASUS_ATTR_GROUP_INT_VALUE_ONLY_RO(nv_base_tgp, ATTR_NV_BASE_TGP, ASUS_WMI_= DEVID_DGPU_BASE_TGP, "Read the base TGP value"); =20 +/* + * fn_lock: toggle whether Fn key is locked (F1-F12 primary) or unlocked + * (media/system keys primary). + * + * On most ASUS laptops this is backed by WMI DEVID 0x00100023. On some + * platforms (e.g. ProArt P16) that DEVS call is a no-op and the state must + * be sent as a HID feature report to the N-Key keyboard via hid-asus. + */ +static ssize_t fn_lock_current_value_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + u32 result; + int err; + + if (asus_armoury.fnlock_use_hid) + return -EOPNOTSUPP; + + err =3D armoury_get_devstate(attr, &result, ASUS_WMI_DEVID_FNLOCK); + if (err) + return err; + + return sysfs_emit(buf, "%u\n", result & 1); +} + +static ssize_t fn_lock_current_value_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + bool enable; + int err; + + err =3D kstrtobool(buf, &enable); + if (err) + return err; + + if (asus_armoury.fnlock_use_hid) { + err =3D asus_hid_fnlock_notify(enable); + if (err) + return err; + } else { + err =3D armoury_set_devstate(attr, enable ? 1 : 0, NULL, + ASUS_WMI_DEVID_FNLOCK); + if (err) + return err; + } + + sysfs_notify(kobj, NULL, attr->attr.name); + return count; +} + +ASUS_ATTR_GROUP_BOOL(fn_lock, "fn_lock", "Set the Fn-lock state"); + /* If an attribute does not require any special case handling add it here = */ static const struct asus_attr_group armoury_attr_groups[] =3D { { &egpu_connected_attr_group, ASUS_WMI_DEVID_EGPU_CONNECTED }, @@ -926,6 +979,16 @@ static int asus_fw_attr_add(void) } } =20 + if (asus_armoury.fnlock_use_hid || + armoury_has_devstate(ASUS_WMI_DEVID_FNLOCK)) { + err =3D sysfs_create_group(&asus_armoury.fw_attr_kset->kobj, + &fn_lock_attr_group); + if (err) { + pr_err("Failed to create sysfs-group for fn_lock\n"); + goto err_remove_gpu_mux_group; + } + } + for (i =3D 0; i < ARRAY_SIZE(armoury_attr_groups); i++) { if (!armoury_has_devstate(armoury_attr_groups[i].wmi_devid)) continue; @@ -963,6 +1026,8 @@ static int asus_fw_attr_add(void) sysfs_remove_group(&asus_armoury.fw_attr_kset->kobj, armoury_attr_groups[i].attr_group); } + sysfs_remove_group(&asus_armoury.fw_attr_kset->kobj, &fn_lock_attr_group); +err_remove_gpu_mux_group: if (asus_armoury.gpu_mux_dev_id) sysfs_remove_group(&asus_armoury.fw_attr_kset->kobj, &gpu_mux_mode_attr_= group); err_remove_mini_led_group: @@ -1121,6 +1186,8 @@ static int __init asus_fw_init(void) =20 init_rog_tunables(); =20 + asus_armoury.fnlock_use_hid =3D dmi_match(DMI_PRODUCT_FAMILY, "ProArt P16= "); + /* Must always be last step to ensure data is available */ return asus_fw_attr_add(); } @@ -1138,6 +1205,8 @@ static void __exit asus_fw_exit(void) if (asus_armoury.gpu_mux_dev_id) sysfs_remove_group(&asus_armoury.fw_attr_kset->kobj, &gpu_mux_mode_attr_= group); =20 + sysfs_remove_group(&asus_armoury.fw_attr_kset->kobj, &fn_lock_attr_group); + if (asus_armoury.mini_led_dev_id) sysfs_remove_group(&asus_armoury.fw_attr_kset->kobj, &mini_led_mode_attr= _group); =20 --=20 2.54.0