From d608d07d89153448ce61113ad3f28fbd7f5f0dc0 Mon Sep 17 00:00:00 2001 From: Denis Date: Sun, 7 Jan 2024 18:02:09 +0100 Subject: [PATCH] Allow to set a specific thermal profile at start-up time --- allynone.c | 1 + config.cfg.default | 1 + main.c | 1 + rog_ally.c | 13 +++++++++---- settings.c | 7 +++++++ settings.h | 1 + 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/allynone.c b/allynone.c index 10e8e0b..3f3ecbe 100644 --- a/allynone.c +++ b/allynone.c @@ -23,6 +23,7 @@ int main(int argc, char ** argv) { .m1m2_mode = 0, .touchbar = true, .enable_thermal_profiles_switching = false, + .default_thermal_profile = -1, .enable_leds_commands = false, }; diff --git a/config.cfg.default b/config.cfg.default index 38faede..8fb3b16 100644 --- a/config.cfg.default +++ b/config.cfg.default @@ -13,4 +13,5 @@ controller_bluetooth = true; dualsense_edge = false; swap_y_z = true; enable_thermal_profiles_switching = true; +default_thermal_profile = -1; enable_leds_commands = true; \ No newline at end of file diff --git a/main.c b/main.c index 5c1ab85..e1822ab 100644 --- a/main.c +++ b/main.c @@ -22,6 +22,7 @@ int main(int argc, char ** argv) { .m1m2_mode = 1, .touchbar = true, .enable_thermal_profiles_switching = false, + .default_thermal_profile = -1, .enable_leds_commands = false, }; diff --git a/rog_ally.c b/rog_ally.c index 2cc61c0..cdf4a32 100644 --- a/rog_ally.c +++ b/rog_ally.c @@ -124,7 +124,7 @@ static rc71l_platform_t hw_platform = { .g = 0x40, .b = 0x40, }, - .current_thermal_profile = 0xFFFFFFFFFFFFFFFF, + .current_thermal_profile = 0, .next_thermal_profile = 0, }; @@ -1528,14 +1528,19 @@ input_dev_composite_t rc71l_composite = { .leds_fn = rc71l_platform_leds, }; -input_dev_composite_t* rog_ally_device_def(const dev_in_settings_t *const settings) { - if (settings->touchbar) { +input_dev_composite_t* rog_ally_device_def(const dev_in_settings_t *const conf) { + if (conf->touchbar) { rc71l_composite.dev[rc71l_composite.dev_count++] = &in_touchscreen_dev; } - if ((settings->enable_leds_commands) || (settings->enable_thermal_profiles_switching)) { + if ((conf->enable_leds_commands) || (conf->enable_thermal_profiles_switching)) { rc71l_composite.dev[rc71l_composite.dev_count++] = &nkey_dev; } + if ((conf->enable_thermal_profiles_switching) && (conf->default_thermal_profile >= 0) && (conf->default_thermal_profile < 3)) { + hw_platform.current_thermal_profile = 0xFFFFFFFFFFFFFFFF; + hw_platform.next_thermal_profile = conf->default_thermal_profile; + } + return &rc71l_composite; } diff --git a/settings.c b/settings.c index bbba22c..31c80fe 100644 --- a/settings.c +++ b/settings.c @@ -62,6 +62,13 @@ void load_in_config(dev_in_settings_t *const out_conf, const char* const filepat fprintf(stderr, "enable_thermal_profiles_switching (bool) configuration not found. Default value will be used.\n"); } + int default_thermal_profile; + if (config_lookup_int(&cfg, "default_thermal_profile", &default_thermal_profile) != CONFIG_FALSE) { + out_conf->default_thermal_profile = default_thermal_profile; + } else { + fprintf(stderr, "default_thermal_profile (int) configuration not found. Default value will be used.\n"); + } + int enable_leds_commands; if (config_lookup_bool(&cfg, "enable_leds_commands", &enable_leds_commands) != CONFIG_FALSE) { out_conf->enable_leds_commands = enable_leds_commands; diff --git a/settings.h b/settings.h index cfbe019..2cacd0f 100644 --- a/settings.h +++ b/settings.h @@ -9,6 +9,7 @@ typedef struct dev_in_settings { uint8_t m1m2_mode; bool touchbar; bool enable_thermal_profiles_switching; + int default_thermal_profile; bool enable_leds_commands; } dev_in_settings_t;