2012-06-15 21:07:11 +02:00
|
|
|
/**
|
|
|
|
* Copyright (C) 2010 Allan McRae <allan@archlinux.org>
|
2016-08-29 10:29:11 +02:00
|
|
|
* Modifications (2012-present) by Daniel Graziotin <daniel@ineed.coffee>
|
2012-06-15 21:07:11 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-08-23 22:32:49 +02:00
|
|
|
#ifndef _MBPFAN_H_
|
|
|
|
#define _MBPFAN_H_
|
|
|
|
|
2012-06-09 16:25:28 +02:00
|
|
|
/** Temperature Thresholds
|
|
|
|
* low_temp - temperature below which fan speed will be at minimum
|
|
|
|
* high_temp - fan will increase speed when higher than this temperature
|
|
|
|
* max_temp - fan will run at full speed above this temperature */
|
2012-06-09 19:07:25 +02:00
|
|
|
extern int low_temp;
|
|
|
|
extern int high_temp;
|
|
|
|
extern int max_temp;
|
2012-06-09 16:25:28 +02:00
|
|
|
|
|
|
|
/** Temperature polling interval
|
|
|
|
* Default value was 10 (seconds)
|
|
|
|
*/
|
2012-06-09 19:07:25 +02:00
|
|
|
extern int polling_interval;
|
2012-06-09 16:25:28 +02:00
|
|
|
|
|
|
|
/** Represents a Temperature sensor
|
|
|
|
*/
|
|
|
|
struct s_sensors;
|
|
|
|
typedef struct s_sensors t_sensors;
|
|
|
|
|
2012-10-24 11:13:25 +02:00
|
|
|
struct s_fans;
|
|
|
|
typedef struct s_fans t_fans;
|
|
|
|
|
2017-07-21 08:43:21 -07:00
|
|
|
char *smprintf(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
|
|
|
|
|
2014-06-22 16:48:44 +02:00
|
|
|
/**
|
|
|
|
* Return true if the kernel is < 3.15.0
|
|
|
|
*/
|
2017-04-02 16:59:50 +00:00
|
|
|
bool is_legacy_sensors_path();
|
2014-06-22 16:48:44 +02:00
|
|
|
|
2012-08-22 15:05:52 +02:00
|
|
|
/**
|
|
|
|
* Tries to use the settings located in
|
|
|
|
* /etc/mbpfan.conf
|
|
|
|
* If it fails, the default hardcoded settings are used
|
|
|
|
*/
|
2019-01-18 20:26:11 +01:00
|
|
|
void retrieve_settings(const char* settings_path, t_fans *fans);
|
2012-08-22 15:05:52 +02:00
|
|
|
|
2012-06-09 16:25:28 +02:00
|
|
|
/**
|
|
|
|
* Detect the sensors in /sys/devices/platform/coretemp.0/temp
|
2018-09-19 21:23:21 +01:00
|
|
|
* and /sys/devices/platform/coretemp.1/temp etc
|
2012-06-09 16:25:28 +02:00
|
|
|
* Return a linked list of t_sensors (first temperature detected)
|
|
|
|
*/
|
2012-06-11 21:43:53 +02:00
|
|
|
t_sensors *retrieve_sensors();
|
2012-06-09 16:25:28 +02:00
|
|
|
|
2012-06-09 19:07:25 +02:00
|
|
|
/**
|
|
|
|
* Given a linked list of t_sensors, refresh their detected
|
|
|
|
* temperature
|
|
|
|
*/
|
|
|
|
t_sensors *refresh_sensors(t_sensors *sensors);
|
|
|
|
|
2012-06-09 16:25:28 +02:00
|
|
|
/**
|
|
|
|
* Detect the fans in /sys/devices/platform/applesmc.768/
|
|
|
|
* Associate each fan to a sensor
|
|
|
|
*/
|
2012-10-24 11:13:25 +02:00
|
|
|
t_fans* retrieve_fans();
|
2012-06-09 16:25:28 +02:00
|
|
|
|
|
|
|
/**
|
2012-06-09 19:07:25 +02:00
|
|
|
* Given a list of sensors with associated fans
|
|
|
|
* Set them to manual control
|
2012-06-09 16:25:28 +02:00
|
|
|
*/
|
2012-10-24 11:13:25 +02:00
|
|
|
void set_fans_man(t_fans *fans);
|
2012-06-11 21:43:53 +02:00
|
|
|
|
2014-07-21 23:44:13 +02:00
|
|
|
/**
|
|
|
|
* Given a list of sensors with associated fans
|
|
|
|
* Set them to automatic control
|
|
|
|
*/
|
|
|
|
void set_fans_auto(t_fans *fans);
|
|
|
|
|
2012-07-03 09:37:44 +02:00
|
|
|
/**
|
2019-01-18 20:26:11 +01:00
|
|
|
* Given a sensors with associated fans
|
2012-07-03 09:37:44 +02:00
|
|
|
* Change their speed
|
|
|
|
*/
|
2019-01-18 20:26:11 +01:00
|
|
|
void set_fan_speed(t_fans* fan, int speed);
|
2012-07-03 09:37:44 +02:00
|
|
|
|
2019-01-18 20:26:11 +01:00
|
|
|
/**
|
|
|
|
* Given a list of fans set their minumum fan speed
|
|
|
|
*/
|
|
|
|
void set_fan_minimum_speed(t_fans* fans);
|
2012-06-16 11:02:48 +02:00
|
|
|
/**
|
2019-10-19 16:30:46 -07:00
|
|
|
* Return maximum CPU temp in degrees
|
2012-06-16 11:02:48 +02:00
|
|
|
*/
|
|
|
|
unsigned short get_temp(t_sensors* sensors);
|
|
|
|
|
2012-06-11 21:43:53 +02:00
|
|
|
/**
|
|
|
|
* Main Program
|
|
|
|
*/
|
2012-08-23 22:32:49 +02:00
|
|
|
void mbpfan();
|
|
|
|
|
2018-09-19 21:23:21 +01:00
|
|
|
#endif
|