pass: thermal: Set priority of thermal device through config file 12/262412/4
authorDongwoo Lee <dwoo08.lee@samsung.com>
Wed, 4 Aug 2021 06:20:59 +0000 (15:20 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 24 Aug 2021 07:46:15 +0000 (16:46 +0900)
Now, the priority of each thermal device is can be determined by
configuration file in pass-hal with 'thermal_priority' section.

Change-Id: I677dd719672dea43c6675ccf774e646b492914d5
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/pass/pass-parser.c
src/pass/pass-thermal.c
src/pass/pass.h

index 0aeb97b..b772276 100644 (file)
@@ -699,6 +699,7 @@ static int parse_resource_data(struct pass *pass, int id, json_object *obj)
        const char *cpu_load_path;
        int number_of_cpus;
        int first_cpu;
+       int thermal_priority;
 
        /* Get property values */
        /* - mandatory properties */
@@ -709,6 +710,10 @@ static int parse_resource_data(struct pass *pass, int id, json_object *obj)
        /* - optional properties */
        thermal_device_name = get_string_from_object(obj, "thermal_device_name");
        cooling_device_name = get_string_from_object(obj, "cooling_device_name");
+       thermal_priority = get_int_from_object(obj, "thermal_priority");
+       /* if thermal_priority is not set, set default */
+       if (thermal_priority < 0)
+               thermal_priority = INT_MAX;
 
        /* - optional properties for only CPU */
        cpu_load_path = get_string_from_object(obj, "cpu,cpu_load_path");
@@ -763,6 +768,8 @@ static int parse_resource_data(struct pass *pass, int id, json_object *obj)
        snprintf(config_data->res_name, BUFF_MAX, "%s", device_name);
        snprintf(config_data->res_thermal_name, BUFF_MAX, "%s", thermal_device_name);
        snprintf(config_data->res_cooling_name, BUFF_MAX, "%s", cooling_device_name);
+       config_data->res_thermal_priority = thermal_priority;
+
        snprintf(config_data->path_conf_file, BUFF_MAX, "%s", device_config_path);
        snprintf(config_data->path_load_table, BUFF_MAX, "%s", cpu_load_path);
        config_data->num_cpus = number_of_cpus;
index f6ae26a..9f21123 100644 (file)
@@ -34,7 +34,6 @@
 #include "pass-resmon.h"
 
 #define DEFAULT_TEMPERATURE            (-1000)
-#define DEFAULT_THERMAL_PRIORITY       (INT_MAX)
 
 static int thermal_update(struct pass_resource *res,
                        struct resmon_result_src_thermal *thermal_result)
@@ -171,7 +170,7 @@ static int thermal_monitor_func(void *result, void *user_data)
        thermal_data.name = res->config_data.res_thermal_name;
        thermal_data.scenario =
                thermal->scenarios[thermal->curr_scenario_idx].name;
-       thermal_data.priority = DEFAULT_THERMAL_PRIORITY;
+       thermal_data.priority = res->config_data.res_thermal_priority;
 
        /*
         * Send notification with thermal scenario name according to
index e5be2a7..1149d27 100644 (file)
@@ -463,6 +463,16 @@ struct pass_resource_config_data {
         *   res_cooling_name is 'cooling_device0'.
         */
        char res_cooling_name[BUFF_MAX];
+
+       /**
+        * [optional] Priority of thermal information(1~INT_MAX)
+        *  - When thermal state of multiple resources are monitored, the scenario of
+        *    the device that has highest priority is used for dbus notification.
+        *    If there are multiple resources has same highest priority, the highest
+        *    level of scenario will be selected.
+        */
+       int res_thermal_priority;
+
        /** [mandatory] Path fo configuration for each h/w resource */
        char path_conf_file[BUFF_MAX];