From 2bbdd999ed91f1e078278feee3b9c5e930202b13 Mon Sep 17 00:00:00 2001 From: Stephen 'Okra' Houston Date: Wed, 12 Jul 2017 01:24:03 -0500 Subject: [PATCH] Sysinfo: Update Cpuclock and Thermal to the powersave api. --- src/modules/sysinfo/cpuclock/cpuclock.c | 8 +++++--- src/modules/sysinfo/sysinfo.h | 1 + src/modules/sysinfo/thermal/thermal.c | 8 +++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/modules/sysinfo/cpuclock/cpuclock.c b/src/modules/sysinfo/cpuclock/cpuclock.c index 394f262bf..71dab70f6 100644 --- a/src/modules/sysinfo/cpuclock/cpuclock.c +++ b/src/modules/sysinfo/cpuclock/cpuclock.c @@ -9,6 +9,7 @@ struct _Thread_Config { int interval; Instance *inst; + E_Powersave_Sleeper *sleeper; }; 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); inst->cfg->cpuclock.status->orig_governor = NULL; break; - case E_POWERSAVE_MODE_MEDIUM: case E_POWERSAVE_MODE_HIGH: 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"); break; } - case E_POWERSAVE_MODE_EXTREME: + default: if (has_powersave) _cpuclock_set_governor("powersave"); break; @@ -831,7 +831,7 @@ _cpuclock_cb_frequency_check_main(void *data, Ecore_Thread *th) else _cpuclock_status_free(status); 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) { Thread_Config *thc = data; + e_powersave_sleeper_free(thc->sleeper); E_FREE_FUNC(thc, free); } @@ -894,6 +895,7 @@ _cpuclock_poll_interval_update(Instance *inst) if (thc) { thc->inst = inst; + thc->sleeper = e_powersave_sleeper_new(); thc->interval = inst->cfg->cpuclock.poll_interval; inst->cfg->cpuclock.frequency_check_thread = ecore_thread_feedback_run(_cpuclock_cb_frequency_check_main, diff --git a/src/modules/sysinfo/sysinfo.h b/src/modules/sysinfo/sysinfo.h index ae9a07981..06f06eaae 100644 --- a/src/modules/sysinfo/sysinfo.h +++ b/src/modules/sysinfo/sysinfo.h @@ -76,6 +76,7 @@ struct _Tempthread const char *sensor_name; const char *sensor_path; void *extn; + E_Powersave_Sleeper *sleeper; #ifdef HAVE_EEZE Eina_List *tempdevs; #endif diff --git a/src/modules/sysinfo/thermal/thermal.c b/src/modules/sysinfo/thermal/thermal.c index e9f670fd5..ddf0d7215 100644 --- a/src/modules/sysinfo/thermal/thermal.c +++ b/src/modules/sysinfo/thermal/thermal.c @@ -13,6 +13,7 @@ _thermal_thread_free(Tempthread *tth) #if defined(HAVE_EEZE) EINA_LIST_FREE(tth->tempdevs, s) eina_stringshare_del(s); #endif + e_powersave_sleeper_free(tth->sleeper); free(tth->extn); free(tth); } @@ -93,7 +94,11 @@ _thermal_check_sysctl(void *data, Ecore_Thread *th) temp = thermal_sysctl_get(tth); if (ptemp != temp) ecore_thread_feedback(th, (void *)((long)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; } } @@ -173,6 +178,7 @@ _thermal_config_updated(Instance *inst) tth->poll_interval = inst->cfg->thermal.poll_interval; tth->sensor_type = inst->cfg->thermal.sensor_type; tth->inst = inst; + tth->sleeper = e_powersave_sleeper_new(); if (inst->cfg->thermal.sensor_name) tth->sensor_name = eina_stringshare_add(inst->cfg->thermal.sensor_name);