Sysinfo: Update Cpuclock and Thermal to the powersave api.

This commit is contained in:
Stephen 'Okra' Houston 2017-07-12 01:24:03 -05:00
parent d03c254f5e
commit 2bbdd999ed
3 changed files with 13 additions and 4 deletions

View File

@ -9,6 +9,7 @@ struct _Thread_Config
{ {
int interval; int interval;
Instance *inst; Instance *inst;
E_Powersave_Sleeper *sleeper;
}; };
typedef struct _Pstate_Config Pstate_Config; typedef struct _Pstate_Config Pstate_Config;
@ -238,7 +239,6 @@ _cpuclock_event_cb_powersave(void *data, int type, void *event)
eina_stringshare_del(inst->cfg->cpuclock.status->orig_governor); eina_stringshare_del(inst->cfg->cpuclock.status->orig_governor);
inst->cfg->cpuclock.status->orig_governor = NULL; inst->cfg->cpuclock.status->orig_governor = NULL;
break; break;
case E_POWERSAVE_MODE_MEDIUM: case E_POWERSAVE_MODE_MEDIUM:
case E_POWERSAVE_MODE_HIGH: case E_POWERSAVE_MODE_HIGH:
if ((inst->cfg->cpuclock.powersave_governor) || (has_conservative)) if ((inst->cfg->cpuclock.powersave_governor) || (has_conservative))
@ -249,8 +249,8 @@ _cpuclock_event_cb_powersave(void *data, int type, void *event)
_cpuclock_set_governor("conservative"); _cpuclock_set_governor("conservative");
break; break;
} }
case E_POWERSAVE_MODE_EXTREME: case E_POWERSAVE_MODE_EXTREME:
default:
if (has_powersave) if (has_powersave)
_cpuclock_set_governor("powersave"); _cpuclock_set_governor("powersave");
break; break;
@ -831,7 +831,7 @@ _cpuclock_cb_frequency_check_main(void *data, Ecore_Thread *th)
else else
_cpuclock_status_free(status); _cpuclock_status_free(status);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
usleep((1000000.0 / 8.0) * (double)thc->interval); e_powersave_sleeper_sleep(thc->sleeper, thc->interval);
} }
} }
@ -877,6 +877,7 @@ static void
_cpuclock_cb_frequency_check_end(void *data, Ecore_Thread *th EINA_UNUSED) _cpuclock_cb_frequency_check_end(void *data, Ecore_Thread *th EINA_UNUSED)
{ {
Thread_Config *thc = data; Thread_Config *thc = data;
e_powersave_sleeper_free(thc->sleeper);
E_FREE_FUNC(thc, free); E_FREE_FUNC(thc, free);
} }
@ -894,6 +895,7 @@ _cpuclock_poll_interval_update(Instance *inst)
if (thc) if (thc)
{ {
thc->inst = inst; thc->inst = inst;
thc->sleeper = e_powersave_sleeper_new();
thc->interval = inst->cfg->cpuclock.poll_interval; thc->interval = inst->cfg->cpuclock.poll_interval;
inst->cfg->cpuclock.frequency_check_thread = inst->cfg->cpuclock.frequency_check_thread =
ecore_thread_feedback_run(_cpuclock_cb_frequency_check_main, ecore_thread_feedback_run(_cpuclock_cb_frequency_check_main,

View File

@ -76,6 +76,7 @@ struct _Tempthread
const char *sensor_name; const char *sensor_name;
const char *sensor_path; const char *sensor_path;
void *extn; void *extn;
E_Powersave_Sleeper *sleeper;
#ifdef HAVE_EEZE #ifdef HAVE_EEZE
Eina_List *tempdevs; Eina_List *tempdevs;
#endif #endif

View File

@ -13,6 +13,7 @@ _thermal_thread_free(Tempthread *tth)
#if defined(HAVE_EEZE) #if defined(HAVE_EEZE)
EINA_LIST_FREE(tth->tempdevs, s) eina_stringshare_del(s); EINA_LIST_FREE(tth->tempdevs, s) eina_stringshare_del(s);
#endif #endif
e_powersave_sleeper_free(tth->sleeper);
free(tth->extn); free(tth->extn);
free(tth); free(tth);
} }
@ -93,7 +94,11 @@ _thermal_check_sysctl(void *data, Ecore_Thread *th)
temp = thermal_sysctl_get(tth); temp = thermal_sysctl_get(tth);
if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp)); if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)temp));
ptemp = temp; ptemp = temp;
usleep((1000000.0 / 8.0) * (double)tth->poll_interval); e_powersave_sleeper_sleep(tth->sleeper, tth->poll_interval);
if (e_powersave_mode_get() == E_POWERSAVE_MODE_FREEZE)
usleep((1000000.0 / 800.0) * (double)tth->poll_interval);
else
usleep((1000000.0 / 8.0) * (double)tth->poll_interval);
if (ecore_thread_check(th)) break; if (ecore_thread_check(th)) break;
} }
} }
@ -173,6 +178,7 @@ _thermal_config_updated(Instance *inst)
tth->poll_interval = inst->cfg->thermal.poll_interval; tth->poll_interval = inst->cfg->thermal.poll_interval;
tth->sensor_type = inst->cfg->thermal.sensor_type; tth->sensor_type = inst->cfg->thermal.sensor_type;
tth->inst = inst; tth->inst = inst;
tth->sleeper = e_powersave_sleeper_new();
if (inst->cfg->thermal.sensor_name) if (inst->cfg->thermal.sensor_name)
tth->sensor_name = eina_stringshare_add(inst->cfg->thermal.sensor_name); tth->sensor_name = eina_stringshare_add(inst->cfg->thermal.sensor_name);