aboutsummaryrefslogtreecommitdiffstats
path: root/cputemp2maxfreq.h
blob: baa691a686cce6a03a230491d4576a85209c9a2d (plain)
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
/*  This file is part of cputemp2maxfreq.

    Copyright (C) 2023-2024 pa4wdh

    cputemp2maxfreq 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.

    cputemp2maxfreq 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.

    You should have received a copy of the GNU General Public License
    along with cputemp2maxfreq; see the file COPYING.  If not, see
    <http://www.gnu.org/licenses>.
*/
#ifndef HAVE_CPUTEMP2MAXFREQ_H
#define HAVE_CPUTEMP2MAXFREQ_H

// Valid frequencies are between 100MHz and 10GHz
#define VALID_FREQ_MIN 100000
#define VALID_FREQ_MAX 10000000

// Valid frequency steps are between 1MHz and 1GHz
#define VALID_STEP_MIN 1000
#define VALID_STEP_MAX 1000000

// Valid temperatures are between 10 and 150 degrees
#define VALID_TEMP_MIN 10000
#define VALID_TEMP_MAX 150000

// Valid intervals are between 1 and 30
#define VALID_INTERVAL_MIN 1
#define VALID_INTERVAL_MAX 30

// Valid transition delays between 0 and 100000
#define VALID_TRANS_MIN 0
#define VALID_TRANS_MAX 100000

struct s_cpudata {
 long int min_freq;           // CPU's minimum frequency
 long int max_freq;           // CPU's maximum frequency
 long int cur_freq;           // CPU's current frequency
 long int cur_temp;           // CPU's current temperature
 long int scale_max;          // Governor's maximum scaling frequency
 long int transition_latency; // CPU's transition latency
 char   **cpulist;            // CPU list, set by cpulist_find_cpus
 int      cpulist_len;        // Length of CPU list, set by cpulist_find_cpus
};

struct s_config {
 char     name[255];       // Name of this program
 char     governor[255];   // The governor to use
 long int max_temp;        // The target temperature
 char     temp_input[255]; // Input file to read the temperature
 long int freq_step;       // Step size to increase/decrease CPU frequency
 long int fallback_freq;   // CPU frquency to set if we fail to protect hardware
 unsigned int interval;    // Time interval to check CPU temperature
 char     logger_name[10]; // Name of the logging function
 void   (*logger)(char *,...); // Pointer to the logging function
 char     log_data;        // Option to log measurement data
 char     csvlog[255];     // CSV logfile
 char     csvoverwrite;    // Overwrite CSV file if it already exists
 FILE    *csvfile;         // File handle for CSV file
 char     use_unixtime;    // Use unixtime timestamps in logs and CSV
 long int transition_latency; // User configurable transition latency, <0 for autodetect
 int      keepstate;       // Keep last state on exit (0=set lowest freq)
 int      cpu;             // CPU to monior when >=0, all on <0
};

#endif