dm_fan_ctrl.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef _DM_FAN_CTRL_H_
  11. #define _DM_FAN_CTRL_H_
  12. #define FAN_SPEED_MAX (100) // max fan speed (%)
  13. #define FAN_SPEED_MIN (0) // min fan speed (%)
  14. #define FAN_SPEED_DEF (80) // default fan speed (%)
  15. #define FAN_SPEED_PREHEAT (10) // preheat fan speed
  16. typedef enum _FAN_MODE
  17. {
  18. FAN_MODE_MANUAL = 0, // manual fan control mode
  19. FAN_MODE_AUTO = 1, // auto fan control mode
  20. } FAN_MODE;
  21. typedef enum _FAN_PROFILE
  22. {
  23. FAN_PF_NORMAL = 0, // normal fan control
  24. FAN_PF_OVERHEAT = 1, // overheat fan control
  25. FAN_PF_PREHEAT = 2, // preheat fan control
  26. } FAN_PROFILE;
  27. typedef struct _c_fan_cfg
  28. {
  29. char fan_mode; // fan mode: auto / manual
  30. char fan_speed; // fan speed (percent)
  31. char fan_speed_preheat; // preheat fan speed (percent)
  32. char fan_ctrl_cycle; // time interval between fan controls (s)
  33. char tmp_chk_span; // time span of temperature rising checks (s)
  34. bool preheat; // true if preheat is enabled
  35. } c_fan_cfg;
  36. extern volatile c_fan_cfg g_fan_cfg; // fan config
  37. extern volatile int g_fan_profile; // fan profile: normal / overheat / preheat
  38. void dm_fanctrl_get_defcfg(c_fan_cfg *p_cfg);
  39. void dm_fanctrl_init(c_fan_cfg *p_cfg);
  40. void dm_fanctrl_set_fan_speed(char speed);
  41. void *dm_fanctrl_thread(void *argv);
  42. #endif // _DM_FAN_CTRL_H_