33
33
#include <linux/units.h>
34
34
#include <linux/unaligned.h>
35
35
#include <linux/bitfield.h>
36
+ #include <linux/bitmap.h>
36
37
37
38
MODULE_AUTHOR ("Carlos Corbacho" );
38
39
MODULE_DESCRIPTION ("Acer Laptop WMI Extras Driver" );
@@ -127,6 +128,7 @@ enum acer_wmi_predator_v4_oc {
127
128
enum acer_wmi_gaming_misc_setting {
128
129
ACER_WMID_MISC_SETTING_OC_1 = 0x0005 ,
129
130
ACER_WMID_MISC_SETTING_OC_2 = 0x0007 ,
131
+ ACER_WMID_MISC_SETTING_SUPPORTED_PROFILES = 0x000A ,
130
132
ACER_WMID_MISC_SETTING_PLATFORM_PROFILE = 0x000B ,
131
133
};
132
134
@@ -782,6 +784,9 @@ static bool platform_profile_support;
782
784
*/
783
785
static int last_non_turbo_profile ;
784
786
787
+ /* The most performant supported profile */
788
+ static int acer_predator_v4_max_perf ;
789
+
785
790
enum acer_predator_v4_thermal_profile {
786
791
ACER_PREDATOR_V4_THERMAL_PROFILE_QUIET = 0x00 ,
787
792
ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED = 0x01 ,
@@ -1999,7 +2004,7 @@ acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof,
1999
2004
if (err )
2000
2005
return err ;
2001
2006
2002
- if (tp != ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO )
2007
+ if (tp != acer_predator_v4_max_perf )
2003
2008
last_non_turbo_profile = tp ;
2004
2009
2005
2010
return 0 ;
@@ -2008,6 +2013,7 @@ acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof,
2008
2013
static int acer_platform_profile_setup (struct platform_device * device )
2009
2014
{
2010
2015
if (quirks -> predator_v4 ) {
2016
+ unsigned long supported_profiles ;
2011
2017
int err ;
2012
2018
2013
2019
platform_profile_handler .name = "acer-wmi" ;
@@ -2017,16 +2023,46 @@ static int acer_platform_profile_setup(struct platform_device *device)
2017
2023
platform_profile_handler .profile_set =
2018
2024
acer_predator_v4_platform_profile_set ;
2019
2025
2020
- set_bit (PLATFORM_PROFILE_PERFORMANCE ,
2021
- platform_profile_handler .choices );
2022
- set_bit (PLATFORM_PROFILE_BALANCED_PERFORMANCE ,
2023
- platform_profile_handler .choices );
2024
- set_bit (PLATFORM_PROFILE_BALANCED ,
2025
- platform_profile_handler .choices );
2026
- set_bit (PLATFORM_PROFILE_QUIET ,
2027
- platform_profile_handler .choices );
2028
- set_bit (PLATFORM_PROFILE_LOW_POWER ,
2029
- platform_profile_handler .choices );
2026
+ err = WMID_gaming_get_misc_setting (ACER_WMID_MISC_SETTING_SUPPORTED_PROFILES ,
2027
+ (u8 * )& supported_profiles );
2028
+ if (err )
2029
+ return err ;
2030
+
2031
+ /* Iterate through supported profiles in order of increasing performance */
2032
+ if (test_bit (ACER_PREDATOR_V4_THERMAL_PROFILE_ECO , & supported_profiles )) {
2033
+ set_bit (PLATFORM_PROFILE_LOW_POWER ,
2034
+ platform_profile_handler .choices );
2035
+ acer_predator_v4_max_perf =
2036
+ ACER_PREDATOR_V4_THERMAL_PROFILE_ECO ;
2037
+ }
2038
+
2039
+ if (test_bit (ACER_PREDATOR_V4_THERMAL_PROFILE_QUIET , & supported_profiles )) {
2040
+ set_bit (PLATFORM_PROFILE_QUIET ,
2041
+ platform_profile_handler .choices );
2042
+ acer_predator_v4_max_perf =
2043
+ ACER_PREDATOR_V4_THERMAL_PROFILE_QUIET ;
2044
+ }
2045
+
2046
+ if (test_bit (ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED , & supported_profiles )) {
2047
+ set_bit (PLATFORM_PROFILE_BALANCED ,
2048
+ platform_profile_handler .choices );
2049
+ acer_predator_v4_max_perf =
2050
+ ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED ;
2051
+ }
2052
+
2053
+ if (test_bit (ACER_PREDATOR_V4_THERMAL_PROFILE_PERFORMANCE , & supported_profiles )) {
2054
+ set_bit (PLATFORM_PROFILE_BALANCED_PERFORMANCE ,
2055
+ platform_profile_handler .choices );
2056
+ acer_predator_v4_max_perf =
2057
+ ACER_PREDATOR_V4_THERMAL_PROFILE_PERFORMANCE ;
2058
+ }
2059
+
2060
+ if (test_bit (ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO , & supported_profiles )) {
2061
+ set_bit (PLATFORM_PROFILE_PERFORMANCE ,
2062
+ platform_profile_handler .choices );
2063
+ acer_predator_v4_max_perf =
2064
+ ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO ;
2065
+ }
2030
2066
2031
2067
err = platform_profile_register (& platform_profile_handler );
2032
2068
if (err )
@@ -2044,7 +2080,8 @@ static int acer_platform_profile_setup(struct platform_device *device)
2044
2080
static int acer_thermal_profile_change (void )
2045
2081
{
2046
2082
/*
2047
- * This mode key will either cycle through each mode or toggle the turbo profile.
2083
+ * This mode key will either cycle through each mode or toggle the
2084
+ * most performant profile.
2048
2085
*/
2049
2086
if (quirks -> predator_v4 ) {
2050
2087
u8 current_tp ;
@@ -2058,18 +2095,18 @@ static int acer_thermal_profile_change(void)
2058
2095
if (err )
2059
2096
return err ;
2060
2097
2061
- if (current_tp == ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO )
2098
+ if (current_tp == acer_predator_v4_max_perf )
2062
2099
tp = last_non_turbo_profile ;
2063
2100
else
2064
- tp = ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO ;
2101
+ tp = acer_predator_v4_max_perf ;
2065
2102
2066
2103
err = WMID_gaming_set_misc_setting (
2067
2104
ACER_WMID_MISC_SETTING_PLATFORM_PROFILE , tp );
2068
2105
if (err )
2069
2106
return err ;
2070
2107
2071
2108
/* Store last profile for toggle */
2072
- if (current_tp != ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO )
2109
+ if (current_tp != acer_predator_v4_max_perf )
2073
2110
last_non_turbo_profile = current_tp ;
2074
2111
2075
2112
platform_profile_notify (& platform_profile_handler );
0 commit comments