Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved.
Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
+Boram Park <boram1288.park@samsung.com>, Changyeon Lee <cyeon.lee@samsung.com>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
#include <sys/types.h>
#include "tbm_bufmgr_int.h"
-tbm_bufmgr_backend
-tbm_backend_alloc (void)
+/* LCOV_EXCL_START */
+tbm_bufmgr_backend tbm_backend_alloc(void)
{
- tbm_bufmgr_backend bufmgr_backend;
+ tbm_bufmgr_backend bufmgr_backend;
- bufmgr_backend = calloc (1, sizeof(struct _tbm_bufmgr_backend));
- if (!bufmgr_backend)
- return NULL;
+ bufmgr_backend = calloc(1, sizeof(struct _tbm_bufmgr_backend));
+ if (!bufmgr_backend)
+ return NULL;
- return bufmgr_backend;
+ return bufmgr_backend;
}
-void
-tbm_backend_free (tbm_bufmgr_backend backend)
+void tbm_backend_free(tbm_bufmgr_backend backend)
{
- if (!backend)
- return;
+ if (!backend)
+ return;
- free (backend);
- backend = NULL;
+ free(backend);
+ backend = NULL;
}
-int
-tbm_backend_init (tbm_bufmgr bufmgr, tbm_bufmgr_backend backend)
+int tbm_backend_init(tbm_bufmgr bufmgr, tbm_bufmgr_backend backend)
{
- int flags = 0;
-
- if (!bufmgr)
- {
- TBM_LOG ("[libtbm:%d] "
- "error (%s): fail to init tbm backend... bufmgr is null\n",
- getpid(), __FUNCTION__);
- return 0;
- }
-
- if (!backend)
- {
- TBM_LOG ("[libtbm:%d] "
- "error (%s): fail to init tbm backend... backend is null\n",
- getpid(), __FUNCTION__);
- return 0;
- }
-
- flags = backend->flags;
- /* check the backend flags */
- if (!(flags&TBM_CACHE_CTRL_BACKEND))
- {
- if (!backend->bo_cache_flush)
- {
- TBM_LOG ("[libtbm:%d] "
- "error (%s): TBM_FLAG_CACHE_CTRL_TBM needs backend->bo_cache_flush\n",
- getpid(), __FUNCTION__);
- return 0;
- }
- }
-
- /* log for tbm flags */
- TBM_LOG ("[libtbm:%d] ", getpid());
- TBM_LOG ("cache_crtl:");
- if (flags&TBM_CACHE_CTRL_BACKEND)
- TBM_LOG ("BACKEND ");
- else
- TBM_LOG ("TBM ");
- TBM_LOG ("lock_crtl:");
- if (flags&TBM_LOCK_CTRL_BACKEND)
- TBM_LOG ("BACKEND ");
- else
- TBM_LOG ("TBM ");
- TBM_LOG ("\n");
-
- bufmgr->backend = backend;
-
- return 1;
+ if (!bufmgr) {
+ TBM_LOG_E("error: fail to init tbm backend... bufmgr is null\n");
+ return 0;
+ }
+
+ if (!backend) {
+ TBM_LOG_E("error: fail to init tbm backend... backend is null\n");
+ return 0;
+ }
+
+ bufmgr->backend = backend;
+ bufmgr->capabilities = TBM_BUFMGR_CAPABILITY_NONE;
+
+ if (bufmgr->backend->bo_import && bufmgr->backend->bo_export)
+ bufmgr->capabilities |= TBM_BUFMGR_CAPABILITY_SHARE_KEY;
+
+ if (bufmgr->backend->bo_import_fd && bufmgr->backend->bo_export_fd)
+ bufmgr->capabilities |= TBM_BUFMGR_CAPABILITY_SHARE_FD;
+
+ return 1;
}
-void *
-tbm_backend_get_bufmgr_priv (tbm_bo bo)
+void *tbm_backend_get_bufmgr_priv(tbm_bo bo)
{
- tbm_bufmgr_backend backend = bo->bufmgr->backend;
+ tbm_bufmgr_backend backend = bo->bufmgr->backend;
- return backend->priv;
+ return backend->priv;
}
-void
-tbm_backend_set_bo_priv (tbm_bo bo, void *bo_priv)
+void *tbm_backend_get_priv_from_bufmgr(tbm_bufmgr bufmgr)
{
- bo->priv = bo_priv;
+ tbm_bufmgr_backend backend = bufmgr->backend;
+
+ return backend->priv;
}
-void *
-tbm_backend_get_bo_priv (tbm_bo bo)
+void tbm_backend_set_bo_priv(tbm_bo bo, void *bo_priv)
{
- return bo->priv;
+ bo->priv = bo_priv;
}
+void *tbm_backend_get_bo_priv(tbm_bo bo)
+{
+ return bo->priv;
+}
+int tbm_backend_is_display_server(void)
+{
+ const char *value;
+ value = (const char*)getenv("TBM_DISPLAY_SERVER");
+ if (!value)
+ return 0;
+
+ return 1;
+}
+/* LCOV_EXCL_STOP */