lshal: Print backend transport information 89/321389/11 accepted/tizen/unified/20250428.091720 accepted/tizen/unified/x/20250429.081837
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 20 Mar 2025 04:19:19 +0000 (13:19 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Fri, 11 Apr 2025 07:42:25 +0000 (16:42 +0900)
To show backend transport information, added function
hal_common_get_backend_transport(). The function has been exported to
be accessed by lshal, but not included in hal-common.h. It was becase
for users might confuse it with hal_common_get_transport() and might
lead to incorrect usage.

Change-Id: I625ca465d6f62740642c8836e23527a29ad35073
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/hal-api-common.c
src/hal-api-compatibility-checker.c
src/hal-api-compatibility-checker.h
tools/lshal/lshal.c

index ff118658b6fce23e318ce0fe9d813e7d902436b6..43f3419d5deb5077a12faf1d76c47d8def4dad92 100644 (file)
@@ -809,3 +809,20 @@ int hal_common_get_stub_proc_name(enum hal_module module, const char **stub_proc
 {
        return hal_api_backend_service_get_stub_proc_name(module, stub_proc_name);
 }
+
+EXPORT
+int hal_common_get_backend_transport(enum hal_module module,
+       enum hal_common_transport *backend_transport)
+{
+       /**
+        * If you get to here searching for backend transport, you can use this function.
+        * But before using it, you should exactly know about difference between platform
+        * transport and backend transport. And you need to distinguish the difference of
+        * hal_common_get_transport() and hal_common_get_backend_transport(). If you don't,
+        * we discourage to use it.
+        *
+        * We exported the function but didn't include it in the header out of concern
+        * that such subtle differences in behavior might lead to incorrect usage.
+        */
+       return hal_api_cc_get_backend_transport(module, backend_transport);
+}
\ No newline at end of file
index 0a51d2a93577b83d6b1b1f9f8d94c1921e3f0348..d904a0a270559d585220b790100a0f12eb2fee53 100644 (file)
@@ -676,3 +676,24 @@ int hal_api_cc_get_transport(enum hal_module module, enum hal_common_transport *
 
        return 0;
 }
+
+int hal_api_cc_get_backend_transport(enum hal_module module,
+       enum hal_common_transport *backend_transport)
+{
+       int ret;
+       struct compatibility_info info = { 0 , };
+
+       if (!backend_transport)
+               return -EINVAL;
+
+       ret = load_module_compatibility_info(module, &info);
+       if (ret < 0) {
+               ret = load_module_compatibility_info_fallback(module, &info, false);
+               if (ret < 0)
+                       return ret;
+       }
+
+       *backend_transport = info.backend_transport;
+
+       return 0;
+}
index ba6b70c3cade2bc7c5c2cd275a1031420fc44172..0033efd6d9ce30879b5b48b4fee434dad7921d60 100644 (file)
@@ -33,6 +33,8 @@ int hal_api_cc_get_supported_interface_versions(enum hal_module module,
        uint32_t **transports, enum hal_common_transport **default_transport,
        int *num_versions);
 int hal_api_cc_get_transport(enum hal_module module, enum hal_common_transport *transport);
+int hal_api_cc_get_backend_transport(enum hal_module module,
+       enum hal_common_transport *backend_transport);
 
 #ifdef HAL_API_COMMON_UNITTEST /* For test use only */
 void hal_api_cc_set_compatibility_result_path(const char *path);
index 5b6953daaed487df3515910c7a80c11d762594b4..d8f999ec35f945e86c1a39c98d0849c90a0ddaee 100644 (file)
@@ -55,6 +55,9 @@ struct _hal_backend_module_data {
        void *unused_buffer[10000];
 } *backend_module_data;
 
+extern int hal_common_get_backend_transport(enum hal_module module,
+       enum hal_common_transport *backend_transport);
+
 static void lshal_print_border(void) {
        for (int i = 0; i < 287; i++)
                printf("-");
@@ -67,7 +70,7 @@ static void lshal_print_hal_backend_info(u_int32_t flags) {
        char str[BUFF_MAX];
 
        lshal_print_border();
-       printf(" %-38s |    | %-55s | %-10s | %-45s | %-25s | %-25s | %-25s | %-15s | %-15s |\n",
+       printf(" %-38s |    | %-55s | %-10s | %-45s | %-25s | %-25s | %-25s | %-20s | %-15s |\n",
                        "",
                        "",
                        "Backend",
@@ -78,7 +81,7 @@ static void lshal_print_hal_backend_info(u_int32_t flags) {
                        "Backend",
                        "");
 
-       printf(" %-38s | ID | %-55s | %-10s | %-45s | %-25s | %-25s | %-25s | %-15s | %-15s |\n",
+       printf(" %-38s | ID | %-55s | %-10s | %-45s | %-25s | %-25s | %-25s | %-20s | %-15s |\n",
                        "HAL Module Name",
                        "Backend Library Name",
                        "Open Count",
@@ -86,7 +89,7 @@ static void lshal_print_hal_backend_info(u_int32_t flags) {
                        "(Written by Developer)",
                        "(Written by Developer)",
                        "Versions(Transport)",
-                       "Version",
+                       "Version(Transport)",
                        "Compatibility");
        lshal_print_border();
 
@@ -206,12 +209,18 @@ static void lshal_print_hal_backend_info(u_int32_t flags) {
 
                        ret = hal_common_get_backend_version(module, &major, &minor);
                        if (ret < 0) {
-                               printf(" %-15s |", "");
+                               printf(" %-20s |", "");
                        } else if (major == 0 && minor == 0) {
-                               printf(" %-15s |", "");
+                               printf(" %-20s |", "");
                        } else {
-                               snprintf(str, BUFF_MAX - 1, "%u.%u", major, minor);
-                               printf(" %-15s |", str);
+                               enum hal_common_transport backend_transport
+                                       = HAL_COMMON_TRANSPORT_UNKNOWN;
+                               hal_common_get_backend_transport(module, &backend_transport);
+                               snprintf(str, BUFF_MAX - 1, "%u.%u%s", major, minor,
+                                       (backend_transport == HAL_COMMON_TRANSPORT_IPC) ? "(ipc)"
+                                       : (backend_transport == HAL_COMMON_TRANSPORT_PASSTHROUGH) ? "(passthrough)"
+                                       : "");
+                               printf(" %-20s |", str);
                        }
                }
 
@@ -235,7 +244,7 @@ static void lshal_print_hal_backend_info(u_int32_t flags) {
        }
 
        lshal_print_border();
-       printf(" %-38s | %-2d | %-55s | %-10s | %-45s | %-25s | %-25s | %-25s | %-15s | %-15s |\n",
+       printf(" %-38s | %-2d | %-55s | %-10s | %-45s | %-25s | %-25s | %-25s | %-20s | %-15s |\n",
                        "TOTAL",
                        HAL_MODULE_END - 1,
                        "",