Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ EXEC=macfand
BINFLAGS=-g -lconfig -lm
ETC_DIR = /etc
MACHINES_DIR = $(PREFIX)/macfand/machines
.PHONY: all macfand clean install
all: macfand

macfand:
Expand Down
1 change: 1 addition & 0 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ makedepends=(git make)
provides=("${_pkgname}")
conflicts=("${_pkgname}")
source=("git+$url")
backup=('etc/macfand.conf')
options=(!debug strip)
md5sums=('SKIP')

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# macfand
Fan control daemon for Apple Computers running Linux through the applesmc kernel module.
Fan control daemon for Apple Computers running Linux through the applesmc kernel module,
or the macsmc_hwmon driver on Linux 7.3+ (T2 Macs such as the MacPro7,1; load it with
`options macsmc_hwmon fan_control=1`).

## Configuration
See the [Configuration](https://github.com/ablakely/macfand/wiki/Configuration) wiki page
Expand Down
6 changes: 6 additions & 0 deletions include/applesmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct sensor
char name[50];
char fname[PATH_MAX];
float value;
bool valid;
};

struct fan
Expand All @@ -28,6 +29,9 @@ struct fan
char out_path[PATH_MAX];
char manual_path[PATH_MAX];
int speed;
int last_speed; /* last speed written, 0 = none yet */
int hw_min; /* fanN_min from sysfs, 0 if unknown */
int hw_max; /* fanN_max from sysfs, 0 if unknown */
float sensor_avg;
};

Expand All @@ -38,6 +42,7 @@ struct applesmc
int fan_cnt;
float temp_avg;
int active_sensors;
bool is_macsmc; /* macsmc_hwmon (kernel >= 7.3) instead of applesmc */

struct sensor *sensors;
struct fan *fans;
Expand All @@ -48,5 +53,6 @@ int countFans(char *basePath);
void find_applesmc(struct applesmc *smc);
void scan_sensors(struct applesmc *smc, struct mfdconfig cfg);
void read_sensors(struct applesmc *smc, struct mfdconfig cfg);
void release_fans(struct applesmc *smc);

#endif
5 changes: 4 additions & 1 deletion include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

#define HWMON_DIR "/sys/class/hwmon"
#define APPLESMC_ID "applesmc"
#define SENSKEY_MAXLEN 16
#define MACSMC_HWMON_ID "macsmc_hwmon"
#define SENSKEY_MAXLEN 48
#define MAXFANS 18
#define MAXSENSORS 100
#define MACHINESDIR "/usr/local/macfand/machines"
Expand Down Expand Up @@ -44,6 +45,8 @@ struct mfdconfig
int temp_avg_ceiling;
bool use_avgctrl;
int pollingInterval;
int rampdown_deadband; /* ignore slow-downs smaller than this (RPM) */
int rampdown_step; /* max slow-down per poll (RPM), 0 = unlimited */
char blacklist[MAX_EXCLUDE][SENSKEY_MAXLEN];
int blacklist_cnt;
struct fan_ctrl fanctrl[MAXFANS];
Expand Down
12 changes: 11 additions & 1 deletion macfand.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ config:
#This is an array of elements, such as:
#fan_ctrl = (
# {
# # fan 1
# # fan 1 - follows the HOTTEST of fan_sensors. Besides SMC keys,
# # any hwmon sensor can be named as "<hwmon name>:<temp label>"
# # (see /sys/class/hwmon/*/name and temp*_label), e.g.
# # "coretemp:Package id 0" or "amdgpu:junction". T2 Macs need this:
# # their SMC has no usable CPU die / GPU junction sensor.
# fan_sensors = ("TC0P", "TM0P", "TM8P");
# floor = 45;
# ceiling = 55;
Expand All @@ -43,6 +47,12 @@ config:
# }, ...
#);

#rampdown_deadband / rampdown_step - Smoothing (RPM). Speed-ups always
#apply immediately; slow-downs smaller than the deadband are ignored and
#larger ones are limited to rampdown_step per poll (0 = unlimited).
#rampdown_deadband = 100;
#rampdown_step = 250;

#log_level - Logging Verbosity
# 0 - startup/exit logging only
# 1 - basic temp / fan logging
Expand Down
Loading