From: Yunhee Seo Date: Wed, 21 Feb 2024 06:26:13 +0000 (+0900) Subject: hal-common-interface: Add hal_common_get_backend_abi_version() X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fsandbox%2Fyunhee%2Fhal-api-foo;p=platform%2Fhal%2Fapi%2Fcommon.git hal-common-interface: Add hal_common_get_backend_abi_version() To get major/minor versions of the hal-backend, this function is added. Change-Id: I8e548aabdeb66c27304a3ea99c2853d30e600c63 Signed-off-by: Yunhee Seo --- diff --git a/include/hal-common-interface.h b/include/hal-common-interface.h index b14eb3a..7d97694 100644 --- a/include/hal-common-interface.h +++ b/include/hal-common-interface.h @@ -45,6 +45,8 @@ typedef struct __hal_backend { const unsigned int abi_version; int (*init) (void **data); int (*exit) (void *data); + const unsigned int major_version; + const unsigned int minor_version; } hal_backend; #ifdef __cplusplus diff --git a/include/hal-common.h b/include/hal-common.h index 0dc0452..9f52108 100644 --- a/include/hal-common.h +++ b/include/hal-common.h @@ -168,6 +168,13 @@ int hal_common_check_backend_abi_version(enum hal_module module, */ unsigned int hal_common_get_backend_abi_version(enum hal_module module); +/** + * @brief Get the backend HAL major/minor 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 + */ +int hal_common_get_backend_version(enum hal_module module, unsigned int *major_version, unsigned int *minor_version); + /** * @brief Get the backend name according to the type of HAL module * @param[in] HAL module id among enum hal_moudle diff --git a/src/hal-api-common.c b/src/hal-api-common.c index 6dc8c52..d8ee702 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -419,7 +419,8 @@ out: } static int __get_backend_data(enum hal_module module, unsigned int *abi_version, - char *name, int name_size, char *vendor, int vendor_size) + char *name, int name_size, char *vendor, int vendor_size, + unsigned int *major_version, unsigned int *minor_version) { struct __hal_module_info *info = NULL; int ret, len; @@ -474,6 +475,9 @@ static int __get_backend_data(enum hal_module module, unsigned int *abi_version, } strncpy(vendor, info->backend->vendor, vendor_size); + } else if (major_version && minor_version) { + *major_version = info->backend->major_version; + *minor_version = info->backend->minor_version; } else { _E("%s: Failed to get backend data\n", info->module_name); ret = -EINVAL; @@ -613,23 +617,29 @@ 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); + ret = __get_backend_data(module, &abi_version, NULL, 0, NULL, 0, NULL, NULL); if (ret < 0) return HAL_ABI_VERSION_UNKNOWN; return abi_version; } +EXPORT +int hal_common_get_backend_version(enum hal_module module, unsigned int *major_version, unsigned int *minor_version) +{ + return __get_backend_data(module, NULL, NULL, 0, NULL, 0, major_version, minor_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); + return __get_backend_data(module, NULL, name, size, NULL, 0, NULL ,NULL); } 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); + return __get_backend_data(module, NULL, NULL, 0, vendor, size, NULL, NULL); }