int hal_common_check_backend_abi_version(enum hal_module module,
enum hal_abi_version abi_version);
+/**
+ * @brief Get the backend HAL ABI version according to the type of HAL module
+ * @param[in] HAL module id among enum hal_moudle
+ * @return @c positive integer value on success, otherwise a zero error value
+ */
+unsigned int hal_common_get_backend_abi_version(enum hal_module module);
+
+/**
+ * @brief Get the backend name according to the type of HAL module
+ * @param[in] HAL module id among enum hal_moudle
+ * @param[out] Backend name of HAL module
+ * @param[in] Arrary size of name[]
+ * @return @c positive integer value on success, otherwise a zero error value
+ */
+int hal_common_get_backend_name(enum hal_module module, char *name, int size);
+
+/**
+ * @brief Get the backend vendor description according to the type of HAL module
+ * @param[in] HAL module id among enum hal_moudle
+ * @param[out] Backend vendor description of HAL module
+ * @param[in] Arrary size of vendor[]
+ * @return @c positive integer value on success, otherwise a zero error value
+ */
+int hal_common_get_backend_vendor(enum hal_module module, char *vendor, int size);
+
#ifdef __cplusplus
}
#endif
return ret;
}
+static int __get_backend_data(enum hal_module module, unsigned int *abi_version,
+ char *name, int name_size, char *vendor, int vendor_size)
+{
+ struct __hal_module_info *info = NULL;
+ int ret, len;
+
+ if (module <= HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) {
+ _E("Invalid parameter of HAL module (%d)\n", module);
+ return 0;
+ }
+
+ G_LOCK(hal_common_lock);
+
+ if (_hal_api_conf_init()) {
+ ret = HAL_ABI_VERSION_UNKNOWN;
+ goto err_unlock;
+ }
+
+ info = _hal_api_conf_get_module_info(module, NULL);
+ if (info == NULL) {
+ _E("Failed to get HAL module(%d) information\n", module);
+ ret = HAL_ABI_VERSION_UNKNOWN;
+ goto err_conf_exit;
+ }
+
+ ret = __open_backend(info);
+ if (ret < 0) {
+ _E("%s: Failed to get the backend library by dlopen\n",
+ info->module_name);
+ ret = TIZEN_ERROR_INVALID_PARAMETER;
+ goto err_conf_exit;
+ }
+
+ /* Return abi_verion of hal_backend structure */
+ if (!name_size && !vendor_size) {
+ *abi_version = info->backend->abi_version;
+
+ /* Return name of hal_backend structure */
+ } else if (info->backend->name && name_size && !vendor_size) {
+ len = strlen(info->backend->name);
+
+ if (!info->backend->name || (len + 1 > name_size)) {
+ _E("%s: Invalid size of name[] array\n", info->module_name);
+ ret = TIZEN_ERROR_INVALID_PARAMETER;
+ goto err_conf_exit;
+ }
+
+ strncpy(name, info->backend->name, len);
+ name[len] = '\0';
+
+ /* Return vendor of hal_backend structure */
+ } else if (info->backend->vendor && !name_size && vendor_size) {
+ len = strlen(info->backend->vendor);
+
+ if (!info->backend->vendor || (len + 1 > vendor_size)) {
+ _E("%s: Invalid size of vendor[] array\n", info->module_name);
+ ret = TIZEN_ERROR_INVALID_PARAMETER;
+ goto err_conf_exit;
+ }
+
+ strncpy(vendor, info->backend->vendor, len);
+ vendor[len] = '\0';
+ } else {
+ _E("%s: Failed to get backend data\n", info->module_name);
+ ret = TIZEN_ERROR_INVALID_PARAMETER;
+ goto err_conf_exit;
+ }
+ ret = TIZEN_ERROR_NONE;
+
+err_conf_exit:
+ _hal_api_conf_exit();
+err_unlock:
+ G_UNLOCK(hal_common_lock);
+ return ret;
+}
+
EXPORT
int hal_common_get_backend(enum hal_module module, void **data)
{
_hal_api_conf_exit();
return ret;
}
+
+EXPORT
+unsigned int hal_common_get_backend_abi_version(enum hal_module module)
+{
+ unsigned int abi_version;
+ int ret;
+
+ ret = __get_backend_data(module, &abi_version, NULL, 0, NULL, 0);
+ if (ret < 0)
+ return HAL_ABI_VERSION_UNKNOWN;
+
+ return abi_version;
+}
+
+EXPORT
+int hal_common_get_backend_name(enum hal_module module, char *name, int size)
+{
+ return __get_backend_data(module, NULL, name, size, NULL, 0);
+}
+
+EXPORT
+int hal_common_get_backend_vendor(enum hal_module module, char *vendor, int size)
+{
+ return __get_backend_data(module, NULL, NULL, 0, vendor, size);
+}