halapi: Add new hal_common_get_backend_module_name function
[platform/hal/api/common.git] / include / hal-common.h
1 /*
2  * HAL (Hardware Abstract Layer) Common API
3  *
4  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __HAL_COMMON__
20 #define __HAL_COMMON__
21
22 #include "hal-common-interface.h"
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 enum hal_module {
29         HAL_MODULE_UNKNOWN = 0,
30
31         /* HAL_GROUP_GRAPHICS */
32         HAL_MODULE_TBM,
33         HAL_MODULE_TDM,
34         HAL_MODULE_COREGL,
35         HAL_MODULE_INPUT,
36
37         /* HAL_GROUP_MULTIMEDIA */
38         HAL_MODULE_AUDIO,
39         HAL_MODULE_CAMERA,
40         HAL_MODULE_RADIO,
41         HAL_MODULE_CODEC,
42         HAL_MODULE_USB_AUDIO,
43         HAL_MODULE_ALSAUCM,
44
45         /* HAL_GROUP_CONNECTIVITY */
46         HAL_MODULE_BLUETOOTH,
47         HAL_MODULE_WIFI,
48         HAL_MODULE_NAN,
49         HAL_MODULE_NFC,
50         HAL_MODULE_ZIGBEE,
51         HAL_MODULE_UWB,
52         HAL_MODULE_MTP,
53
54         /* HAL_GROUP_TELEPHONY */
55         HAL_MODULE_TELEPHONY,
56
57         /* HAL_GROUP_LOCATION */
58         HAL_MODULE_LOCATION,
59
60         /* HAL_GROUP_SYSTEM */
61         HAL_MODULE_COMMON,
62         HAL_MODULE_POWER,
63         HAL_MODULE_SENSOR,
64         HAL_MODULE_PERIPHERAL,
65         HAL_MODULE_DEVICE_BATTERY,
66         HAL_MODULE_DEVICE_BEZEL,
67         HAL_MODULE_DEVICE_DISPLAY,
68         HAL_MODULE_DEVICE_IR,
69         HAL_MODULE_DEVICE_TOUCHSCREEN,
70         HAL_MODULE_DEVICE_LED,
71         HAL_MODULE_DEVICE_BOARD,
72         HAL_MODULE_DEVICE_EXTERNAL_CONNECTION,
73         HAL_MODULE_DEVICE_THERMAL,
74         HAL_MODULE_DEVICE_USB_GADGET,
75         HAL_MODULE_DEVICE_HAPTIC,
76         HAL_MODULE_DEVICE_MEMORY,
77         HAL_MODULE_DEVICE_INPUT,
78         HAL_MODULE_DEVICE_POWER,
79
80         /*
81          * TODO: If need to add new module, have to add it below
82          * without modifying already defined module id.
83          */
84
85         HAL_MODULE_END,
86 };
87
88 /**
89  * @brief Get the backend library name according to the type of HAL module
90  * @param[in] HAL module id among enum hal_moudle
91  * @param[out] Backend Library name of HAL module
92  * @param[in] Arrary size of name[]
93  * @return @c 0 on success, otherwise a negative error value
94  */
95 int hal_common_get_backend_library_name(enum hal_module module, char *name, int size);
96
97 /**
98  * @brief Get the backend symbol name according to the type of HAL module
99  * @param[in] HAL module id among enum hal_moudle
100  * @param[out] Backend symbol name of HAL module
101  * @param[in] Arrary size of name[]
102  * @return @c 0 on success, otherwise a negative error value
103  */
104 int hal_common_get_backend_symbol_name(enum hal_module module, char *name, int size);
105
106 /**
107  * @brief Get the backend module name according to the type of HAL module
108  * @param[in] HAL module id among enum hal_moudle
109  * @param[out] Backend module name of HAL module
110  * @param[in] Arrary size of name[]
111  * @return @c 0 on success, otherwise a negative error value
112  */
113 int hal_common_get_backend_module_name(enum hal_module module, char *name, int size);
114
115 /**
116  * @brief Get the backend data according to the type of HAL module
117  * @param[in] HAL module id among enum hal_moudle
118  * @param[out] Data pointer where 'hal_backend_[module]_funcs' instance
119  *             should be stored from HAL backend binary.
120  * @return @c 0 on success, otherwise a negative error value
121  */
122 int hal_common_get_backend(enum hal_module module, void **data);
123
124 /**
125  * @brief Put the backend data according to the type of HAL module
126  * @param[in] HAL module id among enum hal_moudle
127  * @param[in] Data pointer where 'hal_backend_[module]_funcs' instance
128  * @return @c 0 on success, otherwise a negative error value
129  */
130 int hal_common_put_backend(enum hal_module module, void *data);
131
132 /**
133  * @brief Get the backend data with the specific library name according to the type of HAL module
134  * @param[in] HAL module id among enum hal_moudle
135  * @param[out] Data pointer where 'hal_backend_[module]_funcs' instance
136  *             should be stored from HAL backend binary.
137  * @param[in] HAL backend library name which is not default library name
138  * @return @c 0 on success, otherwise a negative error value
139  */
140 int hal_common_get_backend_with_library_name(enum hal_module module,
141                                         void **data, const char *library_name);
142
143 /**
144  * @brief Put the backend data with the specific library name according to the type of HAL module
145  * @param[in] HAL module id among enum hal_moudle
146  * @param[in] Data pointer where 'hal_backend_[module]_funcs' instance
147  * @param[in] HAL backend library name which is not default library name
148  * @return @c 0 on success, otherwise a negative error value
149  */
150 int hal_common_put_backend_with_library_name(enum hal_module module,
151                                         void *data, const char *library_name);
152
153 /**
154  * @brief Check HAL ABI version whehter is suppored or not on current platform
155  * @param[in] HAL module id among enum hal_moudle
156  * @param[in] HAL ABI version of backend module among enum hal_abi_version
157  * @return @c 0 on success, otherwise a negative error value
158  */
159 int hal_common_check_backend_abi_version(enum hal_module module,
160                                         enum hal_abi_version abi_version);
161
162 /**
163  * @brief Get the backend HAL ABI version according to the type of HAL module
164  * @param[in] HAL module id among enum hal_moudle
165  * @return @c positive integer value on success, otherwise a zero error value
166  */
167 unsigned int hal_common_get_backend_abi_version(enum hal_module module);
168
169 /**
170  * @brief Get the backend name according to the type of HAL module
171  * @param[in] HAL module id among enum hal_moudle
172  * @param[out] Backend name of HAL module
173  * @param[in] Arrary size of name[]
174  * @return @c positive integer value on success, otherwise a zero error value
175  */
176 int hal_common_get_backend_name(enum hal_module module, char *name, int size);
177
178 /**
179  * @brief Get the backend vendor description according to the type of HAL module
180  * @param[in] HAL module id among enum hal_moudle
181  * @param[out] Backend vendor description of HAL module
182  * @param[in] Arrary size of vendor[]
183  * @return @c positive integer value on success, otherwise a zero error value
184  */
185 int hal_common_get_backend_vendor(enum hal_module module, char *vendor, int size);
186
187 /**
188  * @brief Get the number of the backend libraries according to the type of HAL module
189  * @param[in] HAL module id among enum hal_moudle
190  * @return @c 0 on success, otherwise a negative error value
191  */
192 int hal_common_get_backend_count(enum hal_module module);
193
194 /**
195  * @brief Get the backend library names according to the type of HAL module
196  * @param[in] HAL module id among enum hal_moudle
197  * @param[out] Data pointer should be filled by backend library names
198  * @param[in] Number of backend library of specific HAL module
199  * @param[in] Maximum length of the library name
200  * @return @c 0 on success, otherwise a negative error value
201  */
202 int hal_common_get_backend_library_names(enum hal_module module,
203                                         char **library_names,
204                                         int library_count,
205                                         int library_name_size);
206
207 #ifdef __cplusplus
208 }
209 #endif
210 #endif /* __HAL_COMMON__ */