Fix for platform profile issues on USB-C-only models
Subsystems (3)
Armin Wolf
maintainercover Fix for platform profile issues on USB-C-only models
After looking thru the ACPI tables of various people having issues with the bitland-mifs-wmi driver, i came to the following conclusions:
1. There seem to be multiple flavors of the Mifs interface, distinguishable by small changes inside their WMI MOF definitions
2. The buffer format used to communicate with the ACPI-WMI firmware operates differently than previously thought.
This patch series addresses the second point I am aware that there exist multiple outstanding patch series that partially overlap with this one. All of those patch series still rely on the incorrect buffer format currently being used by the driver, so i suggest that this patch series be used as a new base for future patches.
All patches have been tested by a user on his Redmi Book Pro 16 2024.
Armin Wolf (2):
platform/x86: bitland-mifs-wmi: Detect failed function calls platform/x86: bitland-mifs-wmi: Treat WMI_FN_SYSTEM_AC_TYPE as
optional
.../wmi/devices/bitland-mifs-wmi.rst | 64 +++++--- drivers/platform/x86/bitland-mifs-wmi.c | 146 +++++++++--------- 2 files changed, 117 insertions(+), 93 deletions(-)
Signature · 1 line
2.39.5
Armin Wolf
maintainerPATCH 1/2 platform/x86: bitland-mifs-wmi: Detect failed function calls
The first 16-bit field inside the output data of a Mifs method call contains a return code that specifies if the method call succeeded (0x8000) or failed due to missing support (0xE000). The second 16-bit field should then contain the previously executed function id.
Rework the layout of both input and output data to match the format used by the Mifs firmware and check the return code.
--- .../wmi/devices/bitland-mifs-wmi.rst | 61 +++++--- drivers/platform/x86/bitland-mifs-wmi.c | 140 +++++++++--------- 2 files changed, 110 insertions(+), 91 deletions(-)
Documentation/wmi/devices/bitland-mifs-wmi.rst +43 -18
@@ -67,7 +67,7 @@ WMI Methods (MICommonInterface) The ``MICommonInterface`` class (GUID: ``{b60bfb48-3e5b-49e4-a0e9-8cffe1b3434b}``) is the primary control interface. It uses a 32-byte buffer for both input -(``InData``) and output (``OutData``). +(``InData``) and output (``OutData`` + ``Reserved``). Method Structure ----------------
@@ -77,53 +77,78 @@ The data packet follows a standardized format: +----------+------------------------------------------------------------------+ | Byte | Description | +==========+==================================================================+ -| 1 | Method Type: Get (0xFA / 250) or Set (0xFB / 251) | +| 1 and 2 | Method Type or Return Code | +----------+------------------------------------------------------------------+ -| 3 | Command ID (Method Name) | +| 3 and 4 | Command ID (Method Name) | +----------+------------------------------------------------------------------+ -| 4 - 31 | Arguments (for Set) or Return Data (for Get) | +| 5 - 32 | Arguments (for Set) or Return Data (for Get) | +----------+------------------------------------------------------------------+ +Method Types +------------ + +The following Method types are understood by the underlying firmware: + ++--------+---------+ +| Type | Meaning | ++========+=========+ +| 0xFA00 | Read | ++--------+---------+ +| 0xFB00 | Write | ++--------+---------+ + +Return Codes +------------ + +The following Return Codes are know to be returned in response to a WMI method invocation: + ++--------+--------------------+ +| Code | Meaning | ++========+====================+ +| 0x8000 | Success | ++--------+--------------------+ +| 0xE000 | Invalid Command ID | ++--------+--------------------+ Command IDs ----------- -The following Command IDs are used in the third byte of the buffer: +The following Command IDs know to be used on some models: +----------+-----------------------+------------------------------------------+ | ID | Name | Values / Description | +==========+=======================+==========================================+ -| 8 | SystemPerMode | 0: Balance, 1: Performance, 2: Quiet, | +| 0x0800 | SystemPerMode | 0: Balance, 1: Performance, 2: Quiet, | | | | 3: Full-speed | +----------+-----------------------+------------------------------------------+ -| 9 | GPUMode | 0: Hybrid, 1: Discrete, 2: UMA | +| 0x0900 | GPUMode | 0: Hybrid, 1: Discrete, 2: UMA | +----------+-----------------------+------------------------------------------+ -| 10 | KeyboardType | 0: White, 1: Single RGB, 2: Zone RGB | +| 0x0A00 | KeyboardType | 0: White, 1: Single RGB, 2: Zone RGB | +----------+-----------------------+------------------------------------------+ -| 11 | FnLock | 0: Off, 1: On | +| 0x0B00 | FnLock | 0: Off, 1: On | +----------+-----------------------+------------------------------------------+ -| 12 | TPLock | 0: Unlock, 1: Lock (Touchpad) | +| 0x0C00 | TPLock | 0: Unlock, 1: Lock (Touchpad) | +----------+-----------------------+------------------------------------------+ -| 13 | CPUGPUSYSFanSpeed | Returns 12 bytes of fan data: | +| 0x0D00 | CPUGPUSYSFanSpeed | Returns 12 bytes of fan data: | | | | Bytes 4-5: CPU Fan RPM (Little Endian) | | | | Bytes 6-7: GPU Fan RPM (Little Endian) | | | | Bytes 10-11: SYS Fan RPM (Little Endian) | +----------+-----------------------+------------------------------------------+ -| 16 | RGBKeyboardMode | 0: Off, 1: Auto Cyclic, 2: Fixed, | +| 0x1000 | RGBKeyboardMode | 0: Off, 1: Auto Cyclic, 2: Fixed, | | | | 3: Custom | +----------+-----------------------+------------------------------------------+ -| 17 | RGBKeyboardColor | Bytes 4, 5, 6: Red, Green, Blue values | +| 0x1100 | RGBKeyboardColor | Bytes 4, 5, 6: Red, Green, Blue values | +----------+-----------------------+------------------------------------------+ -| 18 | RGBKeyboardBrightness | 0-10: Brightness Levels, 128: Auto | +| 0x1200 | RGBKeyboardBrightness | 0-10: Brightness Levels, 128: Auto | +----------+-----------------------+------------------------------------------+ -| 19 | SystemAcType | 1: Type-C, 2: Circular Hole (DC) | +| 0x1300 | SystemAcType | 1: Type-C, 2: Circular Hole (DC) | +----------+-----------------------+------------------------------------------+ -| 20 | MaxFanSpeedSwitch | Byte 4: Fan Type (0: CPU/GPU, 1: SYS) | +| 0x1400 | MaxFanSpeedSwitch | Byte 4: Fan Type (0: CPU/GPU, 1: SYS) | | | | Byte 5: State (0: Off, 1: On) | +----------+-----------------------+------------------------------------------+ -| 21 | MaxFanSpeed | Sets manual fan speed duty cycle | +| 0x1500 | MaxFanSpeed | Sets manual fan speed duty cycle | +----------+-----------------------+------------------------------------------+ -| 22 | CPUThermometer | Returns CPU Temperature | +| 0x1600 | CPUThermometer | Returns CPU Temperature | +----------+-----------------------+------------------------------------------+ WMI Events (HID_EVENT20)
drivers/platform/x86/bitland-mifs-wmi.c +67 -73
251 lines not on this page · raw message
Signature · 1 line
2.39.5
Armin Wolf
maintainerPATCH 2/2 platform/x86: bitland-mifs-wmi: Treat WMI_FN_SYSTEM_AC_TYPE as optional
In reply to Armin WolfSome systems only support USB-C but can still enter performance mode if connected to a charger. Such systems usually do not support WMI_FN_SYSTEM_AC_TYPE, so bitland_check_performance_capability() currently always fails on them.
Fix this by treating WMI_FN_SYSTEM_AC_TYPE as optional and skip the AC type check if WMI_FN_SYSTEM_AC_TYPE is not supported.
--- Documentation/wmi/devices/bitland-mifs-wmi.rst | 3 ++- drivers/platform/x86/bitland-mifs-wmi.c | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-)
Documentation/wmi/devices/bitland-mifs-wmi.rst +2 -1
@@ -214,7 +214,8 @@ Performance Modes Changing the performance mode via Command ID 0x08 (SystemPerMode) affects the power limits (PL1/PL2) and fan curves managed by the Embedded Controller (EC). Note that the "Full-speed" and "Performance" mode (1, 3) is typically only -available when the system is connected to a DC power source (not USB-C/PD). +available when the system is connected to a DC power source (not USB-C/PD on +model with a dedicated DC connector). In the driver implementation, switch to performance/full-speed mode without DC power connected will throw the EOPNOTSUPP error.
drivers/platform/x86/bitland-mifs-wmi.c +5 -1
@@ -246,7 +246,11 @@ static int bitland_check_performance_capability(struct bitland_mifs_wmi_data *dareturn -EOPNOTSUPP ; ret =bitland_mifs_wmi_call (data, &input, &output); -if (ret) +/* Not all systems support this function, do not perform further checks on them */ +if (ret == -EOPNOTSUPP ) +return 0 ; + +if (ret <0 )return ret;if (output.data[0 ] !=WMI_SYSTEM_AC_CIRCULARHOLE )
Signature · 1 line
2.39.5
Ilpo Järvinen
maintainerQuoted 10 lines · Armin Wolf
After looking thru the ACPI tables of various people having issues with the bitland-mifs-wmi driver, i came to the following conclusions:
1. There seem to be multiple flavors of the Mifs interface, distinguishable by small changes inside their WMI MOF definitions
2. The buffer format used to communicate with the ACPI-WMI firmware operates differently than previously thought.
[...]
Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.
FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.
The list of commits applied:
[1/2] platform/x86: bitland-mifs-wmi: Detect failed function calls
commit: 437954f921dc60a5a988f0a6b343e9e5734b872a
[2/2] platform/x86: bitland-mifs-wmi: Treat WMI_FN_SYSTEM_AC_TYPE as optional
commit: 46482926cce834fa6cb3b08246f10455a0694b03--
i.
Armin Wolf
maintainerAm 15.09.26 um 13:32 schrieb Ilpo Järvinen:
Quoted 8 lines · Armin Wolf
Quoted 7 lines
After looking thru the ACPI tables of various people having issues with the bitland-mifs-wmi driver, i came to the following conclusions:
1. There seem to be multiple flavors of the Mifs interface, distinguishable by small changes inside their WMI MOF definitions
Quoted 8 lines
Quoted 4 lines
2. The buffer format used to communicate with the ACPI-WMI firmware operates differently than previously thought.
[...]
Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.
Thank you :)
Armin Wolf
Quoted 15 lines
FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.
The list of commits applied:
[1/2] platform/x86: bitland-mifs-wmi: Detect failed function callscommit: 437954f921dc60a5a988f0a6b343e9e5734b872a [2/2] platform/x86: bitland-mifs-wmi: Treat WMI_FN_SYSTEM_AC_TYPE as optional commit: 46482926cce834fa6cb3b08246f10455a0694b03--
i.