File gkrellm-cpufreq-couple-controls.patch of Package gkrellm-cpufreq
Index: cpufreq.c
===================================================================
--- cpufreq.c.orig 2014-01-06 17:47:41.798749821 +0100
+++ cpufreq.c 2014-01-06 18:01:04.797093550 +0100
@@ -195,9 +195,9 @@
system(cmd);
}
-static void governor_userspace(unsigned int cpu) {
+static void set_governor(unsigned int cpu, const char *gov) {
char cmd[length];
- sprintf(cmd, "sudo cpupower -c %u frequency-set -g userspace", cpu);
+ sprintf(cmd, "sudo cpupower -c %u frequency-set -g %s", cpu, gov);
system(cmd);
}
@@ -321,10 +321,10 @@
if (controls_coupled) {
unsigned int icpu;
for ( icpu=0; icpu<ncpu; ++icpu ) {
- governor_userspace(icpu);
+ set_governor(icpu, "userspace");
}
} else {
- governor_userspace(cpu);
+ set_governor(cpu, "userspace");
}
}
if (controls_coupled) {
@@ -383,8 +383,21 @@
/* toggle governor */
if(controls_coupled) {
unsigned int icpu;
- for ( icpu=0; icpu<ncpu; ++icpu ) {
- next_governor(icpu);
+ /* figure out if all governors have the same value */
+ for ( icpu=0; icpu<ncpu-1; ++icpu ) {
+ if (strcmp(governor[icpu], governor[icpu+1]) != 0)
+ break;
+ }
+ /* if yes, next_governor for each */
+ if (icpu == ncpu-1) {
+ for ( icpu=0; icpu<ncpu; ++icpu ) {
+ next_governor(icpu);
+ }
+ /* if not, align all governors according to cpu0's */
+ } else {
+ for ( icpu=1; icpu<ncpu; ++icpu ) {
+ set_governor(icpu, governor[0]);
+ }
}
} else {
next_governor(cpu);
@@ -440,7 +453,9 @@
-1, /* x = -1 places at left margin */
y, /* y = -1 places at top margin */
-1); /* w = -1 makes decal the panel width minus margins */
- if (gov_enable && (!controls_coupled || cpu==0) ) {
+ /* display governors unconditionally, even if controls_coupled */
+ /* because governor can be changed from other tool */
+ if ( gov_enable ) {
governor_text[cpu] = governor[cpu];
y = text_decal_gov[cpu]->y + text_decal_gov[cpu]->h + 1;
} else {