#include <pthread.h>
#include <tbm_backend.h>
#include <tbm_drm_helper.h>
+#include <tbm_log.h>
-#define DEBUG
//#define USE_CONTIG_ONLY
//#define USE_CACHE
#define USE_DMAIMPORT
#define TBM_COLOR_FORMAT_COUNT 4
-#ifdef DEBUG
-#define LOG_TAG "TBM_BACKEND"
-#include <dlog.h>
-static int bDebug = 0;
-
#define SPRD_DRM_NAME "sprd"
-static char *
-_target_name(void)
-{
- 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_SPRD_ERROR(fmt, args...) LOGE("\033[31m" "[%s] " fmt "\033[0m", _target_name(), ##args)
-#define TBM_SPRD_DEBUG(fmt, args...) if (bDebug&01) LOGD("[%s] " fmt, _target_name(), ##args)
-#else
-#define TBM_SPRD_ERROR(...)
-#define TBM_SPRD_DEBUG(...)
-#endif
-
#define STRERR_BUFSIZE 128
#define SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1))
/* check condition */
#define SPRD_RETURN_IF_FAIL(cond) {\
if (!(cond)) {\
- TBM_SPRD_ERROR("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\
+ TBM_ERR("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\
return;\
} \
}
#define SPRD_RETURN_VAL_IF_FAIL(cond, val) {\
if (!(cond)) {\
- TBM_SPRD_ERROR("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\
+ TBM_ERR("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\
return val;\
} \
}
err = ioctl(fd, TGL_IOCTL_GET_VERSION, &data);
if (err) {
- TBM_SPRD_ERROR("error(%s) %s:%d\n",
+ TBM_ERR("error(%s) %s:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE));
return 0;
}
- TBM_SPRD_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;
}
err = ioctl(fd, TGL_IOCTL_REGISTER, &data);
if (err) {
- TBM_SPRD_ERROR("error(%s) key:%d\n",
+ TBM_ERR("error(%s) key:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE), key);
return 0;
}
data.key = key;
err = ioctl(fd, TGL_IOCTL_UNREGISTER, &data);
if (err) {
- TBM_SPRD_ERROR("error(%s) key:%d\n",
+ TBM_ERR("error(%s) key:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE), key);
return 0;
}
err = ioctl(fd, TGL_IOCTL_LOCK, &data);
if (err) {
- TBM_SPRD_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;
}
err = ioctl(fd, TGL_IOCTL_UNLOCK, &data);
if (err) {
- TBM_SPRD_ERROR("error(%s) key:%d\n",
+ TBM_ERR("error(%s) key:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE), key);
return 0;
}
err = ioctl(fd, TGL_IOCTL_SET_DATA, &data);
if (err) {
- TBM_SPRD_ERROR("error(%s) key:%d\n",
+ TBM_ERR("error(%s) key:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE), key);
return 0;
}
err = ioctl(fd, TGL_IOCTL_GET_DATA, &data);
if (err) {
- TBM_SPRD_ERROR("error(%s) key:%d\n",
+ TBM_ERR("error(%s) key:%d\n",
strerror_r(errno, buf, STRERR_BUFSIZE), key);
return 0;
}
return fd;
#ifdef HAVE_UDEV
- TBM_SPRD_DEBUG("warning fail to open drm. search drm-device by udev\n");
+ TBM_DBG("warning fail to open drm. search drm-device by udev\n");
udev = udev_new();
if (!udev) {
- TBM_SPRD_ERROR("udev_new() failed.\n");
+ TBM_ERR("udev_new() failed.\n");
return -1;
}
if (device_parent) {
if (strcmp(udev_device_get_sysname(device_parent), "sprd-drm") == 0) {
drm_device = device;
- TBM_SPRD_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;
/* Get device file path. */
filepath = udev_device_get_devnode(drm_device);
if (!filepath) {
- TBM_SPRD_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;
/* Open DRM device file and check validity. */
fd = open(filepath, O_RDWR | O_CLOEXEC);
if (fd < 0) {
- TBM_SPRD_ERROR("open(%s, O_RDWR | O_CLOEXEC) failed.\n");
+ TBM_ERR("open(%s, O_RDWR | O_CLOEXEC) failed.\n");
return -1;
}
if (fstat(fd, &s)) {
- TBM_SPRD_ERROR("fstat() failed %s.\n");
+ TBM_ERR("fstat() failed %s.\n");
close(fd);
return -1;
}
ret = drmCommandWriteRead(bufmgr_sprd->fd, DRM_SPRD_GEM_CACHE_OP, &cache_op,
sizeof(cache_op));
if (ret) {
- TBM_SPRD_ERROR("error fail to flush the cache.\n");
+ TBM_ERR("error fail to flush the cache.\n");
return 0;
}
#endif
/* call cache flush */
_sprd_bo_cache_flush(bufmgr_sprd, bo_sprd, need_flush);
- TBM_SPRD_DEBUG("\tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n",
+ TBM_DBG("\tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n",
bo_sprd->cache_state.data.isCached,
bo_sprd->cache_state.data.isDirtied,
need_flush,
if (bufmgr_sprd->tgl_fd < 0) {
bufmgr_sprd->tgl_fd = open(tgl_devfile1, O_RDWR);
if (bufmgr_sprd->tgl_fd < 0) {
- TBM_SPRD_ERROR("fail to open global_lock:%s\n",
+ TBM_ERR("fail to open global_lock:%s\n",
tgl_devfile1);
return 0;
}
}
if (!_tgl_get_version(bufmgr_sprd->tgl_fd)) {
- TBM_SPRD_ERROR("fail to get tgl_version. tgl init failed.\n");
+ TBM_ERR("fail to get tgl_version. tgl init failed.\n");
close(bufmgr_sprd->tgl_fd);
return 0;
}
if (!_tgl_init(bufmgr_sprd->tgl_fd, GLOBAL_KEY)) {
- TBM_SPRD_ERROR("fail to initialize the tgl\n");
+ TBM_ERR("fail to initialize the tgl\n");
close(bufmgr_sprd->tgl_fd);
return 0;
}
arg.handle = gem;
if (drmIoctl(fd, DRM_IOCTL_GEM_FLINK, &arg)) {
- TBM_SPRD_ERROR("fail to DRM_IOCTL_GEM_FLINK gem:%d", gem);
+ TBM_ERR("fail to DRM_IOCTL_GEM_FLINK gem:%d", gem);
return 0;
}
arg.handle = bo_sprd->gem;
arg.size = bo_sprd->size;
if (drmCommandWriteRead(bo_sprd->fd, DRM_SPRD_GEM_MMAP, &arg, sizeof(arg))) {
- TBM_SPRD_ERROR("error Cannot usrptr gem=%d\n", bo_sprd->gem);
+ TBM_ERR("error Cannot usrptr gem=%d\n", bo_sprd->gem);
return (tbm_bo_handle) NULL;
}
bo_sprd->pBase = (void *)((uint32_t)arg.mapped);
struct drm_prime_handle arg = {0, };
arg.handle = bo_sprd->gem;
if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) {
- TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem);
+ TBM_ERR("error Cannot dmabuf=%d\n", bo_sprd->gem);
return (tbm_bo_handle) NULL;
}
bo_sprd->dmabuf = arg.fd;
case TBM_DEVICE_MM:
#ifdef USE_HEAP_ID
//TODO : Add ioctl for GSP MAP once available.
- TBM_SPRD_DEBUG("%s In case TBM_DEVICE_MM: \n", __FUNCTION_);
+ TBM_DBG("%s In case TBM_DEVICE_MM: \n", __FUNCTION_);
#else
if (!bo_sprd->dmabuf) {
struct drm_prime_handle arg = {0, };
arg.handle = bo_sprd->gem;
if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) {
- TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem);
+ TBM_ERR("error Cannot dmabuf=%d\n", bo_sprd->gem);
return (tbm_bo_handle) NULL;
}
bo_sprd->dmabuf = arg.fd;
#endif
break;
default:
- TBM_SPRD_ERROR("Not supported device:%d\n", device);
+ TBM_ERR("Not supported device:%d\n", device);
bo_handle.ptr = (void *) NULL;
break;
}
if (!tbm_drm_helper_wl_auth_server_init(native_display, bufmgr_sprd->fd,
bufmgr_sprd->device_name, 0)) {
- TBM_SPRD_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;
}
*formats = color_formats;
*num = TBM_COLOR_FORMAT_COUNT;
- TBM_SPRD_DEBUG("supported format count = %d\n", *num);
+ TBM_DBG("supported format count = %d\n", *num);
return TBM_ERROR_NONE;
}
unsigned int sprd_flags;
if (bufmgr_sprd == NULL) {
- TBM_SPRD_ERROR("bufmgr_data is null\n");
+ TBM_ERR("bufmgr_data is null\n");
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return NULL;
bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd));
if (!bo_sprd) {
- TBM_SPRD_ERROR("error fail to allocate the bo_sprd\n");
+ TBM_ERR("error fail to allocate the bo_sprd\n");
if (error)
*error = TBM_ERROR_OUT_OF_MEMORY;
return NULL;
arg.flags = sprd_flags;
if (drmCommandWriteRead(bufmgr_sprd->fd, DRM_SPRD_GEM_CREATE, &arg,
sizeof(arg))) {
- TBM_SPRD_ERROR("error Cannot create bo_sprd(flag:%x, size:%d)\n",
+ TBM_ERR("error Cannot create bo_sprd(flag:%x, size:%d)\n",
arg.flags, (unsigned int)arg.size);
free(bo_sprd);
if (error)
bo_sprd->name = _get_name(bo_sprd->fd, bo_sprd->gem);
if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 0)) {
- TBM_SPRD_ERROR("error fail init cache state(%d)\n", bo_sprd->name);
+ TBM_ERR("error fail init cache state(%d)\n", bo_sprd->name);
free(bo_sprd);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
arg.handle = bo_sprd->gem;
if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) {
- TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem);
+ TBM_ERR("error Cannot dmabuf=%d\n", bo_sprd->gem);
free(bo_sprd);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
/* add bo_sprd to hash */
if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)bo_sprd) < 0)
- TBM_SPRD_ERROR("Cannot insert bo_sprd to Hash(%d)\n", bo_sprd->name);
+ TBM_ERR("Cannot insert bo_sprd to Hash(%d)\n", bo_sprd->name);
- TBM_SPRD_DEBUG("%s size:%d, gem:%d(%d), flags:%d(%d)\n",
+ TBM_DBG("%s size:%d, gem:%d(%d), flags:%d(%d)\n",
__FUNCTION__, bo_sprd->size,
bo_sprd->gem, bo_sprd->name,
flags, sprd_flags);
char buf[STRERR_BUFSIZE];
if (bufmgr_sprd == NULL) {
- TBM_SPRD_ERROR("bufmgr_data is null\n");
+ TBM_ERR("bufmgr_data is null\n");
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return NULL;
arg.fd = key;
if (drmIoctl(bufmgr_sprd->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) {
- TBM_SPRD_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;
name = _get_name(bufmgr_sprd->fd, gem);
if (!name) {
- TBM_SPRD_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;
DRM_SPRD_GEM_GET,
&info,
sizeof(struct drm_sprd_gem_info))) {
- TBM_SPRD_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;
bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd));
if (!bo_sprd) {
- TBM_SPRD_ERROR("error bo_sprd:%p fail to allocate the bo_sprd\n", bo_sprd);
+ TBM_ERR("error bo_sprd:%p fail to allocate the bo_sprd\n", bo_sprd);
if (error)
*error = TBM_ERROR_OUT_OF_MEMORY;
return NULL;
bo_sprd->name = name;
if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 1)) {
- TBM_SPRD_ERROR("error fail init cache state(%d)\n", bo_sprd->name);
+ TBM_ERR("error fail init cache state(%d)\n", bo_sprd->name);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
goto fail_init_cache;
/* add bo_sprd to hash */
if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)bo_sprd) < 0)
- TBM_SPRD_ERROR("bo_sprd:%p Cannot insert bo_sprd to Hash(%d) from gem:%d, fd:%d\n",
+ TBM_ERR("bo_sprd:%p Cannot insert bo_sprd to Hash(%d) from gem:%d, fd:%d\n",
bo_sprd, bo_sprd->name, gem, key);
- TBM_SPRD_DEBUG("bo_sprd:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n",
+ TBM_DBG("bo_sprd:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n",
bo_sprd,
bo_sprd->gem, bo_sprd->name,
bo_sprd->dmabuf,
int ret;
if (bufmgr_sprd == NULL) {
- TBM_SPRD_ERROR("bufmgr_data is null\n");
+ TBM_ERR("bufmgr_data is null\n");
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return NULL;
arg.name = key;
if (drmIoctl(bufmgr_sprd->fd, DRM_IOCTL_GEM_OPEN, &arg)) {
- TBM_SPRD_ERROR("error Cannot open gem name=%d\n", key);
+ TBM_ERR("error Cannot open gem name=%d\n", key);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
return NULL;
DRM_SPRD_GEM_GET,
&info,
sizeof(struct drm_sprd_gem_info))) {
- TBM_SPRD_ERROR("error Cannot get gem info=%d\n", key);
+ TBM_ERR("error Cannot get gem info=%d\n", key);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
goto fail_get_gem;
bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd));
if (!bo_sprd) {
- TBM_SPRD_ERROR("error fail to allocate the bo_sprd\n");
+ TBM_ERR("error fail to allocate the bo_sprd\n");
if (error)
*error = TBM_ERROR_OUT_OF_MEMORY;
goto fail_alloc_bo;
#endif
if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 1)) {
- TBM_SPRD_ERROR("error fail init cache state(%d)\n", bo_sprd->name);
+ TBM_ERR("error fail init cache state(%d)\n", bo_sprd->name);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
goto fail_init_cache;
arg.handle = bo_sprd->gem;
if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) {
- TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem);
+ TBM_ERR("error Cannot dmabuf=%d\n", bo_sprd->gem);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
goto fail_prime_handle_to_fd;
/* add bo_sprd to hash */
if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)bo_sprd) < 0)
- TBM_SPRD_ERROR("Cannot insert bo_sprd to Hash(%d)\n", bo_sprd->name);
+ TBM_ERR("Cannot insert bo_sprd to Hash(%d)\n", bo_sprd->name);
- TBM_SPRD_DEBUG(" bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n",
+ TBM_DBG(" bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n",
bo_sprd,
bo_sprd->gem, bo_sprd->name,
bo_sprd->dmabuf,
if (!bufmgr_sprd)
return;
- TBM_SPRD_DEBUG(" bo_sprd:%p, gem:%d(%d), fd:%d, size:%d\n",
+ TBM_DBG(" bo_sprd:%p, gem:%d(%d), fd:%d, size:%d\n",
bo_sprd,
bo_sprd->gem, bo_sprd->name,
bo_sprd->dmabuf,
if (bo_sprd->pBase) {
if (munmap(bo_sprd->pBase, bo_sprd->size) == -1) {
- TBM_SPRD_ERROR("bo_sprd:%p fail to munmap(%s)\n",
+ TBM_ERR("bo_sprd:%p fail to munmap(%s)\n",
bo_sprd, strerror_r(errno, buf, STRERR_BUFSIZE));
}
}
if (ret == 0)
drmHashDelete(bufmgr_sprd->hashBos, bo_sprd->name);
else
- TBM_SPRD_ERROR("Cannot find bo_sprd to Hash(%d), ret=%d\n", bo_sprd->name, ret);
+ TBM_ERR("Cannot find bo_sprd to Hash(%d), ret=%d\n", bo_sprd->name, ret);
if (temp != bo_sprd)
- TBM_SPRD_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_sprd, bo_sprd);
memset(&arg, 0, sizeof(arg));
arg.handle = bo_sprd->gem;
if (drmIoctl(bo_sprd->fd, DRM_IOCTL_GEM_CLOSE, &arg))
- TBM_SPRD_ERROR("bo_sprd:%p fail to gem close.(%s)\n",
+ TBM_ERR("bo_sprd:%p fail to gem close.(%s)\n",
bo_sprd, strerror_r(errno, buf, STRERR_BUFSIZE));
free(bo_sprd);
}
}
if (!bo_sprd->gem) {
- TBM_SPRD_ERROR("Cannot map gem=%d\n", bo_sprd->gem);
+ TBM_ERR("Cannot map gem=%d\n", bo_sprd->gem);
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return (tbm_bo_handle) NULL;
}
- TBM_SPRD_DEBUG("bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d, %s\n",
+ TBM_DBG("bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d, %s\n",
bo_sprd,
bo_sprd->gem, bo_sprd->name,
bo_sprd->dmabuf,
/*Get mapped bo_handle*/
bo_handle = _sprd_bo_handle(bo_sprd, device);
if (bo_handle.ptr == NULL) {
- TBM_SPRD_ERROR("Cannot get handle: gem:%d, device:%d\n",
+ TBM_ERR("Cannot get handle: gem:%d, device:%d\n",
bo_sprd->gem, device);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
}
if (!bo_sprd->gem) {
- TBM_SPRD_ERROR("Cannot map gem=%d\n", bo_sprd->gem);
+ TBM_ERR("Cannot map gem=%d\n", bo_sprd->gem);
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return (tbm_bo_handle) NULL;
}
- TBM_SPRD_DEBUG(" bo_sprd:%p, gem:%d(%d), fd:%d, %s, %s\n",
+ TBM_DBG(" bo_sprd:%p, gem:%d(%d), fd:%d, %s, %s\n",
bo_sprd,
bo_sprd->gem, bo_sprd->name,
bo_sprd->dmabuf,
/*Get mapped bo_handle*/
bo_handle = _sprd_bo_handle(bo_sprd, device);
if (bo_handle.ptr == NULL) {
- TBM_SPRD_ERROR("Cannot get handle: gem:%d, device:%d, opt:%d\n",
+ TBM_ERR("Cannot get handle: gem:%d, device:%d, opt:%d\n",
bo_sprd->gem, device, opt);
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
if (bo_sprd->map_cnt == 0)
_bo_save_cache_state(bufmgr_sprd, bo_sprd);
- TBM_SPRD_DEBUG(" bo_sprd:%p, gem:%d(%d), fd:%d\n",
+ TBM_DBG(" bo_sprd:%p, gem:%d(%d), fd:%d\n",
bo_sprd,
bo_sprd->gem, bo_sprd->name,
bo_sprd->dmabuf);
arg.handle = bo_sprd->gem;
ret = drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg);
if (ret) {
- TBM_SPRD_ERROR("bo_sprd:%p Cannot dmabuf=%d (%s)\n",
+ TBM_ERR("bo_sprd:%p Cannot dmabuf=%d (%s)\n",
bo_sprd, bo_sprd->gem, strerror_r(errno, buf, STRERR_BUFSIZE));
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
return (tbm_fd) ret;
}
- TBM_SPRD_DEBUG("bo_sprd:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n",
+ TBM_DBG("bo_sprd:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n",
bo_sprd,
bo_sprd->gem, bo_sprd->name,
bo_sprd->dmabuf,
if (!bo_sprd->name) {
bo_sprd->name = _get_name(bo_sprd->fd, bo_sprd->gem);
if (!bo_sprd->name) {
- TBM_SPRD_ERROR("error Cannot get name\n");
+ TBM_ERR("error Cannot get name\n");
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return 0;
}
}
- TBM_SPRD_DEBUG(" bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n",
+ TBM_DBG(" bo_sprd:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d\n",
bo_sprd,
bo_sprd->gem, bo_sprd->name,
bo_sprd->dmabuf,
tbm_error_e err;
if (!bufmgr) {
- TBM_SPRD_ERROR("bufmgr is null.\n");
+ TBM_ERR("bufmgr is null.\n");
if (error)
*error = TBM_ERROR_INVALID_PARAMETER;
return NULL;
bufmgr_sprd = calloc(1, sizeof(struct _tbm_bufmgr_sprd));
if (!bufmgr_sprd) {
- TBM_SPRD_ERROR("fail to alloc bufmgr_sprd!\n");
+ TBM_ERR("fail to alloc bufmgr_sprd!\n");
if (error)
*error = TBM_ERROR_OUT_OF_MEMORY;
return NULL;
if (bufmgr_sprd->fd < 0) {
bufmgr_sprd->fd = _tbm_sprd_open_drm();
if (bufmgr_sprd->fd < 0) {
- TBM_SPRD_ERROR("fail to open drm!\n");
+ TBM_ERR("fail to open drm!\n");
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
goto fail_open_drm;
bufmgr_sprd->device_name = drmGetDeviceNameFromFd(bufmgr_sprd->fd);
if (!bufmgr_sprd->device_name) {
- TBM_SPRD_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;
}
} else {
if (!tbm_drm_helper_get_auth_info(&(bufmgr_sprd->fd), &(bufmgr_sprd->device_name), NULL)) {
- TBM_SPRD_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;
}
if (!_bufmgr_init_cache_state(bufmgr_sprd)) {
- TBM_SPRD_ERROR("fail to init bufmgr cache state\n");
+ TBM_ERR("fail to init bufmgr cache state\n");
if (error)
*error = TBM_ERROR_OPERATION_FAILED;
goto fail_init_cache_state;
/* alloc and register bufmgr_funcs */
bufmgr_func = tbm_backend_bufmgr_alloc_bufmgr_func(bufmgr, &err);
if (!bufmgr_func) {
- TBM_SPRD_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;
err = tbm_backend_bufmgr_register_bufmgr_func(bufmgr, bufmgr_func);
if (err != TBM_ERROR_NONE) {
- TBM_SPRD_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;
/* alloc and register bo_funcs */
bo_func = tbm_backend_bufmgr_alloc_bo_func(bufmgr, &err);
if (!bo_func) {
- TBM_SPRD_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;
err = tbm_backend_bufmgr_register_bo_func(bufmgr, bo_func);
if (err != TBM_ERROR_NONE) {
- TBM_SPRD_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_sprd->bo_func = bo_func;
-#ifdef DEBUG
- {
- char *env;
-
- env = getenv("TBM_SPRD_DEBUG");
- if (env) {
- bDebug = atoi(env);
- TBM_SPRD_ERROR("TBM_SPRD_DEBUG=%s\n", env);
- } else
- bDebug = 0;
- }
-#endif
-
- TBM_SPRD_DEBUG("DMABUF FENCE is %s\n",
+ TBM_DBG("DMABUF FENCE is %s\n",
bufmgr_sprd->use_dma_fence ? "supported!" : "NOT supported!");
- TBM_SPRD_DEBUG("fd:%d\n", bufmgr_sprd->fd);
+ TBM_DBG("fd:%d\n", bufmgr_sprd->fd);
if (error)
*error = TBM_ERROR_NONE;