hal-common-interface: Add hal_common_get_backend_abi_version() 30/308130/2
authorYunhee Seo <yuni.seo@samsung.com>
Wed, 21 Feb 2024 06:26:13 +0000 (15:26 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Tue, 19 Mar 2024 02:07:45 +0000 (11:07 +0900)
To apply HAL ABI Versioning, hal-backend major/minor version information is added.
Platform can decide whether to support hal-backend with major/minor version information.
To get major/minor versions from the hal-backend, this function is added.

int hal_common_get_backend_version(enum hal_module module, unsigned int *major_version, unsigned int *minor_version);
 - It obtains version information from hal-backend.

These variables are added to hal_backend structure.
 - const unsigned int major_version;
 - const unsigned int minor_version;

Change-Id: I8e548aabdeb66c27304a3ea99c2853d30e600c63
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
include/hal-common-interface.h
include/hal-common.h
src/hal-api-common.c

index 36fda8075d539575bd0ac0780a1cc8e45e03e334..1b31c69a8c75e4f64f6ced3731f89cb94aca0734 100644 (file)
@@ -47,6 +47,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
index f4dd4c48dd13466b1e422f54fe5e315356bdc618..b9e011d10fb8d8fbf5b1e85b1f7ac0ab5a82bb0a 100644 (file)
@@ -166,6 +166,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 0 on success, otherwise a negative 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
index 6dc8c52a241a31ac2b1b7b9fa6fc86d80a01ac75..d8ee7027af7b60d36fab1203144bebb6563057cf 100644 (file)
@@ -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);
 }