Implement mos_bo_gem_export_to_prime

Change-Id: I073754f21cee8b3f47ba352d634fefe34755569b
diff --git a/media_driver/linux/common/os/magma/mos_bufmgr_magma.cpp b/media_driver/linux/common/os/magma/mos_bufmgr_magma.cpp
index ecee046..f3d9d8a 100644
--- a/media_driver/linux/common/os/magma/mos_bufmgr_magma.cpp
+++ b/media_driver/linux/common/os/magma/mos_bufmgr_magma.cpp
@@ -607,3 +607,18 @@
 {
     static_cast<MagmaBo*>(bo)->clear_exec_resources();
 }
+
+int mos_bo_gem_export_to_prime(struct mos_linux_bo *mos_linux_bo, int *prime_fd)
+{
+    auto bo = static_cast<MagmaBo*>(mos_linux_bo);
+
+    magma_handle_t handle;
+    magma_status_t status = magma_export(bo->magma_bufmgr()->connection(), bo->buffer(), &handle);
+    if (status != MAGMA_STATUS_OK) {
+        LOG_VERBOSE("magma_export failed: %d", status);
+        return -1;
+    }
+
+    *prime_fd = handle;
+    return 0;
+}
diff --git a/media_driver/linux/common/os/magma/mos_bufmgr_stub.c b/media_driver/linux/common/os/magma/mos_bufmgr_stub.c
index d9f18ec..b0aeb9c 100644
--- a/media_driver/linux/common/os/magma/mos_bufmgr_stub.c
+++ b/media_driver/linux/common/os/magma/mos_bufmgr_stub.c
@@ -44,13 +44,6 @@
     LOG_VERBOSE("mos_bufmgr_gem_enable_reuse unimplemented");
 }
 
-
-int mos_bo_gem_export_to_prime(struct mos_linux_bo *bo, int *prime_fd)
-{
-    LOG_VERBOSE("mos_bo_gem_export_to_prime unimplemented");
-    return 0;
-}
-
 struct mos_linux_bo * mos_bo_gem_create_from_name(struct mos_bufmgr *bufmgr,
                   const char *name,
                   unsigned int handle)