forked from enlightenment/enlightenment
allow cpufreq config to be accessed without a gadget - pstate necessity
This commit is contained in:
parent
4b08e7991a
commit
83e7883ec9
|
@ -215,6 +215,7 @@ src/modules/conf_window_remembers/e_int_config_remembers.c
|
|||
src/modules/conf_window_remembers/e_mod_main.c
|
||||
src/modules/connman/e_mod_main.c
|
||||
src/modules/cpufreq/e_mod_main.c
|
||||
src/modules/cpufreq/e_mod_config.c
|
||||
src/modules/cpufreq/freqset.c
|
||||
src/modules/everything/e_mod_main.c
|
||||
src/modules/everything/evry.c
|
||||
|
|
|
@ -8,7 +8,8 @@ cpufreqpkgdir = $(MDIR)/cpufreq/$(MODULE_ARCH)
|
|||
cpufreqpkg_LTLIBRARIES = cpufreq/module.la
|
||||
|
||||
cpufreq_module_la_SOURCES = cpufreq/e_mod_main.h \
|
||||
cpufreq/e_mod_main.c
|
||||
cpufreq/e_mod_main.c \
|
||||
cpufreq/e_mod_config.c
|
||||
|
||||
freqsetdir = $(cpufreqpkgdir)
|
||||
freqset_PROGRAMS = cpufreq/freqset
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
int poll_interval;
|
||||
int restore_governor;
|
||||
int auto_powersave;
|
||||
char *powersave_governor;
|
||||
char *governor;
|
||||
int pstate_min;
|
||||
int pstate_max;
|
||||
};
|
||||
|
||||
/* Protos */
|
||||
static void *_create_data(E_Config_Dialog *cfd);
|
||||
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
|
||||
E_Config_Dialog *
|
||||
e_int_config_cpufreq_module(E_Container *con, const char *params __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
v->create_cfdata = _create_data;
|
||||
v->free_cfdata = _free_data;
|
||||
v->basic.apply_cfdata = _basic_apply_data;
|
||||
v->basic.create_widgets = _basic_create_widgets;
|
||||
v->basic.check_changed = _basic_check_changed;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/e-module-cpufreq.edj",
|
||||
e_module_dir_get(cpufreq_config->module));
|
||||
cfd = e_config_dialog_new(con, _("Cpu Frequency Control Settings"),
|
||||
"E", "_e_mod_cpufreq_config_dialog",
|
||||
buf, 0, v, NULL);
|
||||
cpufreq_config->config_dialog = cfd;
|
||||
return cfd;
|
||||
}
|
||||
|
||||
static void
|
||||
_fill_data(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (!cpufreq_config) return;
|
||||
cfdata->poll_interval = cpufreq_config->poll_interval;
|
||||
cfdata->restore_governor = cpufreq_config->restore_governor;
|
||||
cfdata->auto_powersave = cpufreq_config->auto_powersave;
|
||||
cfdata->pstate_min = cpufreq_config->pstate_min - 1;
|
||||
cfdata->pstate_max = cpufreq_config->pstate_max - 1;
|
||||
if (cpufreq_config->powersave_governor)
|
||||
cfdata->powersave_governor = strdup(cpufreq_config->powersave_governor);
|
||||
if (cpufreq_config->governor)
|
||||
cfdata->governor = strdup(cpufreq_config->governor);
|
||||
}
|
||||
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
_fill_data(cfdata);
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (!cpufreq_config) return;
|
||||
cpufreq_config->config_dialog = NULL;
|
||||
E_FREE(cfdata);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *ob, *of;
|
||||
E_Radio_Group *rg;
|
||||
|
||||
o = e_widget_list_add(evas, 0, 0);
|
||||
ob = e_widget_check_add(evas, _("Restore CPU Power Policy"), &cfdata->restore_governor);
|
||||
e_widget_list_object_append(o, ob, 1, 0, 0.5);
|
||||
|
||||
ob = e_widget_check_add(evas, _("Automatic powersaving"), &cfdata->auto_powersave);
|
||||
e_widget_list_object_append(o, ob, 1, 0, 0.5);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Update poll interval"), 0);
|
||||
rg = e_widget_radio_group_new(&cfdata->poll_interval);
|
||||
ob = e_widget_radio_add(evas, _("Fast (4 ticks)"), 4, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Medium (8 ticks)"), 8, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Normal (32 ticks)"), 32, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Slow (64 ticks)"), 64, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Very Slow (256 ticks)"), 256, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
e_widget_list_object_append(o, of, 1, 0, 0.5);
|
||||
|
||||
if ((cpufreq_config->status) && (cpufreq_config->status->pstate))
|
||||
{
|
||||
ob = e_widget_label_add(evas, _("Minimum Power State"));
|
||||
e_widget_list_object_append(o, ob, 1, 0, 0.5);
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%3.0f"), 0, 100,
|
||||
1, 0, NULL, &cfdata->pstate_min, 100);
|
||||
e_widget_list_object_append(o, ob, 1, 0, 0.5);
|
||||
|
||||
ob = e_widget_label_add(evas, _("Maximum Power State"));
|
||||
e_widget_list_object_append(o, ob, 1, 0, 0.5);
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%3.0f"), 2, 100,
|
||||
1, 0, NULL, &cfdata->pstate_max, 100);
|
||||
e_widget_list_object_append(o, ob, 1, 0, 0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
// XXX: list governors
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (!cpufreq_config) return 0;
|
||||
cpufreq_config->poll_interval = cfdata->poll_interval;
|
||||
cpufreq_config->restore_governor = cfdata->restore_governor;
|
||||
cpufreq_config->auto_powersave = cfdata->auto_powersave;
|
||||
cpufreq_config->pstate_min = cfdata->pstate_min + 1;
|
||||
cpufreq_config->pstate_max = cfdata->pstate_max + 1;
|
||||
eina_stringshare_replace(&cpufreq_config->powersave_governor, cfdata->powersave_governor);
|
||||
eina_stringshare_replace(&cpufreq_config->governor, cfdata->governor);
|
||||
_cpufreq_poll_interval_update();
|
||||
if (cpufreq_config->governor)
|
||||
_cpufreq_set_governor(cpufreq_config->governor);
|
||||
if (cpufreq_config->pstate_max < cpufreq_config->pstate_min)
|
||||
cpufreq_config->pstate_max = cpufreq_config->pstate_min;
|
||||
if (cpufreq_config->pstate_min > cpufreq_config->pstate_max)
|
||||
cpufreq_config->pstate_min = cpufreq_config->pstate_max;
|
||||
_cpufreq_set_pstate(cpufreq_config->pstate_min - 1,
|
||||
cpufreq_config->pstate_max - 1, 1);
|
||||
e_config_save_queue();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata __UNUSED__)
|
||||
{
|
||||
Eina_Bool ret = EINA_TRUE;
|
||||
return ret;
|
||||
}
|
|
@ -38,9 +38,7 @@ struct _Instance
|
|||
|
||||
static void _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _menu_cb_post(void *data, E_Menu *m);
|
||||
static void _cpufreq_set_governor(const char *governor);
|
||||
static void _cpufreq_set_frequency(int frequency);
|
||||
static void _cpufreq_set_pstate(int min, int max, int turbo);
|
||||
static Eina_Bool _cpufreq_cb_check(void *data);
|
||||
static Status *_cpufreq_status_new(void);
|
||||
static void _cpufreq_status_free(Status *s);
|
||||
|
@ -65,7 +63,6 @@ static void _cpufreq_menu_powersave_governor(void *data, E_Menu *m, E_Menu_
|
|||
static void _cpufreq_menu_frequency(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _cpufreq_menu_pstate_min(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _cpufreq_menu_pstate_max(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
static void _cpufreq_poll_interval_update(void);
|
||||
|
||||
static E_Config_DD *conf_edd = NULL;
|
||||
|
||||
|
@ -162,6 +159,14 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class __UNUSED__)
|
|||
return idbuff;
|
||||
}
|
||||
|
||||
static void
|
||||
_cpufreq_cb_menu_configure(void *data __UNUSED__, E_Menu *m, E_Menu_Item *mi __UNUSED__)
|
||||
{
|
||||
if (!cpufreq_config) return;
|
||||
if (cpufreq_config->config_dialog) return;
|
||||
e_int_config_cpufreq_module(m->zone->container, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_button_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
||||
{
|
||||
|
@ -428,9 +433,16 @@ _button_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED_
|
|||
else if (ev->button == 3)
|
||||
{
|
||||
E_Menu *m;
|
||||
E_Menu_Item *mi;
|
||||
int cx, cy;
|
||||
|
||||
m = e_menu_new();
|
||||
|
||||
mi = e_menu_item_new(m);
|
||||
e_menu_item_label_set(mi, _("Settings"));
|
||||
e_util_menu_item_theme_icon_set(mi, "configure");
|
||||
e_menu_item_callback_set(mi, _cpufreq_cb_menu_configure, NULL);
|
||||
|
||||
m = e_gadcon_client_util_menu_items_append(inst->gcc, m, 0);
|
||||
|
||||
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
|
||||
|
@ -474,7 +486,7 @@ _menu_cb_post(void *data, E_Menu *m __UNUSED__)
|
|||
cpufreq_config->menu_powersave = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
_cpufreq_set_governor(const char *governor)
|
||||
{
|
||||
char buf[4096];
|
||||
|
@ -558,7 +570,7 @@ _cpufreq_set_frequency(int frequency)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
_cpufreq_set_pstate(int min, int max, int turbo)
|
||||
{
|
||||
char buf[4096];
|
||||
|
@ -1252,7 +1264,7 @@ _cpufreq_menu_pstate_max(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNU
|
|||
e_config_save_queue();
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
_cpufreq_poll_interval_update(void)
|
||||
{
|
||||
if (cpufreq_config->frequency_check_poller)
|
||||
|
@ -1364,12 +1376,21 @@ e_modapi_init(E_Module *m)
|
|||
cpufreq_config->module = m;
|
||||
|
||||
e_gadcon_provider_register(&_gadcon_class);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/e-module-cpufreq.edj", e_module_dir_get(m));
|
||||
e_configure_registry_category_add("advanced", 80, _("Advanced"), NULL,
|
||||
"preferences-advanced");
|
||||
e_configure_registry_item_add("advanced/cpufreq", 120, _("CPU Frequency"),
|
||||
NULL, buf, e_int_config_cpufreq_module);
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m __UNUSED__)
|
||||
{
|
||||
e_configure_registry_item_del("advanced/cpufreq");
|
||||
e_configure_registry_category_del("advanced");
|
||||
|
||||
e_gadcon_provider_unregister(&_gadcon_class);
|
||||
|
||||
if (cpufreq_config->frequency_check_poller)
|
||||
|
@ -1408,6 +1429,10 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
|
|||
eina_stringshare_del(cpufreq_config->governor);
|
||||
if (cpufreq_config->status) _cpufreq_status_free(cpufreq_config->status);
|
||||
E_FREE(cpufreq_config->set_exe_path);
|
||||
|
||||
if (cpufreq_config->config_dialog)
|
||||
e_object_del(E_OBJECT(cpufreq_config->config_dialog));
|
||||
|
||||
free(cpufreq_config);
|
||||
cpufreq_config = NULL;
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
|
|
|
@ -51,6 +51,7 @@ struct _Config
|
|||
char *set_exe_path;
|
||||
Ecore_Poller *frequency_check_poller;
|
||||
Ecore_Event_Handler *handler;
|
||||
E_Config_Dialog *config_dialog;
|
||||
};
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
@ -59,6 +60,12 @@ EAPI void *e_modapi_init (E_Module *m);
|
|||
EAPI int e_modapi_shutdown (E_Module *m);
|
||||
EAPI int e_modapi_save (E_Module *m);
|
||||
|
||||
E_Config_Dialog *e_int_config_cpufreq_module(E_Container *con, const char *params);
|
||||
void _cpufreq_poll_interval_update(void);
|
||||
void _cpufreq_set_governor(const char *governor);
|
||||
void _cpufreq_set_pstate(int min, int max, int turbo);
|
||||
|
||||
extern Config *cpufreq_config;
|
||||
|
||||
/**
|
||||
* @addtogroup Optional_Gadgets
|
||||
|
|
Loading…
Reference in New Issue