Source
x
while ((c = getopt_long(argc, argv, "c:dlht:T:vgz:", opts, &id2)) != -1) {
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* tmon.c Thermal Monitor (TMON) main function and entry point
*
* Copyright (C) 2012 Intel Corporation. All rights reserved.
*
* Author: Jacob Pan <jacob.jun.pan@linux.intel.com>
*/
unsigned long ticktime = 1; /* seconds */
unsigned long no_control = 1; /* monitoring only or use cooling device for
* temperature control.
*/
double time_elapsed = 0.0;
unsigned long target_temp_user = 65; /* can be select by tui later */
int dialogue_on;
int tmon_exit;
static short daemon_mode;
static int logging; /* for recording thermal data to a file */
static int debug_on;
FILE *tmon_log;
/*cooling device used for the PID controller */
char ctrl_cdev[CDEV_NAME_SIZE] = "None";
int target_thermal_zone; /* user selected target zone instance */
static void start_daemon_mode(void);
pthread_t event_tid;
pthread_mutex_t input_lock;
void usage()
{
printf("Usage: tmon [OPTION...]\n");
printf(" -c, --control cooling device in control\n");
printf(" -d, --daemon run as daemon, no TUI\n");
printf(" -g, --debug debug message in syslog\n");
printf(" -h, --help show this help message\n");
printf(" -l, --log log data to /var/tmp/tmon.log\n");
printf(" -t, --time-interval sampling time interval, > 1 sec.\n");
printf(" -T, --target-temp initial target temperature\n");
printf(" -v, --version show version\n");
printf(" -z, --zone target thermal zone id\n");
exit(0);
}
void version()
{
printf("TMON version %s\n", VERSION);
exit(EXIT_SUCCESS);
}
static void tmon_cleanup(void)
{
syslog(LOG_INFO, "TMON exit cleanup\n");
fflush(stdout);
refresh();
if (tmon_log)
fclose(tmon_log);
if (event_tid) {
pthread_mutex_lock(&input_lock);
pthread_cancel(event_tid);
pthread_mutex_unlock(&input_lock);
pthread_mutex_destroy(&input_lock);
}
closelog();
/* relax control knobs, undo throttling */
set_ctrl_state(0);
keypad(stdscr, FALSE);
echo();
nocbreak();
close_windows();