1 /**************************************************************************
5 Copyright 2012-2021 Samsung Electronics co., Ltd. All Rights Reserved.
7 Contact: SooChan Lim <sc1.lim@samsung.com>
8 Changyeon Lee <cyeon.lee@samsung.com>
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 **************************************************************************/
34 #include "tbm_bufmgr_int.h"
35 #include "tbm_bufmgr_backend.h"
36 #include "tbm_drm_helper.h"
38 #define PREFIX_LIB "libtbm_"
39 #define SUFFIX_LIB ".so"
40 #define DEFAULT_LIB PREFIX_LIB"default"SUFFIX_LIB
42 /* values to indicate unspecified fields in XF86ModReqInfo. */
43 #define MAJOR_UNSPEC 0xFF
44 #define MINOR_UNSPEC 0xFF
45 #define PATCH_UNSPEC 0xFFFF
46 #define ABI_VERS_UNSPEC 0xFFFFFFFF
48 #define MODULE_VERSION_NUMERIC(maj, min, patch) \
49 ((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | (patch & 0xFFFF))
50 #define GET_MODULE_MAJOR_VERSION(vers) (((vers) >> 24) & 0xFF)
51 #define GET_MODULE_MINOR_VERSION(vers) (((vers) >> 16) & 0xFF)
52 #define GET_MODULE_PATCHLEVEL(vers) ((vers) & 0xFFFF)
56 _tbm_backend_load_hal_tbm(tbm_module *module)
58 hal_tbm_backend *hal_backend = NULL;
59 hal_tbm_bufmgr *hal_bufmgr;
60 hal_tbm_error ret = HAL_TBM_ERROR_NONE;
61 hal_tbm_fd auth_drm_fd = -1;
63 hal_backend = hal_tbm_get_backend(&ret);
64 if (hal_backend == NULL || ret != HAL_TBM_ERROR_NONE) {
65 TBM_ERR("get backend fail");
69 hal_bufmgr = hal_tbm_backend_get_bufmgr(hal_backend, &ret);
70 if (hal_bufmgr == NULL || ret != HAL_TBM_ERROR_NONE) {
71 TBM_ERR("get hal_bufmgr fail");
72 goto get_backend_fail;
75 if (hal_tbm_backend_has_drm_device(hal_backend, &ret)) {
76 auth_drm_fd = hal_tbm_backend_get_master_drm_fd(hal_backend, &ret);
77 if (auth_drm_fd < 0) {
78 TBM_INFO("tbm_backend has no master drm_fd.");
80 auth_drm_fd = tbm_drm_helper_get_master_fd();
81 if (auth_drm_fd < 0) {
82 TBM_INFO("libtbm requests an authenticated drm_fd to a process(display server).");
83 if (!tbm_drm_helper_get_auth_info(&auth_drm_fd, NULL, NULL)) {
84 TBM_ERR("get auth drm_fd fail");
85 goto get_backend_fail;
88 TBM_INFO("libtbm gets a master drm_fd from libtdm via tbm_drm_helper.");
91 TBM_INFO("libtbm sends a master drm_fd as an authentiated drm_fd to tbm_backend.");
92 ret = hal_tbm_backend_set_authenticated_drm_fd(hal_backend, auth_drm_fd);
93 if (ret != HAL_TBM_ERROR_NONE) {
94 TBM_ERR("hal_tbm_backend_set_authenticated_drm_fd failed.");
95 goto get_backend_fail;
98 TBM_INFO("tbm_backend has a master drm_fd.");
100 tbm_drm_helper_set_tbm_master_fd(auth_drm_fd);
102 tbm_drm_helper_set_fd(auth_drm_fd);
105 module->hal_backend = hal_backend;
106 module->hal_bufmgr = hal_bufmgr;
108 module->use_hal_tbm = 1;
110 TBM_INFO("use HAL-TBM_API");
115 if (auth_drm_fd >= 0)
117 hal_tbm_put_backend(hal_backend);
122 _check_version(TBMModuleVersionInfo *data)
124 int backend_module_major, backend_module_minor;
125 int tbm_backend_major, tbm_backend_minor;
127 backend_module_major = GET_ABI_MAJOR(data->abiversion);
128 backend_module_minor = GET_ABI_MINOR(data->abiversion);
130 TBM_DBG("TBM module %s: vendor=\"%s\" ABI=%d,%d\n",
131 data->modname ? data->modname : "UNKNOWN!",
132 data->vendor ? data->vendor : "UNKNOWN!", backend_module_major, backend_module_minor);
134 tbm_backend_major = GET_ABI_MAJOR(TBM_ABI_VERSION);
135 tbm_backend_minor = GET_ABI_MINOR(TBM_ABI_VERSION);
137 TBM_DBG("TBM ABI version %d.%d\n",
138 tbm_backend_major, tbm_backend_minor);
140 if (backend_module_major != tbm_backend_major) {
141 TBM_ERR("TBM module ABI major ver(%d) doesn't match the TBM's ver(%d)\n",
142 backend_module_major, tbm_backend_major);
144 } else if (backend_module_minor > tbm_backend_minor) {
145 TBM_ERR("TBM module ABI minor ver(%d) is newer than the TBM's ver(%d)\n",
146 backend_module_minor, tbm_backend_minor);
154 _tbm_backend_check_bufmgr_func(tbm_backend_bufmgr_func *bufmgr_func)
156 TBM_RETURN_VAL_IF_FAIL(bufmgr_func, 0); /* mandatory symbol */
157 TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_get_capabilities, 0); /* mandatory symbol */
158 TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_bind_native_display, 0); /* mandatory symbol */
159 TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_get_supported_formats, 0); /* mandatory symbol */
160 TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_get_plane_data, 0); /* mandatory symbol */
161 TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_alloc_bo, 0); /* mandatory symbol */
162 if (!bufmgr_func->bufmgr_alloc_bo_with_format)
163 TBM_DBG("No bufmgr_func->bufmgr_alloc_bo_with_format.");
164 TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_import_fd, 0); /* mandatory symbol */
165 if (!bufmgr_func->bufmgr_import_key)
166 TBM_DBG("No bufmgr_func->bo_export_key.");
172 _tbm_backend_check_bufmgr_bo(tbm_backend_bo_func *bo_func)
174 TBM_RETURN_VAL_IF_FAIL(bo_func, 0); /* mandatory symbol */
175 TBM_RETURN_VAL_IF_FAIL(bo_func->bo_free, 0); /* mandatory symbol */
176 TBM_RETURN_VAL_IF_FAIL(bo_func->bo_get_size, 0); /* mandatory symbol */
177 TBM_RETURN_VAL_IF_FAIL(bo_func->bo_get_memory_types, 0); /* mandatory symbol */
178 TBM_RETURN_VAL_IF_FAIL(bo_func->bo_get_handle, 0); /* mandatory symbol */
179 TBM_RETURN_VAL_IF_FAIL(bo_func->bo_map, 0); /* mandatory symbol */
180 TBM_RETURN_VAL_IF_FAIL(bo_func->bo_unmap, 0); /* mandatory symbol */
181 if (!bo_func->bo_lock)
182 TBM_DBG("No bo_func->bo_lock.");
183 if (!bo_func->bo_unlock)
184 TBM_DBG("No bo_func->bo_unlock.");
185 TBM_RETURN_VAL_IF_FAIL(bo_func->bo_export_fd, 0); /* mandatory symbol */
186 if (!bo_func->bo_export_key)
187 TBM_INFO("No bo_func->bo_export_key.");
193 _tbm_backend_load_module(tbm_module *module, const char *file)
195 char path[PATH_MAX] = {0, };
196 void *module_data = NULL;
197 tbm_backend_module *backend_module_data = NULL;
198 tbm_backend_bufmgr_data *bufmgr_data = NULL;
199 int backend_module_major, backend_module_minor;
200 int tbm_backend_major, tbm_backend_minor;
203 snprintf(path, sizeof(path), BUFMGR_MODULE_DIR "/%s", file);
205 module_data = dlopen(path, RTLD_LAZY);
207 TBM_ERR("failed to load module: %s(%s)\n", dlerror(), file);
211 backend_module_data = dlsym(module_data, "tbm_backend_module_data");
212 if (!backend_module_data) {
213 TBM_ERR("Error: module does not have data object.\n");
217 tbm_backend_major = GET_ABI_MAJOR(TBM_BACKEND_ABI_LATEST_VERSION);
218 tbm_backend_minor = GET_ABI_MINOR(TBM_BACKEND_ABI_LATEST_VERSION);
219 TBM_INFO("TBM Backend ABI version %d.%d\n", tbm_backend_major, tbm_backend_minor);
221 backend_module_major = GET_ABI_MAJOR(backend_module_data->abi_version);
222 backend_module_minor = GET_ABI_MINOR(backend_module_data->abi_version);
224 TBM_INFO("TBM module %s: vendor=\"%s\" Backend ABI version=%d.%d\n",
225 backend_module_data->name ? backend_module_data->name : "UNKNOWN!",
226 backend_module_data->vendor ? backend_module_data->vendor : "UNKNOWN!",
227 backend_module_major, backend_module_minor);
229 if (backend_module_major > tbm_backend_major) {
230 TBM_ERR("TBM module ABI major ver(%d) is newer than the TBM's ver(%d)\n",
231 backend_module_major, tbm_backend_major);
233 } else if (backend_module_minor > tbm_backend_minor) {
234 TBM_ERR("TBM module ABI minor ver(%d) is newer than the TBM's ver(%d)\n",
235 backend_module_minor, tbm_backend_minor);
239 if (!backend_module_data->init) {
240 TBM_ERR("Error: module does not supply init symbol.\n");
244 if (!backend_module_data->deinit) {
245 TBM_ERR("Error: module does not supply deinit symbol.\n");
249 bufmgr_data = backend_module_data->init((tbm_bufmgr)module, &error);
251 TBM_ERR("Fail to init module(%s)\n", file);
255 /* check the mandatory symbols of the backend module */
256 if (!_tbm_backend_check_bufmgr_func(module->bufmgr_func)) {
257 TBM_ERR("Fail to check the bufmgr_func symboles.");
261 if (!_tbm_backend_check_bufmgr_bo(module->bo_func)) {
262 TBM_ERR("Fail to check the bufmgr_bo symboles.");
266 module->module_data = module_data;
267 module->backend_module_data = backend_module_data;
268 module->bufmgr_data = bufmgr_data;
270 TBM_INFO("Success to load module(%s)\n", file);
276 module->backend_module_data->deinit(bufmgr_data);
278 dlclose(module_data);
284 _tbm_backend_load_bufmgr_module(tbm_module *module, int fd, const char *file)
286 char path[PATH_MAX] = {0, };
287 TBMModuleVersionInfo *vers;
288 TBMModuleData *initdata;
292 snprintf(path, sizeof(path), BUFMGR_MODULE_DIR "/%s", file);
294 module_data = dlopen(path, RTLD_LAZY);
296 TBM_ERR("failed to load module: %s(%s)\n", dlerror(), file);
300 initdata = dlsym(module_data, "tbmModuleData");
302 TBM_ERR("Error: module does not have data object.\n");
306 vers = initdata->vers;
308 TBM_ERR("Error: module does not supply version information.\n");
312 init = initdata->init;
314 TBM_ERR("Error: module does not supply init symbol.\n");
318 if (!_check_version(vers)) {
319 TBM_ERR("Fail to check version.\n");
323 if (!init((tbm_bufmgr)module, fd)) {
324 TBM_ERR("Fail to init module(%s)\n", file);
328 if (!module->backend || !module->backend->priv) {
329 TBM_ERR("Error: module(%s) wrong operation. Check backend or backend's priv.\n", file);
333 module->module_data = module_data;
335 TBM_DBG("Success to load module(%s)\n", file);
340 dlclose(module_data);
346 tbm_module_load(int fd)
349 struct dirent **namelist;
352 module = calloc(1, sizeof(struct _tbm_module));
354 TBM_ERR("fail to allocate the memory");
358 /* try to load the hal-tbm backend module */
359 ret = _tbm_backend_load_hal_tbm(module);
361 module->type = TBM_MODULE_TYPE_HAL_TBM;
365 /* LCOV_EXCL_START */
366 /* try to load the new backend module */
367 ret = _tbm_backend_load_module(module, DEFAULT_LIB);
369 module->type = TBM_MODULE_TYPE_TBM_BACKEND;
373 /* try to load the old(deprecated) backend mdoule */
374 ret = _tbm_backend_load_bufmgr_module(module, fd, DEFAULT_LIB);
376 module->type = TBM_MODULE_TYPE_BUFMGR_BACKEND;
380 /* load backend_module from configured path */
381 n = scandir(BUFMGR_MODULE_DIR, &namelist, 0, alphasort);
383 TBM_ERR("no files : %s\n", BUFMGR_MODULE_DIR);
384 tbm_module_unload(module);
389 if (!ret && strstr(namelist[n]->d_name, PREFIX_LIB)) {
390 const char *p = strstr(namelist[n]->d_name, SUFFIX_LIB);
392 if (p && !strcmp(p, SUFFIX_LIB)) {
393 ret = _tbm_backend_load_module(module, namelist[n]->d_name);
395 module->type = TBM_MODULE_TYPE_TBM_BACKEND;
397 ret = _tbm_backend_load_bufmgr_module(module, fd, namelist[n]->d_name);
398 module->type = TBM_MODULE_TYPE_BUFMGR_BACKEND;
419 tbm_module_unload(tbm_module *module)
421 switch (module->type) {
422 case TBM_MODULE_TYPE_HAL_TBM:
423 if (module->auth_wl_socket_created) {
424 tbm_drm_helper_wl_auth_server_deinit();
425 close(module->auth_fd);
427 tbm_drm_helper_unset_tbm_master_fd();
428 tbm_drm_helper_unset_fd();
430 hal_tbm_put_backend(module->hal_backend);
431 module->hal_backend = NULL;
432 module->hal_bufmgr = NULL;
433 module->use_hal_tbm = 0;
435 /* LCOV_EXCL_START */
436 case TBM_MODULE_TYPE_TBM_BACKEND:
437 module->backend_module_data->deinit(module->bufmgr_data);
438 module->bo_func = NULL;
439 module->bufmgr_func = NULL;
440 module->bufmgr_data = NULL;
441 module->backend_module_data = NULL;
443 dlclose(module->module_data);
445 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
446 module->backend->bufmgr_deinit(module->backend->priv);
447 module->backend->priv = NULL;
448 tbm_backend_free(module->backend);
449 module->backend = NULL;
451 dlclose(module->module_data);
454 TBM_ERR("Wrong module type:%d", module->type);
463 tbm_module_bufmgr_get_capabilities(tbm_module *module, tbm_error_e *error)
465 int capabilities = 0;
466 tbm_backend_bufmgr_func *bufmgr_func = NULL;
468 TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, TBM_BUFMGR_CAPABILITY_NONE, *error, TBM_ERROR_INVALID_PARAMETER);
470 switch (module->type) {
471 case TBM_MODULE_TYPE_HAL_TBM:
472 capabilities = hal_tbm_bufmgr_get_capabilities(module->hal_bufmgr, (hal_tbm_error *)error);
474 /* LCOV_EXCL_START */
475 case TBM_MODULE_TYPE_TBM_BACKEND:
476 bufmgr_func = module->bufmgr_func;
477 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func, 0, *error, TBM_ERROR_INVALID_OPERATION);
478 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func->bufmgr_get_capabilities, 0, *error, TBM_ERROR_NOT_SUPPORTED);
480 capabilities = module->bufmgr_func->bufmgr_get_capabilities(module->bufmgr_data, error);
482 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
483 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
484 TBM_ERR("Do not support at tbm_bufmgr_backend.");
486 *error = TBM_ERROR_NOT_SUPPORTED;
489 TBM_ERR("Wrong module type:%d", module->type);
490 *error = TBM_ERROR_INVALID_OPERATION;
499 tbm_module_bufmgr_bind_native_display(tbm_module *module, void *native_display)
501 tbm_error_e error = TBM_ERROR_NONE;
502 tbm_backend_bufmgr_func *bufmgr_func = NULL;
503 tbm_bufmgr_backend backend = NULL;
506 TBM_RETURN_VAL_IF_FAIL(module, TBM_ERROR_INVALID_PARAMETER);
508 switch (module->type) {
509 case TBM_MODULE_TYPE_HAL_TBM:
510 if (hal_tbm_backend_has_drm_device(module->hal_backend, &ret)) {
511 int fd = tbm_drm_helper_get_fd(); // this must be the auth drm_fd.(master drm_fd);
513 TBM_ERR("error: module(%p) native_display(%p)\n", module, native_display);
514 return TBM_ERROR_INVALID_OPERATION;
517 // make the wayland server socket for sending the authenticated drm_fd to wayland clients.
518 if (!tbm_drm_helper_wl_auth_server_init(native_display, fd, NULL, 0)) {
519 TBM_ERR("error: tbm_drm_helper_wl_auth_server_init failed\n", module, native_display);
521 return TBM_ERROR_INVALID_OPERATION;
523 TBM_INFO("tbm creates a wayland socket for authentication of drm_fd.");
525 module->auth_wl_socket_created = 1;
526 module->auth_fd = fd;
528 TBM_INFO("tbm_module has no drm device.");
529 error = TBM_ERROR_NONE;
532 /* LCOV_EXCL_START */
533 case TBM_MODULE_TYPE_TBM_BACKEND:
534 bufmgr_func = module->bufmgr_func;
535 TBM_RETURN_VAL_IF_FAIL(bufmgr_func, TBM_ERROR_INVALID_OPERATION);
536 TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_bind_native_display, TBM_ERROR_NOT_SUPPORTED);
538 error = bufmgr_func->bufmgr_bind_native_display(module->bufmgr_data, (tbm_native_display *)native_display);
540 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
541 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
542 backend = module->backend;
543 TBM_RETURN_VAL_IF_FAIL(backend, TBM_ERROR_INVALID_OPERATION);
544 TBM_RETURN_VAL_IF_FAIL(backend->bufmgr_bind_native_display, TBM_ERROR_NOT_SUPPORTED);
546 ret = backend->bufmgr_bind_native_display((tbm_bufmgr)module, native_display);
548 error = TBM_ERROR_INVALID_OPERATION;
552 TBM_ERR("Wrong module type:%d", module->type);
553 error = TBM_ERROR_INVALID_OPERATION;
562 tbm_module_bufmgr_get_supported_formats(tbm_module *module, uint32_t **formats, uint32_t *num)
564 tbm_error_e error = TBM_ERROR_NONE;
565 tbm_backend_bufmgr_func *bufmgr_func = NULL;
566 tbm_bufmgr_backend backend = NULL;
569 TBM_RETURN_VAL_IF_FAIL(module, TBM_ERROR_INVALID_PARAMETER);
571 switch (module->type) {
572 case TBM_MODULE_TYPE_HAL_TBM:
573 error = (tbm_error_e)hal_tbm_bufmgr_get_supported_formats(module->hal_bufmgr, formats, num);
575 /* LCOV_EXCL_START */
576 case TBM_MODULE_TYPE_TBM_BACKEND:
577 bufmgr_func = module->bufmgr_func;
578 TBM_RETURN_VAL_IF_FAIL(bufmgr_func, TBM_ERROR_INVALID_OPERATION);
579 TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_get_supported_formats, TBM_ERROR_NOT_SUPPORTED);
581 error = bufmgr_func->bufmgr_get_supported_formats(module->bufmgr_data, formats, num);
583 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
584 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
585 backend = module->backend;
586 TBM_RETURN_VAL_IF_FAIL(backend, TBM_ERROR_INVALID_OPERATION);
587 TBM_RETURN_VAL_IF_FAIL(backend->surface_supported_format, TBM_ERROR_NOT_SUPPORTED);
589 ret = backend->surface_supported_format(formats, num);
591 error = TBM_ERROR_INVALID_OPERATION;
595 TBM_ERR("Wrong module type:%d", module->type);
596 error = TBM_ERROR_INVALID_OPERATION;
605 tbm_module_bufmgr_get_plane_data(tbm_module *module, int format, int plane_idx, uint32_t w, uint32_t h,
606 uint32_t *size, uint32_t *offset, uint32_t *pitch, int *bo_idx)
608 tbm_error_e error = TBM_ERROR_NONE;
609 tbm_backend_bufmgr_func *bufmgr_func = NULL;
610 tbm_bufmgr_backend backend = NULL;
613 TBM_RETURN_VAL_IF_FAIL(module, TBM_ERROR_INVALID_PARAMETER);
615 switch (module->type) {
616 case TBM_MODULE_TYPE_HAL_TBM:
617 error = (tbm_error_e)hal_tbm_bufmgr_get_plane_data(module->hal_bufmgr, format, plane_idx, w, h, size, offset, pitch, bo_idx);
619 /* LCOV_EXCL_START */
620 case TBM_MODULE_TYPE_TBM_BACKEND:
621 bufmgr_func = module->bufmgr_func;
622 TBM_RETURN_VAL_IF_FAIL(bufmgr_func, TBM_ERROR_INVALID_OPERATION);
623 TBM_RETURN_VAL_IF_FAIL(bufmgr_func->bufmgr_get_plane_data, TBM_ERROR_NOT_SUPPORTED);
625 error = bufmgr_func->bufmgr_get_plane_data(module->bufmgr_data, format, plane_idx, w, h, size, offset, pitch, bo_idx);
627 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
628 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
629 backend = module->backend;
630 TBM_RETURN_VAL_IF_FAIL(backend, TBM_ERROR_INVALID_OPERATION);
631 TBM_RETURN_VAL_IF_FAIL(backend->surface_get_plane_data, TBM_ERROR_NOT_SUPPORTED);
633 ret = backend->surface_get_plane_data(w, h, format, plane_idx, size, offset, pitch, bo_idx);
635 error = TBM_ERROR_INVALID_OPERATION;
638 TBM_ERR("Wrong module type:%d", module->type);
639 error = TBM_ERROR_INVALID_OPERATION;
647 tbm_backend_bo_data *
648 tbm_module_bufmgr_bo_alloc(tbm_module *module, tbm_bo bo, int size, int flags, tbm_error_e *error)
650 tbm_backend_bo_data *bo_data = NULL;
651 tbm_backend_bufmgr_func *bufmgr_func = NULL;
652 tbm_bufmgr_backend backend = NULL;
654 TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, NULL, *error, TBM_ERROR_INVALID_PARAMETER);
656 switch (module->type) {
657 case TBM_MODULE_TYPE_HAL_TBM:
658 bo_data = (tbm_backend_bo_data *)hal_tbm_bufmgr_alloc_bo(module->hal_bufmgr, size, flags, (hal_tbm_error *)error);
660 /* LCOV_EXCL_START */
661 case TBM_MODULE_TYPE_TBM_BACKEND:
662 bufmgr_func = module->bufmgr_func;
663 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func, NULL, *error, TBM_ERROR_INVALID_OPERATION);
664 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func->bufmgr_alloc_bo, NULL, *error, TBM_ERROR_NOT_SUPPORTED);
666 bo_data = module->bufmgr_func->bufmgr_alloc_bo(module->bufmgr_data, (unsigned int)size, flags, error);
668 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
669 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
670 backend = module->backend;
671 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend, NULL, *error, TBM_ERROR_INVALID_OPERATION);
672 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_alloc, NULL, *error, TBM_ERROR_NOT_SUPPORTED);
674 bo_data = (void *)module->backend->bo_alloc(bo, size, flags);
675 *error = TBM_ERROR_NONE;
678 TBM_ERR("Wrong module type:%d", module->type);
679 *error = TBM_ERROR_INVALID_OPERATION;
687 tbm_backend_bo_data *
688 tbm_module_bufmgr_bo_alloc_with_format(tbm_module *module, int format, int bo_idx, int width,
689 int height, int bpp, tbm_bo_memory_type flags, tbm_error_e *error)
691 tbm_backend_bo_data *bo_data = NULL;
692 tbm_backend_bufmgr_func *bufmgr_func = NULL;
694 TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, NULL, *error, TBM_ERROR_INVALID_PARAMETER);
696 switch (module->type) {
697 case TBM_MODULE_TYPE_HAL_TBM:
698 bo_data = (tbm_backend_bo_data *)hal_tbm_bufmgr_alloc_bo_with_format(module->hal_bufmgr,
699 format, bo_idx, width, height, bpp,
700 (hal_tbm_bo_memory_type)flags, (hal_tbm_error *)error);
702 /* LCOV_EXCL_START */
703 case TBM_MODULE_TYPE_TBM_BACKEND:
704 bufmgr_func = module->bufmgr_func;
705 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func, NULL, *error, TBM_ERROR_INVALID_OPERATION);
706 if (!bufmgr_func->bufmgr_alloc_bo_with_format) {
707 *error = TBM_ERROR_NOT_SUPPORTED;
711 bo_data = bufmgr_func->bufmgr_alloc_bo_with_format(module->bufmgr_data, format, bo_idx, width, height, flags, error);
713 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
714 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
715 TBM_ERR("error: not supported tbm_bufmgr_internal_alloc_bo_with_format.");
717 *error = TBM_ERROR_NOT_SUPPORTED;
720 TBM_ERR("Wrong module type:%d", module->type);
721 *error = TBM_ERROR_INVALID_OPERATION;
730 tbm_backend_bo_data *
731 tbm_module_bufmgr_bo_import_fd(tbm_module *module, tbm_bo bo, tbm_fd fd, tbm_error_e *error)
733 tbm_backend_bo_data *bo_data = NULL;
734 tbm_backend_bufmgr_func *bufmgr_func = NULL;
735 tbm_bufmgr_backend backend = NULL;
737 TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, NULL, *error, TBM_ERROR_INVALID_PARAMETER);
739 switch (module->type) {
740 case TBM_MODULE_TYPE_HAL_TBM:
741 bo_data = (tbm_backend_bo_data *)hal_tbm_bufmgr_import_fd(module->hal_bufmgr, (hal_tbm_fd)fd, (hal_tbm_error *)error);
743 /* LCOV_EXCL_START */
744 case TBM_MODULE_TYPE_TBM_BACKEND:
745 bufmgr_func = module->bufmgr_func;
746 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func, NULL, *error, TBM_ERROR_INVALID_OPERATION);
747 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func->bufmgr_import_fd, NULL, *error, TBM_ERROR_NOT_SUPPORTED);
749 bo_data = bufmgr_func->bufmgr_import_fd(module->bufmgr_data, fd, error);
751 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
752 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
753 backend = module->backend;
754 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend, NULL, *error, TBM_ERROR_INVALID_OPERATION);
755 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_import_fd, NULL, *error, TBM_ERROR_NOT_SUPPORTED);
757 bo_data = (void *)backend->bo_import_fd(bo, fd);
759 *error = TBM_ERROR_INVALID_OPERATION;
761 *error = TBM_ERROR_NONE;
764 TBM_ERR("Wrong module type:%d", module->type);
765 *error = TBM_ERROR_INVALID_OPERATION;
773 tbm_backend_bo_data *
774 tbm_module_bufmgr_bo_import_key(tbm_module *module, tbm_bo bo, tbm_key key, tbm_error_e *error)
776 tbm_backend_bo_data *bo_data = NULL;
777 tbm_backend_bufmgr_func *bufmgr_func = NULL;
778 tbm_bufmgr_backend backend = NULL;
780 TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, NULL, *error, TBM_ERROR_INVALID_PARAMETER);
782 switch (module->type) {
783 case TBM_MODULE_TYPE_HAL_TBM:
784 bo_data = (tbm_backend_bo_data *)hal_tbm_bufmgr_import_key(module->hal_bufmgr, key, (hal_tbm_error *)error);
786 /* LCOV_EXCL_START */
787 case TBM_MODULE_TYPE_TBM_BACKEND:
788 bufmgr_func = module->bufmgr_func;
789 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func, NULL, *error, TBM_ERROR_INVALID_OPERATION);
790 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func->bufmgr_import_key, NULL, *error, TBM_ERROR_NOT_SUPPORTED);
792 bo_data = bufmgr_func->bufmgr_import_key(module->bufmgr_data, key, error);
794 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
795 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
796 backend = module->backend;
797 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend, NULL, *error, TBM_ERROR_INVALID_OPERATION);
798 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_import, NULL, *error, TBM_ERROR_NOT_SUPPORTED);
800 bo_data = (void *)backend->bo_import(bo, key);
802 *error = TBM_ERROR_INVALID_OPERATION;
804 *error = TBM_ERROR_NONE;
807 TBM_ERR("Wrong module type:%d", module->type);
808 *error = TBM_ERROR_INVALID_OPERATION;
817 tbm_module_bo_free(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int get_from_hal_surface)
819 tbm_backend_bo_func *bo_func = NULL;
820 tbm_bufmgr_backend backend = NULL;
822 TBM_RETURN_IF_FAIL(module);
823 TBM_RETURN_IF_FAIL(bo);
824 TBM_RETURN_IF_FAIL(bo_data);
826 switch (module->type) {
827 case TBM_MODULE_TYPE_HAL_TBM:
828 // call hal_tbm_bo_free when bo is created by tbm_bo_alloc api.
829 if (get_from_hal_surface)
830 hal_tbm_bo_free(bo_data);
832 /* LCOV_EXCL_START */
833 case TBM_MODULE_TYPE_TBM_BACKEND:
834 bo_func = module->bo_func;
835 TBM_RETURN_IF_FAIL(bo_func);
836 TBM_RETURN_IF_FAIL(bo_func->bo_free);
838 bo_func->bo_free(bo_data);
840 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
841 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
842 backend = module->backend;
843 TBM_RETURN_IF_FAIL(backend);
844 TBM_RETURN_IF_FAIL(backend->bo_free);
846 backend->bo_free(bo);
849 TBM_ERR("Wrong module type:%d", module->type);
856 tbm_module_bo_get_size(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error)
858 tbm_backend_bo_func *bo_func = NULL;
859 tbm_bufmgr_backend backend = NULL;
862 TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, 0, *error, TBM_ERROR_INVALID_PARAMETER);
864 switch (module->type) {
865 case TBM_MODULE_TYPE_HAL_TBM:
866 size = hal_tbm_bo_get_size((hal_tbm_bo *)bo_data, (hal_tbm_error *)error);
868 /* LCOV_EXCL_START */
869 case TBM_MODULE_TYPE_TBM_BACKEND:
870 bo_func = module->bo_func;
871 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func, 0, *error, TBM_ERROR_INVALID_OPERATION);
872 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func->bo_get_size, 0, *error, TBM_ERROR_NOT_SUPPORTED);
874 size = bo_func->bo_get_size(bo_data, error);
876 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
877 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
878 backend = module->backend;
879 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend, 0, *error, TBM_ERROR_INVALID_OPERATION);
880 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_size, 0, *error, TBM_ERROR_NOT_SUPPORTED);
882 size = backend->bo_size(bo);
884 *error = TBM_ERROR_INVALID_OPERATION;
886 *error = TBM_ERROR_NONE;
889 TBM_ERR("Wrong module type:%d", module->type);
890 *error = TBM_ERROR_INVALID_OPERATION;
899 tbm_module_bo_get_memory_types(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error)
901 tbm_backend_bo_func *bo_func = NULL;
902 tbm_bufmgr_backend backend = NULL;
903 int memory_types = TBM_BO_DEFAULT;
905 TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, 0, *error, TBM_ERROR_INVALID_PARAMETER);
907 switch (module->type) {
908 case TBM_MODULE_TYPE_HAL_TBM:
909 memory_types = (tbm_bo_memory_type)hal_tbm_bo_get_memory_types((hal_tbm_bo *)bo_data, (hal_tbm_error *)error);
911 /* LCOV_EXCL_START */
912 case TBM_MODULE_TYPE_TBM_BACKEND:
913 bo_func = module->bo_func;
914 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func, 0, *error, TBM_ERROR_INVALID_OPERATION);
915 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func->bo_get_memory_types, 0, *error, TBM_ERROR_NOT_SUPPORTED);
917 memory_types = bo_func->bo_get_memory_types(bo_data, error);
919 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
920 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
921 backend = module->backend;
922 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend, 0, *error, TBM_ERROR_INVALID_OPERATION);
923 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_get_flags, 0, *error, TBM_ERROR_NOT_SUPPORTED);
925 memory_types = backend->bo_get_flags(bo);
926 *error = TBM_ERROR_NONE;
929 TBM_ERR("Wrong module type:%d", module->type);
930 *error = TBM_ERROR_INVALID_OPERATION;
939 tbm_module_bo_get_handle(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, tbm_error_e *error)
941 tbm_backend_bo_func *bo_func = NULL;
942 tbm_bufmgr_backend backend = NULL;
943 tbm_bo_handle bo_handle;
944 hal_tbm_bo_handle hbo_handle;
946 TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_PARAMETER);
948 switch (module->type) {
949 case TBM_MODULE_TYPE_HAL_TBM:
950 hbo_handle = hal_tbm_bo_get_handle((hal_tbm_bo *)bo_data, device, (hal_tbm_error *)error);
951 if (hbo_handle.ptr != NULL)
952 memcpy(&bo_handle.ptr, &hbo_handle.ptr, sizeof(tbm_bo_handle));
954 /* LCOV_EXCL_START */
955 case TBM_MODULE_TYPE_TBM_BACKEND:
956 bo_func = module->bo_func;
957 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_OPERATION);
958 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func->bo_get_handle, (tbm_bo_handle)NULL, *error, TBM_ERROR_NOT_SUPPORTED);
960 bo_handle = bo_func->bo_get_handle(bo_data, device, error);
962 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
963 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
964 backend = module->backend;
965 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_OPERATION);
966 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_get_handle, (tbm_bo_handle)NULL, *error, TBM_ERROR_NOT_SUPPORTED);
968 bo_handle = backend->bo_get_handle(bo, device);
970 *error = TBM_ERROR_INVALID_OPERATION;
972 *error = TBM_ERROR_NONE;
975 TBM_ERR("Wrong module type:%d", module->type);
976 bo_handle.ptr = NULL;
977 *error = TBM_ERROR_INVALID_OPERATION;
986 tbm_module_bo_map(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, int opt, tbm_error_e *error)
988 tbm_backend_bo_func *bo_func = NULL;
989 tbm_bufmgr_backend backend = NULL;
990 tbm_bo_handle bo_handle;
991 hal_tbm_bo_handle hbo_handle;
993 TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_PARAMETER);
995 switch (module->type) {
996 case TBM_MODULE_TYPE_HAL_TBM:
997 hbo_handle = hal_tbm_bo_map((hal_tbm_bo *)bo_data, device, opt, (hal_tbm_error *)error);
998 if (hbo_handle.ptr != NULL)
999 memcpy(&bo_handle.ptr, &hbo_handle.ptr, sizeof(tbm_bo_handle));
1001 /* LCOV_EXCL_START */
1002 case TBM_MODULE_TYPE_TBM_BACKEND:
1003 bo_func = module->bo_func;
1004 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_OPERATION);
1005 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func->bo_map, (tbm_bo_handle)NULL, *error, TBM_ERROR_NOT_SUPPORTED);
1007 bo_handle = bo_func->bo_map(bo_data, device, opt, error);
1009 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
1010 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
1011 backend = module->backend;
1012 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend, (tbm_bo_handle)NULL, *error, TBM_ERROR_INVALID_OPERATION);
1013 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_map, (tbm_bo_handle)NULL, *error, TBM_ERROR_NOT_SUPPORTED);
1015 bo_handle = backend->bo_map(bo, device, opt);
1017 *error = TBM_ERROR_INVALID_OPERATION;
1019 *error = TBM_ERROR_NONE;
1022 TBM_ERR("Wrong module type:%d", module->type);
1023 bo_handle.ptr = NULL;
1024 *error = TBM_ERROR_INVALID_OPERATION;
1026 /* LCOV_EXCL_STOP */
1033 tbm_module_bo_unmap(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data)
1035 tbm_backend_bo_func *bo_func = NULL;
1036 tbm_bufmgr_backend backend = NULL;
1040 TBM_RETURN_VAL_IF_FAIL(module, TBM_ERROR_INVALID_PARAMETER);
1042 switch (module->type) {
1043 case TBM_MODULE_TYPE_HAL_TBM:
1044 error = (hal_tbm_error)hal_tbm_bo_unmap((hal_tbm_bo *)bo_data);
1046 /* LCOV_EXCL_START */
1047 case TBM_MODULE_TYPE_TBM_BACKEND:
1048 bo_func = module->bo_func;
1049 TBM_RETURN_VAL_IF_FAIL(bo_func, TBM_ERROR_INVALID_OPERATION);
1050 TBM_RETURN_VAL_IF_FAIL(bo_func->bo_unmap, TBM_ERROR_NOT_SUPPORTED);
1052 error = bo_func->bo_unmap(bo->bo_data);
1054 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
1055 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
1056 backend = module->backend;
1057 TBM_RETURN_VAL_IF_FAIL(backend, TBM_ERROR_INVALID_OPERATION);
1058 TBM_RETURN_VAL_IF_FAIL(backend->bo_unmap, TBM_ERROR_NOT_SUPPORTED);
1060 ret = bo->bufmgr->backend->bo_unmap(bo);
1062 error = TBM_ERROR_INVALID_OPERATION;
1064 error = TBM_ERROR_NONE;
1067 TBM_ERR("Wrong module type:%d", module->type);
1068 error = TBM_ERROR_INVALID_OPERATION;
1070 /* LCOV_EXCL_STOP */
1077 tbm_module_bo_lock(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, int device, int opt)
1079 tbm_backend_bo_func *bo_func = NULL;
1080 tbm_bufmgr_backend backend = NULL;
1084 TBM_RETURN_VAL_IF_FAIL(module, TBM_ERROR_INVALID_PARAMETER);
1086 switch (module->type) {
1087 case TBM_MODULE_TYPE_HAL_TBM:
1088 error = (tbm_error_e)hal_tbm_bo_lock((hal_tbm_bo *)bo_data, device, opt);
1090 /* LCOV_EXCL_START */
1091 case TBM_MODULE_TYPE_TBM_BACKEND:
1092 bo_func = module->bo_func;
1093 TBM_RETURN_VAL_IF_FAIL(bo_func, TBM_ERROR_INVALID_OPERATION);
1094 if (!bo_func->bo_lock)
1095 return TBM_ERROR_NOT_SUPPORTED;
1097 error = bo_func->bo_lock(bo_data, device, opt);
1099 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
1100 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
1101 backend = module->backend;
1102 TBM_RETURN_VAL_IF_FAIL(backend, TBM_ERROR_INVALID_OPERATION);
1103 if (!backend->bo_unmap)
1104 return TBM_ERROR_NOT_SUPPORTED;
1106 ret = backend->bo_lock(bo, device, opt);
1108 error = TBM_ERROR_INVALID_OPERATION;
1110 error = TBM_ERROR_NONE;
1113 TBM_ERR("Wrong module type:%d", module->type);
1114 error = TBM_ERROR_INVALID_OPERATION;
1116 /* LCOV_EXCL_STOP */
1123 tbm_module_bo_unlock(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data)
1125 tbm_backend_bo_func *bo_func = NULL;
1126 tbm_bufmgr_backend backend = NULL;
1129 TBM_RETURN_VAL_IF_FAIL(module, TBM_ERROR_INVALID_PARAMETER);
1131 switch (module->type) {
1132 case TBM_MODULE_TYPE_HAL_TBM:
1133 error = (tbm_error_e)hal_tbm_bo_unlock((hal_tbm_bo *)bo_data);
1135 /* LCOV_EXCL_START */
1136 case TBM_MODULE_TYPE_TBM_BACKEND:
1137 bo_func = module->bo_func;
1138 TBM_RETURN_VAL_IF_FAIL(bo_func, TBM_ERROR_INVALID_OPERATION);
1139 if (!bo_func->bo_unlock)
1140 return TBM_ERROR_NOT_SUPPORTED;
1142 error = bo_func->bo_unlock(bo->bo_data);
1144 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
1145 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
1146 backend = module->backend;
1147 TBM_RETURN_VAL_IF_FAIL(backend, TBM_ERROR_INVALID_OPERATION);
1148 if (!backend->bo_unlock)
1149 return TBM_ERROR_NOT_SUPPORTED;
1151 backend->bo_unlock(bo);
1152 error = TBM_ERROR_NONE;
1155 TBM_ERR("Wrong module type:%d", module->type);
1156 error = TBM_ERROR_INVALID_OPERATION;
1158 /* LCOV_EXCL_STOP */
1165 tbm_module_bo_export_fd(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error)
1167 tbm_backend_bo_func *bo_func = NULL;
1168 tbm_bufmgr_backend backend = NULL;
1171 TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, -1, *error, TBM_ERROR_INVALID_PARAMETER);
1173 switch (module->type) {
1174 case TBM_MODULE_TYPE_HAL_TBM:
1175 fd = (hal_tbm_fd)hal_tbm_bo_export_fd((hal_tbm_bo *)bo_data, (hal_tbm_error *)error);
1177 /* LCOV_EXCL_START */
1178 case TBM_MODULE_TYPE_TBM_BACKEND:
1179 bo_func = module->bo_func;
1180 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func, -1, *error, TBM_ERROR_INVALID_OPERATION);
1181 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func->bo_export_fd, -1, *error, TBM_ERROR_NOT_SUPPORTED);
1183 fd = bo_func->bo_export_fd(bo_data, error);
1185 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
1186 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
1187 backend = module->backend;
1188 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend, -1, *error, TBM_ERROR_INVALID_OPERATION);
1189 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_export_fd, -1, *error, TBM_ERROR_NOT_SUPPORTED);
1191 fd = backend->bo_export_fd(bo);
1193 *error = TBM_ERROR_INVALID_OPERATION;
1195 *error = TBM_ERROR_NONE;
1198 TBM_ERR("Wrong module type:%d", module->type);
1200 *error = TBM_ERROR_INVALID_OPERATION;
1202 /* LCOV_EXCL_STOP */
1209 tbm_module_bo_export_key(tbm_module *module, tbm_bo bo, tbm_backend_bo_data *bo_data, tbm_error_e *error)
1211 tbm_backend_bo_func *bo_func = NULL;
1212 tbm_bufmgr_backend backend = NULL;
1215 TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, 0, *error, TBM_ERROR_INVALID_PARAMETER);
1217 switch (module->type) {
1218 case TBM_MODULE_TYPE_HAL_TBM:
1219 ret = (hal_tbm_fd)hal_tbm_bo_export_key((hal_tbm_bo *)bo_data, (hal_tbm_error *)error);
1221 /* LCOV_EXCL_START */
1222 case TBM_MODULE_TYPE_TBM_BACKEND:
1223 bo_func = module->bo_func;
1224 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func, 0, *error, TBM_ERROR_INVALID_OPERATION);
1225 TBM_RETURN_VAL_SET_ERR_IF_FAIL(bo_func->bo_export_key, 0, *error, TBM_ERROR_NOT_SUPPORTED);
1227 ret = bo_func->bo_export_key(bo_data, error);
1229 case TBM_MODULE_TYPE_BUFMGR_BACKEND:
1230 TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 6.5.");
1231 backend = module->backend;
1232 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend, 0, *error, TBM_ERROR_INVALID_OPERATION);
1233 TBM_RETURN_VAL_SET_ERR_IF_FAIL(backend->bo_export, 0, *error, TBM_ERROR_NOT_SUPPORTED);
1235 ret = backend->bo_export(bo);
1237 *error = TBM_ERROR_INVALID_OPERATION;
1239 *error = TBM_ERROR_NONE;
1242 TBM_ERR("Wrong module type:%d", module->type);
1244 *error = TBM_ERROR_INVALID_OPERATION;
1246 /* LCOV_EXCL_STOP */