From: Stefan Sichler <stsichler@web.de>
To: ilpo.jarvinen@linux.intel.com
Cc: jorgealtxwork@gmail.com, platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH v5 2/4] Fix SW_TABLET_MODE detection method
Date: Mon, 19 Aug 2024 18:41:59 +0200 [thread overview]
Message-ID: <40e05e60-e352-46fa-9b3c-b4fc8d90cedd@web.de> (raw)
In-Reply-To: <158df220-b282-3da3-0e87-ae7a3c64d056@linux.intel.com>
Hi Ilpo,
thank you for your comments.
I added some defines for the values of the module param and re-ordered the
logic a bit. I think it is easier to follow now.
I now also use another return variable "ret2" for the result of
hp_wmi_read_int() to not overwrite the result of original
hp_wmi_perform_query() when hp_wmi_read_int() fails. This was actually a
bug in my first implementation.
I still think that re-using the enable_tablet_mode_sw param for that is
a reasonable compromise, because the comment of original
commit 520ee4ea1cc60251a6e3c911cf0336278aa52634 suggests that there was
some problem with hp_wmi_read_int(HPWMI_HARDWARE_QUERY) on newer Tablets.
So, because I cannot test this, I'd prefer to not change current behavior
when the enable_tablet_mode_sw parameter is not set.
Best Regards
Stefan
>>>>>>>>>>>>>>> Actual patch starts here:
From: Stefan Sichler <stsichler@web.de>
Date: Mon, 19 Aug 2024 14:45:57 +0200
Subject: [PATCH] platform/x86: hp-wmi: repair Tablet Mode detection on old
Convertibles
This fixes a regression introduced by commit
520ee4ea1cc60251a6e3c911cf0336278aa52634
("Fix SW_TABLET_MODE detection method").
Investigation showed that some older Convertibles like HP EliteBook 2760p
do neither report Chassis Type correctly nor report tablet state by
HPWMI_SYSTEM_DEVICE_MODE, so for those, it is still required to fallback
to previous HPWMI_HARDWARE_QUERY method.
Since on pre-5.18 kernels, it was required to set enable_tablet_mode_sw
module param to enable this anyway, we re-add this removed parameter here
and re-use it in the following way:
- when left at default -1 (auto): no change to current implementation
- when set to 0 (off): unconditionally disable tablet mode reporting
- when set to 1 (force on): ignore Chassis type and use old
hp_wmi_hw_state(HPWMI_TABLET_MASK) query method in addition to new
hp_wmi_perform_query(HPWMI_SYSTEM_DEVICE_MODE...) method
Signed-off-by: Stefan Sichler <stsichler@web.de>
---
drivers/platform/x86/hp/hp-wmi.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index 876e0a97c..cab01308d 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -38,6 +38,13 @@ MODULE_LICENSE("GPL");
MODULE_ALIAS("wmi:95F24279-4D7B-4334-9387-ACCDC67EF61C");
MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4");
+static int enable_tablet_mode_sw = -1;
+module_param(enable_tablet_mode_sw, int, 0444);
+MODULE_PARM_DESC(enable_tablet_mode_sw, "Enable SW_TABLET_MODE reporting (-1=auto, 0=no, 1=yes)");
+#define HPWMI_TABLET_MODE_SW_AUTO -1
+#define HPWMI_TABLET_MODE_SW_OFF 0
+#define HPWMI_TABLET_MODE_SW_FORCE_ON 1
+
#define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C"
#define HPWMI_BIOS_GUID "5FB7F034-2C63-45E9-BE91-3D44E2C707E4"
@@ -459,23 +466,40 @@ static int hp_wmi_get_tablet_mode(void)
bool tablet_found;
int ret;
+ if (enable_tablet_mode_sw == HPWMI_TABLET_MODE_SW_OFF)
+ return -ENODEV;
+
chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);
if (!chassis_type)
return -ENODEV;
- tablet_found = match_string(tablet_chassis_types,
+ tablet_found =
+ (enable_tablet_mode_sw == HPWMI_TABLET_MODE_SW_FORCE_ON)
+ || (match_string(tablet_chassis_types,
ARRAY_SIZE(tablet_chassis_types),
- chassis_type) >= 0;
+ chassis_type) >= 0);
if (!tablet_found)
return -ENODEV;
ret = hp_wmi_perform_query(HPWMI_SYSTEM_DEVICE_MODE, HPWMI_READ,
system_device_mode, zero_if_sup(system_device_mode),
sizeof(system_device_mode));
- if (ret < 0)
+ if (ret < 0 && enable_tablet_mode_sw != HPWMI_TABLET_MODE_SW_FORCE_ON)
return ret;
- return system_device_mode[0] == DEVICE_MODE_TABLET;
+ if (ret >= 0)
+ ret = (system_device_mode[0] == DEVICE_MODE_TABLET);
+
+ /* workaround for older convertibles. needs to be actively switched on
+ * and is only executed when HPWMI_SYSTEM_DEVICE_MODE query failed or
+ * did not report tablet state, i.e. (ret < 0) or (ret == 0) */
+ if (ret <= 0 && enable_tablet_mode_sw == HPWMI_TABLET_MODE_SW_FORCE_ON) {
+ int ret2 = hp_wmi_read_int(HPWMI_HARDWARE_QUERY);
+ if (ret2 >= 0)
+ ret = !!(ret2 & HPWMI_TABLET_MASK);
+ }
+
+ return ret;
}
static int omen_thermal_profile_set(int mode)
--
2.43.0
next prev parent reply other threads:[~2024-08-19 16:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 21:08 [PATCH v5 0/4] Fix SW_TABLET_MODE detection method Jorge Lopez
2022-03-10 21:08 ` [PATCH v5 1/4] Fix hp_wmi_read_int() reporting error (0x05) Jorge Lopez
2022-03-14 10:41 ` Hans de Goede
2022-03-10 21:08 ` [PATCH v5 2/4] Fix SW_TABLET_MODE detection method Jorge Lopez
2022-03-14 10:44 ` Hans de Goede
2024-08-08 21:46 ` Stefan Sichler
2024-08-13 14:34 ` Ilpo Järvinen
2024-08-19 16:41 ` Stefan Sichler [this message]
2022-03-10 21:08 ` [PATCH v5 3/4] Fix 0x05 error code reported by several WMI calls Jorge Lopez
2022-03-14 10:44 ` Hans de Goede
2022-03-10 21:08 ` [PATCH v5 4/4] Changing bios_args.data to be dynamically allocated Jorge Lopez
2022-03-14 10:51 ` Hans de Goede
2022-03-14 11:33 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40e05e60-e352-46fa-9b3c-b4fc8d90cedd@web.de \
--to=stsichler@web.de \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jorgealtxwork@gmail.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox