1 /*
2  * Copyright (c) 2016, The Linux Foundation. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  * *    * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above
10  *       copyright notice, this list of conditions and the following
11  *       disclaimer in the documentation and/or other materials provided
12  *       with the distribution.
13  *     * Neither the name of The Linux Foundation nor the names of its
14  *       contributors may be used to endorse or promote products derived
15  *       from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #include <cutils/properties.h>
31 #ifndef __THERMAL_CLIENT_H__
32 #define __THERMAL_CLIENT_H__
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define MAX_ACTIONS  (32)
39 
40 /* Enum for supported fields */
41 enum supported_fields {
42 	UNKNOWN_FIELD = 0x0,
43 	DISABLE_FIELD = 0x1,
44 	SAMPLING_FIELD = 0x2,
45 	THRESHOLDS_FIELD = 0x4,
46 	SET_POINT_FIELD = THRESHOLDS_FIELD,
47 	THRESHOLDS_CLR_FIELD = 0x8,
48 	SET_POINT_CLR_FIELD = THRESHOLDS_CLR_FIELD,
49 	ACTION_INFO_FIELD = 0x10,
50 	SUPPORTED_FIELD_MAX = 0x20,
51 };
52 
53 enum field_data_type {
54 	FIELD_INT = 0,
55 	FIELD_STR,
56 	FIELD_INT_ARR,
57 	FIELD_ARR_STR,
58 	FIELD_ARR_INT_ARR,
59 	FIELD_MAX
60 };
61 
62 struct action_info_data {
63 	int info[MAX_ACTIONS];
64 	uint32_t num_actions;
65 };
66 
67 struct field_data {
68 	char *field_name;
69 	enum field_data_type data_type;
70 	uint32_t num_data;
71 	void *data;
72 };
73 
74 struct config_instance {
75 	char *cfg_desc;
76 	char *algo_type;
77 	unsigned int fields_mask;  /* mask set by client to request to adjust supported fields */
78 	uint32_t num_fields;
79 	struct field_data *fields;
80 };
81 
82 int thermal_client_config_query(char *algo_type, struct config_instance **configs);
83 void thermal_client_config_cleanup(struct config_instance *configs, unsigned int config_size);
84 int thermal_client_config_set(struct config_instance *configs, unsigned int config_size);
85 
86 int thermal_client_register_callback(char *client_name, int (*callback)(int , void *, void *), void *data);
87 int thermal_client_request(char *client_name, int req_data);
88 void thermal_client_unregister_callback(int client_cb_handle);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /* __THERMAL_CLIENT_H__ */
95