platform/hal/api/common.git
3 years agohalapi: Replace destructor with reference count method to free memory 93/253193/4
Chanwoo Choi [Thu, 4 Feb 2021 06:53:40 +0000 (15:53 +0900)]
halapi: Replace destructor with reference count method to free memory

Instead of destructor method to free the memory, use the reference count
method to free the memory in order to support multi-thread environment.

So that define the _hal_api_conf_(init|exit)() functions to control
the reference count. These functions either get the resources from hal-api.json
or put the resources according to the reference count.
- _hal_api_conf_init() increments the reference count
- _hal_api_conf_exit() decrements the reference count

hal_common_get_backend() and hal_common_put_backend() functions should
be called pairly in order to free the resources of hal-api.json.

[Detailed use-case of _hal_api_conf_init() and _hal_api_conf_ext()]
hal_common_get_backend()
_hal_api_conf_init()
/* codes */

hal_common_put_backend()
/* codes */
_hal_api_conf_exit()

hal_common_get_backend_library_name()
_hal_api_conf_init()
/* codes */
_hal_api_conf_exit()

hal_common_get_backend_symbol_name()
_hal_api_conf_init()
/* codes */
_hal_api_conf_exit()

hal_common_check_backend_abi_version()
_hal_api_conf_init()
/* codes */
_hal_api_conf_exit()

And change the prototype of hal_common_get_backend_library_name,
hal_common_get_backend_symbol_name as following:
- int hal_common_get_backend_library_name(enum hal_module module, char *name, int size);
- int hal_common_get_backend_symbol_name(enum hal_module module, char *name, int size);

Change-Id: If663b87244cc680d94568818d4358a7b91fb071e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agohalpai: Add support of reference count for hal_common_(get|put)_backend function 02/252802/4
Chanwoo Choi [Tue, 2 Feb 2021 10:09:58 +0000 (19:09 +0900)]
halpai: Add support of reference count for hal_common_(get|put)_backend function

Some HAL module need to call hal_common_(get|put)_backend() funcions at
multiple points at the same time. So that have to support this
requirement by using the reference count. When touching the reference
count, uses the mutex in order to keep the data integrity.

Change-Id: I2c3a662f21d1c56c7b5b077c7a3f155bf47fd792
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agounittest: Add testcase to check backend abi version 14/252814/6
Seungha Son [Tue, 2 Feb 2021 11:25:34 +0000 (20:25 +0900)]
unittest: Add testcase to check backend abi version

Change-Id: Ic740ea639e738dcbd8514497e0f02bd0e1080bd5
Signed-off-by: Seungha Son <seungha.son@samsung.com>
3 years agohalapi: Delete abi_version value of TELEPHONY 20/253020/1
Seungha Son [Thu, 4 Feb 2021 02:56:46 +0000 (11:56 +0900)]
halapi: Delete abi_version value of TELEPHONY

Change-Id: Ia0a132ac0b5fc29bdb1009c47b0f3de50bc1f649
Signed-off-by: Seungha Son <seungha.son@samsung.com>
3 years agohalapi: Change hal-api.json group format 33/252933/2
Seungha Son [Wed, 3 Feb 2021 07:04:38 +0000 (16:04 +0900)]
halapi: Change hal-api.json group format

 The structure of the json file was changed by adding
 a group value in the json file data. The logic for
 parsing group information according to file change
 has been modified.

Change-Id: I52d67da467ce2630714b4dbd75fcdb58631508c3
Signed-off-by: Seungha Son <seungha.son@samsung.com>
3 years agohalapi: Update error log for providing the more correct debugging info 94/252794/3
Chanwoo Choi [Tue, 2 Feb 2021 08:49:34 +0000 (17:49 +0900)]
halapi: Update error log for providing the more correct debugging info

Update error log for providing the more correct debugging info
without any behavior changes.

Change-Id: Icfc9f72fd971e970457e3dbb2d8bb5eb10a61743
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agohalapi: Add configuration feature 89/252389/7
Seungha Son [Tue, 12 Jan 2021 04:56:35 +0000 (13:56 +0900)]
halapi: Add configuration feature

 The purpose of this patch is to change the way
 hal-related information is managed.

 The information specified in the header file is
 changed to json format and can be changed at runtime.
 so that the information changed at runtime can be
 used without recompiling the library.

 A testcase to verify the saved json data was added and
 this testcase is ran at build time.

Change-Id: Ia9b83dfa18ea370ed4a3ce680c36a9f39317c6ff
Signed-off-by: Seungha Son <seungha.son@samsung.com>
3 years agohalapi: Fix cpp build issue when including hal-common.h 53/252753/2
Chanwoo Choi [Tue, 2 Feb 2021 06:46:54 +0000 (15:46 +0900)]
halapi: Fix cpp build issue when including hal-common.h

If the defined enum value is not sequential, some build error happen as
following. So that fix this issue by making enum hal_module sequential.

And remove the temporary defined HAL_MODULE_FOO.

[Build error message with cpp compiler]
"sorry, unimplemented: non-trivial designated initializers not supported "

Change-Id: I8dcd8c7c11807d8873d8e92413e4137ce84a3c6f
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agohalapi: Check enum range for backend_abi_min_version 73/252573/2 accepted/tizen/unified/20210202.143743 submit/tizen/20210201.032626
Seung-Woo Kim [Fri, 29 Jan 2021 10:27:56 +0000 (19:27 +0900)]
halapi: Check enum range for backend_abi_min_version

To avoid out-of-bounds access of version str array, check value
range for data->backend_abi_min_version always.

Change-Id: I3fb05ab9a27394f817937b589ce7751da0467a69
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agohalapi: Ignore already fully put hal backend 60/252560/2 accepted/tizen/unified/20210201.055404 submit/tizen/20210129.082040
Seung-Woo Kim [Fri, 29 Jan 2021 07:52:35 +0000 (16:52 +0900)]
halapi: Ignore already fully put hal backend

In hal_common_put_backend(), requested module backend can be
already put fully. For the case, ignore the hal backend.

Change-Id: I7eef57fa12273760d28b22738ee878ac423da651
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agohalapi: fix wrong module's number about CODEC 25/252325/2 accepted/tizen/unified/20210127.144826 submit/tizen/20210127.011131
Jaehoon Chung [Wed, 27 Jan 2021 00:27:40 +0000 (09:27 +0900)]
halapi: fix wrong module's number about CODEC

Fix wrong module's number about CODEC.
It's not HAL_MODULE_UNKNOWN.

Change-Id: I9cdc3d58ee2feb3bf5137d973972033741c8e352
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agohalapi: Fix pkgconfig .pc file about libdir 28/251928/2 accepted/tizen/unified/20210121.134559 submit/tizen/20210121.041820
Chang Joo Lee [Thu, 21 Jan 2021 04:11:18 +0000 (13:11 +0900)]
halapi: Fix pkgconfig .pc file about libdir

The commit e4c687e484e1 ("packaging: Remove redundant separator") has
missed the update of .pc file. This patch fix the wrong path issue.

Change-Id: I26847c506dcd801030ed616822fccca8595f97ef
Fixes: e4c687e484e1 ("packaging: Remove redundant separator")
Signed-off-by: Chang Joo Lee <changjoo.lee@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopackaging: Remove redundant separator 62/251862/1
Chanwoo Choi [Wed, 20 Jan 2021 04:42:47 +0000 (13:42 +0900)]
packaging: Remove redundant separator

The spec file has passed the redundant separator ('/') with %{_libdir}.
It is not needed. So that remove it.

Change-Id: I531f6a6449e6ab3defec82bb4383ecc22045dc20
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agopackaging: create hal directory to use backend packages 40/251840/1 accepted/tizen/unified/20210120.120800 submit/tizen/20210120.012527
Jaehoon Chung [Wed, 20 Jan 2021 00:42:28 +0000 (09:42 +0900)]
packaging: create hal directory to use backend packages

If hal.img will be split from core image, it has to exist hal directory
under root directory before mounting hal.img.
Otherwise, it can't mount anywhere to use hal-backend.
This patch is for preparing to use hal.img.
- The mounting hal.img will be did in ramdisk.

Change-Id: I8ef56c0e383e142269c4164d7cfeba9560fbb039
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agohalapi: Add /etc/ld.so.conf.d/libhal-api.conf 07/251707/5 accepted/tizen/unified/20210119.130216 submit/tizen/20210119.020839
INSUN PYO [Tue, 19 Jan 2021 00:35:10 +0000 (09:35 +0900)]
halapi: Add /etc/ld.so.conf.d/libhal-api.conf

A ldd and ldconfig commands do not work.

Example1) "ldd /usr/bin/deviced | grep libhal-api-common"
Example2) "ldconfig -p | grep libhal-api-common"

Change-Id: I42d0ece00df2ebd4ef36e4f215140a31204397b0
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
3 years agohalapi: Fix fault by using backend instance before dlclose backend library 84/251684/2 submit/tizen/20210119.012202
Chanwoo Choi [Mon, 18 Jan 2021 10:48:06 +0000 (19:48 +0900)]
halapi: Fix fault by using backend instance before dlclose backend library

When try to use backend->name, backend->vendor variables
after dlclose(handle) of HAL backend shared library, segmentation fault happen.
So that move dlclose(hanlde) at the end of hal_common_put_backend() to
fix the segmentation fault.

Change-Id: Icc89e26b0ff11706657f1bfdeff16eba17f255d9
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agohalapi: Include stdbool header for common.h 04/251504/3
Seungha Son [Thu, 14 Jan 2021 09:57:06 +0000 (18:57 +0900)]
halapi: Include stdbool header for common.h

 The stdbool.h file is required to use the bool data type.

Change-Id: I0cc08f2a0229bfb64ddbcf46c1cd69da1a183c82
Signed-off-by: Seungha Son <seungha.son@samsung.com>
3 years agoAdd hal-api-common uniitest skeleton 14/251114/6 accepted/tizen/unified/20210113.121021 submit/tizen/20210113.011459
Seungha Son [Fri, 8 Jan 2021 07:52:23 +0000 (16:52 +0900)]
Add hal-api-common uniitest skeleton

 This test will run automatically when building gbs.
 The result can be checked by the developer and
 the side effect of the edited content can be checked.

 it is a test for the currently implemented operation,
 and a test for applying TDD in the future.

Change-Id: I5af141dbb601524ff517b78e7cc970323ed138fc
Signed-off-by: Seungha Son <linuxias@gmail.com>
3 years agoFix wrong spelling 02/251302/1
Seungha Son [Tue, 12 Jan 2021 08:52:23 +0000 (17:52 +0900)]
Fix wrong spelling

 HAL_MODULE_TELPEPHONY -> HAL_MODULE_TELEPHONY

Change-Id: Ie3b77e9b3839de8306e2c49e10bdeb4b3fe91744
Signed-off-by: Seungha Son <linuxias@gmail.com>
3 years agohalapi: common: Change variable name for improving the readability 85/251185/3 accepted/tizen/unified/20210111.125423 submit/tizen/20210111.072925
Chanwoo Choi [Mon, 11 Jan 2021 06:00:55 +0000 (15:00 +0900)]
halapi: common: Change variable name for improving the readability

Change the variable name for improving the readability
because prior defined variable name is vague to pass
the correct meaning of version. So that change the name as following
in order to improve the readability and understanding.

[Chagned variable names]
- g_curr_hal_abi_version -> g_platform_curr_abi_version
- current_version -> platform_abi_version
- compat_version -> backend_min_abi_version

Change-Id: I733b203a6c0fe058dedb6e9e26f832a0629ccc15
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agohalapi: common: Add hal_api_version_str array and an error message 64/251164/3
Jaehoon Chung [Sun, 10 Jan 2021 23:03:47 +0000 (08:03 +0900)]
halapi: common: Add hal_api_version_str array and an error message

Add hal_api_version_str array to display as string after converting each
enum value.
It's easier to understand than using enum value.
If abi version doesn't support about current version and compatible version,
then it needs to notice about not supporting abi_version.

Change-Id: I67f31423a4b9d911b269d8c7560c9907a6bafc8b
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agohalapi: common: Change the parameter name of helper functions for readability 91/251091/2 accepted/tizen/unified/20210108.125849 submit/tizen/20210108.044006
Chanwoo Choi [Fri, 8 Jan 2021 03:46:15 +0000 (12:46 +0900)]
halapi: common: Change the parameter name of helper functions for readability

hal-api-common's helper functions have the 'enum hal_module' as first
parameter. In order to improve the readability, replace parameter name
from 'handle' to 'module'.

Change-Id: I3baa384885d9e5225987f143d4b1951c4b6aedd6
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agohalapi: common: Fix bug by using the module parameter 89/251089/1
Chanwoo Choi [Fri, 8 Jan 2021 03:30:03 +0000 (12:30 +0900)]
halapi: common: Fix bug by using the module parameter

hal-api-common helper functions have been used the fixed hal module id
such as HAL_MODULE_FOO. It is wrong usage. hal-api-common helper
functions have to use the 'module' parameter.

Change-Id: Ifa27e0e4df3c5b89ce96511802ef5a008cf2a279
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agohalapi: common: Change return type of hal_common_put_backend and backend->exit 34/251034/1 accepted/tizen/unified/20210107.123346 submit/tizen/20210107.062142
Chanwoo Choi [Thu, 7 Jan 2021 05:35:40 +0000 (14:35 +0900)]
halapi: common: Change return type of hal_common_put_backend and backend->exit

Change the return type of hal_common_put_backend() and backend->exit()
from void to int in order to pass the error value.

Change-Id: I155a33e469511319303bd56d3866d3bbfbec786c
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agohalapi: common: Add hal_common_(get|put)_backend() function to handle backend data 61/250461/4 accepted/tizen/unified/20210104.130218 submit/tizen/20210104.043912
Chanwoo Choi [Mon, 28 Dec 2020 04:43:47 +0000 (13:43 +0900)]
halapi: common: Add hal_common_(get|put)_backend() function to handle backend data

Following step is for getting the backend data which contains the
function pointers for each HAL module.
1. get library name of HAL backend
2. dlopen with library name
3. get symbol name of HAL backend
4. dlsym with symbol name
5. Get the backend data via backend->init()

In order to reduce the duplicate code on each HAL API packages,
add hal_common_get_backend() helper function which contains
the above steps to get the backend data.

And add hal_common_put_backend() helper function to free
the hal_backend instance and dlclose the shared library.

Change-Id: Ic603d3e4f0ba1ff2aed9699b1eaf925cbd97c60c
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agohalapi: common: Divide hal-common.h into two header files 62/250462/4
Chanwoo Choi [Mon, 28 Dec 2020 04:50:34 +0000 (13:50 +0900)]
halapi: common: Divide hal-common.h into two header files

Divide hal-common.h into two header files as following:
- hal-common.h is used for HAL API packages (/platform/hal/api/)
- hal-common-interface.h is used for HAL backend packages (/platform/hal/device/)

Change-Id: Ida3192ed4dbb29d9b718b2b90f3a61f8ed380e2e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agohalapi: common: Add library and symbol name for hal-api-device 85/250485/2
Chanwoo Choi [Mon, 28 Dec 2020 07:21:36 +0000 (16:21 +0900)]
halapi: common: Add library and symbol name for hal-api-device

Change-Id: I83f661c30b1e2dcb763c9956804d03db57e3aa46
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agoAdd support hal-api-common library to check HAL ABI and support of haltest 65/250165/14
Chanwoo Choi [Fri, 18 Dec 2020 04:20:37 +0000 (13:20 +0900)]
Add support hal-api-common library to check HAL ABI and support of haltest

Need to provide the helper function of HAL ABI version check
in order to support HAL API layer on Tizen 6.5. By supporing
the ABI check method, Tizen can separate the hal.img from core image
and then we can remove the h/w dependency from Tizen core image.

hal-api-common-*.rpm contains the shared library providing the helper
function of the HAL ABI version check and the HAL ABI data of all
modules. If some module changes the their owr HAL ABI interface,
they must update the ABI information to /platform/hal/api/common.
It contains the following files:
- /usr/lib/hal/libhal-api-common.so
- /usr/share/licenses/hal-api-common/LICENSE

hal-api-common-devel-*.rpm contains the header file for including
the helper function of HAL ABI version check.
It contains the following files:
- /usr/include/hal/hal-common.h
- /usr/lib/pkgconfig/hal-api-common.pc

But, this patch is not enough. Usually, the configuraiton data
like HAL ABI version information should get the file like xml, json
style format file and so on. But, it just specify the HAL ABI versin
information of all modules in the src/common.h as workardound style.
It must need to be fixed on later. And this version doesn't include
the any haltest code even if it is necessary. Also on later,
The role of common-haltest make the pre-considition environment
for all haltests and then execute the haltest file to verify
the hal.img and the implementation of HAL backend pacakges.

For example, show the relationship among hal-api-foo, hal-backend-foo
and hal-api-common as following:

-----------------------------------
| 'User of hal-api-foo'           |
|   executes C HAl API.           |
-----------------------------------
    |
    | (Call HAL API)
    |
-----------------------------------
| /usr/include/hal-foo.h          |
|                                 |
|                                 |       ----------------------------------
| hal-api-foo.rpm                 | <---> | (Check HAL ABI Version)        |
| (/usr/lib/libhal-api-foo.so)    |       |                                |
|                                 |       | hal-api-common.rpm             |
|                                 |       | (/usr/lib/libhal-api-common.so)|
| /usr/include/hal-foo-interface.h|       ----------------------------------
----------------------------------|
    |
    | dlopen ("/hal/lib/libhal-backend-foo.so")
    | dlsym ("hal_backend_foo_daa")
    |
-----------------------------------
| hal-backend-foo-rpi4.rpm        |
| (/hal/lib/libhal-backend-foo.so)|
-----------------------------------

Change-Id: Ifb4b10e94c419517882794cc101bfcd598570335
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agoInitial empty repository master
Tizen Infrastructure [Fri, 18 Dec 2020 00:45:59 +0000 (00:45 +0000)]
Initial empty repository