klte-common: Clean up camera wrapper code

* Make static functions static
* Code formatting
* Standardize function signatures

Change-Id: I2396073069e7bf21fcc85d7272865a1a59600f3b
This commit is contained in:
Ethan Chen 2014-11-23 14:46:50 -08:00
parent 1eeeb43867
commit 8f74663053
1 changed files with 133 additions and 133 deletions

View File

@ -22,7 +22,6 @@
*/
//#define LOG_NDEBUG 0
#define LOG_PARAMETERS
#define LOG_TAG "CameraWrapper"
#include <cutils/log.h>
@ -44,8 +43,6 @@ static int camera_device_open(const hw_module_t* module, const char* name,
static int camera_device_close(hw_device_t *device);
static int camera_get_number_of_cameras(void);
static int camera_get_camera_info(int camera_id, struct camera_info *info);
static int camera_send_command(struct camera_device * device, int32_t cmd,
int32_t arg1, int32_t arg2);
static struct hw_module_methods_t camera_module_methods = {
.open = camera_device_open
@ -53,7 +50,7 @@ static struct hw_module_methods_t camera_module_methods = {
camera_module_t HAL_MODULE_INFO_SYM = {
.common = {
tag: HARDWARE_MODULE_TAG,
.tag = HARDWARE_MODULE_TAG,
.module_api_version = CAMERA_MODULE_API_VERSION_1_0,
.hal_api_version = HARDWARE_HAL_API_VERSION,
.id = CAMERA_HARDWARE_MODULE_ID,
@ -87,7 +84,7 @@ typedef struct wrapper_camera_device {
static int check_vendor_module()
{
int rv = 0;
ALOGI("%s", __FUNCTION__);
ALOGV("%s", __FUNCTION__);
if (gVendorModule)
return 0;
@ -108,7 +105,7 @@ static char *camera_fixup_getparams(int __attribute__((unused)) id,
android::CameraParameters params;
params.unflatten(android::String8(settings));
#ifdef LOG_PARAMETERS
#if !LOG_NDEBUG
ALOGV("%s: original parameters:", __FUNCTION__);
params.dump();
#endif
@ -128,20 +125,20 @@ static char *camera_fixup_getparams(int __attribute__((unused)) id,
android::String8 strParams = params.flatten();
char *ret = strdup(strParams.string());
#ifdef LOG_PARAMETERS
#if !LOG_NDEBUG
ALOGV("%s: fixed parameters:", __FUNCTION__);
params.dump();
#endif
return ret;
}
char * camera_fixup_setparams(struct camera_device * device, const char * settings)
static char *camera_fixup_setparams(int id, const char *settings)
{
int id = CAMERA_ID(device);
android::CameraParameters params;
params.unflatten(android::String8(settings));
#ifdef LOG_PARAMETERS
#if !LOG_NDEBUG
ALOGV("%s: original parameters:", __FUNCTION__);
params.dump();
#endif
@ -163,7 +160,7 @@ char * camera_fixup_setparams(struct camera_device * device, const char * settin
fixed_set_params[id] = strdup(strParams.string());
char *ret = fixed_set_params[id];
#ifdef LOG_PARAMETERS
#if !LOG_NDEBUG
ALOGV("%s: fixed parameters:", __FUNCTION__);
params.dump();
#endif
@ -175,10 +172,11 @@ char * camera_fixup_setparams(struct camera_device * device, const char * settin
* implementation of camera_device_ops functions
*******************************************************************/
int camera_set_preview_window(struct camera_device * device,
static int camera_set_preview_window(struct camera_device *device,
struct preview_stream_ops *window)
{
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
@ -186,15 +184,15 @@ int camera_set_preview_window(struct camera_device * device,
return VENDOR_CALL(device, set_preview_window, window);
}
void camera_set_callbacks(struct camera_device * device,
static void camera_set_callbacks(struct camera_device *device,
camera_notify_callback notify_cb,
camera_data_callback data_cb,
camera_data_timestamp_callback data_cb_timestamp,
camera_request_memory get_memory,
void *user)
{
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGI("%s", __FUNCTION__);
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return;
@ -202,10 +200,11 @@ void camera_set_callbacks(struct camera_device * device,
VENDOR_CALL(device, set_callbacks, notify_cb, data_cb, data_cb_timestamp, get_memory, user);
}
void camera_enable_msg_type(struct camera_device * device, int32_t msg_type)
static void camera_enable_msg_type(struct camera_device *device,
int32_t msg_type)
{
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGI("%s", __FUNCTION__);
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return;
@ -213,10 +212,11 @@ void camera_enable_msg_type(struct camera_device * device, int32_t msg_type)
VENDOR_CALL(device, enable_msg_type, msg_type);
}
void camera_disable_msg_type(struct camera_device * device, int32_t msg_type)
static void camera_disable_msg_type(struct camera_device *device,
int32_t msg_type)
{
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGI("%s", __FUNCTION__);
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return;
@ -224,10 +224,11 @@ void camera_disable_msg_type(struct camera_device * device, int32_t msg_type)
VENDOR_CALL(device, disable_msg_type, msg_type);
}
int camera_msg_type_enabled(struct camera_device * device, int32_t msg_type)
static int camera_msg_type_enabled(struct camera_device *device,
int32_t msg_type)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return 0;
@ -235,10 +236,10 @@ int camera_msg_type_enabled(struct camera_device * device, int32_t msg_type)
return VENDOR_CALL(device, msg_type_enabled, msg_type);
}
int camera_start_preview(struct camera_device * device)
static int camera_start_preview(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
@ -246,10 +247,10 @@ int camera_start_preview(struct camera_device * device)
return VENDOR_CALL(device, start_preview);
}
void camera_stop_preview(struct camera_device * device)
static void camera_stop_preview(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return;
@ -257,10 +258,10 @@ void camera_stop_preview(struct camera_device * device)
VENDOR_CALL(device, stop_preview);
}
int camera_preview_enabled(struct camera_device * device)
static int camera_preview_enabled(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
@ -268,10 +269,11 @@ int camera_preview_enabled(struct camera_device * device)
return VENDOR_CALL(device, preview_enabled);
}
int camera_store_meta_data_in_buffers(struct camera_device * device, int enable)
static int camera_store_meta_data_in_buffers(struct camera_device *device,
int enable)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
@ -279,10 +281,10 @@ int camera_store_meta_data_in_buffers(struct camera_device * device, int enable)
return VENDOR_CALL(device, store_meta_data_in_buffers, enable);
}
int camera_start_recording(struct camera_device * device)
static int camera_start_recording(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return EINVAL;
@ -290,22 +292,21 @@ int camera_start_recording(struct camera_device * device)
return VENDOR_CALL(device, start_recording);
}
void camera_stop_recording(struct camera_device * device)
static void camera_stop_recording(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return;
VENDOR_CALL(device, stop_recording);
}
int camera_recording_enabled(struct camera_device * device)
static int camera_recording_enabled(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
@ -313,11 +314,11 @@ int camera_recording_enabled(struct camera_device * device)
return VENDOR_CALL(device, recording_enabled);
}
void camera_release_recording_frame(struct camera_device * device,
static void camera_release_recording_frame(struct camera_device *device,
const void *opaque)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return;
@ -325,22 +326,21 @@ void camera_release_recording_frame(struct camera_device * device,
VENDOR_CALL(device, release_recording_frame, opaque);
}
int camera_auto_focus(struct camera_device * device)
static int camera_auto_focus(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
return VENDOR_CALL(device, auto_focus);
}
int camera_cancel_auto_focus(struct camera_device * device)
static int camera_cancel_auto_focus(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
@ -348,10 +348,10 @@ int camera_cancel_auto_focus(struct camera_device * device)
return VENDOR_CALL(device, cancel_auto_focus);
}
int camera_take_picture(struct camera_device * device)
static int camera_take_picture(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
@ -359,10 +359,10 @@ int camera_take_picture(struct camera_device * device)
return VENDOR_CALL(device, take_picture);
}
int camera_cancel_picture(struct camera_device * device)
static int camera_cancel_picture(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
@ -370,25 +370,25 @@ int camera_cancel_picture(struct camera_device * device)
return VENDOR_CALL(device, cancel_picture);
}
int camera_set_parameters(struct camera_device * device, const char *params)
static int camera_set_parameters(struct camera_device *device, const char *params)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
char *tmp = NULL;
tmp = camera_fixup_setparams(device, params);
tmp = camera_fixup_setparams(CAMERA_ID(device), params);
int ret = VENDOR_CALL(device, set_parameters, tmp);
return ret;
}
char* camera_get_parameters(struct camera_device * device)
static char *camera_get_parameters(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return NULL;
@ -404,18 +404,18 @@ char* camera_get_parameters(struct camera_device * device)
static void camera_put_parameters(struct camera_device *device, char *params)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (params)
free(params);
}
int camera_send_command(struct camera_device * device,
static int camera_send_command(struct camera_device *device,
int32_t cmd, int32_t arg1, int32_t arg2)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
@ -423,10 +423,10 @@ int camera_send_command(struct camera_device * device,
return VENDOR_CALL(device, send_command, cmd, arg1, arg2);
}
void camera_release(struct camera_device * device)
static void camera_release(struct camera_device *device)
{
ALOGI("%s", __FUNCTION__);
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return;
@ -434,8 +434,11 @@ void camera_release(struct camera_device * device)
VENDOR_CALL(device, release);
}
int camera_dump(struct camera_device * device, int fd)
static int camera_dump(struct camera_device *device, int fd)
{
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
if (!device)
return -EINVAL;
@ -444,12 +447,12 @@ int camera_dump(struct camera_device * device, int fd)
extern "C" void heaptracker_free_leaked_memory(void);
int camera_device_close(hw_device_t* device)
static int camera_device_close(hw_device_t *device)
{
int ret = 0;
wrapper_camera_device_t *wrapper_dev = NULL;
ALOGI("%s", __FUNCTION__);
ALOGV("%s", __FUNCTION__);
android::Mutex::Autolock lock(gCameraWrapperLock);
@ -486,7 +489,7 @@ done:
* so this function will always only be called once per camera instance
*/
int camera_device_open(const hw_module_t* module, const char* name,
static int camera_device_open(const hw_module_t *module, const char *name,
hw_device_t **device)
{
int rv = 0;
@ -497,7 +500,7 @@ int camera_device_open(const hw_module_t* module, const char* name,
android::Mutex::Autolock lock(gCameraWrapperLock);
ALOGI("camera_device open");
ALOGV("camera_device open");
if (name != NULL) {
if (check_vendor_module())
@ -514,8 +517,7 @@ int camera_device_open(const hw_module_t* module, const char* name,
}
memset(fixed_set_params, 0, sizeof(char *) * num_cameras);
if(cameraid > num_cameras)
{
if (cameraid > num_cameras) {
ALOGE("camera service provided cameraid out of bounds, "
"cameraid = %d, num supported = %d",
cameraid, num_cameras);
@ -524,8 +526,7 @@ int camera_device_open(const hw_module_t* module, const char* name,
}
camera_device = (wrapper_camera_device_t*)malloc(sizeof(*camera_device));
if(!camera_device)
{
if (!camera_device) {
ALOGE("camera_device allocation fail");
rv = -ENOMEM;
goto fail;
@ -540,12 +541,11 @@ int camera_device_open(const hw_module_t* module, const char* name,
ALOGE("vendor camera open fail");
goto fail;
}
ALOGI("%s: got vendor camera device 0x%08X",
ALOGV("%s: got vendor camera device 0x%08X",
__FUNCTION__, (uintptr_t)(camera_device->vendor));
camera_ops = (camera_device_ops_t*)malloc(sizeof(*camera_ops));
if(!camera_ops)
{
if (!camera_ops) {
ALOGE("camera_ops allocation fail");
rv = -ENOMEM;
goto fail;
@ -601,17 +601,17 @@ fail:
return rv;
}
int camera_get_number_of_cameras(void)
static int camera_get_number_of_cameras(void)
{
ALOGI("%s", __FUNCTION__);
ALOGV("%s", __FUNCTION__);
if (check_vendor_module())
return 0;
return gVendorModule->get_number_of_cameras();
}
int camera_get_camera_info(int camera_id, struct camera_info *info)
static int camera_get_camera_info(int camera_id, struct camera_info *info)
{
ALOGI("%s", __FUNCTION__);
ALOGV("%s", __FUNCTION__);
if (check_vendor_module())
return 0;
return gVendorModule->get_camera_info(camera_id, info);