remove the unused code 51/100051/1
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 25 Nov 2016 03:46:50 +0000 (12:46 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 25 Nov 2016 03:56:38 +0000 (12:56 +0900)
We do not use tgl and do not use the user lock of the dmafence at tm1
- remove lock/unlock
- block the tgl codes

Change-Id: If71fd61f4def380959079e8feb8f3aa163ed99ee

src/tbm_bufmgr_sprd.c

index 2ac2b4a..9d1f486 100644 (file)
@@ -56,12 +56,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #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
@@ -254,6 +256,7 @@ uint32_t tbm_sprd_color_format_list[TBM_COLOR_FORMAT_COUNT] = {
                                                                                TBM_FORMAT_YUV420
                                                                        };
 
+#ifdef USE_CACHE
 static inline int
 _tgl_get_version(int fd)
 {
@@ -271,7 +274,6 @@ _tgl_get_version(int fd)
        return 1;
 }
 
-
 static inline int
 _tgl_init(int fd, unsigned int key)
 {
@@ -357,7 +359,6 @@ _tgl_unlock(int fd, unsigned int key)
        return 1;
 }
 
-#ifdef USE_CACHE
 static inline int
 _tgl_set_data(int fd, unsigned int key, unsigned int val)
 {
@@ -476,8 +477,7 @@ _tbm_sprd_open_drm(void)
                return -1;
        }
 #else
-       TBM_SPRD_ERROR("warning fail to open drm\n",
-                     );
+       TBM_SPRD_ERROR("warning fail to open drm\n");
 #endif
 
        return fd;
@@ -534,6 +534,7 @@ _sprd_bo_cache_flush(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int flags
                return 0;
        }
 #endif
+
        return 1;
 }
 #endif
@@ -541,6 +542,7 @@ _sprd_bo_cache_flush(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int flags
 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);
 
@@ -549,7 +551,6 @@ _bo_init_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int impor
 
        _tgl_init(bufmgr_sprd->tgl_fd, bo_sprd->name);
 
-#ifdef USE_CACHE
        tbm_bo_cache_state cache_state;
 
        if (import == 0) {
@@ -656,6 +657,7 @@ _bo_save_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd)
 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);
 
@@ -663,11 +665,13 @@ _bo_destroy_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd)
                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)
@@ -691,7 +695,6 @@ _bufmgr_init_cache_state(tbm_bufmgr_sprd bufmgr_sprd)
                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);
@@ -705,6 +708,7 @@ _bufmgr_init_cache_state(tbm_bufmgr_sprd bufmgr_sprd)
 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)
@@ -712,6 +716,7 @@ _bufmgr_deinit_cache_state(tbm_bufmgr_sprd bufmgr_sprd)
 
        if (bufmgr_sprd->tgl_fd >= 0)
                close(bufmgr_sprd->tgl_fd);
+#endif
 }
 
 #ifndef USE_CONTIG_ONLY
@@ -1376,149 +1381,6 @@ tbm_sprd_bo_unmap(tbm_bo bo)
        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)
 {
@@ -1954,8 +1816,8 @@ init_tbm_bufmgr_priv(tbm_bufmgr bufmgr, int fd)
        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)) {