2006-04-20 04:30:25 -07:00
|
|
|
#include "e.h"
|
2005-04-18 07:33:24 -07:00
|
|
|
#include "e_mod_main.h"
|
|
|
|
|
2012-11-12 23:54:03 -08:00
|
|
|
/* NOTE: for OpenBSD, as we cannot set the frequency but
|
|
|
|
* only its percent, we store percents 25-50-75-100
|
|
|
|
* in s->frequencies instead of available frequencies.
|
|
|
|
*/
|
|
|
|
|
2012-10-01 10:40:43 -07:00
|
|
|
#if defined (__FreeBSD__) || defined (__OpenBSD__)
|
|
|
|
# include <sys/sysctl.h>
|
2009-12-22 05:14:07 -08:00
|
|
|
#endif
|
2005-08-22 00:46:41 -07:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
/* gadcon requirements */
|
2006-05-31 09:31:51 -07:00
|
|
|
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
|
2012-08-15 00:04:54 -07:00
|
|
|
static void _gc_shutdown(E_Gadcon_Client *gcc);
|
|
|
|
static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
|
|
|
static const char *_gc_label(const E_Gadcon_Client_Class *client_class);
|
|
|
|
static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas);
|
|
|
|
static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class);
|
2006-04-20 04:30:25 -07:00
|
|
|
/* and actually define the gadcon class that this module provides (just 1) */
|
|
|
|
static const E_Gadcon_Client_Class _gadcon_class =
|
|
|
|
{
|
2010-04-10 11:26:29 -07:00
|
|
|
GADCON_CLIENT_CLASS_VERSION, "cpufreq",
|
2012-08-15 00:04:54 -07:00
|
|
|
{
|
|
|
|
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL, NULL
|
|
|
|
},
|
2006-08-08 23:38:35 -07:00
|
|
|
E_GADCON_CLIENT_STYLE_PLAIN
|
2006-04-20 04:30:25 -07:00
|
|
|
};
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
/* actual module specifics */
|
|
|
|
typedef struct _Instance Instance;
|
|
|
|
|
|
|
|
struct _Instance
|
2005-09-23 10:13:47 -07:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
E_Gadcon_Client *gcc;
|
2012-08-15 00:04:54 -07:00
|
|
|
Evas_Object *o_cpu;
|
2005-09-23 10:13:47 -07:00
|
|
|
};
|
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
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_frequency(int frequency);
|
2010-06-24 09:19:12 -07:00
|
|
|
static Eina_Bool _cpufreq_cb_check(void *data);
|
2012-08-15 00:04:54 -07:00
|
|
|
static Status *_cpufreq_status_new(void);
|
|
|
|
static void _cpufreq_status_free(Status *s);
|
2012-11-12 23:54:03 -08:00
|
|
|
static void _cpufreq_status_check_available(Status *s);
|
2012-08-15 00:04:54 -07:00
|
|
|
static int _cpufreq_status_check_current(Status *s);
|
|
|
|
static int _cpufreq_cb_sort(const void *item1, const void *item2);
|
|
|
|
static void _cpufreq_face_update_available(Instance *inst);
|
|
|
|
static void _cpufreq_face_update_current(Instance *inst);
|
|
|
|
static void _cpufreq_face_cb_set_frequency(void *data, Evas_Object *o, const char *emission, const char *source);
|
|
|
|
static void _cpufreq_face_cb_set_governor(void *data, Evas_Object *o, const char *emission, const char *source);
|
2010-06-24 09:19:12 -07:00
|
|
|
static Eina_Bool _cpufreq_event_cb_powersave(void *data __UNUSED__, int type, void *event);
|
2006-04-20 04:30:25 -07:00
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
static void _cpufreq_menu_fast(void *data, E_Menu *m, E_Menu_Item *mi);
|
|
|
|
static void _cpufreq_menu_medium(void *data, E_Menu *m, E_Menu_Item *mi);
|
|
|
|
static void _cpufreq_menu_normal(void *data, E_Menu *m, E_Menu_Item *mi);
|
|
|
|
static void _cpufreq_menu_slow(void *data, E_Menu *m, E_Menu_Item *mi);
|
|
|
|
static void _cpufreq_menu_very_slow(void *data, E_Menu *m, E_Menu_Item *mi);
|
|
|
|
static void _cpufreq_menu_restore_governor(void *data, E_Menu *m, E_Menu_Item *mi);
|
|
|
|
static void _cpufreq_menu_auto_powersave(void *data, E_Menu *m, E_Menu_Item *mi);
|
|
|
|
static void _cpufreq_menu_governor(void *data, E_Menu *m, E_Menu_Item *mi);
|
|
|
|
static void _cpufreq_menu_powersave_governor(void *data, E_Menu *m, E_Menu_Item *mi);
|
|
|
|
static void _cpufreq_menu_frequency(void *data, E_Menu *m, E_Menu_Item *mi);
|
2013-05-21 05:57:56 -07:00
|
|
|
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);
|
2006-04-20 04:30:25 -07:00
|
|
|
|
|
|
|
static E_Config_DD *conf_edd = NULL;
|
|
|
|
|
|
|
|
Config *cpufreq_config = NULL;
|
|
|
|
|
|
|
|
static E_Gadcon_Client *
|
2006-05-31 09:31:51 -07:00
|
|
|
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
Evas_Object *o;
|
|
|
|
E_Gadcon_Client *gcc;
|
|
|
|
Instance *inst;
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
inst = E_NEW(Instance, 1);
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
o = edje_object_add(gc->evas);
|
|
|
|
e_theme_edje_object_set(o, "base/theme/modules/cpufreq",
|
2012-08-15 00:04:54 -07:00
|
|
|
"e/modules/cpufreq/main");
|
2012-06-12 03:02:01 -07:00
|
|
|
edje_object_signal_callback_add(o, "e,action,governor,next", "*",
|
2010-04-10 11:26:29 -07:00
|
|
|
_cpufreq_face_cb_set_governor, NULL);
|
2012-06-12 03:02:01 -07:00
|
|
|
edje_object_signal_callback_add(o, "e,action,frequency,increase", "*",
|
2010-04-10 11:26:29 -07:00
|
|
|
_cpufreq_face_cb_set_frequency, NULL);
|
2012-06-12 03:02:01 -07:00
|
|
|
edje_object_signal_callback_add(o, "e,action,frequency,decrease", "*",
|
2010-04-10 11:26:29 -07:00
|
|
|
_cpufreq_face_cb_set_frequency, NULL);
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2006-12-30 15:32:25 -08:00
|
|
|
gcc = e_gadcon_client_new(gc, name, id, style, o);
|
2006-04-20 04:30:25 -07:00
|
|
|
gcc->data = inst;
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
inst->gcc = gcc;
|
|
|
|
inst->o_cpu = o;
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
|
2012-08-15 00:04:54 -07:00
|
|
|
_button_cb_mouse_down, inst);
|
2012-06-12 03:02:01 -07:00
|
|
|
cpufreq_config->instances =
|
2010-04-10 11:26:29 -07:00
|
|
|
eina_list_append(cpufreq_config->instances, inst);
|
2006-04-20 04:30:25 -07:00
|
|
|
if (cpufreq_config->status) _cpufreq_status_free(cpufreq_config->status);
|
|
|
|
cpufreq_config->status = _cpufreq_status_new();
|
|
|
|
_cpufreq_cb_check(NULL);
|
|
|
|
_cpufreq_face_update_available(inst);
|
2008-11-24 00:32:34 -08:00
|
|
|
|
2012-06-12 03:02:01 -07:00
|
|
|
cpufreq_config->handler =
|
2010-04-10 11:26:29 -07:00
|
|
|
ecore_event_handler_add(E_EVENT_POWERSAVE_UPDATE,
|
|
|
|
_cpufreq_event_cb_powersave, NULL);
|
2006-04-20 04:30:25 -07:00
|
|
|
return gcc;
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static void
|
|
|
|
_gc_shutdown(E_Gadcon_Client *gcc)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
Instance *inst;
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
inst = gcc->data;
|
2012-06-12 03:02:01 -07:00
|
|
|
cpufreq_config->instances =
|
2010-04-10 11:26:29 -07:00
|
|
|
eina_list_remove(cpufreq_config->instances, inst);
|
2006-04-20 04:30:25 -07:00
|
|
|
evas_object_del(inst->o_cpu);
|
|
|
|
free(inst);
|
2008-11-24 00:32:34 -08:00
|
|
|
|
2012-06-12 03:02:01 -07:00
|
|
|
if (cpufreq_config->handler)
|
2010-04-10 11:26:29 -07:00
|
|
|
ecore_event_handler_del(cpufreq_config->handler);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
e_gadcon_client_aspect_set(gcc, 16, 16);
|
|
|
|
e_gadcon_client_min_size_set(gcc, 16, 16);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
2006-05-09 06:02:48 -07:00
|
|
|
|
2011-11-14 13:46:57 -08:00
|
|
|
static const char *
|
2012-07-27 01:25:22 -07:00
|
|
|
_gc_label(const E_Gadcon_Client_Class *client_class __UNUSED__)
|
2006-05-09 06:02:48 -07:00
|
|
|
{
|
|
|
|
return _("Cpufreq");
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2012-07-27 01:25:22 -07:00
|
|
|
_gc_icon(const E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
|
2006-05-09 06:02:48 -07:00
|
|
|
{
|
|
|
|
Evas_Object *o;
|
2010-04-10 11:26:29 -07:00
|
|
|
char buf[PATH_MAX];
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2006-05-09 06:02:48 -07:00
|
|
|
o = edje_object_add(evas);
|
2007-03-24 16:12:23 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/e-module-cpufreq.edj",
|
2012-08-15 00:04:54 -07:00
|
|
|
e_module_dir_get(cpufreq_config->module));
|
2006-05-09 06:02:48 -07:00
|
|
|
edje_object_file_set(o, buf, "icon");
|
|
|
|
return o;
|
|
|
|
}
|
2007-09-15 17:02:53 -07:00
|
|
|
|
|
|
|
static const char *
|
2012-07-27 01:25:22 -07:00
|
|
|
_gc_id_new(const E_Gadcon_Client_Class *client_class __UNUSED__)
|
2007-09-15 17:02:53 -07:00
|
|
|
{
|
2010-04-12 12:54:43 -07:00
|
|
|
static char idbuff[32];
|
2010-04-12 12:26:09 -07:00
|
|
|
|
2012-06-12 03:02:01 -07:00
|
|
|
snprintf(idbuff, sizeof(idbuff), "%s.%d", _gadcon_class.name,
|
2010-04-10 11:26:29 -07:00
|
|
|
eina_list_count(cpufreq_config->instances));
|
2010-04-12 09:04:36 -07:00
|
|
|
return idbuff;
|
2010-04-10 11:26:29 -07:00
|
|
|
}
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2013-08-24 03:22:39 -07:00
|
|
|
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;
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
e_int_config_cpufreq_module(m->zone->comp, NULL);
|
2013-08-24 03:22:39 -07:00
|
|
|
}
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_button_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
Instance *inst;
|
|
|
|
Evas_Event_Mouse_Down *ev;
|
2012-06-12 03:02:01 -07:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
inst = data;
|
|
|
|
ev = event_info;
|
2011-02-09 14:44:29 -08:00
|
|
|
|
|
|
|
if (ev->button == 1)
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
E_Menu *mg, *mo;
|
|
|
|
E_Menu_Item *mi;
|
|
|
|
Eina_List *l;
|
|
|
|
int cx, cy;
|
|
|
|
char buf[256];
|
|
|
|
|
2013-03-13 00:46:56 -07:00
|
|
|
if (cpufreq_config->menu_poll) return;
|
2012-08-15 00:04:54 -07:00
|
|
|
mo = e_menu_new();
|
|
|
|
cpufreq_config->menu_poll = mo;
|
|
|
|
|
|
|
|
mi = e_menu_item_new(mo);
|
|
|
|
e_menu_item_label_set(mi, _("Fast (4 ticks)"));
|
|
|
|
e_menu_item_radio_set(mi, 1);
|
|
|
|
e_menu_item_radio_group_set(mi, 1);
|
|
|
|
if (cpufreq_config->poll_interval <= 4) e_menu_item_toggle_set(mi, 1);
|
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_fast, NULL);
|
|
|
|
|
|
|
|
mi = e_menu_item_new(mo);
|
|
|
|
e_menu_item_label_set(mi, _("Medium (8 ticks)"));
|
|
|
|
e_menu_item_radio_set(mi, 1);
|
|
|
|
e_menu_item_radio_group_set(mi, 1);
|
|
|
|
if (cpufreq_config->poll_interval > 4) e_menu_item_toggle_set(mi, 1);
|
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_medium, NULL);
|
|
|
|
|
|
|
|
mi = e_menu_item_new(mo);
|
|
|
|
e_menu_item_label_set(mi, _("Normal (32 ticks)"));
|
|
|
|
e_menu_item_radio_set(mi, 1);
|
|
|
|
e_menu_item_radio_group_set(mi, 1);
|
|
|
|
if (cpufreq_config->poll_interval >= 32) e_menu_item_toggle_set(mi, 1);
|
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_normal, NULL);
|
|
|
|
|
|
|
|
mi = e_menu_item_new(mo);
|
|
|
|
e_menu_item_label_set(mi, _("Slow (64 ticks)"));
|
|
|
|
e_menu_item_radio_set(mi, 1);
|
|
|
|
e_menu_item_radio_group_set(mi, 1);
|
|
|
|
if (cpufreq_config->poll_interval >= 64) e_menu_item_toggle_set(mi, 1);
|
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_slow, NULL);
|
|
|
|
|
|
|
|
mi = e_menu_item_new(mo);
|
|
|
|
e_menu_item_label_set(mi, _("Very Slow (256 ticks)"));
|
|
|
|
e_menu_item_radio_set(mi, 1);
|
|
|
|
e_menu_item_radio_group_set(mi, 1);
|
|
|
|
if (cpufreq_config->poll_interval >= 128)
|
2010-04-10 11:26:29 -07:00
|
|
|
e_menu_item_toggle_set(mi, 1);
|
2012-08-15 00:04:54 -07:00
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_very_slow, NULL);
|
|
|
|
|
|
|
|
if (cpufreq_config->status->governors)
|
|
|
|
{
|
|
|
|
mo = e_menu_new();
|
|
|
|
cpufreq_config->menu_governor = mo;
|
|
|
|
|
|
|
|
for (l = cpufreq_config->status->governors; l; l = l->next)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(mo);
|
|
|
|
if (!strcmp(l->data, "userspace"))
|
|
|
|
e_menu_item_label_set(mi, _("Manual"));
|
|
|
|
else if (!strcmp(l->data, "ondemand"))
|
|
|
|
e_menu_item_label_set(mi, _("Automatic"));
|
|
|
|
else if (!strcmp(l->data, "conservative"))
|
|
|
|
e_menu_item_label_set(mi, _("Lower Power Automatic"));
|
2012-12-06 14:13:15 -08:00
|
|
|
else if (!strcmp(l->data, "interactive"))
|
|
|
|
e_menu_item_label_set(mi, _("Automatic Interactive"));
|
2012-08-15 00:04:54 -07:00
|
|
|
else if (!strcmp(l->data, "powersave"))
|
|
|
|
e_menu_item_label_set(mi, _("Minimum Speed"));
|
|
|
|
else if (!strcmp(l->data, "performance"))
|
|
|
|
e_menu_item_label_set(mi, _("Maximum Speed"));
|
2012-12-06 14:22:01 -08:00
|
|
|
else
|
|
|
|
e_menu_item_label_set(mi, l->data);
|
2012-08-15 00:04:54 -07:00
|
|
|
e_menu_item_radio_set(mi, 1);
|
|
|
|
e_menu_item_radio_group_set(mi, 1);
|
|
|
|
if (!strcmp(cpufreq_config->status->cur_governor, l->data))
|
|
|
|
e_menu_item_toggle_set(mi, 1);
|
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_governor, l->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
e_menu_item_separator_set(e_menu_item_new(mo), 1);
|
|
|
|
|
|
|
|
mi = e_menu_item_new(mo);
|
|
|
|
e_menu_item_label_set(mi, _("Restore CPU Power Policy"));
|
|
|
|
e_menu_item_check_set(mi, 1);
|
|
|
|
e_menu_item_toggle_set(mi, cpufreq_config->restore_governor);
|
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_restore_governor, NULL);
|
|
|
|
|
|
|
|
mo = e_menu_new();
|
|
|
|
cpufreq_config->menu_powersave = mo;
|
|
|
|
|
|
|
|
for (l = cpufreq_config->status->governors; l; l = l->next)
|
|
|
|
{
|
|
|
|
if (!strcmp(l->data, "userspace"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
mi = e_menu_item_new(mo);
|
|
|
|
if (!strcmp(l->data, "ondemand"))
|
|
|
|
e_menu_item_label_set(mi, _("Automatic"));
|
|
|
|
else if (!strcmp(l->data, "conservative"))
|
|
|
|
e_menu_item_label_set(mi, _("Lower Power Automatic"));
|
2012-12-06 14:13:15 -08:00
|
|
|
else if (!strcmp(l->data, "interactive"))
|
|
|
|
e_menu_item_label_set(mi, _("Automatic Interactive"));
|
2012-08-15 00:04:54 -07:00
|
|
|
else if (!strcmp(l->data, "powersave"))
|
|
|
|
e_menu_item_label_set(mi, _("Minimum Speed"));
|
|
|
|
else if (!strcmp(l->data, "performance"))
|
|
|
|
e_menu_item_label_set(mi, _("Maximum Speed"));
|
2012-12-06 14:22:01 -08:00
|
|
|
else
|
|
|
|
e_menu_item_label_set(mi, l->data);
|
2012-08-15 00:04:54 -07:00
|
|
|
|
|
|
|
e_menu_item_radio_set(mi, 1);
|
|
|
|
e_menu_item_radio_group_set(mi, 1);
|
|
|
|
if (cpufreq_config->powersave_governor
|
|
|
|
&& !strcmp(cpufreq_config->powersave_governor, l->data))
|
|
|
|
e_menu_item_toggle_set(mi, 1);
|
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_powersave_governor, l->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
e_menu_item_separator_set(e_menu_item_new(mo), 1);
|
|
|
|
|
|
|
|
mi = e_menu_item_new(mo);
|
|
|
|
e_menu_item_label_set(mi, _("Automatic powersaving"));
|
|
|
|
e_menu_item_check_set(mi, 1);
|
|
|
|
e_menu_item_toggle_set(mi, cpufreq_config->auto_powersave);
|
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_auto_powersave, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((cpufreq_config->status->frequencies) &&
|
|
|
|
(cpufreq_config->status->can_set_frequency))
|
|
|
|
{
|
|
|
|
mo = e_menu_new();
|
|
|
|
cpufreq_config->menu_frequency = mo;
|
|
|
|
|
|
|
|
for (l = cpufreq_config->status->frequencies; l; l = l->next)
|
|
|
|
{
|
|
|
|
int frequency;
|
|
|
|
|
|
|
|
frequency = (long)l->data;
|
|
|
|
mi = e_menu_item_new(mo);
|
2012-10-01 10:40:43 -07:00
|
|
|
|
|
|
|
#ifdef __OpenBSD__
|
|
|
|
snprintf(buf, sizeof(buf), "%i %%", frequency);
|
|
|
|
#else
|
2012-08-15 00:04:54 -07:00
|
|
|
if (frequency < 1000000)
|
|
|
|
snprintf(buf, sizeof(buf), _("%i MHz"), frequency / 1000);
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), _("%'.1f GHz"),
|
|
|
|
frequency / 1000000.);
|
2012-10-01 10:40:43 -07:00
|
|
|
#endif
|
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
e_menu_item_label_set(mi, buf);
|
|
|
|
e_menu_item_radio_set(mi, 1);
|
|
|
|
e_menu_item_radio_group_set(mi, 1);
|
2012-10-01 10:40:43 -07:00
|
|
|
|
|
|
|
#ifdef __OpenBSD__
|
|
|
|
if (cpufreq_config->status->cur_percent == frequency)
|
|
|
|
e_menu_item_toggle_set(mi, 1);
|
|
|
|
#else
|
2012-08-15 00:04:54 -07:00
|
|
|
if (cpufreq_config->status->cur_frequency == frequency)
|
|
|
|
e_menu_item_toggle_set(mi, 1);
|
2012-10-01 10:40:43 -07:00
|
|
|
#endif
|
2012-08-15 00:04:54 -07:00
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_frequency, l->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-21 05:57:56 -07:00
|
|
|
if (cpufreq_config->status->pstate)
|
|
|
|
{
|
|
|
|
int set;
|
|
|
|
|
|
|
|
mo = e_menu_new();
|
|
|
|
cpufreq_config->menu_pstate1 = mo;
|
|
|
|
|
|
|
|
set = 0;
|
|
|
|
#define VALMIN(_n) \
|
|
|
|
mi = e_menu_item_new(mo); \
|
|
|
|
e_menu_item_label_set(mi, #_n); \
|
|
|
|
e_menu_item_radio_set(mi, 1); \
|
|
|
|
e_menu_item_radio_group_set(mi, 1); \
|
|
|
|
if ((!set) && (cpufreq_config->status->pstate_min <= _n)) \
|
|
|
|
{ set = 1; e_menu_item_toggle_set(mi, 1); } \
|
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_pstate_min, (void *)_n)
|
|
|
|
VALMIN(0);
|
|
|
|
VALMIN(25);
|
|
|
|
VALMIN(50);
|
|
|
|
VALMIN(75);
|
|
|
|
VALMIN(100);
|
|
|
|
|
|
|
|
mo = e_menu_new();
|
|
|
|
cpufreq_config->menu_pstate2 = mo;
|
|
|
|
|
|
|
|
set = 0;
|
|
|
|
#define VALMAX(_n) \
|
|
|
|
mi = e_menu_item_new(mo); \
|
|
|
|
e_menu_item_label_set(mi, #_n); \
|
|
|
|
e_menu_item_radio_set(mi, 1); \
|
|
|
|
e_menu_item_radio_group_set(mi, 1); \
|
|
|
|
if ((!set) && (cpufreq_config->status->pstate_max <= _n)) \
|
|
|
|
{ set = 1; e_menu_item_toggle_set(mi, 1); } \
|
|
|
|
e_menu_item_callback_set(mi, _cpufreq_menu_pstate_max, (void *)_n)
|
|
|
|
VALMAX(5);
|
|
|
|
VALMAX(25);
|
|
|
|
VALMAX(50);
|
|
|
|
VALMAX(75);
|
|
|
|
VALMAX(100);
|
|
|
|
}
|
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
mg = e_menu_new();
|
|
|
|
mi = e_menu_item_new(mg);
|
|
|
|
e_menu_item_label_set(mi, _("Time Between Updates"));
|
|
|
|
e_menu_item_submenu_set(mi, cpufreq_config->menu_poll);
|
|
|
|
|
|
|
|
if (cpufreq_config->menu_governor)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(mg);
|
|
|
|
e_menu_item_label_set(mi, _("Set CPU Power Policy"));
|
|
|
|
e_menu_item_submenu_set(mi, cpufreq_config->menu_governor);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cpufreq_config->menu_frequency)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(mg);
|
|
|
|
e_menu_item_label_set(mi, _("Set CPU Speed"));
|
|
|
|
e_menu_item_submenu_set(mi, cpufreq_config->menu_frequency);
|
|
|
|
}
|
|
|
|
if (cpufreq_config->menu_powersave)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(mg);
|
|
|
|
e_menu_item_label_set(mi, _("Powersaving behavior"));
|
|
|
|
e_menu_item_submenu_set(mi, cpufreq_config->menu_powersave);
|
|
|
|
}
|
2013-05-21 05:57:56 -07:00
|
|
|
if (cpufreq_config->menu_pstate1)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(mg);
|
|
|
|
e_menu_item_label_set(mi, _("Power State Min"));
|
|
|
|
e_menu_item_submenu_set(mi, cpufreq_config->menu_pstate1);
|
|
|
|
}
|
|
|
|
if (cpufreq_config->menu_pstate2)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(mg);
|
|
|
|
e_menu_item_label_set(mi, _("Power State Max"));
|
|
|
|
e_menu_item_submenu_set(mi, cpufreq_config->menu_pstate2);
|
|
|
|
}
|
2012-08-15 00:04:54 -07:00
|
|
|
|
|
|
|
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
|
|
|
|
&cx, &cy, NULL, NULL);
|
|
|
|
cpufreq_config->menu = mg;
|
|
|
|
e_menu_post_deactivate_callback_set(mg, _menu_cb_post, inst);
|
|
|
|
|
|
|
|
e_gadcon_locked_set(inst->gcc->gadcon, 1);
|
|
|
|
|
|
|
|
e_menu_activate_mouse(mg,
|
|
|
|
e_util_zone_current_get(e_manager_current_get()),
|
|
|
|
cx + ev->output.x, cy + ev->output.y, 1, 1,
|
|
|
|
E_MENU_POP_DIRECTION_AUTO, ev->timestamp);
|
2013-03-13 00:46:56 -07:00
|
|
|
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
|
|
|
|
EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
2011-02-09 14:44:29 -08:00
|
|
|
}
|
|
|
|
else if (ev->button == 3)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
E_Menu *m;
|
2013-08-24 03:22:39 -07:00
|
|
|
E_Menu_Item *mi;
|
2012-08-15 00:04:54 -07:00
|
|
|
int cx, cy;
|
2012-06-12 03:02:01 -07:00
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
m = e_menu_new();
|
2013-08-24 03:22:39 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
m = e_gadcon_client_util_menu_items_append(inst->gcc, m, 0);
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
|
|
|
|
&cx, &cy, NULL, NULL);
|
2011-02-09 14:44:29 -08:00
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
e_menu_activate_mouse(m,
|
|
|
|
e_util_zone_current_get(e_manager_current_get()),
|
|
|
|
cx + ev->output.x, cy + ev->output.y, 1, 1,
|
|
|
|
E_MENU_POP_DIRECTION_AUTO, ev->timestamp);
|
2012-08-15 00:22:04 -07:00
|
|
|
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
|
|
|
|
EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
2006-04-20 04:30:25 -07:00
|
|
|
}
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-09 14:44:29 -08:00
|
|
|
_menu_cb_post(void *data, E_Menu *m __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2011-02-09 14:44:29 -08:00
|
|
|
Instance *inst = data;
|
|
|
|
|
|
|
|
if (inst)
|
2012-06-12 03:02:01 -07:00
|
|
|
e_gadcon_locked_set(inst->gcc->gadcon, 0);
|
2011-02-09 14:44:29 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
if (!cpufreq_config->menu) return;
|
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu));
|
|
|
|
cpufreq_config->menu = NULL;
|
2012-06-12 03:02:01 -07:00
|
|
|
if (cpufreq_config->menu_poll)
|
2010-04-10 11:26:29 -07:00
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu_poll));
|
2006-04-20 04:30:25 -07:00
|
|
|
cpufreq_config->menu_poll = NULL;
|
2012-06-12 03:02:01 -07:00
|
|
|
if (cpufreq_config->menu_governor)
|
2010-04-10 11:26:29 -07:00
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu_governor));
|
2006-04-20 04:30:25 -07:00
|
|
|
cpufreq_config->menu_governor = NULL;
|
2012-06-12 03:02:01 -07:00
|
|
|
if (cpufreq_config->menu_frequency)
|
2010-04-10 11:26:29 -07:00
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu_frequency));
|
2006-04-20 04:30:25 -07:00
|
|
|
cpufreq_config->menu_frequency = NULL;
|
2012-06-12 03:02:01 -07:00
|
|
|
if (cpufreq_config->menu_powersave)
|
2010-04-10 11:26:29 -07:00
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu_powersave));
|
2013-05-21 05:57:56 -07:00
|
|
|
if (cpufreq_config->menu_pstate1)
|
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu_pstate1));
|
|
|
|
if (cpufreq_config->menu_pstate2)
|
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu_pstate2));
|
2008-11-24 00:32:34 -08:00
|
|
|
cpufreq_config->menu_powersave = NULL;
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
2013-08-24 03:22:39 -07:00
|
|
|
void
|
2006-04-20 04:30:25 -07:00
|
|
|
_cpufreq_set_governor(const char *governor)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2012-08-22 00:32:12 -07:00
|
|
|
char buf[4096];
|
2005-04-18 07:33:24 -07:00
|
|
|
int ret;
|
|
|
|
|
2009-12-22 05:14:07 -08:00
|
|
|
snprintf(buf, sizeof(buf),
|
2012-08-15 00:04:54 -07:00
|
|
|
"%s %s %s", cpufreq_config->set_exe_path, "governor", governor);
|
2005-04-18 07:33:24 -07:00
|
|
|
ret = system(buf);
|
|
|
|
if (ret != 0)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
E_Dialog *dia;
|
2005-09-20 18:18:30 -07:00
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
if (!(dia = e_dialog_new(NULL, "E", "_e_mod_cpufreq_error_setfreq")))
|
2010-04-10 11:26:29 -07:00
|
|
|
return;
|
2012-08-15 00:04:54 -07:00
|
|
|
e_dialog_title_set(dia, "Enlightenment Cpufreq Module");
|
|
|
|
e_dialog_icon_set(dia, "enlightenment", 64);
|
|
|
|
e_dialog_text_set(dia, _("There was an error trying to set the<br>"
|
|
|
|
"cpu frequency governor via the module's<br>"
|
|
|
|
"setfreq utility."));
|
|
|
|
e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
|
|
|
|
e_win_centered_set(dia->win, 1);
|
|
|
|
e_dialog_show(dia);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-04-20 04:30:25 -07:00
|
|
|
_cpufreq_set_frequency(int frequency)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2012-08-22 00:32:12 -07:00
|
|
|
char buf[4096];
|
2005-04-18 07:33:24 -07:00
|
|
|
int ret;
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2005-08-22 00:46:41 -07:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
frequency /= 1000;
|
2009-12-22 05:14:07 -08:00
|
|
|
#endif
|
2006-04-20 04:30:25 -07:00
|
|
|
if (!cpufreq_config->status->can_set_frequency)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
E_Dialog *dia;
|
2005-09-20 18:18:30 -07:00
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
if (!(dia = e_dialog_new(NULL, "E", "_e_mod_cpufreq_error_setfreq")))
|
2010-04-10 11:26:29 -07:00
|
|
|
return;
|
2012-08-15 00:04:54 -07:00
|
|
|
e_dialog_title_set(dia, "Enlightenment Cpufreq Module");
|
|
|
|
e_dialog_icon_set(dia, "enlightenment", 64);
|
|
|
|
e_dialog_text_set(dia, _("Your kernel does not support setting the<br>"
|
|
|
|
"CPU frequency at all. You may be missing<br>"
|
|
|
|
"Kernel modules or features, or your CPU<br>"
|
|
|
|
"simply does not support this feature."));
|
|
|
|
e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
|
|
|
|
e_win_centered_set(dia->win, 1);
|
|
|
|
e_dialog_show(dia);
|
|
|
|
return;
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2012-10-01 10:40:43 -07:00
|
|
|
#ifndef __OpenBSD__
|
|
|
|
/* OpenBSD doesn't have governors */
|
2009-12-22 05:14:07 -08:00
|
|
|
_cpufreq_set_governor("userspace");
|
2012-10-01 10:40:43 -07:00
|
|
|
#endif
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
snprintf(buf, sizeof(buf),
|
2012-08-15 00:04:54 -07:00
|
|
|
"%s %s %i", cpufreq_config->set_exe_path, "frequency", frequency);
|
2006-04-20 04:30:25 -07:00
|
|
|
ret = system(buf);
|
|
|
|
if (ret != 0)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
E_Dialog *dia;
|
2005-08-30 07:45:24 -07:00
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
if (!(dia = e_dialog_new(NULL, "E", "_e_mod_cpufreq_error_setfreq")))
|
2010-04-10 11:26:29 -07:00
|
|
|
return;
|
2012-08-15 00:04:54 -07:00
|
|
|
e_dialog_title_set(dia, "Enlightenment Cpufreq Module");
|
|
|
|
e_dialog_icon_set(dia, "enlightenment", 64);
|
|
|
|
e_dialog_text_set(dia, _("There was an error trying to set the<br>"
|
|
|
|
"cpu frequency setting via the module's<br>"
|
|
|
|
"setfreq utility."));
|
|
|
|
e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
|
|
|
|
e_win_centered_set(dia->win, 1);
|
|
|
|
e_dialog_show(dia);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-24 03:22:39 -07:00
|
|
|
void
|
2013-05-21 05:57:56 -07:00
|
|
|
_cpufreq_set_pstate(int min, int max, int turbo)
|
|
|
|
{
|
|
|
|
char buf[4096];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf),
|
|
|
|
"%s %s %i %i %i", cpufreq_config->set_exe_path, "pstate", min, max, turbo);
|
|
|
|
ret = system(buf);
|
|
|
|
if (ret != 0)
|
|
|
|
{
|
|
|
|
E_Dialog *dia;
|
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
if (!(dia = e_dialog_new(NULL, "E", "_e_mod_cpufreq_error_setfreq")))
|
2013-05-21 05:57:56 -07:00
|
|
|
return;
|
|
|
|
e_dialog_title_set(dia, "Enlightenment Cpufreq Module");
|
|
|
|
e_dialog_icon_set(dia, "enlightenment", 64);
|
|
|
|
e_dialog_text_set(dia, _("There was an error trying to set the<br>"
|
|
|
|
"cpu power state setting via the module's<br>"
|
|
|
|
"setfreq utility."));
|
|
|
|
e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
|
|
|
|
e_win_centered_set(dia->win, 1);
|
|
|
|
e_dialog_show(dia);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-24 09:19:12 -07:00
|
|
|
static Eina_Bool
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_cb_check(void *data __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
Instance *inst;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2005-04-18 20:51:49 -07:00
|
|
|
int active;
|
2006-05-05 16:31:12 -07:00
|
|
|
|
2010-06-24 09:19:12 -07:00
|
|
|
if (cpufreq_config->menu_poll) return ECORE_CALLBACK_RENEW;
|
2006-04-20 04:30:25 -07:00
|
|
|
active = cpufreq_config->status->active;
|
|
|
|
if (_cpufreq_status_check_current(cpufreq_config->status))
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
for (l = cpufreq_config->instances; l; l = l->next)
|
|
|
|
{
|
|
|
|
inst = l->data;
|
|
|
|
_cpufreq_face_update_current(inst);
|
|
|
|
}
|
2005-04-18 20:51:49 -07:00
|
|
|
}
|
2006-04-20 04:30:25 -07:00
|
|
|
if (active != cpufreq_config->status->active)
|
2005-04-18 20:51:49 -07:00
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
for (l = cpufreq_config->instances; l; l = l->next)
|
|
|
|
{
|
|
|
|
inst = l->data;
|
|
|
|
if (cpufreq_config->status->active == 0)
|
|
|
|
edje_object_signal_emit(inst->o_cpu, "e,state,disabled", "e");
|
|
|
|
else if (cpufreq_config->status->active == 1)
|
|
|
|
edje_object_signal_emit(inst->o_cpu, "e,state,enabled", "e");
|
|
|
|
}
|
2005-04-18 20:51:49 -07:00
|
|
|
}
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2010-06-24 09:19:12 -07:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Status *
|
2012-05-18 06:02:20 -07:00
|
|
|
_cpufreq_status_new(void)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
Status *s;
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
s = E_NEW(Status, 1);
|
|
|
|
if (!s) return NULL;
|
|
|
|
s->active = -1;
|
|
|
|
return s;
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-04-20 04:30:25 -07:00
|
|
|
_cpufreq_status_free(Status *s)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
if (s->frequencies) eina_list_free(s->frequencies);
|
2006-04-20 04:30:25 -07:00
|
|
|
if (s->governors)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
for (l = s->governors; l; l = l->next)
|
|
|
|
free(l->data);
|
|
|
|
eina_list_free(s->governors);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
2012-12-21 13:31:13 -08:00
|
|
|
free(s->cur_governor);
|
2008-11-24 00:32:34 -08:00
|
|
|
if (s->orig_governor) eina_stringshare_del(s->orig_governor);
|
2006-04-20 04:30:25 -07:00
|
|
|
free(s);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2008-10-27 03:46:43 -07:00
|
|
|
_cpufreq_cb_sort(const void *item1, const void *item2)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
|
|
|
int a, b;
|
|
|
|
|
2009-09-03 09:32:48 -07:00
|
|
|
a = (long)item1;
|
|
|
|
b = (long)item2;
|
2006-04-20 04:30:25 -07:00
|
|
|
if (a < b) return -1;
|
2012-08-15 00:04:54 -07:00
|
|
|
else if (a > b)
|
|
|
|
return 1;
|
2006-04-20 04:30:25 -07:00
|
|
|
return 0;
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
2012-11-12 23:54:03 -08:00
|
|
|
static void
|
2006-04-20 04:30:25 -07:00
|
|
|
_cpufreq_status_check_available(Status *s)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2012-08-22 00:32:12 -07:00
|
|
|
char buf[4096];
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2012-10-01 10:40:43 -07:00
|
|
|
// FIXME: this assumes all cores accept the same freqs/ might be wrong
|
|
|
|
|
|
|
|
#if defined (__OpenBSD__)
|
|
|
|
int p;
|
|
|
|
|
2012-11-12 23:54:03 -08:00
|
|
|
if (s->frequencies)
|
2012-10-01 10:40:43 -07:00
|
|
|
{
|
2012-11-12 23:54:03 -08:00
|
|
|
eina_list_free(s->frequencies);
|
|
|
|
s->frequencies = NULL;
|
2012-10-01 10:40:43 -07:00
|
|
|
}
|
2012-11-12 23:54:03 -08:00
|
|
|
|
|
|
|
/* storing percents */
|
|
|
|
p = 100;
|
|
|
|
s->frequencies = eina_list_append(s->frequencies, (void *)p);
|
|
|
|
p = 75;
|
|
|
|
s->frequencies = eina_list_append(s->frequencies, (void *)p);
|
|
|
|
p = 50;
|
|
|
|
s->frequencies = eina_list_append(s->frequencies, (void *)p);
|
|
|
|
p = 25;
|
|
|
|
s->frequencies = eina_list_append(s->frequencies, (void *)p);
|
2012-10-01 10:40:43 -07:00
|
|
|
#elif defined (__FreeBSD__)
|
|
|
|
int freq;
|
|
|
|
size_t len = sizeof(buf);
|
2012-10-04 16:26:48 -07:00
|
|
|
char *pos, *q;
|
2005-08-22 00:46:41 -07:00
|
|
|
|
|
|
|
/* read freq_levels sysctl and store it in freq */
|
|
|
|
if (sysctlbyname("dev.cpu.0.freq_levels", buf, &len, NULL, 0) == 0)
|
2009-12-22 05:14:07 -08:00
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
/* sysctl returns 0 on success */
|
|
|
|
if (s->frequencies)
|
|
|
|
{
|
|
|
|
eina_list_free(s->frequencies);
|
|
|
|
s->frequencies = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* parse freqs and store the frequencies in s->frequencies */
|
|
|
|
pos = buf;
|
|
|
|
while (pos)
|
|
|
|
{
|
|
|
|
q = strchr(pos, '/');
|
|
|
|
if (!q) break;
|
|
|
|
|
|
|
|
*q = '\0';
|
|
|
|
freq = atoi(pos);
|
|
|
|
freq *= 1000;
|
|
|
|
s->frequencies = eina_list_append(s->frequencies, (void *)freq);
|
|
|
|
|
|
|
|
pos = q + 1;
|
|
|
|
pos = strchr(pos, ' ');
|
|
|
|
}
|
2005-08-22 00:46:41 -07:00
|
|
|
}
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2005-08-22 00:46:41 -07:00
|
|
|
/* sort is not necessary because freq_levels is already sorted */
|
|
|
|
/* freebsd doesn't have governors */
|
2006-04-20 04:30:25 -07:00
|
|
|
if (s->governors)
|
2005-08-22 00:46:41 -07:00
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
for (l = s->governors; l; l = l->next)
|
|
|
|
free(l->data);
|
|
|
|
eina_list_free(s->governors);
|
|
|
|
s->governors = NULL;
|
2005-08-22 00:46:41 -07:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
FILE *f;
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2005-04-18 07:33:24 -07:00
|
|
|
f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies", "r");
|
|
|
|
if (f)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
char *freq;
|
|
|
|
|
|
|
|
if (s->frequencies)
|
|
|
|
{
|
|
|
|
eina_list_free(s->frequencies);
|
|
|
|
s->frequencies = NULL;
|
|
|
|
}
|
|
|
|
|
2012-11-12 23:54:03 -08:00
|
|
|
if (fgets(buf, sizeof(buf), f) == NULL)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return;
|
|
|
|
}
|
2012-08-15 00:04:54 -07:00
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
freq = strtok(buf, " ");
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (atoi(freq) != 0)
|
|
|
|
{
|
|
|
|
s->frequencies = eina_list_append(s->frequencies,
|
|
|
|
(void *)(long)atoi(freq));
|
|
|
|
}
|
|
|
|
freq = strtok(NULL, " ");
|
|
|
|
}
|
|
|
|
while (freq);
|
|
|
|
|
|
|
|
s->frequencies = eina_list_sort(s->frequencies,
|
|
|
|
eina_list_count(s->frequencies),
|
|
|
|
_cpufreq_cb_sort);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors", "r");
|
|
|
|
if (f)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
char *gov;
|
2013-05-20 09:25:19 -07:00
|
|
|
int len;
|
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
if (s->governors)
|
|
|
|
{
|
|
|
|
for (l = s->governors; l; l = l->next)
|
|
|
|
free(l->data);
|
|
|
|
eina_list_free(s->governors);
|
|
|
|
s->governors = NULL;
|
|
|
|
}
|
|
|
|
|
2012-11-12 23:54:03 -08:00
|
|
|
if (fgets(buf, sizeof(buf), f) == NULL)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return;
|
|
|
|
}
|
2012-08-15 00:04:54 -07:00
|
|
|
fclose(f);
|
2013-05-20 09:25:19 -07:00
|
|
|
len = strlen(buf);
|
|
|
|
if (len > 0)
|
|
|
|
{
|
|
|
|
gov = buf + len - 1;
|
|
|
|
while ((gov > buf) && (isspace(*gov)))
|
|
|
|
{
|
|
|
|
*gov = 0;
|
|
|
|
gov--;
|
|
|
|
}
|
|
|
|
}
|
2012-08-15 00:04:54 -07:00
|
|
|
gov = strtok(buf, " ");
|
|
|
|
do
|
|
|
|
{
|
|
|
|
while ((*gov) && (isspace(*gov)))
|
|
|
|
gov++;
|
|
|
|
if (strlen(gov) != 0)
|
|
|
|
s->governors = eina_list_append(s->governors, strdup(gov));
|
|
|
|
gov = strtok(NULL, " ");
|
|
|
|
}
|
|
|
|
while (gov);
|
|
|
|
|
|
|
|
s->governors =
|
2010-04-10 11:26:29 -07:00
|
|
|
eina_list_sort(s->governors, eina_list_count(s->governors),
|
|
|
|
(int (*)(const void *, const void *))strcmp);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
2005-08-22 00:46:41 -07:00
|
|
|
#endif
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-04-20 04:30:25 -07:00
|
|
|
_cpufreq_status_check_current(Status *s)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2005-08-22 00:46:41 -07:00
|
|
|
int ret = 0;
|
|
|
|
int frequency = 0;
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2012-10-01 10:40:43 -07:00
|
|
|
#if defined (__OpenBSD__)
|
|
|
|
size_t len = sizeof(frequency);
|
|
|
|
int percent, mib[] = {CTL_HW, HW_CPUSPEED};
|
|
|
|
s->active = 0;
|
|
|
|
|
|
|
|
_cpufreq_status_check_available(s);
|
|
|
|
|
|
|
|
if (sysctl(mib, 2, &frequency, &len, NULL, 0) == 0)
|
|
|
|
{
|
|
|
|
frequency *= 1000;
|
|
|
|
if (frequency != s->cur_frequency) ret = 1;
|
|
|
|
s->cur_frequency = frequency;
|
|
|
|
s->active = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mib[1] = HW_SETPERF;
|
|
|
|
|
|
|
|
if (sysctl(mib, 2, &percent, &len, NULL, 0) == 0)
|
|
|
|
{
|
|
|
|
s->cur_percent = percent;
|
|
|
|
}
|
|
|
|
|
|
|
|
s->can_set_frequency = 1;
|
|
|
|
s->cur_governor = NULL;
|
2012-11-12 23:54:03 -08:00
|
|
|
|
2012-10-01 10:40:43 -07:00
|
|
|
#elif defined (__FreeBSD__)
|
|
|
|
size_t len = sizeof(frequency);
|
2006-04-20 04:30:25 -07:00
|
|
|
s->active = 0;
|
2012-10-01 10:40:43 -07:00
|
|
|
|
2005-08-22 00:46:41 -07:00
|
|
|
/* frequency is stored in dev.cpu.0.freq */
|
|
|
|
if (sysctlbyname("dev.cpu.0.freq", &frequency, &len, NULL, 0) == 0)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
frequency *= 1000;
|
|
|
|
if (frequency != s->cur_frequency) ret = 1;
|
|
|
|
s->cur_frequency = frequency;
|
|
|
|
s->active = 1;
|
2005-08-22 00:46:41 -07:00
|
|
|
}
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2009-12-22 05:14:07 -08:00
|
|
|
/* hardcoded for testing */
|
|
|
|
s->can_set_frequency = 1;
|
|
|
|
s->cur_governor = NULL;
|
2012-11-12 23:54:03 -08:00
|
|
|
|
2005-08-22 00:46:41 -07:00
|
|
|
#else
|
2012-10-01 10:40:43 -07:00
|
|
|
char buf[4096];
|
|
|
|
FILE *f;
|
|
|
|
int frequency_min = 0x7fffffff;
|
|
|
|
int frequency_max = 0;
|
|
|
|
int freqtot = 0;
|
|
|
|
int i;
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
s->active = 0;
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2006-04-28 21:37:48 -07:00
|
|
|
_cpufreq_status_check_available(s);
|
2010-11-13 19:04:20 -08:00
|
|
|
// average out frequencies of all cores
|
|
|
|
for (i = 0; i < 64; i++)
|
2012-08-15 00:04:54 -07:00
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_cur_freq", i);
|
|
|
|
f = fopen(buf, "r");
|
|
|
|
if (f)
|
|
|
|
{
|
2012-11-12 23:54:03 -08:00
|
|
|
if (fgets(buf, sizeof(buf), f) == NULL)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
continue;
|
|
|
|
}
|
2012-08-15 00:04:54 -07:00
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
frequency = atoi(buf);
|
|
|
|
if (frequency > frequency_max) frequency_max = frequency;
|
|
|
|
if (frequency < frequency_min) frequency_min = frequency;
|
|
|
|
freqtot += frequency;
|
|
|
|
s->active = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i < 1) i = 1;
|
|
|
|
frequency = freqtot / i;
|
|
|
|
if (frequency != s->cur_frequency) ret = 1;
|
|
|
|
if (frequency_min != s->cur_min_frequency) ret = 1;
|
|
|
|
if (frequency_max != s->cur_max_frequency) ret = 1;
|
|
|
|
s->cur_frequency = frequency;
|
|
|
|
s->cur_min_frequency = frequency_min;
|
|
|
|
s->cur_max_frequency = frequency_max;
|
2012-06-12 03:02:01 -07:00
|
|
|
|
2010-11-29 02:52:32 -08:00
|
|
|
// printf("%i | %i %i\n", frequency, frequency_min, frequency_max);
|
2012-06-12 03:02:01 -07:00
|
|
|
|
2012-10-01 10:40:43 -07:00
|
|
|
// FIXME: this assumes all cores are on the same governor
|
2005-04-18 07:33:24 -07:00
|
|
|
f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed", "r");
|
|
|
|
if (f)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
s->can_set_frequency = 1;
|
|
|
|
fclose(f);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
s->can_set_frequency = 0;
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2005-04-18 07:33:24 -07:00
|
|
|
f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "r");
|
|
|
|
if (f)
|
|
|
|
{
|
2010-12-13 00:04:10 -08:00
|
|
|
char *p;
|
2012-06-12 03:02:01 -07:00
|
|
|
|
2012-11-12 23:54:03 -08:00
|
|
|
if (fgets(buf, sizeof(buf), f) == NULL)
|
|
|
|
{
|
|
|
|
fclose(f);
|
|
|
|
return ret;
|
|
|
|
}
|
2012-08-15 00:04:54 -07:00
|
|
|
fclose(f);
|
2012-11-12 23:54:03 -08:00
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
for (p = buf; (*p != 0) && (isalnum(*p)); p++) ;
|
2010-12-13 00:04:10 -08:00
|
|
|
*p = 0;
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
if ((!s->cur_governor) || (strcmp(buf, s->cur_governor)))
|
|
|
|
{
|
|
|
|
ret = 1;
|
|
|
|
|
2012-12-21 13:31:13 -08:00
|
|
|
free(s->cur_governor);
|
2012-08-15 00:04:54 -07:00
|
|
|
s->cur_governor = strdup(buf);
|
|
|
|
|
|
|
|
for (i = strlen(s->cur_governor) - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (isspace(s->cur_governor[i]))
|
|
|
|
s->cur_governor[i] = 0;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
2013-05-21 05:57:56 -07:00
|
|
|
f = fopen("/sys/devices/system/cpu/intel_pstate/min_perf_pct", "r");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
if (fgets(buf, sizeof(buf), f) != NULL)
|
|
|
|
{
|
|
|
|
s->pstate_min = atoi(buf);
|
|
|
|
s->pstate = 1;
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
f = fopen("/sys/devices/system/cpu/intel_pstate/max_perf_pct", "r");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
if (fgets(buf, sizeof(buf), f) != NULL)
|
|
|
|
{
|
|
|
|
s->pstate_max = atoi(buf);
|
|
|
|
s->pstate = 1;
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
f = fopen("/sys/devices/system/cpu/intel_pstate/no_turbo", "r");
|
|
|
|
if (f)
|
|
|
|
{
|
|
|
|
if (fgets(buf, sizeof(buf), f) != NULL)
|
|
|
|
{
|
|
|
|
s->pstate_turbo = atoi(buf);
|
|
|
|
if (s->pstate_turbo) s->pstate_turbo = 0;
|
|
|
|
else s->pstate_turbo = 1;
|
|
|
|
s->pstate = 1;
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
}
|
2005-08-22 00:46:41 -07:00
|
|
|
#endif
|
2005-04-18 07:33:24 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static void
|
|
|
|
_cpufreq_face_update_available(Instance *inst)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
Edje_Message_Int_Set *frequency_msg;
|
|
|
|
Edje_Message_String_Set *governor_msg;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2006-04-20 04:30:25 -07:00
|
|
|
int i;
|
|
|
|
int count;
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
count = eina_list_count(cpufreq_config->status->frequencies);
|
2006-04-20 04:30:25 -07:00
|
|
|
frequency_msg = malloc(sizeof(Edje_Message_Int_Set) + (count - 1) * sizeof(int));
|
2010-12-22 17:10:48 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(frequency_msg);
|
2006-04-20 04:30:25 -07:00
|
|
|
frequency_msg->count = count;
|
2009-12-22 05:14:07 -08:00
|
|
|
for (l = cpufreq_config->status->frequencies, i = 0; l; l = l->next, i++)
|
2009-09-03 09:32:48 -07:00
|
|
|
frequency_msg->val[i] = (long)l->data;
|
2006-04-20 04:30:25 -07:00
|
|
|
edje_object_message_send(inst->o_cpu, EDJE_MESSAGE_INT_SET, 1, frequency_msg);
|
|
|
|
free(frequency_msg);
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
count = eina_list_count(cpufreq_config->status->governors);
|
2006-04-20 04:30:25 -07:00
|
|
|
governor_msg = malloc(sizeof(Edje_Message_String_Set) + (count - 1) * sizeof(char *));
|
|
|
|
governor_msg->count = count;
|
|
|
|
for (l = cpufreq_config->status->governors, i = 0; l; l = l->next, i++)
|
|
|
|
governor_msg->str[i] = (char *)l->data;
|
|
|
|
edje_object_message_send(inst->o_cpu, EDJE_MESSAGE_STRING_SET, 2, governor_msg);
|
|
|
|
free(governor_msg);
|
|
|
|
}
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static void
|
|
|
|
_cpufreq_face_update_current(Instance *inst)
|
|
|
|
{
|
|
|
|
Edje_Message_Int_Set *frequency_msg;
|
|
|
|
Edje_Message_String governor_msg;
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2010-11-29 02:52:32 -08:00
|
|
|
frequency_msg = malloc(sizeof(Edje_Message_Int_Set) + (sizeof(int) * 4));
|
2010-12-22 17:10:48 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(frequency_msg);
|
2010-11-29 02:52:32 -08:00
|
|
|
frequency_msg->count = 5;
|
2006-04-20 04:30:25 -07:00
|
|
|
frequency_msg->val[0] = cpufreq_config->status->cur_frequency;
|
|
|
|
frequency_msg->val[1] = cpufreq_config->status->can_set_frequency;
|
2010-11-29 02:52:32 -08:00
|
|
|
frequency_msg->val[2] = cpufreq_config->status->cur_min_frequency;
|
|
|
|
frequency_msg->val[3] = cpufreq_config->status->cur_max_frequency;
|
|
|
|
frequency_msg->val[4] = 0; // pad
|
2006-04-20 04:30:25 -07:00
|
|
|
edje_object_message_send(inst->o_cpu, EDJE_MESSAGE_INT_SET, 3,
|
2012-08-15 00:04:54 -07:00
|
|
|
frequency_msg);
|
2006-04-20 04:30:25 -07:00
|
|
|
free(frequency_msg);
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
/* BSD crashes here without the if-condition
|
|
|
|
* since it has no governors (yet) */
|
2010-08-21 06:52:25 -07:00
|
|
|
if (cpufreq_config->status->cur_governor)
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
governor_msg.str = cpufreq_config->status->cur_governor;
|
|
|
|
edje_object_message_send(inst->o_cpu, EDJE_MESSAGE_STRING, 4,
|
|
|
|
&governor_msg);
|
2006-04-20 04:30:25 -07:00
|
|
|
}
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_face_cb_set_frequency(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *emission, const char *src __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2006-04-20 04:30:25 -07:00
|
|
|
int next_frequency = 0;
|
|
|
|
|
|
|
|
for (l = cpufreq_config->status->frequencies; l; l = l->next)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
if (cpufreq_config->status->cur_frequency == (long)l->data)
|
|
|
|
{
|
|
|
|
if (!strcmp(emission, "e,action,frequency,increase"))
|
|
|
|
{
|
|
|
|
if (l->next) next_frequency = (long)l->next->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!strcmp(emission, "e,action,frequency,decrease"))
|
|
|
|
{
|
|
|
|
if (l->prev) next_frequency = (long)l->prev->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2006-04-20 04:30:25 -07:00
|
|
|
}
|
|
|
|
if (next_frequency != 0) _cpufreq_set_frequency(next_frequency);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_face_cb_set_governor(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *src __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2006-04-20 04:30:25 -07:00
|
|
|
char *next_governor = NULL;
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
for (l = cpufreq_config->status->governors; l; l = l->next)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
if (!strcmp(l->data, cpufreq_config->status->cur_governor))
|
|
|
|
{
|
|
|
|
if (l->next)
|
|
|
|
next_governor = l->next->data;
|
|
|
|
else
|
|
|
|
next_governor = cpufreq_config->status->governors->data;
|
|
|
|
break;
|
|
|
|
}
|
2006-04-20 04:30:25 -07:00
|
|
|
}
|
2010-08-21 06:52:25 -07:00
|
|
|
if (next_governor) _cpufreq_set_governor(next_governor);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
2010-06-24 09:19:12 -07:00
|
|
|
static Eina_Bool
|
2008-11-24 00:32:34 -08:00
|
|
|
_cpufreq_event_cb_powersave(void *data __UNUSED__, int type, void *event)
|
|
|
|
{
|
|
|
|
E_Event_Powersave_Update *ev;
|
|
|
|
Eina_List *l;
|
2009-02-26 14:47:20 -08:00
|
|
|
Eina_Bool has_powersave = EINA_FALSE;
|
|
|
|
Eina_Bool has_conservative = EINA_FALSE;
|
2008-11-24 00:32:34 -08:00
|
|
|
|
2010-06-24 09:19:12 -07:00
|
|
|
if (type != E_EVENT_POWERSAVE_UPDATE) return ECORE_CALLBACK_PASS_ON;
|
|
|
|
if (!cpufreq_config->auto_powersave) return ECORE_CALLBACK_PASS_ON;
|
2008-11-24 00:32:34 -08:00
|
|
|
|
|
|
|
ev = event;
|
|
|
|
if (!cpufreq_config->status->orig_governor)
|
|
|
|
cpufreq_config->status->orig_governor = eina_stringshare_add(cpufreq_config->status->cur_governor);
|
|
|
|
|
|
|
|
for (l = cpufreq_config->status->governors; l; l = l->next)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
if (!strcmp(l->data, "conservative"))
|
|
|
|
has_conservative = EINA_TRUE;
|
|
|
|
else if (!strcmp(l->data, "powersave"))
|
|
|
|
has_powersave = EINA_TRUE;
|
2012-12-06 14:13:15 -08:00
|
|
|
else if (!strcmp(l->data, "interactive"))
|
|
|
|
has_powersave = EINA_TRUE;
|
2008-11-24 00:32:34 -08:00
|
|
|
}
|
|
|
|
|
2012-08-15 00:04:54 -07:00
|
|
|
switch (ev->mode)
|
2008-11-24 00:32:34 -08:00
|
|
|
{
|
|
|
|
case E_POWERSAVE_MODE_NONE:
|
|
|
|
case E_POWERSAVE_MODE_LOW:
|
2012-08-15 00:04:54 -07:00
|
|
|
_cpufreq_set_governor(cpufreq_config->status->orig_governor);
|
|
|
|
eina_stringshare_del(cpufreq_config->status->orig_governor);
|
|
|
|
cpufreq_config->status->orig_governor = NULL;
|
|
|
|
break;
|
|
|
|
|
2008-11-24 00:32:34 -08:00
|
|
|
case E_POWERSAVE_MODE_MEDIUM:
|
|
|
|
case E_POWERSAVE_MODE_HIGH:
|
2012-08-15 00:04:54 -07:00
|
|
|
if ((cpufreq_config->powersave_governor) || (has_conservative))
|
|
|
|
{
|
|
|
|
if (cpufreq_config->powersave_governor)
|
|
|
|
_cpufreq_set_governor(cpufreq_config->powersave_governor);
|
|
|
|
else
|
|
|
|
_cpufreq_set_governor("conservative");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-11-24 00:32:34 -08:00
|
|
|
case E_POWERSAVE_MODE_EXTREME:
|
2012-08-15 00:04:54 -07:00
|
|
|
if (has_powersave)
|
|
|
|
_cpufreq_set_governor("powersave");
|
|
|
|
break;
|
2008-11-24 00:32:34 -08:00
|
|
|
}
|
|
|
|
|
2010-06-24 09:19:12 -07:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2008-11-24 00:32:34 -08:00
|
|
|
}
|
|
|
|
|
2005-04-18 07:33:24 -07:00
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_menu_fast(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2008-01-10 23:33:57 -08:00
|
|
|
cpufreq_config->poll_interval = 4;
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_poll_interval_update();
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_menu_medium(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2008-01-10 23:33:57 -08:00
|
|
|
cpufreq_config->poll_interval = 8;
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_poll_interval_update();
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_menu_normal(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2008-01-10 23:33:57 -08:00
|
|
|
cpufreq_config->poll_interval = 32;
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_poll_interval_update();
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_menu_slow(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2008-01-10 23:33:57 -08:00
|
|
|
cpufreq_config->poll_interval = 64;
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_poll_interval_update();
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_menu_very_slow(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2008-01-10 23:33:57 -08:00
|
|
|
cpufreq_config->poll_interval = 256;
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_poll_interval_update();
|
2006-04-20 04:30:25 -07:00
|
|
|
}
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_menu_restore_governor(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi)
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
|
|
|
cpufreq_config->restore_governor = e_menu_item_toggle_get(mi);
|
2009-12-22 05:14:07 -08:00
|
|
|
if ((!cpufreq_config->governor) ||
|
2006-04-20 04:30:25 -07:00
|
|
|
(strcmp(cpufreq_config->status->cur_governor, cpufreq_config->governor)))
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2012-06-12 03:02:01 -07:00
|
|
|
eina_stringshare_replace(&cpufreq_config->governor,
|
2010-08-19 08:38:22 -07:00
|
|
|
cpufreq_config->status->cur_governor);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
2006-04-20 04:30:25 -07:00
|
|
|
e_config_save_queue();
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
2008-11-24 00:32:34 -08:00
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_menu_auto_powersave(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi)
|
2008-11-24 00:32:34 -08:00
|
|
|
{
|
|
|
|
cpufreq_config->auto_powersave = e_menu_item_toggle_get(mi);
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
|
2005-04-18 07:33:24 -07:00
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_menu_governor(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2008-11-24 00:32:34 -08:00
|
|
|
const char *governor;
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2006-05-05 16:31:12 -07:00
|
|
|
governor = data;
|
2006-04-20 04:30:25 -07:00
|
|
|
if (governor)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
_cpufreq_set_governor(governor);
|
2010-08-19 08:38:22 -07:00
|
|
|
eina_stringshare_replace(&cpufreq_config->governor, governor);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
2006-04-20 04:30:25 -07:00
|
|
|
e_config_save_queue();
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
2008-11-24 00:32:34 -08:00
|
|
|
static void
|
2010-08-19 08:38:22 -07:00
|
|
|
_cpufreq_menu_powersave_governor(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
2008-11-24 00:32:34 -08:00
|
|
|
{
|
|
|
|
const char *governor;
|
|
|
|
|
|
|
|
governor = data;
|
|
|
|
if (governor)
|
2010-08-19 08:38:22 -07:00
|
|
|
eina_stringshare_replace(&cpufreq_config->powersave_governor, governor);
|
2008-11-24 00:32:34 -08:00
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
|
2005-04-18 07:33:24 -07:00
|
|
|
static void
|
2012-08-15 00:04:54 -07:00
|
|
|
_cpufreq_menu_frequency(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
int frequency;
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2009-09-03 09:32:48 -07:00
|
|
|
frequency = (long)data;
|
2006-05-05 16:31:12 -07:00
|
|
|
if (frequency > 0) _cpufreq_set_frequency(frequency);
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
2013-05-21 05:57:56 -07:00
|
|
|
static void
|
|
|
|
_cpufreq_menu_pstate_min(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
|
|
|
{
|
|
|
|
int min = (long)data;
|
|
|
|
cpufreq_config->pstate_min = min + 1;
|
|
|
|
if (cpufreq_config->pstate_max < cpufreq_config->pstate_min)
|
|
|
|
cpufreq_config->pstate_max = cpufreq_config->pstate_min;
|
|
|
|
_cpufreq_set_pstate(cpufreq_config->pstate_min - 1,
|
|
|
|
cpufreq_config->pstate_max - 1, 1);
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cpufreq_menu_pstate_max(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
|
|
|
{
|
|
|
|
int max = (long)data;
|
|
|
|
cpufreq_config->pstate_max = max + 1;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2013-08-24 03:22:39 -07:00
|
|
|
void
|
2012-06-12 03:02:01 -07:00
|
|
|
_cpufreq_poll_interval_update(void)
|
2010-08-19 08:38:22 -07:00
|
|
|
{
|
|
|
|
if (cpufreq_config->frequency_check_poller)
|
|
|
|
ecore_poller_del(cpufreq_config->frequency_check_poller);
|
|
|
|
cpufreq_config->frequency_check_poller =
|
|
|
|
ecore_poller_add(ECORE_POLLER_CORE, cpufreq_config->poll_interval,
|
2012-08-15 00:04:54 -07:00
|
|
|
_cpufreq_cb_check, NULL);
|
2010-08-19 08:38:22 -07:00
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
/* module setup */
|
2009-12-22 05:14:07 -08:00
|
|
|
EAPI E_Module_Api e_modapi =
|
2010-04-10 11:26:29 -07:00
|
|
|
{
|
|
|
|
E_MODULE_API_VERSION, "Cpufreq"
|
|
|
|
};
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2006-06-06 08:33:44 -07:00
|
|
|
EAPI void *
|
2006-05-09 06:02:48 -07:00
|
|
|
e_modapi_init(E_Module *m)
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
2012-12-13 01:02:20 -08:00
|
|
|
struct stat st;
|
2010-04-10 11:26:29 -07:00
|
|
|
char buf[PATH_MAX];
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
conf_edd = E_CONFIG_DD_NEW("Cpufreq_Config", Config);
|
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
#define T Config
|
|
|
|
#define D conf_edd
|
2008-11-24 00:32:34 -08:00
|
|
|
E_CONFIG_VAL(D, T, config_version, INT);
|
2008-01-10 23:33:57 -08:00
|
|
|
E_CONFIG_VAL(D, T, poll_interval, INT);
|
2006-04-20 04:30:25 -07:00
|
|
|
E_CONFIG_VAL(D, T, restore_governor, INT);
|
2008-11-24 00:32:34 -08:00
|
|
|
E_CONFIG_VAL(D, T, auto_powersave, INT);
|
|
|
|
E_CONFIG_VAL(D, T, powersave_governor, STR);
|
2006-04-20 04:30:25 -07:00
|
|
|
E_CONFIG_VAL(D, T, governor, STR);
|
2013-05-21 05:57:56 -07:00
|
|
|
E_CONFIG_VAL(D, T, pstate_min, INT);
|
|
|
|
E_CONFIG_VAL(D, T, pstate_max, INT);
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
cpufreq_config = e_config_domain_load("module.cpufreq", conf_edd);
|
2012-06-12 03:02:01 -07:00
|
|
|
if ((cpufreq_config) &&
|
2010-04-10 11:26:29 -07:00
|
|
|
(cpufreq_config->config_version != CPUFREQ_CONFIG_VERSION))
|
2008-11-24 00:32:34 -08:00
|
|
|
E_FREE(cpufreq_config);
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
if (!cpufreq_config)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
cpufreq_config = E_NEW(Config, 1);
|
|
|
|
cpufreq_config->config_version = CPUFREQ_CONFIG_VERSION;
|
|
|
|
cpufreq_config->poll_interval = 32;
|
|
|
|
cpufreq_config->restore_governor = 0;
|
|
|
|
cpufreq_config->auto_powersave = 1;
|
|
|
|
cpufreq_config->powersave_governor = NULL;
|
|
|
|
cpufreq_config->governor = NULL;
|
2013-05-21 05:57:56 -07:00
|
|
|
cpufreq_config->pstate_min = 1;
|
|
|
|
cpufreq_config->pstate_max = 101;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (cpufreq_config->pstate_min == 0) cpufreq_config->pstate_min = 1;
|
|
|
|
if (cpufreq_config->pstate_max == 0) cpufreq_config->pstate_max = 101;
|
2006-04-20 04:30:25 -07:00
|
|
|
}
|
2008-01-10 23:33:57 -08:00
|
|
|
E_CONFIG_LIMIT(cpufreq_config->poll_interval, 1, 1024);
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2012-06-12 03:02:01 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s/freqset",
|
2010-04-10 11:26:29 -07:00
|
|
|
e_module_dir_get(m), MODULE_ARCH);
|
2006-04-20 04:30:25 -07:00
|
|
|
cpufreq_config->set_exe_path = strdup(buf);
|
2012-12-13 01:02:20 -08:00
|
|
|
|
|
|
|
if (stat(buf, &st) < 0)
|
|
|
|
{
|
|
|
|
e_util_dialog_show(_("Cpufreq Error"),
|
|
|
|
_("The freqset binary in the cpufreq module<br>"
|
|
|
|
"directory cannot be found (stat failed)"));
|
|
|
|
}
|
|
|
|
else if ((st.st_uid != 0) ||
|
|
|
|
((st.st_mode & (S_ISUID)) != (S_ISUID)) ||
|
|
|
|
((st.st_mode & (S_IXOTH)) != (S_IXOTH)))
|
|
|
|
{
|
|
|
|
e_util_dialog_show(_("Cpufreq Permissions Error"),
|
|
|
|
_("The freqset binary in the cpufreq module<br>"
|
|
|
|
"is not owned by root or does not have the<br>"
|
2012-12-14 09:40:12 -08:00
|
|
|
"setuid bit set. Please ensure this is the<br>"
|
2012-12-13 01:02:20 -08:00
|
|
|
"case. For example:<br>"
|
|
|
|
"<br>"
|
|
|
|
"sudo chown root %s<br>"
|
|
|
|
"sudo chmod u+s,a+x %s<br>"),
|
|
|
|
buf, buf);
|
|
|
|
}
|
|
|
|
|
2009-12-22 05:14:07 -08:00
|
|
|
cpufreq_config->frequency_check_poller =
|
2010-04-10 11:26:29 -07:00
|
|
|
ecore_poller_add(ECORE_POLLER_CORE, cpufreq_config->poll_interval,
|
2012-08-15 00:04:54 -07:00
|
|
|
_cpufreq_cb_check, NULL);
|
2006-04-20 04:30:25 -07:00
|
|
|
cpufreq_config->status = _cpufreq_status_new();
|
|
|
|
|
|
|
|
_cpufreq_status_check_available(cpufreq_config->status);
|
|
|
|
if ((cpufreq_config->restore_governor) && (cpufreq_config->governor))
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
/* If the governor is available, restore it */
|
|
|
|
for (l = cpufreq_config->status->governors; l; l = l->next)
|
|
|
|
{
|
|
|
|
if (!strcmp(l->data, cpufreq_config->governor))
|
|
|
|
{
|
|
|
|
_cpufreq_set_governor(cpufreq_config->governor);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
2006-05-09 06:02:48 -07:00
|
|
|
|
2013-05-21 05:57:56 -07:00
|
|
|
_cpufreq_set_pstate(cpufreq_config->pstate_min - 1,
|
|
|
|
cpufreq_config->pstate_max - 1, 1);
|
|
|
|
|
2006-05-09 06:02:48 -07:00
|
|
|
cpufreq_config->module = m;
|
2008-11-24 00:32:34 -08:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
e_gadcon_provider_register(&_gadcon_class);
|
2013-08-24 03:22:39 -07:00
|
|
|
|
|
|
|
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);
|
2006-07-24 21:11:41 -07:00
|
|
|
return m;
|
2006-04-20 04:30:25 -07:00
|
|
|
}
|
2005-04-18 07:33:24 -07:00
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
EAPI int
|
2010-08-19 08:38:22 -07:00
|
|
|
e_modapi_shutdown(E_Module *m __UNUSED__)
|
2006-04-20 04:30:25 -07:00
|
|
|
{
|
2013-08-24 03:22:39 -07:00
|
|
|
e_configure_registry_item_del("advanced/cpufreq");
|
|
|
|
e_configure_registry_category_del("advanced");
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
e_gadcon_provider_unregister(&_gadcon_class);
|
2009-12-22 05:14:07 -08:00
|
|
|
|
2008-01-10 23:33:57 -08:00
|
|
|
if (cpufreq_config->frequency_check_poller)
|
|
|
|
ecore_poller_del(cpufreq_config->frequency_check_poller);
|
2006-04-21 08:54:11 -07:00
|
|
|
if (cpufreq_config->menu)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
e_menu_post_deactivate_callback_set(cpufreq_config->menu, NULL, NULL);
|
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu));
|
|
|
|
cpufreq_config->menu = NULL;
|
2006-04-21 08:54:11 -07:00
|
|
|
}
|
|
|
|
if (cpufreq_config->menu_poll)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
e_menu_post_deactivate_callback_set(cpufreq_config->menu_poll, NULL, NULL);
|
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu_poll));
|
|
|
|
cpufreq_config->menu_poll = NULL;
|
2006-04-21 08:54:11 -07:00
|
|
|
}
|
|
|
|
if (cpufreq_config->menu_governor)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
e_menu_post_deactivate_callback_set(cpufreq_config->menu_governor, NULL, NULL);
|
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu_governor));
|
|
|
|
cpufreq_config->menu_governor = NULL;
|
2006-04-21 08:54:11 -07:00
|
|
|
}
|
|
|
|
if (cpufreq_config->menu_frequency)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
e_menu_post_deactivate_callback_set(cpufreq_config->menu_frequency, NULL, NULL);
|
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu_frequency));
|
|
|
|
cpufreq_config->menu_frequency = NULL;
|
2006-04-21 08:54:11 -07:00
|
|
|
}
|
2008-11-24 00:32:34 -08:00
|
|
|
if (cpufreq_config->menu_powersave)
|
|
|
|
{
|
2012-08-15 00:04:54 -07:00
|
|
|
e_menu_post_deactivate_callback_set(cpufreq_config->menu_powersave, NULL, NULL);
|
|
|
|
e_object_del(E_OBJECT(cpufreq_config->menu_powersave));
|
|
|
|
cpufreq_config->menu_powersave = NULL;
|
2008-11-24 00:32:34 -08:00
|
|
|
}
|
2006-04-20 04:30:25 -07:00
|
|
|
if (cpufreq_config->governor)
|
2008-10-15 08:12:56 -07:00
|
|
|
eina_stringshare_del(cpufreq_config->governor);
|
2007-03-25 14:58:09 -07:00
|
|
|
if (cpufreq_config->status) _cpufreq_status_free(cpufreq_config->status);
|
2007-03-25 15:07:39 -07:00
|
|
|
E_FREE(cpufreq_config->set_exe_path);
|
2013-08-24 03:22:39 -07:00
|
|
|
|
|
|
|
if (cpufreq_config->config_dialog)
|
|
|
|
e_object_del(E_OBJECT(cpufreq_config->config_dialog));
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
free(cpufreq_config);
|
|
|
|
cpufreq_config = NULL;
|
|
|
|
E_CONFIG_DD_FREE(conf_edd);
|
|
|
|
return 1;
|
2005-04-18 07:33:24 -07:00
|
|
|
}
|
|
|
|
|
2006-04-20 04:30:25 -07:00
|
|
|
EAPI int
|
2010-08-19 08:38:22 -07:00
|
|
|
e_modapi_save(E_Module *m __UNUSED__)
|
2005-04-18 07:33:24 -07:00
|
|
|
{
|
2006-04-20 04:30:25 -07:00
|
|
|
e_config_domain_save("module.cpufreq", conf_edd, cpufreq_config);
|
|
|
|
return 1;
|
|
|
|
}
|
2012-08-15 00:04:54 -07:00
|
|
|
|