Skip to content

Commit 50f3a67

Browse files
mikaelbjoerngaul
authored andcommitted
Add support for many processors (not just cores)
Add an outer loop in mbpfan.c:retrieve_sensors to loop over all coretemp directories. Also increase hard-coded limits from 10 to 12 or 16 since the temp endpoints are sometimes indexed that high. For example, this is required for supporting a Mac Pro with two processors of 16 cores, requiring /sys/devices/platform/coretemp.0/hwmon/hwmon0/temp{1..12} /sys/devices/platform/coretemp.1/hwmon/hwmon1/temp{1..12} Fixes #152.
1 parent c8f33ec commit 50f3a67

File tree

11 files changed

+209
-159
lines changed

11 files changed

+209
-159
lines changed

mbpfan.conf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
[general]
22
# see https://ineed.coffee/3838/a-beginners-tutorial-for-mbpfan-under-ubuntu for the values
3-
#min_fan_speed = 2000 # put the *lowest* value of "cat /sys/devices/platform/applesmc.768/fan*_min"
4-
#max_fan_speed = 6200 # put the *highest* value of "cat /sys/devices/platform/applesmc.768/fan*_max"
3+
#
4+
# mbpfan will load the max / min speed of from the files produced by the applesmc driver. If these files are not found it will set all fans to the default of min_speed = 2000 and max_speed = 6200
5+
# by setting the values for the speeds in this config it will override whatever it finds in:
6+
# /sys/devices/platform/applesmc.768/fan*_min
7+
# /sys/devices/platform/applesmc.768/fan*_max
8+
# or the defaults.
9+
#
10+
# multiple fans can be configured by using the config key of min_fan*_speed and max_fan*_speed
11+
# the number used will correlate to the file number of the fan in the applesmc driver that are used to control the fan speed.
12+
#
13+
#min_fan1_speed = 2000 # put the *lowest* value of "cat /sys/devices/platform/applesmc.768/fan*_min"
14+
#max_fan1_speed = 6200 # put the *highest* value of "cat /sys/devices/platform/applesmc.768/fan*_max"
515
low_temp = 63 # try ranges 55-63, default is 63
616
high_temp = 66 # try ranges 58-66, default is 66
717
max_temp = 86 # take highest number returned by "cat /sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_max", divide by 1000

mbpfan.conf.test0

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[general]
22
# see https://ineed.coffee/3838/a-beginners-tutorial-for-mbpfan-under-ubuntu for the values
3-
min_fan_speed = 2000 # put the *lowest* value of "cat /sys/devices/platform/applesmc.768/fan*_min"
4-
max_fan_speed = 6200 # put the *highest* value of "cat /sys/devices/platform/applesmc.768/fan*_max"
3+
min_fan1_speed = 2000 # put the *lowest* value of "cat /sys/devices/platform/applesmc.768/fan*_min"
4+
max_fan1_speed = 6200 # put the *highest* value of "cat /sys/devices/platform/applesmc.768/fan*_max"
55
low_temp = 63 # try ranges 55-63, default is 63
66
high_temp = 66 # try ranges 58-66, default is 66
77
max_temp = 86 # take highest number returned by "cat /sys/devices/platform/coretemp.*/hwmon/hwmon*/temp*_max", divide by 1000

mbpfan.conf.test1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[general]
2-
min_fan_speed = 6200 # default is 2000
3-
max_fan_speed = 6200 # default is 6200
2+
min_fan1_speed = 6200 # default is 2000
3+
max_fan1_speed = 6200 # default is 6200
44
low_temp = 63 # try ranges 55-63, default is 63
55
high_temp = 66 # try ranges 58-66, default is 66
66
max_temp = 86 # do not set it > 90, default is 86

mbpfan.conf.test2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[general]
2+
min_fan1_speed = 2000 # default is 2000
3+
min_fan2_speed = 2000 # default is 6200
4+
low_temp = 63 # try ranges 55-63, default is 63
5+
high_temp = 66 # try ranges 58-66, default is 66
6+
max_temp = 86 # do not set it > 90, default is 86
7+
polling_interval = 1 # default is 7

src/daemon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void signal_handler(int signal)
112112
switch(signal) {
113113
case SIGHUP:
114114
syslog(LOG_WARNING, "Received SIGHUP signal.");
115-
retrieve_settings(NULL);
115+
retrieve_settings(NULL, fans);
116116
break;
117117

118118
case SIGTERM:

src/global.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ struct s_fans {
1919
char* path; // TODO: unused
2020
char* fan_output_path;
2121
char* fan_manual_path;
22+
int step_up;
23+
int step_down;
24+
int fan_id;
2225
int old_speed;
26+
int fan_max_speed;
27+
int fan_min_speed;
2328
struct s_fans *next;
2429
};
2530

@@ -29,4 +34,4 @@ typedef struct s_fans t_fans;
2934
extern t_sensors* sensors;
3035
extern t_fans* fans;
3136

32-
#endif
37+
#endif

src/main.c

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ void print_usage(int argc, char *argv[])
5454
}
5555
}
5656

57-
5857
void check_requirements()
5958
{
6059

@@ -97,49 +96,6 @@ void check_requirements()
9796

9897
}
9998

100-
101-
static int read_value(const char *path)
102-
{
103-
int value = -1;
104-
FILE *file = fopen(path, "r");
105-
if (file != NULL) {
106-
fscanf(file, "%d", &value);
107-
fclose(file);
108-
}
109-
return value;
110-
}
111-
112-
113-
void set_defaults(void)
114-
{
115-
int i;
116-
char *path;
117-
int value;
118-
for (i = 1; i <= 10; ++i) {
119-
path = smprintf("%s/fan%d_min", APPLESMC_PATH, i);
120-
value = read_value(path);
121-
if (value != -1 && (min_fan_speed == -1 || value < min_fan_speed)) {
122-
min_fan_speed = value;
123-
}
124-
free(path);
125-
126-
path = smprintf("%s/fan%d_max", APPLESMC_PATH, i);
127-
value = read_value(path);
128-
if (value != -1 && (max_fan_speed == -1 || value > max_fan_speed)) {
129-
max_fan_speed = value;
130-
}
131-
free(path);
132-
}
133-
134-
if (min_fan_speed == -1) {
135-
min_fan_speed = 2000;
136-
}
137-
if (max_fan_speed == -1) {
138-
max_fan_speed = 6200;
139-
}
140-
}
141-
142-
14399
int main(int argc, char *argv[])
144100
{
145101

@@ -170,10 +126,7 @@ int main(int argc, char *argv[])
170126
}
171127
}
172128

173-
174-
175129
check_requirements();
176-
set_defaults();
177130

178131
// pointer to mbpfan() function in mbpfan.c
179132
void (*fan_control)() = mbpfan;

src/main.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
void check_requirements();
2-
void set_defaults();

0 commit comments

Comments
 (0)