/ dm_fan_ctrl.h
dm_fan_ctrl.h
 1  /*
 2   * Copyright 2018 Duan Hao
 3   * Copyright 2018 Con Kolivas <kernel@kolivas.org>
 4   *
 5   * This program is free software; you can redistribute it and/or modify it
 6   * under the terms of the GNU General Public License as published by the Free
 7   * Software Foundation; either version 3 of the License, or (at your option)
 8   * any later version.  See COPYING for more details.
 9   */
10  
11  #ifndef _DM_FAN_CTRL_H_
12  #define _DM_FAN_CTRL_H_
13  
14  #define FAN_SPEED_MAX			(100)			// max fan speed (%)
15  #define FAN_SPEED_MIN			(0)			// min fan speed (%)
16  #define FAN_SPEED_DEF			(80)			// default fan speed (%)
17  #define FAN_SPEED_PREHEAT		(10)			// preheat fan speed
18  
19  typedef enum _FAN_MODE
20  {
21  	FAN_MODE_MANUAL	= 0,				// manual fan control mode
22  	FAN_MODE_AUTO	= 1,				// auto fan control mode
23  } FAN_MODE;
24  
25  typedef enum _FAN_PROFILE
26  {
27  	FAN_PF_NORMAL	= 0,				// normal fan control
28  	FAN_PF_OVERHEAT	= 1,				// overheat fan control
29  	FAN_PF_PREHEAT	= 2,				// preheat fan control
30  } FAN_PROFILE;
31  
32  typedef struct _c_fan_cfg
33  {
34  	char fan_mode;						// fan mode: auto / manual
35  	char fan_speed;						// fan speed (percent)
36  	char fan_speed_preheat;				// preheat fan speed (percent)
37  	char fan_ctrl_cycle;				// time interval between fan controls (s)
38  	char tmp_chk_span;					// time span of temperature rising checks (s)
39  	bool preheat;						// true if preheat is enabled
40  } c_fan_cfg;
41  
42  extern volatile c_fan_cfg	g_fan_cfg;		// fan config
43  extern volatile int			g_fan_profile;	// fan profile: normal / overheat / preheat
44  	
45  
46  void dm_fanctrl_get_defcfg(c_fan_cfg *p_cfg);
47  void dm_fanctrl_init(c_fan_cfg *p_cfg);
48  void dm_fanctrl_set_fan_speed(char speed);
49  void *dm_fanctrl_thread(void *argv);
50  
51  #endif // _DM_FAN_CTRL_H_
52