From nobody Sat Apr 11 21:14:18 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 324C0C00140 for ; Mon, 8 Aug 2022 03:12:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236131AbiHHDMU (ORCPT ); Sun, 7 Aug 2022 23:12:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234723AbiHHDMG (ORCPT ); Sun, 7 Aug 2022 23:12:06 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11038DE8E; Sun, 7 Aug 2022 20:11:47 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 730325C00EC; Sun, 7 Aug 2022 23:11:46 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sun, 07 Aug 2022 23:11:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1659928306; x=1660014706; bh=rb q+GR1KjHrdFBIltGS8U+6Pe1Bj1GnwkA90Taje7+0=; b=lQunEgi4l1RjirM1a/ 1/aYxZbjILHeJTAiHipaxLis7nbwTNJtbID5eGnD++XOJXlCg//cfBFOIzfXrpGH Pq5LDbpwVZxYkmrmzwGdeg0TXhld6kUp5yitShaNPjwgr39P81y/xfvBihaY8PzE mz3SoIt1ZoN9mawephY7bqhnIpDvS5Dy0sN6bZih4hdMrEdaiFtKw+ZLGEVVEei0 ULlrsPpr5Fw1Xmo4V/cH3jDsfzkFCZz3BM+6THOZsCp/p88wny8Jr6mRTei+ffhS 6IxBPE7KeId3RzINUDdTR2bTCl0J3SWnapf1k7VhAaLDwGY8cVAlQlPUzIDJp915 Uy7g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1659928306; x=1660014706; bh=rbq+GR1KjHrdF BIltGS8U+6Pe1Bj1GnwkA90Taje7+0=; b=yUjU73D2hlCsuP0yhmlC4FOu7RJwV eo9/JdUq/BrpwgxKyRCDj7B0bfqQhn0Ut5Nfu8FL/d5bby7G7PmaCqyNY4NIDUz3 OLI3Vm7t//TDJa1lNW6mWaW4fm7Wf31nPSMfMGY3vTeMWoU655/4uL6yymwD4hQd Iy+Bzjx3yGMw822DpxTyXL7V4s76uTMpRyAHaLomzfzw3wOhcY2KyKO0IZzbbRku 8dazX6gLy9iZ/kQiZ7og2Wx1phm4VeE6OLOwyBUOZsvdmku/wrWxAo2jskQZRf3d BY5jIFMjBsRLD3KPe6jC9Uc2I1dEndQrmadv+PmvHJOJQnsktWINNquWw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdefjedgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 Aug 2022 23:11:44 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: markgross@kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 2/2] asus-wmi: Add support for ROG X13 tablet mode Date: Mon, 8 Aug 2022 15:11:32 +1200 Message-Id: <20220808031132.10075-3-luke@ljones.dev> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220808031132.10075-1-luke@ljones.dev> References: <20220808031132.10075-1-luke@ljones.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add quirk for ASUS ROG X13 Flow 2-in-1 to enable tablet mode with lid flip (all screen rotations). Signed-off-by: Luke D. Jones --- drivers/platform/x86/asus-nb-wmi.c | 17 +++++++++- drivers/platform/x86/asus-wmi.c | 36 ++++++++++++++++++++++ drivers/platform/x86/asus-wmi.h | 1 + include/linux/platform_data/x86/asus-wmi.h | 1 + 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus= -nb-wmi.c index 3a93e056c4e1..4aeaac92296f 100644 --- a/drivers/platform/x86/asus-nb-wmi.c +++ b/drivers/platform/x86/asus-nb-wmi.c @@ -123,6 +123,11 @@ static struct quirk_entry quirk_asus_use_lid_flip_devi= d =3D { .tablet_switch_mode =3D asus_wmi_lid_flip_devid, }; =20 +static struct quirk_entry quirk_asus_tablet_mode =3D { + .wmi_backlight_set_devstate =3D true, + .tablet_switch_mode =3D asus_wmi_lid_flip_rog_devid, +}; + static int dmi_matched(const struct dmi_system_id *dmi) { pr_info("Identified laptop model '%s'\n", dmi->ident); @@ -471,6 +476,15 @@ static const struct dmi_system_id asus_quirks[] =3D { }, .driver_data =3D &quirk_asus_use_lid_flip_devid, }, + { + .callback =3D dmi_matched, + .ident =3D "ASUS ROG FLOW X13", + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "GV301Q"), + }, + .driver_data =3D &quirk_asus_tablet_mode, + }, {}, }; =20 @@ -574,7 +588,8 @@ static const struct key_entry asus_nb_wmi_keymap[] =3D { { KE_KEY, 0xC4, { KEY_KBDILLUMUP } }, { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } }, { KE_IGNORE, 0xC6, }, /* Ambient Light Sensor notification */ - { KE_KEY, 0xFA, { KEY_PROG2 } }, /* Lid flip action */ + { KE_KEY, 0xFA, { KEY_PROG2 } }, /* Lid flip action */ + { KE_KEY, 0xBD, { KEY_PROG2 } }, /* Lid flip action on ROG xflow laptops = */ { KE_END, 0}, }; =20 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index a32e99205697..51610bd6b1c4 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -68,6 +68,7 @@ module_param(fnlock_default, bool, 0444); #define NOTIFY_KBD_FBM 0x99 #define NOTIFY_KBD_TTP 0xae #define NOTIFY_LID_FLIP 0xfa +#define NOTIFY_LID_FLIP_ROG 0xbd =20 #define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0) =20 @@ -529,6 +530,19 @@ static int asus_wmi_input_init(struct asus_wmi *asus) pr_err("Error checking for lid-flip: %d\n", result); } break; + case asus_wmi_lid_flip_rog_devid: + result =3D asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_LID_FLIP_RO= G); + if (result < 0) + asus->driver->quirks->tablet_switch_mode =3D asus_wmi_no_tablet_switch; + if (result >=3D 0) { + input_set_capability(asus->inputdev, EV_SW, SW_TABLET_MODE); + input_report_switch(asus->inputdev, SW_TABLET_MODE, result); + } else if (result =3D=3D -ENODEV) { + pr_err("This device has lid-flip-rog quirk but got ENODEV checking it. = This is a bug."); + } else { + pr_err("Error checking for lid-flip: %d\n", result); + } + break; } =20 err =3D input_register_device(asus->inputdev); @@ -562,6 +576,16 @@ static void lid_flip_tablet_mode_get_state(struct asus= _wmi *asus) } } =20 +static void lid_flip_rog_tablet_mode_get_state(struct asus_wmi *asus) +{ + int result =3D asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_LID_FLIP= _ROG); + + if (result >=3D 0) { + input_report_switch(asus->inputdev, SW_TABLET_MODE, result); + input_sync(asus->inputdev); + } +} + /* dGPU ******************************************************************= **/ static int dgpu_disable_check_present(struct asus_wmi *asus) { @@ -3106,6 +3130,12 @@ static void asus_wmi_handle_event_code(int code, str= uct asus_wmi *asus) return; } break; + case asus_wmi_lid_flip_rog_devid: + if (code =3D=3D NOTIFY_LID_FLIP_ROG) { + lid_flip_rog_tablet_mode_get_state(asus); + return; + } + break; } =20 if (asus->fan_boost_mode_available && code =3D=3D NOTIFY_KBD_FBM) { @@ -3747,6 +3777,9 @@ static int asus_hotk_resume(struct device *device) case asus_wmi_lid_flip_devid: lid_flip_tablet_mode_get_state(asus); break; + case asus_wmi_lid_flip_rog_devid: + lid_flip_rog_tablet_mode_get_state(asus); + break; } =20 return 0; @@ -3795,6 +3828,9 @@ static int asus_hotk_restore(struct device *device) case asus_wmi_lid_flip_devid: lid_flip_tablet_mode_get_state(asus); break; + case asus_wmi_lid_flip_rog_devid: + lid_flip_rog_tablet_mode_get_state(asus); + break; } =20 return 0; diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wm= i.h index 413920bad0c6..0187f13d2414 100644 --- a/drivers/platform/x86/asus-wmi.h +++ b/drivers/platform/x86/asus-wmi.h @@ -29,6 +29,7 @@ enum asus_wmi_tablet_switch_mode { asus_wmi_no_tablet_switch, asus_wmi_kbd_dock_devid, asus_wmi_lid_flip_devid, + asus_wmi_lid_flip_rog_devid, }; =20 struct quirk_entry { diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index a571b47ff362..d54458431600 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -64,6 +64,7 @@ #define ASUS_WMI_DEVID_PANEL_OD 0x00050019 #define ASUS_WMI_DEVID_CAMERA 0x00060013 #define ASUS_WMI_DEVID_LID_FLIP 0x00060062 +#define ASUS_WMI_DEVID_LID_FLIP_ROG 0x00060077 =20 /* Storage */ #define ASUS_WMI_DEVID_CARDREADER 0x00080013 --=20 2.37.1