summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/modules/Makefile_cpufreq.am3
-rw-r--r--src/modules/cpufreq/e_mod_config.c155
-rw-r--r--src/modules/cpufreq/e_mod_main.c37
-rw-r--r--src/modules/cpufreq/e_mod_main.h7
5 files changed, 196 insertions, 7 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9909b53..25864b0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -215,6 +215,7 @@ src/modules/conf_window_remembers/e_int_config_remembers.c
215src/modules/conf_window_remembers/e_mod_main.c 215src/modules/conf_window_remembers/e_mod_main.c
216src/modules/connman/e_mod_main.c 216src/modules/connman/e_mod_main.c
217src/modules/cpufreq/e_mod_main.c 217src/modules/cpufreq/e_mod_main.c
218src/modules/cpufreq/e_mod_config.c
218src/modules/cpufreq/freqset.c 219src/modules/cpufreq/freqset.c
219src/modules/everything/e_mod_main.c 220src/modules/everything/e_mod_main.c
220src/modules/everything/evry.c 221src/modules/everything/evry.c
diff --git a/src/modules/Makefile_cpufreq.am b/src/modules/Makefile_cpufreq.am
index 2d2bb96..bee9e15 100644
--- a/src/modules/Makefile_cpufreq.am
+++ b/src/modules/Makefile_cpufreq.am
@@ -8,7 +8,8 @@ cpufreqpkgdir = $(MDIR)/cpufreq/$(MODULE_ARCH)
8cpufreqpkg_LTLIBRARIES = cpufreq/module.la 8cpufreqpkg_LTLIBRARIES = cpufreq/module.la
9 9
10cpufreq_module_la_SOURCES = cpufreq/e_mod_main.h \ 10cpufreq_module_la_SOURCES = cpufreq/e_mod_main.h \
11 cpufreq/e_mod_main.c 11 cpufreq/e_mod_main.c \
12 cpufreq/e_mod_config.c
12 13
13freqsetdir = $(cpufreqpkgdir) 14freqsetdir = $(cpufreqpkgdir)
14freqset_PROGRAMS = cpufreq/freqset 15freqset_PROGRAMS = cpufreq/freqset
diff --git a/src/modules/cpufreq/e_mod_config.c b/src/modules/cpufreq/e_mod_config.c
new file mode 100644
index 0000000..a6ac0ca
--- /dev/null
+++ b/src/modules/cpufreq/e_mod_config.c
@@ -0,0 +1,155 @@
1#include "e.h"
2#include "e_mod_main.h"
3
4struct _E_Config_Dialog_Data
5{
6 int poll_interval;
7 int restore_governor;
8 int auto_powersave;
9 char *powersave_governor;
10 char *governor;
11 int pstate_min;
12 int pstate_max;
13};
14
15/* Protos */
16static void *_create_data(E_Config_Dialog *cfd);
17static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
18static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
19static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
20static int _basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
21
22E_Config_Dialog *
23e_int_config_cpufreq_module(E_Container *con, const char *params __UNUSED__)
24{
25 E_Config_Dialog *cfd;
26 E_Config_Dialog_View *v;
27 char buf[PATH_MAX];
28
29 v = E_NEW(E_Config_Dialog_View, 1);
30 v->create_cfdata = _create_data;
31 v->free_cfdata = _free_data;
32 v->basic.apply_cfdata = _basic_apply_data;
33 v->basic.create_widgets = _basic_create_widgets;
34 v->basic.check_changed = _basic_check_changed;
35
36 snprintf(buf, sizeof(buf), "%s/e-module-cpufreq.edj",
37 e_module_dir_get(cpufreq_config->module));
38 cfd = e_config_dialog_new(con, _("Cpu Frequency Control Settings"),
39 "E", "_e_mod_cpufreq_config_dialog",
40 buf, 0, v, NULL);
41 cpufreq_config->config_dialog = cfd;
42 return cfd;
43}
44
45static void
46_fill_data(E_Config_Dialog_Data *cfdata)
47{
48 if (!cpufreq_config) return;
49 cfdata->poll_interval = cpufreq_config->poll_interval;
50 cfdata->restore_governor = cpufreq_config->restore_governor;
51 cfdata->auto_powersave = cpufreq_config->auto_powersave;
52 cfdata->pstate_min = cpufreq_config->pstate_min - 1;
53 cfdata->pstate_max = cpufreq_config->pstate_max - 1;
54 if (cpufreq_config->powersave_governor)
55 cfdata->powersave_governor = strdup(cpufreq_config->powersave_governor);
56 if (cpufreq_config->governor)
57 cfdata->governor = strdup(cpufreq_config->governor);
58}
59
60static void *
61_create_data(E_Config_Dialog *cfd __UNUSED__)
62{
63 E_Config_Dialog_Data *cfdata;
64
65 cfdata = E_NEW(E_Config_Dialog_Data, 1);
66 _fill_data(cfdata);
67 return cfdata;
68}
69
70static void
71_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
72{
73 if (!cpufreq_config) return;
74 cpufreq_config->config_dialog = NULL;
75 E_FREE(cfdata);
76}
77
78static Evas_Object *
79_basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
80{
81 Evas_Object *o, *ob, *of;
82 E_Radio_Group *rg;
83
84 o = e_widget_list_add(evas, 0, 0);
85 ob = e_widget_check_add(evas, _("Restore CPU Power Policy"), &cfdata->restore_governor);
86 e_widget_list_object_append(o, ob, 1, 0, 0.5);
87
88 ob = e_widget_check_add(evas, _("Automatic powersaving"), &cfdata->auto_powersave);
89 e_widget_list_object_append(o, ob, 1, 0, 0.5);
90
91 of = e_widget_framelist_add(evas, _("Update poll interval"), 0);
92 rg = e_widget_radio_group_new(&cfdata->poll_interval);
93 ob = e_widget_radio_add(evas, _("Fast (4 ticks)"), 4, rg);
94 e_widget_framelist_object_append(of, ob);
95 ob = e_widget_radio_add(evas, _("Medium (8 ticks)"), 8, rg);
96 e_widget_framelist_object_append(of, ob);
97 ob = e_widget_radio_add(evas, _("Normal (32 ticks)"), 32, rg);
98 e_widget_framelist_object_append(of, ob);
99 ob = e_widget_radio_add(evas, _("Slow (64 ticks)"), 64, rg);
100 e_widget_framelist_object_append(of, ob);
101 ob = e_widget_radio_add(evas, _("Very Slow (256 ticks)"), 256, rg);
102 e_widget_framelist_object_append(of, ob);
103 e_widget_list_object_append(o, of, 1, 0, 0.5);
104
105 if ((cpufreq_config->status) && (cpufreq_config->status->pstate))
106 {
107 ob = e_widget_label_add(evas, _("Minimum Power State"));
108 e_widget_list_object_append(o, ob, 1, 0, 0.5);
109 ob = e_widget_slider_add(evas, 1, 0, _("%3.0f"), 0, 100,
110 1, 0, NULL, &cfdata->pstate_min, 100);
111 e_widget_list_object_append(o, ob, 1, 0, 0.5);
112
113 ob = e_widget_label_add(evas, _("Maximum Power State"));
114 e_widget_list_object_append(o, ob, 1, 0, 0.5);
115 ob = e_widget_slider_add(evas, 1, 0, _("%3.0f"), 2, 100,
116 1, 0, NULL, &cfdata->pstate_max, 100);
117 e_widget_list_object_append(o, ob, 1, 0, 0.5);
118 }
119 else
120 {
121 // XXX: list governors
122 }
123 return o;
124}
125
126static int
127_basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
128{
129 if (!cpufreq_config) return 0;
130 cpufreq_config->poll_interval = cfdata->poll_interval;
131 cpufreq_config->restore_governor = cfdata->restore_governor;
132 cpufreq_config->auto_powersave = cfdata->auto_powersave;
133 cpufreq_config->pstate_min = cfdata->pstate_min + 1;
134 cpufreq_config->pstate_max = cfdata->pstate_max + 1;
135 eina_stringshare_replace(&cpufreq_config->powersave_governor, cfdata->powersave_governor);
136 eina_stringshare_replace(&cpufreq_config->governor, cfdata->governor);
137 _cpufreq_poll_interval_update();
138 if (cpufreq_config->governor)
139 _cpufreq_set_governor(cpufreq_config->governor);
140 if (cpufreq_config->pstate_max < cpufreq_config->pstate_min)
141 cpufreq_config->pstate_max = cpufreq_config->pstate_min;
142 if (cpufreq_config->pstate_min > cpufreq_config->pstate_max)
143 cpufreq_config->pstate_min = cpufreq_config->pstate_max;
144 _cpufreq_set_pstate(cpufreq_config->pstate_min - 1,
145 cpufreq_config->pstate_max - 1, 1);
146 e_config_save_queue();
147 return 1;
148}
149
150static int
151_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata __UNUSED__)
152{
153 Eina_Bool ret = EINA_TRUE;
154 return ret;
155}
diff --git a/src/modules/cpufreq/e_mod_main.c b/src/modules/cpufreq/e_mod_main.c
index 943fd84..7183cb3 100644
--- a/src/modules/cpufreq/e_mod_main.c
+++ b/src/modules/cpufreq/e_mod_main.c
@@ -38,9 +38,7 @@ struct _Instance
38 38
39static void _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); 39static void _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
40static void _menu_cb_post(void *data, E_Menu *m); 40static void _menu_cb_post(void *data, E_Menu *m);
41static void _cpufreq_set_governor(const char *governor);
42static void _cpufreq_set_frequency(int frequency); 41static void _cpufreq_set_frequency(int frequency);
43static void _cpufreq_set_pstate(int min, int max, int turbo);
44static Eina_Bool _cpufreq_cb_check(void *data); 42static Eina_Bool _cpufreq_cb_check(void *data);
45static Status *_cpufreq_status_new(void); 43static Status *_cpufreq_status_new(void);
46static void _cpufreq_status_free(Status *s); 44static void _cpufreq_status_free(Status *s);
@@ -65,7 +63,6 @@ static void _cpufreq_menu_powersave_governor(void *data, E_Menu *m, E_Menu_
65static void _cpufreq_menu_frequency(void *data, E_Menu *m, E_Menu_Item *mi); 63static void _cpufreq_menu_frequency(void *data, E_Menu *m, E_Menu_Item *mi);
66static void _cpufreq_menu_pstate_min(void *data, E_Menu *m, E_Menu_Item *mi); 64static void _cpufreq_menu_pstate_min(void *data, E_Menu *m, E_Menu_Item *mi);
67static void _cpufreq_menu_pstate_max(void *data, E_Menu *m, E_Menu_Item *mi); 65static void _cpufreq_menu_pstate_max(void *data, E_Menu *m, E_Menu_Item *mi);
68static void _cpufreq_poll_interval_update(void);
69 66
70static E_Config_DD *conf_edd = NULL; 67static E_Config_DD *conf_edd = NULL;
71 68
@@ -163,6 +160,14 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class __UNUSED__)
163} 160}
164 161
165static void 162static void
163_cpufreq_cb_menu_configure(void *data __UNUSED__, E_Menu *m, E_Menu_Item *mi __UNUSED__)
164{
165 if (!cpufreq_config) return;
166 if (cpufreq_config->config_dialog) return;
167 e_int_config_cpufreq_module(m->zone->container, NULL);
168}
169
170static void
166_button_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) 171_button_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
167{ 172{
168 Instance *inst; 173 Instance *inst;
@@ -428,9 +433,16 @@ _button_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED_
428 else if (ev->button == 3) 433 else if (ev->button == 3)
429 { 434 {
430 E_Menu *m; 435 E_Menu *m;
436 E_Menu_Item *mi;
431 int cx, cy; 437 int cx, cy;
432 438
433 m = e_menu_new(); 439 m = e_menu_new();
440
441 mi = e_menu_item_new(m);
442 e_menu_item_label_set(mi, _("Settings"));
443 e_util_menu_item_theme_icon_set(mi, "configure");
444 e_menu_item_callback_set(mi, _cpufreq_cb_menu_configure, NULL);
445
434 m = e_gadcon_client_util_menu_items_append(inst->gcc, m, 0); 446 m = e_gadcon_client_util_menu_items_append(inst->gcc, m, 0);
435 447
436 e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, 448 e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
@@ -474,7 +486,7 @@ _menu_cb_post(void *data, E_Menu *m __UNUSED__)
474 cpufreq_config->menu_powersave = NULL; 486 cpufreq_config->menu_powersave = NULL;
475} 487}
476 488
477static void 489void
478_cpufreq_set_governor(const char *governor) 490_cpufreq_set_governor(const char *governor)
479{ 491{
480 char buf[4096]; 492 char buf[4096];
@@ -558,7 +570,7 @@ _cpufreq_set_frequency(int frequency)
558 } 570 }
559} 571}
560 572
561static void 573void
562_cpufreq_set_pstate(int min, int max, int turbo) 574_cpufreq_set_pstate(int min, int max, int turbo)
563{ 575{
564 char buf[4096]; 576 char buf[4096];
@@ -1252,7 +1264,7 @@ _cpufreq_menu_pstate_max(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNU
1252 e_config_save_queue(); 1264 e_config_save_queue();
1253} 1265}
1254 1266
1255static void 1267void
1256_cpufreq_poll_interval_update(void) 1268_cpufreq_poll_interval_update(void)
1257{ 1269{
1258 if (cpufreq_config->frequency_check_poller) 1270 if (cpufreq_config->frequency_check_poller)
@@ -1364,12 +1376,21 @@ e_modapi_init(E_Module *m)
1364 cpufreq_config->module = m; 1376 cpufreq_config->module = m;
1365 1377
1366 e_gadcon_provider_register(&_gadcon_class); 1378 e_gadcon_provider_register(&_gadcon_class);
1379
1380 snprintf(buf, sizeof(buf), "%s/e-module-cpufreq.edj", e_module_dir_get(m));
1381 e_configure_registry_category_add("advanced", 80, _("Advanced"), NULL,
1382 "preferences-advanced");
1383 e_configure_registry_item_add("advanced/cpufreq", 120, _("CPU Frequency"),
1384 NULL, buf, e_int_config_cpufreq_module);
1367 return m; 1385 return m;
1368} 1386}
1369 1387
1370EAPI int 1388EAPI int
1371e_modapi_shutdown(E_Module *m __UNUSED__) 1389e_modapi_shutdown(E_Module *m __UNUSED__)
1372{ 1390{
1391 e_configure_registry_item_del("advanced/cpufreq");
1392 e_configure_registry_category_del("advanced");
1393
1373 e_gadcon_provider_unregister(&_gadcon_class); 1394 e_gadcon_provider_unregister(&_gadcon_class);
1374 1395
1375 if (cpufreq_config->frequency_check_poller) 1396 if (cpufreq_config->frequency_check_poller)
@@ -1408,6 +1429,10 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
1408 eina_stringshare_del(cpufreq_config->governor); 1429 eina_stringshare_del(cpufreq_config->governor);
1409 if (cpufreq_config->status) _cpufreq_status_free(cpufreq_config->status); 1430 if (cpufreq_config->status) _cpufreq_status_free(cpufreq_config->status);
1410 E_FREE(cpufreq_config->set_exe_path); 1431 E_FREE(cpufreq_config->set_exe_path);
1432
1433 if (cpufreq_config->config_dialog)
1434 e_object_del(E_OBJECT(cpufreq_config->config_dialog));
1435
1411 free(cpufreq_config); 1436 free(cpufreq_config);
1412 cpufreq_config = NULL; 1437 cpufreq_config = NULL;
1413 E_CONFIG_DD_FREE(conf_edd); 1438 E_CONFIG_DD_FREE(conf_edd);
diff --git a/src/modules/cpufreq/e_mod_main.h b/src/modules/cpufreq/e_mod_main.h
index f462c9b..5879cb8 100644
--- a/src/modules/cpufreq/e_mod_main.h
+++ b/src/modules/cpufreq/e_mod_main.h
@@ -51,6 +51,7 @@ struct _Config
51 char *set_exe_path; 51 char *set_exe_path;
52 Ecore_Poller *frequency_check_poller; 52 Ecore_Poller *frequency_check_poller;
53 Ecore_Event_Handler *handler; 53 Ecore_Event_Handler *handler;
54 E_Config_Dialog *config_dialog;
54}; 55};
55 56
56EAPI extern E_Module_Api e_modapi; 57EAPI extern E_Module_Api e_modapi;
@@ -59,6 +60,12 @@ EAPI void *e_modapi_init (E_Module *m);
59EAPI int e_modapi_shutdown (E_Module *m); 60EAPI int e_modapi_shutdown (E_Module *m);
60EAPI int e_modapi_save (E_Module *m); 61EAPI int e_modapi_save (E_Module *m);
61 62
63E_Config_Dialog *e_int_config_cpufreq_module(E_Container *con, const char *params);
64void _cpufreq_poll_interval_update(void);
65void _cpufreq_set_governor(const char *governor);
66void _cpufreq_set_pstate(int min, int max, int turbo);
67
68extern Config *cpufreq_config;
62 69
63/** 70/**
64 * @addtogroup Optional_Gadgets 71 * @addtogroup Optional_Gadgets