diff --git a/libgralloc/Android.mk b/libgralloc/Android.mk old mode 100644 new mode 100755 index 545c1d3..a95babb --- a/libgralloc/Android.mk +++ b/libgralloc/Android.mk @@ -21,8 +21,10 @@ include $(CLEAR_VARS) LOCAL_PRELINK_MODULE := false LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw LOCAL_SHARED_LIBRARIES := liblog libcutils libGLESv1_CM libutils libmemalloc +LOCAL_SHARED_LIBRARIES += libgenlock LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include +LOCAL_C_INCLUDES += hardware/qcom/display/libgenlock LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr LOCAL_SRC_FILES := framebuffer.cpp \ gpu.cpp \ diff --git a/libgralloc/gpu.cpp b/libgralloc/gpu.cpp old mode 100644 new mode 100755 index e0f3ebb..da9f4c1 --- a/libgralloc/gpu.cpp +++ b/libgralloc/gpu.cpp @@ -21,6 +21,8 @@ #include #include +#include + #include "gr.h" #include "gpu.h" #include "memalloc.h" @@ -289,6 +291,13 @@ int gpu_context_t::alloc_impl(int w, int h, int format, int usage, return err; } + // Create a genlock lock for this buffer handle. + err = genlock_create_lock((native_handle_t*)(*pHandle)); + if (err) { + LOGE("%s: genlock_create_lock failed", __FUNCTION__); + free_impl(reinterpret_cast(pHandle)); + return err; + } *pStride = alignedw; return 0; } @@ -308,6 +317,13 @@ int gpu_context_t::free_impl(private_handle_t const* hnd) { return err; terminateBuffer(&m->base, const_cast(hnd)); } + + // Release the genlock + int err = genlock_release_lock((native_handle_t*)hnd); + if (err) { + LOGE("%s: genlock_release_lock failed", __FUNCTION__); + } + delete hnd; return 0; } diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp old mode 100644 new mode 100755 index d6024b0..e324552 --- a/libgralloc/mapper.cpp +++ b/libgralloc/mapper.cpp @@ -34,6 +34,7 @@ #include #include +#include #include @@ -134,6 +135,17 @@ int gralloc_register_buffer(gralloc_module_t const* module, hnd->base = 0; hnd->lockState = 0; hnd->writeOwner = 0; + // Reset the genlock private fd flag in the handle + hnd->genlockPrivFd = -1; + + // Check if there is a valid lock attached to the handle. + if (-1 == hnd->genlockHandle) { + LOGE("%s: the lock is invalid.", __FUNCTION__); + return -EINVAL; + } + + // Attach the genlock handle + return genlock_attach_lock((native_handle_t *)handle); } return 0; } @@ -164,6 +176,14 @@ int gralloc_unregister_buffer(gralloc_module_t const* module, hnd->base = 0; hnd->lockState = 0; hnd->writeOwner = 0; + + // Release the genlock + if (-1 != hnd->genlockHandle) { + return genlock_release_lock((native_handle_t *)handle); + } else { + LOGE("%s: there was no genlock attached to this buffer", __FUNCTION__); + return -EINVAL; + } } return 0; }