brintos

brintos / linux-shallow public Read only

0
0
Text · 4.1 KiB · 1abc560 Raw
143 lines · c
1/* SPDX-License-Identifier: LGPL-2.1+ */2/* Copyright (C) 2022, Linaro Ltd - Daniel Lezcano <daniel.lezcano@linaro.org> */3#ifndef __LIBTHERMAL_H4#define __LIBTHERMAL_H5 6#include <linux/thermal.h>7 8#ifndef LIBTHERMAL_API9#define LIBTHERMAL_API __attribute__((visibility("default")))10#endif11 12#ifdef __cplusplus13extern "C" {14#endif15 16struct thermal_sampling_ops {17	int (*tz_temp)(int tz_id, int temp, void *arg);18};19 20struct 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);34};35 36struct thermal_ops {37	struct thermal_sampling_ops sampling;38	struct thermal_events_ops events;39};40 41struct thermal_trip {42	int id;43	int type;44	int temp;45	int hyst;46};47 48struct thermal_zone {49	int id;50	int temp;51	char name[THERMAL_NAME_LENGTH];52	char governor[THERMAL_NAME_LENGTH];53	struct thermal_trip *trip;54};55 56struct thermal_cdev {57	int id;58	char name[THERMAL_NAME_LENGTH];59	int max_state;60	int min_state;61	int cur_state;62};63 64typedef enum {65	THERMAL_ERROR = -1,66	THERMAL_SUCCESS = 0,67} thermal_error_t;68 69struct thermal_handler;70 71typedef int (*cb_tz_t)(struct thermal_zone *, void *);72 73typedef int (*cb_tt_t)(struct thermal_trip *, void *);74 75typedef int (*cb_tc_t)(struct thermal_cdev *, void *);76 77LIBTHERMAL_API int for_each_thermal_zone(struct thermal_zone *tz, cb_tz_t cb, void *arg);78 79LIBTHERMAL_API int for_each_thermal_trip(struct thermal_trip *tt, cb_tt_t cb, void *arg);80 81LIBTHERMAL_API int for_each_thermal_cdev(struct thermal_cdev *cdev, cb_tc_t cb, void *arg);82 83LIBTHERMAL_API struct thermal_zone *thermal_zone_find_by_name(struct thermal_zone *tz,84							      const char *name);85 86LIBTHERMAL_API struct thermal_zone *thermal_zone_find_by_id(struct thermal_zone *tz, int id);87 88LIBTHERMAL_API struct thermal_zone *thermal_zone_discover(struct thermal_handler *th);89 90LIBTHERMAL_API struct thermal_handler *thermal_init(struct thermal_ops *ops);91 92LIBTHERMAL_API void thermal_exit(struct thermal_handler *th);93 94/*95 * Netlink thermal events96 */97LIBTHERMAL_API thermal_error_t thermal_events_exit(struct thermal_handler *th);98 99LIBTHERMAL_API thermal_error_t thermal_events_init(struct thermal_handler *th);100 101LIBTHERMAL_API thermal_error_t thermal_events_handle(struct thermal_handler *th, void *arg);102 103LIBTHERMAL_API int thermal_events_fd(struct thermal_handler *th);104 105/*106 * Netlink thermal commands107 */108LIBTHERMAL_API thermal_error_t thermal_cmd_exit(struct thermal_handler *th);109 110LIBTHERMAL_API thermal_error_t thermal_cmd_init(struct thermal_handler *th);111 112LIBTHERMAL_API thermal_error_t thermal_cmd_get_tz(struct thermal_handler *th,113						  struct thermal_zone **tz);114 115LIBTHERMAL_API thermal_error_t thermal_cmd_get_cdev(struct thermal_handler *th,116						    struct thermal_cdev **tc);117 118LIBTHERMAL_API thermal_error_t thermal_cmd_get_trip(struct thermal_handler *th,119						    struct thermal_zone *tz);120 121LIBTHERMAL_API thermal_error_t thermal_cmd_get_governor(struct thermal_handler *th,122							struct thermal_zone *tz);123 124LIBTHERMAL_API thermal_error_t thermal_cmd_get_temp(struct thermal_handler *th,125						    struct thermal_zone *tz);126 127/*128 * Netlink thermal samples129 */130LIBTHERMAL_API thermal_error_t thermal_sampling_exit(struct thermal_handler *th);131 132LIBTHERMAL_API thermal_error_t thermal_sampling_init(struct thermal_handler *th);133 134LIBTHERMAL_API thermal_error_t thermal_sampling_handle(struct thermal_handler *th, void *arg);135 136LIBTHERMAL_API int thermal_sampling_fd(struct thermal_handler *th);137 138#endif /* __LIBTHERMAL_H */139 140#ifdef __cplusplus141}142#endif143