pass: thermal: Supprot mupltiple resources for 'thermal_get_scenario' 05/262805/2
authorDongwoo Lee <dwoo08.lee@samsung.com>
Fri, 20 Aug 2021 02:45:41 +0000 (11:45 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 24 Aug 2021 07:46:15 +0000 (16:46 +0900)
To response 'getCoolDownStatus' dbus method call during boot, initial
scenario state should be set before thermal monitor works once. When
there are multiple resources which have thermal data, the final state
of thermal scenario should be determined theirs priority. For this,
this enables supporting multiple resources on 'thermal_get_scenario'
handler.

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

index 07a1b957d150e7e1d00b6386ae693dd44f2ee58b..f8820418a5e93fcdbe08051df230db9713c3c7f5 100644 (file)
@@ -198,15 +198,31 @@ static int thermal_monitor_func(void *result, void *user_data)
 
 static void response_scenario(void *data, void *user_data)
 {
+       static int cur_priority = INT_MAX;
        struct pass_resource *res = data;
        struct pass_thermal *thermal = &res->thermal;
-       void **scenario = user_data;
+       char **resp = user_data;
+       int priority = res->config_data.res_thermal_priority;
+       char *scenario = thermal->scenarios[thermal->curr_scenario_idx].name;
 
        /*
         * Inform the thermal scenario name to
         * DEVICE_NOTIFIER_THERMAL_GET_SCENARIO client.
         */
-       *scenario = (void *)thermal->scenarios[thermal->curr_scenario_idx].name;
+       if (priority < cur_priority || !*resp) {
+               cur_priority = priority;
+               *resp = scenario;
+       } else if (priority == cur_priority) {
+               int i;
+
+               for (i = 0; i < thermal->num_scenarios; i++) {
+                       if (!strncmp(thermal->scenarios[i].name, *resp, strlen(*resp))) {
+                               if (i < thermal->curr_scenario_idx)
+                                       *resp = scenario;
+                               break;
+                       }
+               }
+       }
 
        return 0;
 }
index 6b9a04efcd42cc832e65d3085eaa975500dc089c..a58772cc8be457c894a936edba9d74c945c7ba5b 100644 (file)
@@ -144,13 +144,6 @@ static int thermal_init_done(void *data, void *user_data)
                                        g_thermal->list[i].name);
        }
 
-       /* FIXME:
-        * Currently, initial thermal scenario among multiple resources are not
-        * settled properly; it is rather determined by one of scenario initialized
-        * lastly. So, it is required that the method for retrieving the current
-        * state of each device here.
-        */
-
        device_notify(DEVICE_NOTIFIER_THERMAL_GET_SCENARIO, &scenario);
 
        if (!scenario) {