1 /* SPDX-License-Identifier: LGPL-2.1+ */
6 #include <linux/thermal.h>
9 #define LIBTHERMAL_API __attribute__((visibility("default")))
16 struct thermal_sampling_ops {
17 int (*tz_temp)(int tz_id, int temp, void *arg);
20 struct thermal_events_ops {
21 int (*tz_create)(const char *name, int tz_id, void *arg);
22 int (*tz_delete)(int tz_id, void *arg);
23 int (*tz_enable)(int tz_id, void *arg);
24 int (*tz_disable)(int tz_id, void *arg);
25 int (*trip_high)(int tz_id, int trip_id, int temp, void *arg);
26 int (*trip_low)(int tz_id, int trip_id, int temp, void *arg);
27 int (*trip_add)(int tz_id, int trip_id, int type, int temp, int hyst, void *arg);
28 int (*trip_change)(int tz_id, int trip_id, int type, int temp, int hyst, void *arg);
29 int (*trip_delete)(int tz_id, int trip_id, void *arg);
30 int (*cdev_add)(const char *name, int cdev_id, int max_state, void *arg);
31 int (*cdev_delete)(int cdev_id, void *arg);
32 int (*cdev_update)(int cdev_id, int cur_state, void *arg);
33 int (*gov_change)(int tz_id, const char *gov_name, void *arg);
37 struct thermal_sampling_ops sampling;
38 struct thermal_events_ops events;
51 char name[THERMAL_NAME_LENGTH];
52 char governor[THERMAL_NAME_LENGTH];
53 struct thermal_trip *trip;
58 char name[THERMAL_NAME_LENGTH];
69 struct thermal_handler;
71 typedef int (*cb_tz_t)(struct thermal_zone *, void *);
73 typedef int (*cb_tt_t)(struct thermal_trip *, void *);
75 typedef int (*cb_tc_t)(struct thermal_cdev *, void *);
77 LIBTHERMAL_API int for_each_thermal_zone(struct thermal_zone *tz, cb_tz_t cb, void *arg);
79 LIBTHERMAL_API int for_each_thermal_trip(struct thermal_trip *tt, cb_tt_t cb, void *arg);
81 LIBTHERMAL_API int for_each_thermal_cdev(struct thermal_cdev *cdev, cb_tc_t cb, void *arg);
83 LIBTHERMAL_API struct thermal_zone *thermal_zone_find_by_name(struct thermal_zone *tz,
86 LIBTHERMAL_API struct thermal_zone *thermal_zone_find_by_id(struct thermal_zone *tz, int id);
88 LIBTHERMAL_API struct thermal_zone *thermal_zone_discover(struct thermal_handler *th);
90 LIBTHERMAL_API struct thermal_handler *thermal_init(struct thermal_ops *ops);
92 LIBTHERMAL_API void thermal_exit(struct thermal_handler *th);
95 * Netlink thermal events
97 LIBTHERMAL_API thermal_error_t thermal_events_exit(struct thermal_handler *th);
99 LIBTHERMAL_API thermal_error_t thermal_events_init(struct thermal_handler *th);
101 LIBTHERMAL_API thermal_error_t thermal_events_handle(struct thermal_handler *th, void *arg);
103 LIBTHERMAL_API int thermal_events_fd(struct thermal_handler *th);
106 * Netlink thermal commands
108 LIBTHERMAL_API thermal_error_t thermal_cmd_exit(struct thermal_handler *th);
110 LIBTHERMAL_API thermal_error_t thermal_cmd_init(struct thermal_handler *th);
112 LIBTHERMAL_API thermal_error_t thermal_cmd_get_tz(struct thermal_handler *th,
113 struct thermal_zone **tz);
115 LIBTHERMAL_API thermal_error_t thermal_cmd_get_cdev(struct thermal_handler *th,
116 struct thermal_cdev **tc);
118 LIBTHERMAL_API thermal_error_t thermal_cmd_get_trip(struct thermal_handler *th,
119 struct thermal_zone *tz);
121 LIBTHERMAL_API thermal_error_t thermal_cmd_get_governor(struct thermal_handler *th,
122 struct thermal_zone *tz);
124 LIBTHERMAL_API thermal_error_t thermal_cmd_get_temp(struct thermal_handler *th,
125 struct thermal_zone *tz);
128 * Netlink thermal samples
130 LIBTHERMAL_API thermal_error_t thermal_sampling_exit(struct thermal_handler *th);
132 LIBTHERMAL_API thermal_error_t thermal_sampling_init(struct thermal_handler *th);
134 LIBTHERMAL_API thermal_error_t thermal_sampling_handle(struct thermal_handler *th, void *arg);
136 LIBTHERMAL_API int thermal_sampling_fd(struct thermal_handler *th);
138 #endif /* __LIBTHERMAL_H */