set TBM_BO_TILED flags to bo in import_fd/key 97/207697/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Tue, 11 Jun 2019 08:00:17 +0000 (17:00 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Tue, 11 Jun 2019 08:02:09 +0000 (17:02 +0900)
Change-Id: I7194ec559b46713399054b768cc0e9b94698dfaf

src/tbm_bufmgr_vc4.c

index 82cccdc..37c9934 100644 (file)
@@ -1625,8 +1625,18 @@ tbm_vc4_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_e
        bo_vc4->fd = bufmgr_vc4->fd;
        bo_vc4->gem = gem;
        bo_vc4->size = real_size;
-       bo_vc4->flags_tbm = 0;
        bo_vc4->name = name;
+       bo_vc4->flags_tbm = 0;
+
+#ifdef VC4_TILED_FORMAT
+       struct drm_vc4_get_tiling get_tiling = {
+               .handle = bo_vc4->gem,
+       };
+       drmIoctl(bo_vc4->fd, DRM_IOCTL_VC4_GET_TILING, &get_tiling);
+
+       if (get_tiling.modifier == DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED)
+               bo_vc4->flags_tbm |= TBM_BO_TILED;
+#endif
 
        if (!_bo_init_cache_state(bufmgr_vc4, bo_vc4, 1)) {
                TBM_ERR("fail init cache state(%d)\n", bo_vc4->name);
@@ -1701,6 +1711,16 @@ tbm_vc4_bufmgr_import_key(tbm_backend_bufmgr_data *bufmgr_data, tbm_key key, tbm
        bo_vc4->name = key;
        bo_vc4->flags_tbm = 0;
 
+#ifdef VC4_TILED_FORMAT
+       struct drm_vc4_get_tiling get_tiling = {
+               .handle = bo_vc4->gem,
+       };
+       drmIoctl(bo_vc4->fd, DRM_IOCTL_VC4_GET_TILING, &get_tiling);
+
+       if (get_tiling.modifier == DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED)
+               bo_vc4->flags_tbm |= TBM_BO_TILED;
+#endif
+
        if (!_bo_init_cache_state(bufmgr_vc4, bo_vc4, 1)) {
                TBM_ERR("fail init cache state(%d)\n", bo_vc4->name);
                free(bo_vc4);