libgralloc: Create, attach and release genlock locks
Add support in the gralloc to: - Create a lock during buffer allocation. - Release a lock when the buffer is freed or unregistered. - Attach a lock when the buffer is registered. Change-Id: I788e411f43d5fcf88d7dcf39c530559a12d6361c
This commit is contained in:
parent
aa4994d543
commit
1b5f80522b
2
libgralloc/Android.mk
Normal file → Executable file
2
libgralloc/Android.mk
Normal file → Executable file
@ -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 \
|
||||
|
16
libgralloc/gpu.cpp
Normal file → Executable file
16
libgralloc/gpu.cpp
Normal file → Executable file
@ -21,6 +21,8 @@
|
||||
#include <cutils/properties.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <genlock.h>
|
||||
|
||||
#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<private_handle_t*>(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<private_handle_t*>(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;
|
||||
}
|
||||
|
20
libgralloc/mapper.cpp
Normal file → Executable file
20
libgralloc/mapper.cpp
Normal file → Executable file
@ -34,6 +34,7 @@
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/gralloc.h>
|
||||
#include <genlock.h>
|
||||
|
||||
#include <linux/android_pmem.h>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user