Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | /* SPDX-License-Identifier: GPL-2.0-or-later */ /* * tmon.h contains data structures and constants used by TMON * * Copyright (C) 2012 Intel Corporation. All rights reserved. * * Author Name Jacob Pan <jacob.jun.pan@linux.intel.com> */ #ifndef TMON_H #define TMON_H #define MAX_DISP_TEMP 125 #define MAX_CTRL_TEMP 105 #define MIN_CTRL_TEMP 40 #define MAX_NR_TZONE 16 #define MAX_NR_CDEV 32 #define MAX_NR_TRIP 16 #define MAX_NR_CDEV_TRIP 12 /* number of cooling devices that can bind * to a thermal zone trip. */ #define MAX_TEMP_KC 140000 /* starting char position to draw sensor data, such as tz names * trip point list, etc. */ #define DATA_LEFT_ALIGN 10 #define NR_LINES_TZDATA 1 #define TMON_LOG_FILE "/var/tmp/tmon.log" #include <sys/time.h> #include <pthread.h> extern unsigned long ticktime; extern double time_elapsed; extern unsigned long target_temp_user; extern int dialogue_on; extern char ctrl_cdev[]; extern pthread_mutex_t input_lock; extern int tmon_exit; extern int target_thermal_zone; /* use fixed size record to simplify data processing and transfer * TBD: more info to be added, e.g. programmable trip point data. */ struct thermal_data_record { struct timeval tv; unsigned long temp[MAX_NR_TZONE]; double pid_out_pct; }; struct cdev_info { char type[64]; int instance; unsigned long max_state; unsigned long cur_state; unsigned long flag; }; enum trip_type { THERMAL_TRIP_CRITICAL, THERMAL_TRIP_HOT, THERMAL_TRIP_PASSIVE, THERMAL_TRIP_ACTIVE, NR_THERMAL_TRIP_TYPE, }; struct trip_point { enum trip_type type; unsigned long temp; unsigned long hysteresis; int attribute; /* programmability etc. */ }; /* thermal zone configuration information, binding with cooling devices could * change at runtime. */ struct tz_info { char type[256]; /* e.g. acpitz */ int instance; int passive; /* active zone has passive node to force passive mode */ int nr_cdev; /* number of cooling device binded */ int nr_trip_pts; struct trip_point tp[MAX_NR_TRIP]; unsigned long cdev_binding; /* bitmap for attached cdevs */ /* cdev bind trip points, allow one cdev bind to multiple trips */ unsigned long trip_binding[MAX_NR_CDEV]; }; struct tmon_platform_data { int nr_tz_sensor; int nr_cooling_dev; /* keep track of instance ids since there might be gaps */ int max_tz_instance; int max_cdev_instance; struct tz_info *tzi; struct cdev_info *cdi; }; struct control_ops { void (*set_ratio)(unsigned long ratio); unsigned long (*get_ratio)(unsigned long ratio); }; enum cdev_types { CDEV_TYPE_PROC, CDEV_TYPE_FAN, CDEV_TYPE_MEM, CDEV_TYPE_NR, }; /* REVISIT: the idea is to group sensors if possible, e.g. on intel mid * we have "skin0", "skin1", "sys", "msicdie" * on DPTF enabled systems, we might have PCH, TSKN, TAMB, etc. */ enum tzone_types { TZONE_TYPE_ACPI, TZONE_TYPE_PCH, TZONE_TYPE_NR, }; /* limit the output of PID controller adjustment */ #define LIMIT_HIGH (95) #define LIMIT_LOW (2) struct pid_params { double kp; /* Controller gain from Dialog Box */ double ki; /* Time-constant for I action from Dialog Box */ double kd; /* Time-constant for D action from Dialog Box */ double ts; double k_lpf; double t_target; double y_k; }; extern int init_thermal_controller(void); extern void controller_handler(const double xk, double *yk); extern struct tmon_platform_data ptdata; extern struct pid_params p_param; extern FILE *tmon_log; extern int cur_thermal_record; /* index to the trec array */ extern struct thermal_data_record trec[]; extern const char *trip_type_name[]; extern unsigned long no_control; extern void initialize_curses(void); extern void show_controller_stats(char *line); extern void show_title_bar(void); extern void setup_windows(void); extern void disable_tui(void); extern void show_sensors_w(void); extern void show_data_w(void); extern void write_status_bar(int x, char *line); extern void show_control_w(); extern void show_cooling_device(void); extern void show_dialogue(void); extern int update_thermal_data(void); extern int probe_thermal_sysfs(void); extern void free_thermal_data(void); extern void resize_handler(int sig); extern void set_ctrl_state(unsigned long state); extern void get_ctrl_state(unsigned long *state); extern void *handle_tui_events(void *arg); extern int sysfs_set_ulong(char *path, char *filename, unsigned long val); extern int zone_instance_to_index(int zone_inst); extern void close_windows(void); #define PT_COLOR_DEFAULT 1 #define PT_COLOR_HEADER_BAR 2 #define PT_COLOR_ERROR 3 #define PT_COLOR_RED 4 #define PT_COLOR_YELLOW 5 #define PT_COLOR_GREEN 6 #define PT_COLOR_BRIGHT 7 #define PT_COLOR_BLUE 8 /* each thermal zone uses 12 chars, 8 for name, 2 for instance, 2 space * also used to list trip points in forms of AAAC, which represents * A: Active * C: Critical */ #define TZONE_RECORD_SIZE 12 #define TZ_LEFT_ALIGN 32 #define CDEV_NAME_SIZE 20 #define CDEV_FLAG_IN_CONTROL (1 << 0) /* dialogue box starts */ #define DIAG_X 48 #define DIAG_Y 8 #define THERMAL_SYSFS "/sys/class/thermal" #define CDEV "cooling_device" #define TZONE "thermal_zone" #define TDATA_LEFT 16 #endif /* TMON_H */ |