summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSooChan Lim <sc1.lim@samsung.com>2018-03-20 11:23:44 +0900
committerSooChan Lim <sc1.lim@samsung.com>2018-03-20 11:23:44 +0900
commit6eb8dc8f14abb5c4fac45cb0fd479e33a280118a (patch)
tree00bde4ab12e713a48d072ae5f83a18cda9feb1a1
parentd02e09b82d389b8b2a5d6d2f359f9bc90ffeeb1a (diff)
downloadlibtbm-exynos-tgm-6eb8dc8f14abb5c4fac45cb0fd479e33a280118a.tar.gz
libtbm-exynos-tgm-6eb8dc8f14abb5c4fac45cb0fd479e33a280118a.tar.bz2
libtbm-exynos-tgm-6eb8dc8f14abb5c4fac45cb0fd479e33a280118a.zip
use the tbm_log.h for logging.
Change-Id: I358ffd142a7c000262df4a48104f77e2e726f537
-rw-r--r--src/tbm_bufmgr_exynos.c243
1 files changed, 92 insertions, 151 deletions
diff --git a/src/tbm_bufmgr_exynos.c b/src/tbm_bufmgr_exynos.c
index da711ae..dd7a043 100644
--- a/src/tbm_bufmgr_exynos.c
+++ b/src/tbm_bufmgr_exynos.c
@@ -50,59 +50,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <pthread.h>
#include <tbm_backend.h>
#include <tbm_drm_helper.h>
+#include <tbm_log.h>
#include "tbm_bufmgr_tgl.h"
-#define DEBUG
#define USE_DMAIMPORT
#define TBM_COLOR_FORMAT_COUNT 4
-#ifdef DEBUG
-#define LOG_TAG "TBM_BACKEND"
-#include <dlog.h>
-static int bDebug;
-
#define EXYNOS_DRM_NAME "tgm"
-char *target_name()
-{
- static char app_name[128] = {0, };
- static int initialized = 0;
- char *slash;
- FILE *f;
-
- if (initialized)
- return app_name;
-
- /* get the application name */
- f = fopen("/proc/self/cmdline", "r");
- if (!f)
- return NULL;
-
- memset(app_name, 0x00, sizeof(app_name));
-
- if (fgets(app_name, 100, f) == NULL) {
- fclose(f);
- return NULL;
- }
-
- fclose(f);
-
- slash = strrchr(app_name, '/');
- if (slash != NULL)
- memmove(app_name, slash + 1, strlen(slash));
-
- initialized = 1;
-
- return app_name;
-}
-
-#define TBM_EXYNOS_ERROR(fmt, args...) LOGE("\033[31m" "[%s] " fmt "\033[0m", target_name(), ##args)
-#define TBM_EXYNOS_DEBUG(fmt, args...) {if (bDebug&01) LOGD("[%s] " fmt, target_name(), ##args); }
-#else
-#define TBM_EXYNOS_ERROR(...)
-#define TBM_EXYNOS_DEBUG(...)
-#endif
-
#define STRERR_BUFSIZE 128
#define SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1))
@@ -127,14 +82,14 @@ char *target_name()
/* check condition */
#define EXYNOS_RETURN_IF_FAIL(cond) {\
if (!(cond)) {\
- TBM_EXYNOS_ERROR("[%s] : '%s' failed.\n", __func__, #cond);\
+ TBM_ERR("[%s] : '%s' failed.\n", __func__, #cond);\
return;\
} \
}
#define EXYNOS_RETURN_VAL_IF_FAIL(cond, val) {\
if (!(cond)) {\
- TBM_EXYNOS_ERROR("[%s] : '%s' failed.\n", __func__, #cond);\
+ TBM_ERR("[%s] : '%s' failed.\n", __func__, #cond);\
return val;\
} \
}
@@ -275,12 +230,12 @@ _tgl_get_version(int fd)
err = ioctl(fd, TGL_IOCTL_GET_VERSION, &data);
if (err) {
- TBM_EXYNOS_ERROR("error(%s) %s:%d\n",
+ TBM_ERR("error(%s) %s:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE));
return 0;
}
- TBM_EXYNOS_DEBUG("tgl version is (%u, %u).\n", data.major, data.minor);
+ TBM_DBG("tgl version is (%u, %u).\n", data.major, data.minor);
return 1;
}
@@ -298,7 +253,7 @@ _tgl_init(int fd, unsigned int key)
err = ioctl(fd, TGL_IOCTL_REGISTER, &data);
if (err) {
- TBM_EXYNOS_ERROR("error(%s) key:%d\n",
+ TBM_ERR("error(%s) key:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE), key);
return 0;
}
@@ -316,7 +271,7 @@ _tgl_destroy(int fd, unsigned int key)
data.key = key;
err = ioctl(fd, TGL_IOCTL_UNREGISTER, &data);
if (err) {
- TBM_EXYNOS_ERROR("error(%s) key:%d\n",
+ TBM_ERR("error(%s) key:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE), key);
return 0;
}
@@ -332,7 +287,7 @@ _tgl_lock(int fd, unsigned int key, int opt)
char buf[STRERR_BUFSIZE];
if (opt & TBM_OPTION_VENDOR) {
- TBM_EXYNOS_ERROR("error(invalid argument) opt:%d\n", opt);
+ TBM_ERR("error(invalid argument) opt:%d\n", opt);
opt &= ~TBM_OPTION_VENDOR;
}
@@ -341,7 +296,7 @@ _tgl_lock(int fd, unsigned int key, int opt)
err = ioctl(fd, TGL_IOCTL_LOCK, &data);
if (err) {
- TBM_EXYNOS_ERROR("error(%s) key:%d opt:%d\n",
+ TBM_ERR("error(%s) key:%d opt:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE), key, opt);
return 0;
}
@@ -361,7 +316,7 @@ _tgl_unlock(int fd, unsigned int key)
err = ioctl(fd, TGL_IOCTL_UNLOCK, &data);
if (err) {
- TBM_EXYNOS_ERROR("error(%s) key:%d\n",
+ TBM_ERR("error(%s) key:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE), key);
return 0;
}
@@ -381,7 +336,7 @@ _tgl_set_data(int fd, unsigned int key, unsigned int val)
err = ioctl(fd, TGL_IOCTL_SET_DATA, &data);
if (err) {
- TBM_EXYNOS_ERROR("error(%s) key:%d\n",
+ TBM_ERR("error(%s) key:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE), key);
return 0;
}
@@ -400,7 +355,7 @@ _tgl_get_data(int fd, unsigned int key)
err = ioctl(fd, TGL_IOCTL_GET_DATA, &data);
if (err) {
- TBM_EXYNOS_ERROR("error(%s) key:%d\n",
+ TBM_ERR("error(%s) key:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE), key);
return 0;
}
@@ -452,7 +407,7 @@ _exynos_cache_flush(tbm_bufmgr_exynos bufmgr_exynos, tbm_bo_exynos bo_exynos, in
ret = drmCommandWriteRead(bufmgr_exynos->fd, DRM_EXYNOS_GEM_CACHE_OP, &cache_op,
sizeof(cache_op));
if (ret) {
- TBM_EXYNOS_ERROR("fail to flush the cache.\n");
+ TBM_ERR("fail to flush the cache.\n");
return 0;
}
@@ -542,7 +497,7 @@ _bo_set_cache_state(tbm_bufmgr_exynos bufmgr_exynos, tbm_bo_exynos bo_exynos, in
/* call cache flush */
_exynos_cache_flush(bufmgr_exynos, bo_exynos, need_flush);
- TBM_EXYNOS_DEBUG(" \tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n",
+ TBM_DBG(" \tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n",
bo_exynos->cache_state.data.isCached,
bo_exynos->cache_state.data.isDirtied,
need_flush,
@@ -606,7 +561,7 @@ _bufmgr_init_cache_state(tbm_bufmgr_exynos bufmgr_exynos)
if (bufmgr_exynos->tgl_fd < 0) {
bufmgr_exynos->tgl_fd = open(tgl_devfile1, O_RDWR);
if (bufmgr_exynos->tgl_fd < 0) {
- TBM_EXYNOS_ERROR("fail to open global_lock:%s\n",
+ TBM_ERR("fail to open global_lock:%s\n",
tgl_devfile1);
return 0;
}
@@ -614,14 +569,14 @@ _bufmgr_init_cache_state(tbm_bufmgr_exynos bufmgr_exynos)
#ifdef TGL_GET_VERSION
if (!_tgl_get_version(bufmgr_exynos->tgl_fd)) {
- TBM_EXYNOS_ERROR("fail to get tgl_version. tgl init failed.\n");
+ TBM_ERR("fail to get tgl_version. tgl init failed.\n");
close(bufmgr_exynos->tgl_fd);
return 0;
}
#endif
if (!_tgl_init(bufmgr_exynos->tgl_fd, GLOBAL_KEY)) {
- TBM_EXYNOS_ERROR("fail to initialize the tgl\n");
+ TBM_ERR("fail to initialize the tgl\n");
close(bufmgr_exynos->tgl_fd);
return 0;
}
@@ -651,7 +606,7 @@ _tbm_exynos_open_drm()
fd = drmOpen(EXYNOS_DRM_NAME, NULL);
if (fd < 0) {
- TBM_EXYNOS_ERROR("fail to open drm.(%s)\n", EXYNOS_DRM_NAME);
+ TBM_ERR("fail to open drm.(%s)\n", EXYNOS_DRM_NAME);
}
if (fd < 0) {
@@ -663,11 +618,11 @@ _tbm_exynos_open_drm()
struct stat s;
int ret;
- TBM_EXYNOS_DEBUG("search drm-device by udev\n");
+ TBM_DBG("search drm-device by udev\n");
udev = udev_new();
if (!udev) {
- TBM_EXYNOS_ERROR("udev_new() failed.\n");
+ TBM_ERR("udev_new() failed.\n");
return -1;
}
@@ -684,8 +639,7 @@ _tbm_exynos_open_drm()
if (device_parent) {
if (strcmp(udev_device_get_sysname(device_parent), "exynos-drm") == 0) {
drm_device = device;
- TBM_EXYNOS_DEBUG("[%s] Found render device: '%s' (%s)\n",
- target_name(),
+ TBM_DBG("Found render device: '%s' (%s)\n",
udev_device_get_syspath(drm_device),
udev_device_get_sysname(device_parent));
break;
@@ -699,7 +653,7 @@ _tbm_exynos_open_drm()
/* Get device file path. */
filepath = udev_device_get_devnode(drm_device);
if (!filepath) {
- TBM_EXYNOS_ERROR("udev_device_get_devnode() failed.\n");
+ TBM_ERR("udev_device_get_devnode() failed.\n");
udev_device_unref(drm_device);
udev_unref(udev);
return -1;
@@ -708,7 +662,7 @@ _tbm_exynos_open_drm()
/* Open DRM device file and check validity. */
fd = open(filepath, O_RDWR | O_CLOEXEC);
if (fd < 0) {
- TBM_EXYNOS_ERROR("open(%s, O_RDWR | O_CLOEXEC) failed.\n");
+ TBM_ERR("open(%s, O_RDWR | O_CLOEXEC) failed.\n");
udev_device_unref(drm_device);
udev_unref(udev);
return -1;
@@ -716,7 +670,7 @@ _tbm_exynos_open_drm()
ret = fstat(fd, &s);
if (ret) {
- TBM_EXYNOS_ERROR("fstat() failed %s.\n");
+ TBM_ERR("fstat() failed %s.\n");
close(fd);
udev_device_unref(drm_device);
udev_unref(udev);
@@ -743,7 +697,7 @@ _check_render_node(void)
udev = udev_new();
if (!udev) {
- TBM_EXYNOS_ERROR("udev_new() failed.\n");
+ TBM_ERR("udev_new() failed.\n");
return -1;
}
@@ -760,7 +714,7 @@ _check_render_node(void)
if (device_parent) {
if (strcmp(udev_device_get_sysname(device_parent), "exynos-drm") == 0) {
drm_device = device;
- TBM_EXYNOS_DEBUG("Found render device: '%s' (%s)\n",
+ TBM_DBG("Found render device: '%s' (%s)\n",
udev_device_get_syspath(drm_device),
udev_device_get_sysname(device_parent));
break;
@@ -796,7 +750,7 @@ _get_render_node(void)
udev = udev_new();
if (!udev) {
- TBM_EXYNOS_ERROR("udev_new() failed.\n");
+ TBM_ERR("udev_new() failed.\n");
return -1;
}
@@ -813,7 +767,7 @@ _get_render_node(void)
if (device_parent) {
if (strcmp(udev_device_get_sysname(device_parent), "exynos-drm") == 0) {
drm_device = device;
- TBM_EXYNOS_DEBUG("Found render device: '%s' (%s)\n",
+ TBM_DBG("Found render device: '%s' (%s)\n",
udev_device_get_syspath(drm_device),
udev_device_get_sysname(device_parent));
break;
@@ -827,7 +781,7 @@ _get_render_node(void)
/* Get device file path. */
filepath = udev_device_get_devnode(drm_device);
if (!filepath) {
- TBM_EXYNOS_ERROR("udev_device_get_devnode() failed.\n");
+ TBM_ERR("udev_device_get_devnode() failed.\n");
udev_device_unref(drm_device);
udev_unref(udev);
return -1;
@@ -836,7 +790,7 @@ _get_render_node(void)
/* Open DRM device file and check validity. */
fd = open(filepath, O_RDWR | O_CLOEXEC);
if (fd < 0) {
- TBM_EXYNOS_ERROR("open(%s, O_RDWR | O_CLOEXEC) failed.\n");
+ TBM_ERR("open(%s, O_RDWR | O_CLOEXEC) failed.\n");
udev_device_unref(drm_device);
udev_unref(udev);
return -1;
@@ -844,7 +798,7 @@ _get_render_node(void)
ret = fstat(fd, &s);
if (ret) {
- TBM_EXYNOS_ERROR("fstat() failed %s.\n");
+ TBM_ERR("fstat() failed %s.\n");
udev_device_unref(drm_device);
udev_unref(udev);
close(fd);
@@ -899,7 +853,7 @@ _get_name(int fd, unsigned int gem)
arg.handle = gem;
if (drmIoctl(fd, DRM_IOCTL_GEM_FLINK, &arg)) {
- TBM_EXYNOS_ERROR("fail to DRM_IOCTL_GEM_FLINK gem:%d", gem);
+ TBM_ERR("fail to DRM_IOCTL_GEM_FLINK gem:%d", gem);
return 0;
}
@@ -927,7 +881,7 @@ _exynos_bo_handle(tbm_bo_exynos bo_exynos, int device)
if (drmCommandWriteRead(bo_exynos->fd, DRM_TBM_GEM_MMAP, &arg,
sizeof(arg))) {
- TBM_EXYNOS_ERROR("Cannot map_dumb gem=%d\n", bo_exynos->gem);
+ TBM_ERR("Cannot map_dumb gem=%d\n", bo_exynos->gem);
return (tbm_bo_handle) NULL;
}
@@ -947,7 +901,7 @@ _exynos_bo_handle(tbm_bo_exynos bo_exynos, int device)
arg.handle = bo_exynos->gem;
if (drmIoctl(bo_exynos->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) {
- TBM_EXYNOS_ERROR("Cannot dmabuf=%d\n", bo_exynos->gem);
+ TBM_ERR("Cannot dmabuf=%d\n", bo_exynos->gem);
return (tbm_bo_handle) NULL;
}
bo_exynos->dmabuf = arg.fd;
@@ -962,7 +916,7 @@ _exynos_bo_handle(tbm_bo_exynos bo_exynos, int device)
arg.handle = bo_exynos->gem;
if (drmIoctl(bo_exynos->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) {
- TBM_EXYNOS_ERROR("Cannot dmabuf=%d\n", bo_exynos->gem);
+ TBM_ERR("Cannot dmabuf=%d\n", bo_exynos->gem);
return (tbm_bo_handle) NULL;
}
bo_exynos->dmabuf = arg.fd;
@@ -971,7 +925,7 @@ _exynos_bo_handle(tbm_bo_exynos bo_exynos, int device)
bo_handle.u32 = (uint32_t)bo_exynos->dmabuf;
break;
default:
- TBM_EXYNOS_ERROR("Not supported device:%d\n", device);
+ TBM_ERR("Not supported device:%d\n", device);
bo_handle.ptr = (void *) NULL;
break;
}
@@ -1053,7 +1007,7 @@ tbm_exynos_bufmgr_bind_native_display(tbm_backend_bufmgr_data *bufmgr_data, tbm_
if (!tbm_drm_helper_wl_auth_server_init(native_display, bufmgr_exynos->fd,
bufmgr_exynos->device_name, 0)) {
- TBM_EXYNOS_ERROR("fail to tbm_drm_helper_wl_server_init\n");
+ TBM_ERR("fail to tbm_drm_helper_wl_server_init\n");
return TBM_ERROR_OPERATION_FAILED;
}
@@ -1080,7 +1034,7 @@ tbm_exynos_bufmgr_get_supported_formats(tbm_backend_bufmgr_data *bufmgr_data,
*formats = color_formats;
*num = TBM_COLOR_FORMAT_COUNT;
- TBM_EXYNOS_DEBUG("supported format count = %d\n", *num);
+ TBM_DBG("supported format count = %d\n", *num);
return TBM_ERROR_NONE;
}
@@ -1385,7 +1339,7 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b
unsigned int exynos_flags;
if (bufmgr_exynos == NULL) {
- TBM_EXYNOS_ERROR("bufmgr_data is null\n");
+ TBM_ERR("bufmgr_data is null\n");
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return NULL;
@@ -1393,7 +1347,7 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b
bo_exynos = calloc(1, sizeof(struct _tbm_bo_exynos));
if (!bo_exynos) {
- TBM_EXYNOS_ERROR("fail to allocate the bo_exynos private\n");
+ TBM_ERR("fail to allocate the bo_exynos private\n");
if (error)
*error = TBM_ERROR_OUT_OF_MEMORY;
return NULL;
@@ -1412,7 +1366,7 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b
arg.flags = exynos_flags;
if (drmCommandWriteRead(bufmgr_exynos->fd, DRM_EXYNOS_GEM_CREATE, &arg,
sizeof(arg))) {
- TBM_EXYNOS_ERROR("Cannot create bo_exynos(flag:%x, size:%d)\n", arg.flags,
+ TBM_ERR("Cannot create bo_exynos(flag:%x, size:%d)\n", arg.flags,
(unsigned int)arg.size);
free(bo_exynos);
if (error)
@@ -1428,7 +1382,7 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b
bo_exynos->name = _get_name(bo_exynos->fd, bo_exynos->gem);
if (!_bo_init_cache_state(bufmgr_exynos, bo_exynos, 0)) {
- TBM_EXYNOS_ERROR("fail init cache state(%d)\n", bo_exynos->name);
+ TBM_ERR("fail init cache state(%d)\n", bo_exynos->name);
free(bo_exynos);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
@@ -1442,7 +1396,7 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b
arg.handle = bo_exynos->gem;
if (drmIoctl(bo_exynos->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) {
- TBM_EXYNOS_ERROR("Cannot dmabuf=%d\n", bo_exynos->gem);
+ TBM_ERR("Cannot dmabuf=%d\n", bo_exynos->gem);
free(bo_exynos);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
@@ -1453,9 +1407,9 @@ tbm_exynos_bufmgr_alloc_bo(tbm_backend_bufmgr_data *bufmgr_data, int size, tbm_b
/* add bo_exynos to hash */
if (drmHashInsert(bufmgr_exynos->hashBos, bo_exynos->name, (void *)bo_exynos) < 0)
- TBM_EXYNOS_ERROR("Cannot insert bo_exynos to Hash(%d)\n", bo_exynos->name);
+ TBM_ERR("Cannot insert bo_exynos to Hash(%d)\n", bo_exynos->name);
- TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), flags:%d(%d), size:%d\n",
+ TBM_DBG(" bo_exynos:%p, gem:%d(%d), flags:%d(%d), size:%d\n",
bo_exynos,
bo_exynos->gem, bo_exynos->name,
flags, exynos_flags,
@@ -1479,7 +1433,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb
char buf[STRERR_BUFSIZE];
if (bufmgr_exynos == NULL) {
- TBM_EXYNOS_ERROR("bufmgr_data is null\n");
+ TBM_ERR("bufmgr_data is null\n");
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return NULL;
@@ -1491,7 +1445,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb
arg.fd = key;
arg.flags = 0;
if (drmIoctl(bufmgr_exynos->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) {
- TBM_EXYNOS_ERROR("Cannot get gem handle from fd:%d (%s)\n",
+ TBM_ERR("Cannot get gem handle from fd:%d (%s)\n",
arg.fd, strerror_r(errno, buf, STRERR_BUFSIZE));
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
@@ -1501,7 +1455,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb
name = _get_name(bufmgr_exynos->fd, gem);
if (!name) {
- TBM_EXYNOS_ERROR("Cannot get name from gem:%d, fd:%d (%s)\n",
+ TBM_ERR("Cannot get name from gem:%d, fd:%d (%s)\n",
gem, key, strerror_r(errno, buf, STRERR_BUFSIZE));
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
@@ -1533,7 +1487,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb
DRM_EXYNOS_GEM_GET,
&info,
sizeof(struct drm_exynos_gem_info))) {
- TBM_EXYNOS_ERROR("Cannot get gem info from gem:%d, fd:%d (%s)\n",
+ TBM_ERR("Cannot get gem info from gem:%d, fd:%d (%s)\n",
gem, key, strerror_r(errno, buf, STRERR_BUFSIZE));
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
@@ -1545,7 +1499,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb
bo_exynos = calloc(1, sizeof(struct _tbm_bo_exynos));
if (!bo_exynos) {
- TBM_EXYNOS_ERROR("bo_exynos:%p fail to allocate the bo_exynos\n", bo_exynos);
+ TBM_ERR("bo_exynos:%p fail to allocate the bo_exynos\n", bo_exynos);
if (error)
*error = TBM_ERROR_OUT_OF_MEMORY;
return NULL;
@@ -1560,7 +1514,7 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb
bo_exynos->name = name;
if (!_bo_init_cache_state(bufmgr_exynos, bo_exynos, 1)) {
- TBM_EXYNOS_ERROR("fail init cache state(%d)\n", bo_exynos->name);
+ TBM_ERR("fail init cache state(%d)\n", bo_exynos->name);
free(bo_exynos);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
@@ -1569,10 +1523,10 @@ tbm_exynos_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tb
/* add bo_exynos to hash */
if (drmHashInsert(bufmgr_exynos->hashBos, bo_exynos->name, (void *)bo_exynos) < 0)
- TBM_EXYNOS_ERROR("bo_exynos:%p Cannot insert bo_exynos to Hash(%d) from gem:%d, fd:%d\n",
+ TBM_ERR("bo_exynos:%p Cannot insert bo_exynos to Hash(%d) from gem:%d, fd:%d\n",
bo_exynos, bo_exynos->name, gem, key);
- TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n",
+ TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n",
bo_exynos,
bo_exynos->gem, bo_exynos->name,
bo_exynos->dmabuf,
@@ -1594,7 +1548,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key,
int ret;
if (bufmgr_exynos == NULL) {
- TBM_EXYNOS_ERROR("bufmgr_data is null\n");
+ TBM_ERR("bufmgr_data is null\n");
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return NULL;
@@ -1612,7 +1566,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key,
arg.name = key;
if (drmIoctl(bufmgr_exynos->fd, DRM_IOCTL_GEM_OPEN, &arg)) {
- TBM_EXYNOS_ERROR("Cannot open gem name=%d\n", key);
+ TBM_ERR("Cannot open gem name=%d\n", key);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
return NULL;
@@ -1623,7 +1577,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key,
DRM_EXYNOS_GEM_GET,
&info,
sizeof(struct drm_exynos_gem_info))) {
- TBM_EXYNOS_ERROR("Cannot get gem info=%d\n", key);
+ TBM_ERR("Cannot get gem info=%d\n", key);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
return NULL;
@@ -1631,7 +1585,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key,
bo_exynos = calloc(1, sizeof(struct _tbm_bo_exynos));
if (!bo_exynos) {
- TBM_EXYNOS_ERROR("fail to allocate the bo_exynos private\n");
+ TBM_ERR("fail to allocate the bo_exynos private\n");
if (error)
*error = TBM_ERROR_OUT_OF_MEMORY;
return NULL;
@@ -1646,7 +1600,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key,
bo_exynos->flags_tbm = _get_tbm_flag_from_exynos(bo_exynos->flags_exynos);
if (!_bo_init_cache_state(bufmgr_exynos, bo_exynos, 1)) {
- TBM_EXYNOS_ERROR("fail init cache state(%d)\n", bo_exynos->name);
+ TBM_ERR("fail init cache state(%d)\n", bo_exynos->name);
free(bo_exynos);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
@@ -1658,7 +1612,7 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key,
arg.handle = bo_exynos->gem;
if (drmIoctl(bo_exynos->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) {
- TBM_EXYNOS_ERROR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD gem=%d\n", bo_exynos->gem);
+ TBM_ERR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD gem=%d\n", bo_exynos->gem);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
free(bo_exynos);
@@ -1669,9 +1623,9 @@ tbm_exynos_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key,
/* add bo_exynos to hash */
if (drmHashInsert(bufmgr_exynos->hashBos, bo_exynos->name, (void *)bo_exynos) < 0)
- TBM_EXYNOS_ERROR("Cannot insert bo_exynos to Hash(%d)\n", bo_exynos->name);
+ TBM_ERR("Cannot insert bo_exynos to Hash(%d)\n", bo_exynos->name);
- TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n",
+ TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n",
bo_exynos,
bo_exynos->gem, bo_exynos->name,
bo_exynos->dmabuf,
@@ -1700,7 +1654,7 @@ tbm_exynos_bo_free(tbm_backend_bo_data *bo_data)
if (!bufmgr_exynos)
return;
- TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, size:%d\n",
+ TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, size:%d\n",
bo_exynos,
bo_exynos->gem, bo_exynos->name,
bo_exynos->dmabuf,
@@ -1708,7 +1662,7 @@ tbm_exynos_bo_free(tbm_backend_bo_data *bo_data)
if (bo_exynos->pBase) {
if (munmap(bo_exynos->pBase, bo_exynos->size) == -1) {
- TBM_EXYNOS_ERROR("bo_exynos:%p fail to munmap(%s)\n",
+ TBM_ERR("bo_exynos:%p fail to munmap(%s)\n",
bo_exynos, strerror_r(errno, buf, STRERR_BUFSIZE));
}
}
@@ -1724,10 +1678,10 @@ tbm_exynos_bo_free(tbm_backend_bo_data *bo_data)
if (ret == 0)
drmHashDelete(bufmgr_exynos->hashBos, bo_exynos->name);
else
- TBM_EXYNOS_ERROR("Cannot find bo_exynos to Hash(%d), ret=%d\n", bo_exynos->name, ret);
+ TBM_ERR("Cannot find bo_exynos to Hash(%d), ret=%d\n", bo_exynos->name, ret);
if (temp != bo_exynos)
- TBM_EXYNOS_ERROR("hashBos probably has several BOs with same name!!!\n");
+ TBM_ERR("hashBos probably has several BOs with same name!!!\n");
_bo_destroy_cache_state(bufmgr_exynos, bo_exynos);
@@ -1737,7 +1691,7 @@ tbm_exynos_bo_free(tbm_backend_bo_data *bo_data)
memset(&arg, 0, sizeof(arg));
arg.handle = bo_exynos->gem;
if (drmIoctl(bo_exynos->fd, DRM_IOCTL_GEM_CLOSE, &arg))
- TBM_EXYNOS_ERROR("bo_exynos:%p fail to gem close.(%s)\n",
+ TBM_ERR("bo_exynos:%p fail to gem close.(%s)\n",
bo_exynos, strerror_r(errno, buf, STRERR_BUFSIZE));
free(bo_exynos);
@@ -1790,13 +1744,13 @@ tbm_exynos_bo_get_handle(tbm_backend_bo_data *bo_data, tbm_bo_device_type device
}
if (!bo_exynos->gem) {
- TBM_EXYNOS_ERROR("Cannot map gem=%d\n", bo_exynos->gem);
+ TBM_ERR("Cannot map gem=%d\n", bo_exynos->gem);
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return (tbm_bo_handle) NULL;
}
- TBM_EXYNOS_DEBUG("bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d, %s\n",
+ TBM_DBG("bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d, %s\n",
bo_exynos,
bo_exynos->gem, bo_exynos->name,
bo_exynos->dmabuf,
@@ -1807,7 +1761,7 @@ tbm_exynos_bo_get_handle(tbm_backend_bo_data *bo_data, tbm_bo_device_type device
/*Get mapped bo_handle*/
bo_handle = _exynos_bo_handle(bo_exynos, device);
if (bo_handle.ptr == NULL) {
- TBM_EXYNOS_ERROR("Cannot get handle: gem:%d, device:%d\n",
+ TBM_ERR("Cannot get handle: gem:%d, device:%d\n",
bo_exynos->gem, device);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
@@ -1842,13 +1796,13 @@ tbm_exynos_bo_map(tbm_backend_bo_data *bo_data, tbm_bo_device_type device,
}
if (!bo_exynos->gem) {
- TBM_EXYNOS_ERROR("Cannot map gem=%d\n", bo_exynos->gem);
+ TBM_ERR("Cannot map gem=%d\n", bo_exynos->gem);
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return (tbm_bo_handle) NULL;
}
- TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, %s, %s\n",
+ TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, %s, %s\n",
bo_exynos,
bo_exynos->gem, bo_exynos->name,
bo_exynos->dmabuf,
@@ -1858,7 +1812,7 @@ tbm_exynos_bo_map(tbm_backend_bo_data *bo_data, tbm_bo_device_type device,
/*Get mapped bo_handle*/
bo_handle = _exynos_bo_handle(bo_exynos, device);
if (bo_handle.ptr == NULL) {
- TBM_EXYNOS_ERROR("Cannot get handle: gem:%d, device:%d, opt:%d\n",
+ TBM_ERR("Cannot get handle: gem:%d, device:%d, opt:%d\n",
bo_exynos->gem, device, opt);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
@@ -1906,7 +1860,7 @@ tbm_exynos_bo_unmap(tbm_backend_bo_data *bo_data)
bo_exynos->last_map_device = -1;
- TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d\n",
+ TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d\n",
bo_exynos,
bo_exynos->gem, bo_exynos->name,
bo_exynos->dmabuf);
@@ -1942,7 +1896,7 @@ tbm_exynos_bo_lock(tbm_backend_bo_data *bo_data, tbm_bo_device_type device,
if (drmCommandWriteRead(bo_exynos->fd, DRM_TBM_GEM_CPU_PREP,
&arg, sizeof(arg))) {
- TBM_EXYNOS_ERROR("Can not prepare CPU gem=%d(%s)\n",
+ TBM_ERR("Can not prepare CPU gem=%d(%s)\n",
arg.handle, strerror_r(errno, buf, STRERR_BUFSIZE));
return TBM_ERROR_OPERATION_FAILED;
}
@@ -1980,7 +1934,7 @@ tbm_exynos_bo_unlock(tbm_backend_bo_data *bo_data)
if (drmCommandWriteRead(bo_exynos->fd, DRM_TBM_GEM_CPU_FINI,
&arg, sizeof(arg))) {
- TBM_EXYNOS_ERROR("Can not fini CPU gem=%d(%s)\n",
+ TBM_ERR("Can not fini CPU gem=%d(%s)\n",
arg.handle, strerror_r(errno, buf, STRERR_BUFSIZE));
return TBM_ERROR_OPERATION_FAILED;
}
@@ -2009,14 +1963,14 @@ tbm_exynos_bo_export_fd(tbm_backend_bo_data *bo_data, tbm_error_e *error)
arg.handle = bo_exynos->gem;
ret = drmIoctl(bo_exynos->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg);
if (ret) {
- TBM_EXYNOS_ERROR("bo_exynos:%p Cannot dmabuf=%d (%s)\n",
+ TBM_ERR("bo_exynos:%p Cannot dmabuf=%d (%s)\n",
bo_exynos, bo_exynos->gem, strerror_r(errno, buf, STRERR_BUFSIZE));
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
return (tbm_fd) ret;
}
- TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n",
+ TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n",
bo_exynos,
bo_exynos->gem, bo_exynos->name,
bo_exynos->dmabuf,
@@ -2044,14 +1998,14 @@ tbm_exynos_bo_export_key(tbm_backend_bo_data *bo_data, tbm_error_e *error)
if (!bo_exynos->name) {
bo_exynos->name = _get_name(bo_exynos->fd, bo_exynos->gem);
if (!bo_exynos->name) {
- TBM_EXYNOS_ERROR("error Cannot get name\n");
+ TBM_ERR("error Cannot get name\n");
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return 0;
}
}
- TBM_EXYNOS_DEBUG(" bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n",
+ TBM_DBG(" bo_exynos:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n",
bo_exynos,
bo_exynos->gem, bo_exynos->name,
bo_exynos->dmabuf,
@@ -2118,7 +2072,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error)
tbm_error_e err;
if (!bufmgr) {
- TBM_EXYNOS_ERROR("bufmgr is null.\n");
+ TBM_ERR("bufmgr is null.\n");
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return NULL;
@@ -2126,7 +2080,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error)
bufmgr_exynos = calloc(1, sizeof(struct _tbm_bufmgr_exynos));
if (!bufmgr_exynos) {
- TBM_EXYNOS_ERROR("fail to alloc bufmgr_exynos!\n");
+ TBM_ERR("fail to alloc bufmgr_exynos!\n");
if (error)
*error = TBM_ERROR_OUT_OF_MEMORY;
return NULL;
@@ -2137,7 +2091,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error)
if (bufmgr_exynos->fd < 0) {
bufmgr_exynos->fd = _tbm_exynos_open_drm();
if (bufmgr_exynos->fd < 0) {
- TBM_EXYNOS_ERROR("fail to open drm!\n");
+ TBM_ERR("fail to open drm!\n");
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
goto fail_open_drm;
@@ -2148,7 +2102,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error)
bufmgr_exynos->device_name = drmGetDeviceNameFromFd(bufmgr_exynos->fd);
if (!bufmgr_exynos->device_name) {
- TBM_EXYNOS_ERROR("fail to get device name!\n");
+ TBM_ERR("fail to get device name!\n");
tbm_drm_helper_unset_tbm_master_fd();
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
@@ -2158,15 +2112,15 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error)
if (_check_render_node()) {
bufmgr_exynos->fd = _get_render_node();
if (bufmgr_exynos->fd < 0) {
- TBM_EXYNOS_ERROR("fail to get render node\n");
+ TBM_ERR("fail to get render node\n");
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
goto fail_get_render_node;
}
- TBM_EXYNOS_DEBUG("Use render node:%d\n", bufmgr_exynos->fd);
+ TBM_DBG("Use render node:%d\n", bufmgr_exynos->fd);
} else {
if (!tbm_drm_helper_get_auth_info(&(bufmgr_exynos->fd), &(bufmgr_exynos->device_name), NULL)) {
- TBM_EXYNOS_ERROR("fail to get auth drm info!\n");
+ TBM_ERR("fail to get auth drm info!\n");
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
goto fail_get_auth_info;
@@ -2188,7 +2142,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error)
}
if (!_bufmgr_init_cache_state(bufmgr_exynos)) {
- TBM_EXYNOS_ERROR("fail to init bufmgr cache state\n");
+ TBM_ERR("fail to init bufmgr cache state\n");
goto fail_init_cache_state;
}
@@ -2198,7 +2152,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error)
/* alloc and register bufmgr_funcs */
bufmgr_func = tbm_backend_bufmgr_alloc_bufmgr_func(bufmgr, &err);
if (!bufmgr_func) {
- TBM_EXYNOS_ERROR("fail to alloc bufmgr_func! err(%d)\n", err);
+ TBM_ERR("fail to alloc bufmgr_func! err(%d)\n", err);
if (error)
*error = TBM_ERROR_OUT_OF_MEMORY;
goto fail_alloc_bufmgr_func;
@@ -2216,7 +2170,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error)
err = tbm_backend_bufmgr_register_bufmgr_func(bufmgr, bufmgr_func);
if (err != TBM_ERROR_NONE) {
- TBM_EXYNOS_ERROR("fail to register bufmgr_func! err(%d)\n", err);
+ TBM_ERR("fail to register bufmgr_func! err(%d)\n", err);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
goto fail_register_bufmgr_func;
@@ -2226,7 +2180,7 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error)
/* alloc and register bo_funcs */
bo_func = tbm_backend_bufmgr_alloc_bo_func(bufmgr, &err);
if (!bo_func) {
- TBM_EXYNOS_ERROR("fail to alloc bo_func! err(%d)\n", err);
+ TBM_ERR("fail to alloc bo_func! err(%d)\n", err);
if (error)
*error = TBM_ERROR_OUT_OF_MEMORY;
goto fail_alloc_bo_func;
@@ -2245,27 +2199,14 @@ tbm_exynos_init(tbm_bufmgr bufmgr, tbm_error_e *error)
err = tbm_backend_bufmgr_register_bo_func(bufmgr, bo_func);
if (err != TBM_ERROR_NONE) {
- TBM_EXYNOS_ERROR("fail to register bo_func! err(%d)\n", err);
+ TBM_ERR("fail to register bo_func! err(%d)\n", err);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
goto fail_register_bo_func;
}
bufmgr_exynos->bo_func = bo_func;
-#ifdef DEBUG
- {
- char *env;
-
- env = getenv("TBM_EXYNOS_DEBUG");
- if (env) {
- bDebug = atoi(env);
- TBM_EXYNOS_ERROR("TBM_EXYNOS_DEBUG=%s\n", env);
- } else
- bDebug = 0;
- }
-#endif
-
- TBM_EXYNOS_DEBUG("drm_fd:%d\n", bufmgr_exynos->fd);
+ TBM_DBG("drm_fd:%d\n", bufmgr_exynos->fd);
if (error)
*error = TBM_ERROR_NONE;