Revert "exynos: gralloc: implement gralloc_lock_ycbcr"
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos5.git] / gralloc / mapper.cpp
index eb82ed9a67e5feaaa4d94730679bbe9abc338dc4..1a709738fed6faf60a184b4b01046cc29b69b450 100644 (file)
@@ -72,16 +72,6 @@ static int gralloc_unmap(gralloc_module_t const* module, buffer_handle_t handle)
 
 /*****************************************************************************/
 
-int grallocMap(gralloc_module_t const* module, private_handle_t *hnd)
-{
-    return gralloc_map(module, hnd);
-}
-
-int grallocUnmap(gralloc_module_t const* module, private_handle_t *hnd)        
-{
-    return gralloc_unmap(module, hnd);
-}
-
 int getIonFd(gralloc_module_t const *module)
 {
     private_module_t* m = const_cast<private_module_t*>(reinterpret_cast<const private_module_t*>(module));
@@ -97,12 +87,9 @@ static pthread_mutex_t sMapLock = PTHREAD_MUTEX_INITIALIZER;
 int gralloc_register_buffer(gralloc_module_t const* module,
                             buffer_handle_t handle)
 {
-    int err;
     if (private_handle_t::validate(handle) < 0)
         return -EINVAL;
 
-    err = gralloc_map(module, handle);
-
     private_handle_t* hnd = (private_handle_t*)handle;
     ALOGV("%s: base %p %d %d %d %d\n", __func__, hnd->base, hnd->size,
           hnd->width, hnd->height, hnd->stride);
@@ -122,7 +109,7 @@ int gralloc_register_buffer(gralloc_module_t const* module,
             ALOGE("error importing handle2 %d %x\n", hnd->fd2, hnd->format);
     }
 
-    return err;
+    return ret;
 }
 
 int gralloc_unregister_buffer(gralloc_module_t const* module,
@@ -164,6 +151,8 @@ int gralloc_lock(gralloc_module_t const* module,
         return -EINVAL;
 
     private_handle_t* hnd = (private_handle_t*)handle;
+    if (!hnd->base)
+        gralloc_map(module, hnd);
     *vaddr = (void*)hnd->base;
     return 0;
 }
@@ -173,6 +162,12 @@ int gralloc_unlock(gralloc_module_t const* module,
 {
     // we're done with a software buffer. nothing to do in this
     // implementation. typically this is used to flush the data cache.
+    private_handle_t* hnd = (private_handle_t*)handle;
+    ion_sync_fd(getIonFd(module), hnd->fd);
+    if (hnd->fd1 >= 0)
+        ion_sync_fd(getIonFd(module), hnd->fd1);
+    if (hnd->fd2 >= 0)
+        ion_sync_fd(getIonFd(module), hnd->fd2);
 
     if (private_handle_t::validate(handle) < 0)
         return -EINVAL;