platform/x86: hp-wmi: Fix SW_TABLET_MODE detection method
authorJorge Lopez <jorge.lopez2@hp.com>
Thu, 10 Mar 2022 21:08:51 +0000 (15:08 -0600)
committerHans de Goede <hdegoede@redhat.com>
Mon, 14 Mar 2022 15:25:24 +0000 (16:25 +0100)
commit520ee4ea1cc60251a6e3c911cf0336278aa52634
tree6a2e3574513a014865147c01e8751fc50cabc838
parent12b19f14a21a2ee6348825d95b642ef2cd16794f
platform/x86: hp-wmi: Fix SW_TABLET_MODE detection method

The purpose of this patch is to introduce a fix and removal of the
current hack when determining tablet mode status.

Determining the tablet mode status requires reading Byte 0 bit 2 as
reported by HPWMI_HARDWARE_QUERY.  The investigation identified the
failure was rooted in two areas: HPWMI_HARDWARE_QUERY failure (0x05)
and reading Byte 0, bit 2 only to determine the table mode status.
HPWMI_HARDWARE_QUERY WMI failure also rendered the dock state value
invalid.

The latest changes use SMBIOS Type 3 (chassis type) and WMI Command
0x40 (device_mode_status) information to determine if the device is
in tablet mode or not.

hp_wmi_hw_state function was split into two functions;
hp_wmi_get_dock_state and hp_wmi_get_tablet_mode.  The new functions
separate how dock_state and tablet_mode is handled in a cleaner
manner.

All changes were validated on a HP ZBook Workstation notebook,
HP EliteBook x360, and HP EliteBook 850 G8.

Signed-off-by: Jorge Lopez <jorge.lopez2@hp.com>
Link: https://lore.kernel.org/r/20220310210853.28367-3-jorge.lopez2@hp.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/hp-wmi.c