VIGS: implement bo_import_fd/bo_export_fd 26/45326/1 tizen_3.0.m1_mobile tizen_3.0.m1_tv accepted/tizen/mobile/20150810.080659 accepted/tizen/tv/20150810.080711 accepted/tizen/wearable/20150810.080810 submit/tizen_common/20151023.083358 submit/tizen_common/20151026.085049 submit/tizen_mobile/20150810.070932 submit/tizen_tv/20150810.070924 submit/tizen_wearable/20150810.070944 tizen_3.0.m1_mobile_release tizen_3.0.m1_tv_release tizen_3.0.m2.a1_mobile_release tizen_3.0.m2.a1_tv_release
authorVasiliy Ulyanov <v.ulyanov@samsung.com>
Wed, 27 May 2015 12:30:17 +0000 (15:30 +0300)
committerjinhyung.jo <jinhyung.jo@samsung.com>
Wed, 5 Aug 2015 02:44:06 +0000 (11:44 +0900)
These callbacks are required for DRI3 support

Change-Id: I1be70edf767503bedf4471fce14eb4a81ccbd27d
Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
src/tbm_bufmgr_emulator.c

index a9c28c7a0434308adc73282d37c5fe4e6790b1c7..c158c2a1f0df13bf559577d2c7e38b9e830f42d4 100755 (executable)
@@ -174,6 +174,31 @@ static void *tbm_bufmgr_emulator_bo_import(tbm_bo bo, unsigned int key)
     return sfc;
 }
 
+static void *tbm_bufmgr_emulator_bo_import_fd(tbm_bo bo, tbm_fd key)
+{
+    struct vigs_drm_device *drm_dev;
+    struct vigs_drm_surface *sfc;
+    int ret;
+
+    TBM_EMULATOR_LOG_DEBUG("bo = %p, key = %d", bo, key);
+
+    drm_dev = (struct vigs_drm_device *)tbm_backend_get_bufmgr_priv(bo);
+
+    ret = vigs_drm_prime_import_fd(drm_dev, key, &sfc);
+
+    if (ret != 0) {
+        TBM_EMULATOR_LOG_ERROR("vigs_drm_prime_import_fd failed for key %d: %s",
+                               key,
+                               strerror(-ret));
+        return NULL;
+    }
+
+    TBM_EMULATOR_LOG_DEBUG("handle = %u", sfc->gem.handle);
+
+    return sfc;
+}
+
+
 static unsigned int tbm_bufmgr_emulator_bo_export(tbm_bo bo)
 {
     struct vigs_drm_surface *sfc;
@@ -194,6 +219,28 @@ static unsigned int tbm_bufmgr_emulator_bo_export(tbm_bo bo)
     return sfc->gem.name;
 }
 
+tbm_fd tbm_bufmgr_emulator_bo_export_fd(tbm_bo bo)
+{
+    struct vigs_drm_device *drm_dev;
+    struct vigs_drm_surface *sfc;
+    int ret, fd = 0;
+
+    TBM_EMULATOR_LOG_DEBUG("bo = %p", bo);
+
+    drm_dev = (struct vigs_drm_device *)tbm_backend_get_bufmgr_priv(bo);
+    sfc = (struct vigs_drm_surface *)tbm_backend_get_bo_priv(bo);;
+
+    ret = vigs_drm_prime_export_fd(drm_dev, sfc, &fd);
+
+    if (ret != 0) {
+        TBM_EMULATOR_LOG_ERROR("vigs_drm_prime_export_fd failed: %s",
+                               strerror(-ret));
+        return 0;
+    }
+
+    return fd;
+}
+
 static tbm_bo_handle tbm_bufmgr_emulator_bo_get_handle(tbm_bo bo, int device)
 {
     struct vigs_drm_surface *sfc;
@@ -466,7 +513,9 @@ int tbm_bufmgr_emulator_init(tbm_bufmgr bufmgr, int fd)
     backend->bo_alloc = tbm_bufmgr_emulator_bo_alloc;
     backend->bo_free = tbm_bufmgr_emulator_bo_free;
     backend->bo_import = tbm_bufmgr_emulator_bo_import;
+    backend->bo_import_fd = tbm_bufmgr_emulator_bo_import_fd;
     backend->bo_export = tbm_bufmgr_emulator_bo_export;
+    backend->bo_export_fd = tbm_bufmgr_emulator_bo_export_fd;
     backend->bo_get_handle = tbm_bufmgr_emulator_bo_get_handle;
     backend->bo_map = tbm_bufmgr_emulator_bo_map;
     backend->bo_unmap = tbm_bufmgr_emulator_bo_unmap;