#include <pass/device-notifier.h>
#include "pass.h"
+#include "pass-rescon.h"
#include "pass-resmon.h"
#define DEFAULT_TEMPERATURE (-1000)
struct resmon_result_src_thermal *thermal_result)
{
struct pass_thermal *thermal = &res->thermal;;
+ struct pass_scenario *scenario;
int timer_interval_of_scenario, timer_interval;
int curr_temp, prev_temp, temp;
int i, scenario_idx;
if (thermal->curr_scenario_idx == scenario_idx)
return 0;
+ scenario = &thermal->scenarios[scenario_idx];
/* Get the new timer interval of each scenario */
- timer_interval_of_scenario
- = thermal->scenarios[scenario_idx].thermal.timer_interval;
+ timer_interval_of_scenario = scenario->thermal.timer_interval;
if (timer_interval_of_scenario > 0)
timer_interval = timer_interval_of_scenario;
else
res->config_data.res_name, RESMON_SRC_THERMAL);
}
+ /* Update thermal information of each h/w resource */
thermal->curr_temp = curr_temp;
+ thermal->prev_scenario_idx = thermal->curr_scenario_idx;
thermal->curr_scenario_idx = scenario_idx;
+ /* Set ScenarioLevel for current scenario */
+ ret = pass_rescon_set_scenario_level(res, scenario->level);
+ if (ret < 0) {
+ _W("failed to set ScenarioLevel%d " \
+ "(res_name:%s, src_type: 0x%x)\n",
+ scenario->level,
+ res->config_data.res_name, RESMON_SRC_THERMAL);
+ }
+
+ /* Unset ScenarioLevel of previous scenario */
+ if (thermal->prev_scenario_idx >= 0) {
+ struct pass_scenario *p_scenario =
+ &thermal->scenarios[thermal->prev_scenario_idx];
+ ret = pass_rescon_unset_scenario_level(res, p_scenario->level);
+ if (ret < 0) {
+ _W("failed to unset ScenarioLevel%d " \
+ "(res_name:%s, src_type: 0x%x)\n",
+ p_scenario->level,
+ res->config_data.res_name, RESMON_SRC_THERMAL);
+ }
+ }
+
+ ret = pass_rescon_sync(res);
+ if (ret < 0) {
+ _W("failed to synchronize h/w resource " \
+ "(res_name:%s, src_type: 0x%x)\n",
+ res->config_data.res_name, RESMON_SRC_THERMAL);
+ }
+
_I("Monitor '%-12s' of '%s' resource ('%3d' degrees,'%5d' ms)\n",
- thermal->scenarios[scenario_idx].name,
+ scenario->name,
res->config_data.res_name,
curr_temp, timer_interval);