From 00bd746427a41684d7f9ef5ff2aff3caad205094 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Wed, 24 Jun 2009 16:52:08 -0700 Subject: [PATCH] copybit now uses a native_handle_t* instead of a fd/offset --- libcopybit/Android.mk | 3 ++- libcopybit/{copybit.c => copybit.cpp} | 38 +++++++++++++++------------ 2 files changed, 23 insertions(+), 18 deletions(-) rename libcopybit/{copybit.c => copybit.cpp} (93%) diff --git a/libcopybit/Android.mk b/libcopybit/Android.mk index f6a1b4b..af65671 100644 --- a/libcopybit/Android.mk +++ b/libcopybit/Android.mk @@ -20,6 +20,7 @@ include $(CLEAR_VARS) LOCAL_PRELINK_MODULE := false LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw LOCAL_SHARED_LIBRARIES := liblog -LOCAL_SRC_FILES := copybit.c +LOCAL_SRC_FILES := copybit.cpp LOCAL_MODULE := copybit.msm7k +LOCAL_C_INCLUDES += hardware/libhardware/modules/gralloc include $(BUILD_SHARED_LIBRARY) diff --git a/libcopybit/copybit.c b/libcopybit/copybit.cpp similarity index 93% rename from libcopybit/copybit.c rename to libcopybit/copybit.cpp index 3565074..60adc48 100644 --- a/libcopybit/copybit.c +++ b/libcopybit/copybit.cpp @@ -34,6 +34,8 @@ #include +#include "gralloc_priv.h" + /******************************************************************************/ /** State information for each device instance */ @@ -52,21 +54,21 @@ static int open_copybit(const struct hw_module_t* module, const char* name, struct hw_device_t** device); static struct hw_module_methods_t copybit_module_methods = { - .open = open_copybit + open: open_copybit }; /* * The COPYBIT Module */ -const struct copybit_module_t HAL_MODULE_INFO_SYM = { - .common = { - .tag = HARDWARE_MODULE_TAG, - .version_major = 1, - .version_minor = 0, - .id = COPYBIT_HARDWARE_MODULE_ID, - .name = "QCT MSM7K COPYBIT Module", - .author = "Google, Inc.", - .methods = ©bit_module_methods, +struct copybit_module_t HAL_MODULE_INFO_SYM = { + common: { + tag: HARDWARE_MODULE_TAG, + version_major: 1, + version_minor: 0, + id: COPYBIT_HARDWARE_MODULE_ID, + name: "QCT MSM7K COPYBIT Module", + author: "Google, Inc.", + methods: ©bit_module_methods } }; @@ -113,13 +115,14 @@ static int get_format(int format) { } /** convert from copybit image to mdp image structure */ -static void set_image(struct mdp_img *img, - const struct copybit_image_t *rhs) { +static void set_image(struct mdp_img *img, const struct copybit_image_t *rhs) +{ + private_handle_t* hnd = (private_handle_t*)rhs->handle; img->width = rhs->w; img->height = rhs->h; img->format = get_format(rhs->format); - img->offset = rhs->offset; - img->memory_id = rhs->fd; + img->offset = hnd->offset; + img->memory_id = hnd->fd; } /** setup rectangles */ @@ -360,12 +363,13 @@ static int open_copybit(const struct hw_module_t* module, const char* name, struct hw_device_t** device) { int status = -EINVAL; - struct copybit_context_t *ctx = malloc(sizeof(struct copybit_context_t)); + copybit_context_t *ctx; + ctx = (copybit_context_t *)malloc(sizeof(copybit_context_t)); memset(ctx, 0, sizeof(*ctx)); ctx->device.common.tag = HARDWARE_DEVICE_TAG; - ctx->device.common.version = 0; - ctx->device.common.module = module; + ctx->device.common.version = 1; + ctx->device.common.module = const_cast(module); ctx->device.common.close = close_copybit; ctx->device.set_parameter = set_parameter_copybit; ctx->device.get = get;