#include <tbm_drm_helper.h>
#define DEBUG
-#include "tbm_bufmgr_tgl.h"
-
//#define USE_CONTIG_ONLY
//#define USE_CACHE
#define USE_DMAIMPORT
+#ifdef USE_CACHE
+#include "tbm_bufmgr_tgl.h"
+#endif
+
#define TBM_COLOR_FORMAT_COUNT 4
#ifdef DEBUG
TBM_FORMAT_YUV420
};
+#ifdef USE_CACHE
static inline int
_tgl_get_version(int fd)
{
return 1;
}
-
static inline int
_tgl_init(int fd, unsigned int key)
{
return 1;
}
-#ifdef USE_CACHE
static inline int
_tgl_set_data(int fd, unsigned int key, unsigned int val)
{
return -1;
}
#else
- TBM_SPRD_ERROR("warning fail to open drm\n",
- );
+ TBM_SPRD_ERROR("warning fail to open drm\n");
#endif
return fd;
return 0;
}
#endif
+
return 1;
}
#endif
static int
_bo_init_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int import)
{
+#ifdef USE_CACHE
SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0);
SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0);
_tgl_init(bufmgr_sprd->tgl_fd, bo_sprd->name);
-#ifdef USE_CACHE
tbm_bo_cache_state cache_state;
if (import == 0) {
static void
_bo_destroy_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd)
{
+#ifdef USE_CACHE
SPRD_RETURN_IF_FAIL(bo_sprd != NULL);
SPRD_RETURN_IF_FAIL(bufmgr_sprd != NULL);
return;
_tgl_destroy(bufmgr_sprd->tgl_fd, bo_sprd->name);
+#endif
}
static int
_bufmgr_init_cache_state(tbm_bufmgr_sprd bufmgr_sprd)
{
+#ifdef USE_CACHE
SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0);
if (bufmgr_sprd->use_dma_fence)
return 0;
}
-#ifdef USE_CACHE
if (!_tgl_init(bufmgr_sprd->tgl_fd, GLOBAL_KEY)) {
TBM_SPRD_ERROR("fail to initialize the tgl\n");
close(bufmgr_sprd->tgl_fd);
static void
_bufmgr_deinit_cache_state(tbm_bufmgr_sprd bufmgr_sprd)
{
+#ifdef USE_CACHE
SPRD_RETURN_IF_FAIL(bufmgr_sprd != NULL);
if (bufmgr_sprd->use_dma_fence)
if (bufmgr_sprd->tgl_fd >= 0)
close(bufmgr_sprd->tgl_fd);
+#endif
}
#ifndef USE_CONTIG_ONLY
return 1;
}
-static int
-tbm_sprd_bo_lock(tbm_bo bo, int device, int opt)
-{
- SPRD_RETURN_VAL_IF_FAIL(bo != NULL, 0);
-
- tbm_bufmgr_sprd bufmgr_sprd;
- tbm_bo_sprd bo_sprd;
-
- bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo);
- SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0);
-
- bufmgr_sprd = (tbm_bufmgr_sprd)tbm_backend_get_bufmgr_priv(bo);
- SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0);
-
-#if USE_BACKEND_LOCK
- int ret = 0;
-
- if (bufmgr_sprd->use_dma_fence) {
- struct dma_buf_fence fence;
-
- memset(&fence, 0, sizeof(struct dma_buf_fence));
-
- /* Check if the given type is valid or not. */
- if (opt & TBM_OPTION_WRITE) {
- if (device == TBM_DEVICE_CPU)
- fence.type = DMA_BUF_ACCESS_WRITE;
- else if (device == TBM_DEVICE_3D)
- fence.type = DMA_BUF_ACCESS_WRITE | DMA_BUF_ACCESS_DMA;
- else {
- TBM_SPRD_DEBUG("GET_FENCE is ignored(device type is not 3D/CPU),\n");
- return 0;
- }
- } else if (opt & TBM_OPTION_READ) {
- if (device == TBM_DEVICE_CPU)
- fence.type = DMA_BUF_ACCESS_READ;
- else if (device == TBM_DEVICE_3D)
- fence.type = DMA_BUF_ACCESS_READ | DMA_BUF_ACCESS_DMA;
- else {
- TBM_SPRD_DEBUG("GET_FENCE is ignored(device type is not 3D/CPU),\n");
- return 0;
- }
- } else {
- TBM_SPRD_ERROR("error Invalid argument\n");
- return 0;
- }
-
- ret = ioctl(bo_sprd->dmabuf, DMABUF_IOCTL_GET_FENCE, &fence);
- if (ret < 0) {
- TBM_SPRD_ERROR("error Can not set GET FENCE(%s)\n", strerror(errno));
- return 0;
- }
-
- pthread_mutex_lock(&bo_sprd->mutex);
- int i;
- for (i = 0; i < DMA_FENCE_LIST_MAX; i++) {
- if (bo_sprd->dma_fence[i].ctx == 0) {
- bo_sprd->dma_fence[i].type = fence.type;
- bo_sprd->dma_fence[i].ctx = fence.ctx;
- break;
- }
- }
- if (i == DMA_FENCE_LIST_MAX) {
- //TODO: if dma_fence list is full, it needs realloc. I will fix this. by minseok3.kim
- TBM_SPRD_ERROR("error fence list is full\n");
- }
- pthread_mutex_unlock(&bo_sprd->mutex);
-
- TBM_SPRD_DEBUG("DMABUF_IOCTL_GET_FENCE! flink_id=%d dmabuf=%d\n",
- bo_sprd->name, bo_sprd->dmabuf);
- } else {
- ret = _tgl_lock(bufmgr_sprd->tgl_fd, bo_sprd->name, opt);
-
- TBM_SPRD_DEBUG("lock tgl flink_id:%d\n", bo_sprd->name);
-
- return ret;
- }
-#endif
-
- return 1;
-}
-
-static int
-tbm_sprd_bo_unlock(tbm_bo bo)
-{
- SPRD_RETURN_VAL_IF_FAIL(bo != NULL, 0);
-
- tbm_bufmgr_sprd bufmgr_sprd;
- tbm_bo_sprd bo_sprd;
-
- bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo);
- SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, 0);
-
- bufmgr_sprd = (tbm_bufmgr_sprd)tbm_backend_get_bufmgr_priv(bo);
- SPRD_RETURN_VAL_IF_FAIL(bufmgr_sprd != NULL, 0);
-
-#if USE_BACKEND_LOCK
- int ret = 0;
-
- if (bufmgr_sprd->use_dma_fence) {
- struct dma_buf_fence fence;
-
- if (!bo_sprd->dma_fence[0].ctx) {
- TBM_SPRD_DEBUG("FENCE not support or ignored,\n";
- return 0;
- }
-
- if (!bo_sprd->dma_fence[0].type) {
- TBM_SPRD_DEBUG("device type is not 3D/CPU,\n");
- return 0;
- }
-
- pthread_mutex_lock(&bo_sprd->mutex);
- fence.type = bo_sprd->dma_fence[0].type;
- fence.ctx = bo_sprd->dma_fence[0].ctx;
- int i;
- for (i = 1; i < DMA_FENCE_LIST_MAX; i++) {
- bo_sprd->dma_fence[i - 1].type = bo_sprd->dma_fence[i].type;
- bo_sprd->dma_fence[i - 1].ctx = bo_sprd->dma_fence[i].ctx;
- }
- bo_sprd->dma_fence[DMA_FENCE_LIST_MAX - 1].type = 0;
- bo_sprd->dma_fence[DMA_FENCE_LIST_MAX - 1].ctx = 0;
- pthread_mutex_unlock(&bo_sprd->mutex);
-
- ret = ioctl(bo_sprd->dmabuf, DMABUF_IOCTL_PUT_FENCE, &fence);
- if (ret < 0) {
- TBM_SPRD_ERROR("error Can not set PUT FENCE(%s)\n", strerror(errno));
- return 0;
- }
-
- TBM_SPRD_DEBUG("DMABUF_IOCTL_PUT_FENCE! flink_id=%d dmabuf=%d\n",
- bo_sprd->name, bo_sprd->dmabuf);
- } else {
- ret = _tgl_unlock(bufmgr_sprd->tgl_fd, bo_sprd->name);
-
- TBM_SPRD_DEBUG("unlock tgl flink_id:%d\n", bo_sprd->name);
-
- return ret;
- }
-#endif
-
- return 1;
-}
-
static void
tbm_sprd_bufmgr_deinit(void *priv)
{
bufmgr_backend->surface_get_plane_data = tbm_sprd_surface_get_plane_data;
bufmgr_backend->surface_supported_format = tbm_sprd_surface_supported_format;
bufmgr_backend->bo_get_flags = tbm_sprd_bo_get_flags;
- bufmgr_backend->bo_lock = tbm_sprd_bo_lock;
- bufmgr_backend->bo_unlock = tbm_sprd_bo_unlock;
+ bufmgr_backend->bo_lock = NULL;
+ bufmgr_backend->bo_unlock = NULL;
bufmgr_backend->bufmgr_bind_native_display = tbm_sprd_bufmgr_bind_native_display;
if (!tbm_backend_init(bufmgr, bufmgr_backend)) {