1
2
3
4
5
6
7
8
9
10 #ifndef TMON_H
11 #define TMON_H
12
13 #define MAX_DISP_TEMP 125
14 #define MAX_CTRL_TEMP 105
15 #define MIN_CTRL_TEMP 40
16 #define MAX_NR_TZONE 16
17 #define MAX_NR_CDEV 32
18 #define MAX_NR_TRIP 16
19 #define MAX_NR_CDEV_TRIP 12
20
21
22 #define MAX_TEMP_KC 140000
23
24
25
26 #define DATA_LEFT_ALIGN 10
27 #define NR_LINES_TZDATA 1
28 #define TMON_LOG_FILE "/var/tmp/tmon.log"
29
30 extern unsigned long ticktime;
31 extern double time_elapsed;
32 extern unsigned long target_temp_user;
33 extern int dialogue_on;
34 extern char ctrl_cdev[];
35 extern pthread_mutex_t input_lock;
36 extern int tmon_exit;
37 extern int target_thermal_zone;
38
39
40
41 struct thermal_data_record {
42 struct timeval tv;
43 unsigned long temp[MAX_NR_TZONE];
44 double pid_out_pct;
45 };
46
47 struct cdev_info {
48 char type[64];
49 int instance;
50 unsigned long max_state;
51 unsigned long cur_state;
52 unsigned long flag;
53 };
54
55 enum trip_type {
56 THERMAL_TRIP_CRITICAL,
57 THERMAL_TRIP_HOT,
58 THERMAL_TRIP_PASSIVE,
59 THERMAL_TRIP_ACTIVE,
60 NR_THERMAL_TRIP_TYPE,
61 };
62
63 struct trip_point {
64 enum trip_type type;
65 unsigned long temp;
66 unsigned long hysteresis;
67 int attribute;
68 };
69
70
71
72
73 struct tz_info {
74 char type[256];
75 int instance;
76 int passive;
77 int nr_cdev;
78 int nr_trip_pts;
79 struct trip_point tp[MAX_NR_TRIP];
80 unsigned long cdev_binding;
81
82 unsigned long trip_binding[MAX_NR_CDEV];
83 };
84
85 struct tmon_platform_data {
86 int nr_tz_sensor;
87 int nr_cooling_dev;
88
89 int max_tz_instance;
90 int max_cdev_instance;
91 struct tz_info *tzi;
92 struct cdev_info *cdi;
93 };
94
95 struct control_ops {
96 void (*set_ratio)(unsigned long ratio);
97 unsigned long (*get_ratio)(unsigned long ratio);
98
99 };
100
101 enum cdev_types {
102 CDEV_TYPE_PROC,
103 CDEV_TYPE_FAN,
104 CDEV_TYPE_MEM,
105 CDEV_TYPE_NR,
106 };
107
108
109
110
111
112 enum tzone_types {
113 TZONE_TYPE_ACPI,
114 TZONE_TYPE_PCH,
115 TZONE_TYPE_NR,
116 };
117
118
119 #define LIMIT_HIGH (95)
120 #define LIMIT_LOW (2)
121
122 struct pid_params {
123 double kp;
124 double ki;
125 double kd;
126 double ts;
127 double k_lpf;
128
129 double t_target;
130 double y_k;
131 };
132
133 extern int init_thermal_controller(void);
134 extern void controller_handler(const double xk, double *yk);
135
136 extern struct tmon_platform_data ptdata;
137 extern struct pid_params p_param;
138
139 extern FILE *tmon_log;
140 extern int cur_thermal_record;
141 extern struct thermal_data_record trec[];
142 extern const char *trip_type_name[];
143 extern unsigned long no_control;
144
145 extern void initialize_curses(void);
146 extern void show_controller_stats(char *line);
147 extern void show_title_bar(void);
148 extern void setup_windows(void);
149 extern void disable_tui(void);
150 extern void show_sensors_w(void);
151 extern void show_data_w(void);
152 extern void write_status_bar(int x, char *line);
153 extern void show_control_w();
154
155 extern void show_cooling_device(void);
156 extern void show_dialogue(void);
157 extern int update_thermal_data(void);
158
159 extern int probe_thermal_sysfs(void);
160 extern void free_thermal_data(void);
161 extern void resize_handler(int sig);
162 extern void set_ctrl_state(unsigned long state);
163 extern void get_ctrl_state(unsigned long *state);
164 extern void *handle_tui_events(void *arg);
165 extern int sysfs_set_ulong(char *path, char *filename, unsigned long val);
166 extern int zone_instance_to_index(int zone_inst);
167 extern void close_windows(void);
168
169 #define PT_COLOR_DEFAULT 1
170 #define PT_COLOR_HEADER_BAR 2
171 #define PT_COLOR_ERROR 3
172 #define PT_COLOR_RED 4
173 #define PT_COLOR_YELLOW 5
174 #define PT_COLOR_GREEN 6
175 #define PT_COLOR_BRIGHT 7
176 #define PT_COLOR_BLUE 8
177
178
179
180
181
182
183 #define TZONE_RECORD_SIZE 12
184 #define TZ_LEFT_ALIGN 32
185 #define CDEV_NAME_SIZE 20
186 #define CDEV_FLAG_IN_CONTROL (1 << 0)
187
188
189 #define DIAG_X 48
190 #define DIAG_Y 8
191 #define THERMAL_SYSFS "/sys/class/thermal"
192 #define CDEV "cooling_device"
193 #define TZONE "thermal_zone"
194 #define TDATA_LEFT 16
195 #endif