From 288ce91925dd75cd9d5c57dedc4fd55d2ac16978 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 29 Oct 2009 19:50:47 -0700 Subject: [PATCH] fix[2222341] Soft reset while going back from camcorder settings add a way to convert a mapped "pushbuffer" buffer to a gralloc handle which then can be safely used by surfaceflinger also make sure to not send empty rectangles to the MDP. --- gralloc.cpp | 4 ++++ mapper.cpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/gralloc.cpp b/gralloc.cpp index 479ed0c..45746ef 100644 --- a/gralloc.cpp +++ b/gralloc.cpp @@ -77,6 +77,9 @@ extern int gralloc_register_buffer(gralloc_module_t const* module, extern int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_handle_t handle); +extern int gralloc_perform(struct gralloc_module_t const* module, + int operation, ... ); + /*****************************************************************************/ static struct hw_module_methods_t gralloc_module_methods = { @@ -98,6 +101,7 @@ struct private_module_t HAL_MODULE_INFO_SYM = { unregisterBuffer: gralloc_unregister_buffer, lock: gralloc_lock, unlock: gralloc_unlock, + perform: gralloc_perform, }, framebuffer: 0, flags: 0, diff --git a/mapper.cpp b/mapper.cpp index 93264a6..8c199b3 100644 --- a/mapper.cpp +++ b/mapper.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -284,3 +285,38 @@ int gralloc_unlock(gralloc_module_t const* module, return 0; } + +/*****************************************************************************/ + +int gralloc_perform(struct gralloc_module_t const* module, + int operation, ... ) +{ + int res = -EINVAL; + va_list args; + va_start(args, operation); + + switch (operation) { + case GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER: { + int fd = va_arg(args, int); + size_t size = va_arg(args, size_t); + size_t offset = va_arg(args, size_t); + void* base = va_arg(args, void*); + native_handle_t** handle = va_arg(args, native_handle_t**); + private_handle_t* hnd = (private_handle_t*)native_handle_create( + private_handle_t::sNumFds, private_handle_t::sNumInts); + hnd->magic = private_handle_t::sMagic; + hnd->fd = fd; + hnd->flags = private_handle_t::PRIV_FLAGS_USES_PMEM; + hnd->size = size; + hnd->offset = offset; + hnd->base = intptr_t(base) + offset; + hnd->lockState = private_handle_t::LOCK_STATE_MAPPED; + *handle = (native_handle_t *)hnd; + res = 0; + break; + } + } + + va_end(args); + return res; +}