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.
This commit is contained in:
Mathias Agopian 2009-10-29 19:50:47 -07:00
parent b8dba8904e
commit b73f40535f
3 changed files with 83 additions and 6 deletions

View File

@ -36,6 +36,8 @@
#include "gralloc_priv.h"
#define DEBUG_MDP_ERRORS 0
/******************************************************************************/
#if defined(COPYBIT_MSM7K)
@ -201,10 +203,37 @@ static int msm_copybit(struct copybit_context_t *dev, void const *list)
int err = ioctl(dev->mFD, MSMFB_BLIT,
(struct mdp_blit_req_list const*)list);
LOGE_IF(err<0, "copyBits failed (%s)", strerror(errno));
if (err == 0)
if (err == 0) {
return 0;
else
} else {
#if DEBUG_MDP_ERRORS
struct mdp_blit_req_list const* l = (struct mdp_blit_req_list const*)list;
for (int i=0 ; i<l->count ; i++) {
LOGD("%d: src={w=%d, h=%d, f=%d, rect={%d,%d,%d,%d}}\n"
" dst={w=%d, h=%d, f=%d, rect={%d,%d,%d,%d}}\n"
" flags=%08lx"
,
i,
l->req[i].src.width,
l->req[i].src.height,
l->req[i].src.format,
l->req[i].src_rect.x,
l->req[i].src_rect.y,
l->req[i].src_rect.w,
l->req[i].src_rect.h,
l->req[i].dst.width,
l->req[i].dst.height,
l->req[i].dst.format,
l->req[i].dst_rect.x,
l->req[i].dst_rect.y,
l->req[i].dst_rect.w,
l->req[i].dst_rect.h,
l->req[i].flags
);
}
#endif
return -errno;
}
}
/*****************************************************************************/
@ -338,10 +367,18 @@ static int stretch_copybit(
status = 0;
while ((status == 0) && region->next(region, &clip)) {
intersect(&clip, &bounds, &clip);
set_infos(ctx, &list.req[list.count]);
set_image(&list.req[list.count].dst, dst);
set_image(&list.req[list.count].src, src);
set_rects(ctx, &list.req[list.count], dst_rect, src_rect, &clip);
mdp_blit_req* req = &list.req[list.count];
set_infos(ctx, req);
set_image(&req->dst, dst);
set_image(&req->src, src);
set_rects(ctx, req, dst_rect, src_rect, &clip);
if (req->src_rect.w<=0 || req->src_rect.h<=0)
continue;
if (req->dst_rect.w<=0 || req->dst_rect.h<=0)
continue;
if (++list.count == maxCount) {
status = msm_copybit(ctx, &list);
list.count = 0;

View File

@ -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,

View File

@ -19,6 +19,7 @@
#include <pthread.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include <sys/mman.h>
#include <sys/stat.h>
@ -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;
}