0001
0002
0003 #ifndef __LIBTHERMAL_H
0004 #define __LIBTHERMAL_H
0005
0006 #include <linux/thermal.h>
0007
0008 #ifndef LIBTHERMAL_API
0009 #define LIBTHERMAL_API __attribute__((visibility("default")))
0010 #endif
0011
0012 #ifdef __cplusplus
0013 extern "C" {
0014 #endif
0015
0016 struct thermal_sampling_ops {
0017 int (*tz_temp)(int tz_id, int temp, void *arg);
0018 };
0019
0020 struct thermal_events_ops {
0021 int (*tz_create)(const char *name, int tz_id, void *arg);
0022 int (*tz_delete)(int tz_id, void *arg);
0023 int (*tz_enable)(int tz_id, void *arg);
0024 int (*tz_disable)(int tz_id, void *arg);
0025 int (*trip_high)(int tz_id, int trip_id, int temp, void *arg);
0026 int (*trip_low)(int tz_id, int trip_id, int temp, void *arg);
0027 int (*trip_add)(int tz_id, int trip_id, int type, int temp, int hyst, void *arg);
0028 int (*trip_change)(int tz_id, int trip_id, int type, int temp, int hyst, void *arg);
0029 int (*trip_delete)(int tz_id, int trip_id, void *arg);
0030 int (*cdev_add)(const char *name, int cdev_id, int max_state, void *arg);
0031 int (*cdev_delete)(int cdev_id, void *arg);
0032 int (*cdev_update)(int cdev_id, int cur_state, void *arg);
0033 int (*gov_change)(int tz_id, const char *gov_name, void *arg);
0034 };
0035
0036 struct thermal_ops {
0037 struct thermal_sampling_ops sampling;
0038 struct thermal_events_ops events;
0039 };
0040
0041 struct thermal_trip {
0042 int id;
0043 int type;
0044 int temp;
0045 int hyst;
0046 };
0047
0048 struct thermal_zone {
0049 int id;
0050 int temp;
0051 char name[THERMAL_NAME_LENGTH];
0052 char governor[THERMAL_NAME_LENGTH];
0053 struct thermal_trip *trip;
0054 };
0055
0056 struct thermal_cdev {
0057 int id;
0058 char name[THERMAL_NAME_LENGTH];
0059 int max_state;
0060 int min_state;
0061 int cur_state;
0062 };
0063
0064 typedef enum {
0065 THERMAL_ERROR = -1,
0066 THERMAL_SUCCESS = 0,
0067 } thermal_error_t;
0068
0069 struct thermal_handler;
0070
0071 typedef int (*cb_tz_t)(struct thermal_zone *, void *);
0072
0073 typedef int (*cb_tt_t)(struct thermal_trip *, void *);
0074
0075 typedef int (*cb_tc_t)(struct thermal_cdev *, void *);
0076
0077 LIBTHERMAL_API int for_each_thermal_zone(struct thermal_zone *tz, cb_tz_t cb, void *arg);
0078
0079 LIBTHERMAL_API int for_each_thermal_trip(struct thermal_trip *tt, cb_tt_t cb, void *arg);
0080
0081 LIBTHERMAL_API int for_each_thermal_cdev(struct thermal_cdev *cdev, cb_tc_t cb, void *arg);
0082
0083 LIBTHERMAL_API struct thermal_zone *thermal_zone_find_by_name(struct thermal_zone *tz,
0084 const char *name);
0085
0086 LIBTHERMAL_API struct thermal_zone *thermal_zone_find_by_id(struct thermal_zone *tz, int id);
0087
0088 LIBTHERMAL_API struct thermal_zone *thermal_zone_discover(struct thermal_handler *th);
0089
0090 LIBTHERMAL_API struct thermal_handler *thermal_init(struct thermal_ops *ops);
0091
0092 LIBTHERMAL_API void thermal_exit(struct thermal_handler *th);
0093
0094
0095
0096
0097 LIBTHERMAL_API thermal_error_t thermal_events_exit(struct thermal_handler *th);
0098
0099 LIBTHERMAL_API thermal_error_t thermal_events_init(struct thermal_handler *th);
0100
0101 LIBTHERMAL_API thermal_error_t thermal_events_handle(struct thermal_handler *th, void *arg);
0102
0103 LIBTHERMAL_API int thermal_events_fd(struct thermal_handler *th);
0104
0105
0106
0107
0108 LIBTHERMAL_API thermal_error_t thermal_cmd_exit(struct thermal_handler *th);
0109
0110 LIBTHERMAL_API thermal_error_t thermal_cmd_init(struct thermal_handler *th);
0111
0112 LIBTHERMAL_API thermal_error_t thermal_cmd_get_tz(struct thermal_handler *th,
0113 struct thermal_zone **tz);
0114
0115 LIBTHERMAL_API thermal_error_t thermal_cmd_get_cdev(struct thermal_handler *th,
0116 struct thermal_cdev **tc);
0117
0118 LIBTHERMAL_API thermal_error_t thermal_cmd_get_trip(struct thermal_handler *th,
0119 struct thermal_zone *tz);
0120
0121 LIBTHERMAL_API thermal_error_t thermal_cmd_get_governor(struct thermal_handler *th,
0122 struct thermal_zone *tz);
0123
0124 LIBTHERMAL_API thermal_error_t thermal_cmd_get_temp(struct thermal_handler *th,
0125 struct thermal_zone *tz);
0126
0127
0128
0129
0130 LIBTHERMAL_API thermal_error_t thermal_sampling_exit(struct thermal_handler *th);
0131
0132 LIBTHERMAL_API thermal_error_t thermal_sampling_init(struct thermal_handler *th);
0133
0134 LIBTHERMAL_API thermal_error_t thermal_sampling_handle(struct thermal_handler *th, void *arg);
0135
0136 LIBTHERMAL_API int thermal_sampling_fd(struct thermal_handler *th);
0137
0138 #endif
0139
0140 #ifdef __cplusplus
0141 }
0142 #endif