mondrianwifi: Clean up camera wrapper
- Clean up formatting - Clean up logging - Clean up method calls - Staticise all the functions Change-Id: If14611e9fdd3ee7f83611204ea51d8b004209ad4
This commit is contained in:
parent
ee432f65ae
commit
f2648c708e
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2012-2015, The CyanogenMod Project
|
* Copyright (C) 2012-2016, The CyanogenMod Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -18,29 +18,27 @@
|
|||||||
* @file CameraWrapper.cpp
|
* @file CameraWrapper.cpp
|
||||||
*
|
*
|
||||||
* This file wraps a vendor camera module.
|
* This file wraps a vendor camera module.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOG_NDEBUG 1
|
|
||||||
#define LOG_PARAMETERS
|
|
||||||
|
|
||||||
#define LOG_TAG "CameraWrapper"
|
#define LOG_TAG "CameraWrapper"
|
||||||
#include <cutils/log.h>
|
|
||||||
|
|
||||||
#include <utils/threads.h>
|
|
||||||
#include <utils/String8.h>
|
|
||||||
#include <hardware/hardware.h>
|
|
||||||
#include <hardware/camera.h>
|
|
||||||
//#include <camera/Camera.h>
|
|
||||||
#include <camera/CameraParameters.h>
|
#include <camera/CameraParameters.h>
|
||||||
|
#include <camera/Camera.h>
|
||||||
|
#include <cutils/log.h>
|
||||||
|
#include <hardware/camera.h>
|
||||||
|
#include <hardware/hardware.h>
|
||||||
|
#include <utils/String8.h>
|
||||||
|
#include <utils/threads.h>
|
||||||
|
|
||||||
static const char KEY_DIS[] = "dis";
|
static const char KEY_DIS[] = "dis";
|
||||||
static const char DIS_DISABLE[] = "disable";
|
static const char DIS_DISABLE[] = "disable";
|
||||||
static const char KEY_ZSL[] = "zsl";
|
static const char KEY_ZSL[] = "zsl";
|
||||||
static const char ZSL_ON[] = "on";
|
static const char ON[] = "on";
|
||||||
static const char ZSL_OFF[] = "off";
|
static const char OFF[] = "off";
|
||||||
|
|
||||||
static android::Mutex gCameraWrapperLock;
|
using namespace android;
|
||||||
|
|
||||||
|
static Mutex gCameraWrapperLock;
|
||||||
static camera_module_t *gVendorModule = 0;
|
static camera_module_t *gVendorModule = 0;
|
||||||
|
|
||||||
static camera_notify_callback gUserNotifyCb = NULL;
|
static camera_notify_callback gUserNotifyCb = NULL;
|
||||||
@ -51,41 +49,35 @@ static void *gUserCameraDevice = NULL;
|
|||||||
|
|
||||||
static char **fixed_set_params = NULL;
|
static char **fixed_set_params = NULL;
|
||||||
|
|
||||||
static 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);
|
hw_device_t **device);
|
||||||
static int camera_device_close(hw_device_t* device);
|
|
||||||
static int camera_get_number_of_cameras(void);
|
static int camera_get_number_of_cameras(void);
|
||||||
static 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);
|
||||||
static int camera_send_command(struct camera_device * device, int32_t cmd,
|
|
||||||
int32_t arg1, int32_t arg2);
|
|
||||||
static void camera_get_vendor_tag_ops(vendor_tag_ops_t* ops);
|
|
||||||
static int camera_open_legacy(const struct hw_module_t* module,
|
|
||||||
const char* id, uint32_t halVersion, struct hw_device_t** device);
|
|
||||||
|
|
||||||
static struct hw_module_methods_t camera_module_methods = {
|
static struct hw_module_methods_t camera_module_methods = {
|
||||||
open: camera_device_open
|
.open = camera_device_open,
|
||||||
};
|
};
|
||||||
|
|
||||||
camera_module_t HAL_MODULE_INFO_SYM = {
|
camera_module_t HAL_MODULE_INFO_SYM = {
|
||||||
.common = {
|
.common = {
|
||||||
tag: HARDWARE_MODULE_TAG,
|
.tag = HARDWARE_MODULE_TAG,
|
||||||
.module_api_version = CAMERA_MODULE_API_VERSION_1_0,
|
.module_api_version = CAMERA_MODULE_API_VERSION_1_0,
|
||||||
.hal_api_version = HARDWARE_HAL_API_VERSION,
|
.hal_api_version = HARDWARE_HAL_API_VERSION,
|
||||||
.id = CAMERA_HARDWARE_MODULE_ID,
|
.id = CAMERA_HARDWARE_MODULE_ID,
|
||||||
.name = "MSM8974 Camera Wrapper",
|
.name = "MSM8974 Camera Wrapper",
|
||||||
.author = "The CyanogenMod Project",
|
.author = "The CyanogenMod Project",
|
||||||
.methods = &camera_module_methods,
|
.methods = &camera_module_methods,
|
||||||
.dso = NULL, /* remove compilation warnings */
|
.dso = NULL,
|
||||||
.reserved = {0}, /* remove compilation warnings */
|
.reserved = {0},
|
||||||
},
|
},
|
||||||
.get_number_of_cameras = camera_get_number_of_cameras,
|
.get_number_of_cameras = camera_get_number_of_cameras,
|
||||||
.get_camera_info = camera_get_camera_info,
|
.get_camera_info = camera_get_camera_info,
|
||||||
.set_callbacks = NULL, /* remove compilation warnings */
|
.set_callbacks = NULL,
|
||||||
.get_vendor_tag_ops = NULL, /* remove compilation warnings */
|
.get_vendor_tag_ops = NULL,
|
||||||
.open_legacy = NULL, /* remove compilation warnings */
|
.open_legacy = NULL,
|
||||||
.set_torch_mode = NULL, /* remove compilation warnings */
|
.set_torch_mode = NULL,
|
||||||
.init = NULL, /* remove compilation warnings */
|
.init = NULL,
|
||||||
.reserved = {0}, /* remove compilation warnings */
|
.reserved = {0},
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct wrapper_camera_device {
|
typedef struct wrapper_camera_device {
|
||||||
@ -99,133 +91,90 @@ typedef struct wrapper_camera_device {
|
|||||||
__wrapper_dev->vendor->ops->func(__wrapper_dev->vendor, ##__VA_ARGS__); \
|
__wrapper_dev->vendor->ops->func(__wrapper_dev->vendor, ##__VA_ARGS__); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define CAMERA_ID(device) (((wrapper_camera_device_t *)(device))->id)
|
#define CAMERA_ID(device) (((wrapper_camera_device_t *)device)->id)
|
||||||
|
|
||||||
static int check_vendor_module()
|
static int check_vendor_module()
|
||||||
{
|
{
|
||||||
int rv = 0;
|
int rv;
|
||||||
ALOGE("%s:%u ->", __func__,__LINE__);
|
ALOGV("%s", __FUNCTION__);
|
||||||
|
|
||||||
if(gVendorModule)
|
if (gVendorModule)
|
||||||
{
|
|
||||||
ALOGE("%s:%u <- %d", __func__,__LINE__, 0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
rv = hw_get_module_by_class("camera", "vendor",
|
rv = hw_get_module_by_class("camera", "vendor",
|
||||||
(const hw_module_t **)&gVendorModule);
|
(const hw_module_t**)&gVendorModule);
|
||||||
|
|
||||||
if (rv)
|
if (rv)
|
||||||
ALOGE("failed to open vendor camera module");
|
ALOGE("Failed to open vendor camera module %d", rv);
|
||||||
|
|
||||||
ALOGE("%s:%u <- %d", __func__,__LINE__, rv);
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void camera_get_vendor_tag_ops(vendor_tag_ops_t* ops)
|
|
||||||
{
|
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int camera_open_legacy(const struct hw_module_t* module,
|
|
||||||
const char* id, uint32_t halVersion, struct hw_device_t** device)
|
|
||||||
{
|
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
|
||||||
return -ENOSYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define KEY_VIDEO_HFR_VALUES "video-hfr-values"
|
#define KEY_VIDEO_HFR_VALUES "video-hfr-values"
|
||||||
|
|
||||||
static char * camera_fixup_getparams(int id, const char * settings)
|
static char *camera_fixup_getparams(int __attribute__((unused)) id,
|
||||||
|
const char *settings)
|
||||||
{
|
{
|
||||||
android::CameraParameters params;
|
CameraParameters params;
|
||||||
|
params.unflatten(String8(settings));
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
|
||||||
|
|
||||||
params.unflatten(android::String8(settings));
|
|
||||||
|
|
||||||
#ifdef LOG_PARAMETERS
|
|
||||||
ALOGV("%s: original parameters:", __FUNCTION__);
|
ALOGV("%s: original parameters:", __FUNCTION__);
|
||||||
params.dump();
|
params.dump();
|
||||||
#endif
|
|
||||||
|
|
||||||
/* If the vendor has HFR values but doesn't also expose that
|
/* If the vendor has HFR values but doesn't also expose that
|
||||||
* this can be turned off, fixup the params to tell the Camera
|
* this can be turned off, fixup the params to tell the Camera
|
||||||
* that it really is okay to turn it off.
|
* that it really is okay to turn it off.
|
||||||
*/
|
*/
|
||||||
|
const char *hfrModeValues = params.get(KEY_VIDEO_HFR_VALUES);
|
||||||
const char* hfrValues = params.get(KEY_VIDEO_HFR_VALUES);
|
if (hfrModeValues && !strstr(hfrModeValues, "off")) {
|
||||||
if (hfrValues && *hfrValues && ! strstr(hfrValues, "off")) {
|
char hfrModes[strlen(hfrModeValues) + 4 + 1];
|
||||||
char tmp[strlen(hfrValues) + 4 + 1];
|
sprintf(hfrModes, "%s,off", hfrModeValues);
|
||||||
sprintf(tmp, "%s,off", hfrValues);
|
params.set(KEY_VIDEO_HFR_VALUES, hfrModes);
|
||||||
params.set(KEY_VIDEO_HFR_VALUES, tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ALOGV("%s: Fixed parameters:", __FUNCTION__);
|
||||||
|
params.dump();
|
||||||
|
|
||||||
android::String8 strParams = params.flatten();
|
String8 strParams = params.flatten();
|
||||||
char *ret = strdup(strParams.string());
|
char *ret = strdup(strParams.string());
|
||||||
|
|
||||||
#ifdef LOG_PARAMETERS
|
|
||||||
ALOGV("%s: fixed parameters:", __FUNCTION__);
|
|
||||||
params.dump();
|
|
||||||
#endif
|
|
||||||
return ret;
|
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);
|
CameraParameters params;
|
||||||
android::CameraParameters params;
|
params.unflatten(String8(settings));
|
||||||
|
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
|
||||||
|
|
||||||
params.unflatten(android::String8(settings));
|
|
||||||
|
|
||||||
#ifdef LOG_PARAMETERS
|
|
||||||
ALOGV("%s: original parameters:", __FUNCTION__);
|
ALOGV("%s: original parameters:", __FUNCTION__);
|
||||||
params.dump();
|
params.dump();
|
||||||
#endif
|
|
||||||
|
|
||||||
const char* recordingHint = params.get(android::CameraParameters::KEY_RECORDING_HINT);
|
ALOGV("%s: Fixed parameters:", __FUNCTION__);
|
||||||
bool isVideo = recordingHint && !strcmp(recordingHint, "true");
|
params.dump();
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (isVideo) {
|
|
||||||
params.set("dis", "disable");
|
|
||||||
params.set(android::CameraParameters::KEY_ZSL, "off");
|
|
||||||
} else {
|
|
||||||
params.set(android::CameraParameters::KEY_ZSL, "on");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
android::String8 strParams = params.flatten();
|
|
||||||
|
|
||||||
|
String8 strParams = params.flatten();
|
||||||
if (fixed_set_params[id])
|
if (fixed_set_params[id])
|
||||||
free(fixed_set_params[id]);
|
free(fixed_set_params[id]);
|
||||||
fixed_set_params[id] = strdup(strParams.string());
|
fixed_set_params[id] = strdup(strParams.string());
|
||||||
char *ret = fixed_set_params[id];
|
char *ret = fixed_set_params[id];
|
||||||
|
|
||||||
#ifdef LOG_PARAMETERS
|
|
||||||
ALOGV("%s: fixed parameters:", __FUNCTION__);
|
|
||||||
params.dump();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
* implementation of camera_device_ops functions
|
* Implementation of camera_device_ops functions
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
|
static char *camera_get_parameters(struct camera_device *device);
|
||||||
|
static int camera_set_parameters(struct camera_device *device, const char *params);
|
||||||
|
|
||||||
int camera_set_preview_window(struct camera_device * device,
|
static int camera_set_preview_window(struct camera_device *device,
|
||||||
struct preview_stream_ops *window)
|
struct preview_stream_ops *window)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, set_preview_window, window);
|
return VENDOR_CALL(device, set_preview_window, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,19 +197,19 @@ camera_memory_t* camera_get_memory(int fd, size_t buf_size,
|
|||||||
return gUserGetMemory(fd, buf_size, num_bufs, gUserCameraDevice);
|
return gUserGetMemory(fd, buf_size, num_bufs, gUserCameraDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
void camera_set_callbacks(struct camera_device * device,
|
static void camera_set_callbacks(struct camera_device *device,
|
||||||
camera_notify_callback notify_cb,
|
camera_notify_callback notify_cb,
|
||||||
camera_data_callback data_cb,
|
camera_data_callback data_cb,
|
||||||
camera_data_timestamp_callback data_cb_timestamp,
|
camera_data_timestamp_callback data_cb_timestamp,
|
||||||
camera_request_memory get_memory,
|
camera_request_memory get_memory,
|
||||||
void *user)
|
void *user)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
gUserNotifyCb = notify_cb;
|
gUserNotifyCb = notify_cb;
|
||||||
gUserDataCb = data_cb;
|
gUserDataCb = data_cb;
|
||||||
gUserDataCbTimestamp = data_cb_timestamp;
|
gUserDataCbTimestamp = data_cb_timestamp;
|
||||||
@ -271,258 +220,258 @@ void camera_set_callbacks(struct camera_device * device,
|
|||||||
camera_data_cb_timestamp, camera_get_memory, user);
|
camera_data_cb_timestamp, camera_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)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
VENDOR_CALL(device, enable_msg_type, 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)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
VENDOR_CALL(device, disable_msg_type, 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)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, msg_type_enabled, 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)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, start_preview);
|
return VENDOR_CALL(device, start_preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
void camera_stop_preview(struct camera_device * device)
|
static void camera_stop_preview(struct camera_device *device)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
VENDOR_CALL(device, stop_preview);
|
VENDOR_CALL(device, stop_preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
int camera_preview_enabled(struct camera_device * device)
|
static int camera_preview_enabled(struct camera_device *device)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, preview_enabled);
|
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)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, store_meta_data_in_buffers, 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)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
return VENDOR_CALL(device, start_recording);
|
return VENDOR_CALL(device, start_recording);
|
||||||
}
|
}
|
||||||
|
|
||||||
void camera_stop_recording(struct camera_device * device)
|
static void camera_stop_recording(struct camera_device *device)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
VENDOR_CALL(device, stop_recording);
|
VENDOR_CALL(device, stop_recording);
|
||||||
}
|
}
|
||||||
|
|
||||||
int camera_recording_enabled(struct camera_device * device)
|
static int camera_recording_enabled(struct camera_device *device)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, recording_enabled);
|
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)
|
const void *opaque)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
VENDOR_CALL(device, release_recording_frame, opaque);
|
VENDOR_CALL(device, release_recording_frame, opaque);
|
||||||
}
|
}
|
||||||
|
|
||||||
int camera_auto_focus(struct camera_device * device)
|
static int camera_auto_focus(struct camera_device *device)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, auto_focus);
|
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)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, cancel_auto_focus);
|
return VENDOR_CALL(device, cancel_auto_focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
int camera_take_picture(struct camera_device * device)
|
static int camera_take_picture(struct camera_device *device)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, take_picture);
|
return VENDOR_CALL(device, take_picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
int camera_cancel_picture(struct camera_device * device)
|
static int camera_cancel_picture(struct camera_device *device)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, cancel_picture);
|
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)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
char *tmp = NULL;
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
tmp = camera_fixup_setparams(device, params);
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
int ret = VENDOR_CALL(device, set_parameters, tmp);
|
char *tmp = camera_fixup_setparams(CAMERA_ID(device), params);
|
||||||
return ret;
|
|
||||||
|
return VENDOR_CALL(device, set_parameters, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* camera_get_parameters(struct camera_device * device)
|
static char *camera_get_parameters(struct camera_device *device)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
char* params = VENDOR_CALL(device, get_parameters);
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
|
char *params = VENDOR_CALL(device, get_parameters);
|
||||||
|
|
||||||
|
char *tmp = camera_fixup_getparams(CAMERA_ID(device), params);
|
||||||
|
|
||||||
char * tmp = camera_fixup_getparams(CAMERA_ID(device), params);
|
|
||||||
VENDOR_CALL(device, put_parameters, params);
|
VENDOR_CALL(device, put_parameters, params);
|
||||||
params = tmp;
|
params = tmp;
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void camera_put_parameters(struct camera_device *device, char *params)
|
static void camera_put_parameters(__unused struct camera_device *device,
|
||||||
|
char *params)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (params)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(params)
|
|
||||||
free(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)
|
int32_t cmd, int32_t arg1, int32_t arg2)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, send_command, cmd, arg1, arg2);
|
return VENDOR_CALL(device, send_command, cmd, arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void camera_release(struct camera_device * device)
|
static void camera_release(struct camera_device *device)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
ALOGI("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
|
||||||
|
|
||||||
if(!device)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
VENDOR_CALL(device, release);
|
VENDOR_CALL(device, release);
|
||||||
}
|
}
|
||||||
|
|
||||||
int camera_dump(struct camera_device * device, int fd)
|
static int camera_dump(struct camera_device *device, int fd)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
if (!device)
|
||||||
if(!device)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
|
||||||
|
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
|
||||||
|
|
||||||
return VENDOR_CALL(device, dump, fd);
|
return VENDOR_CALL(device, dump, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void heaptracker_free_leaked_memory(void);
|
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)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
wrapper_camera_device_t *wrapper_dev = NULL;
|
wrapper_camera_device_t *wrapper_dev = NULL;
|
||||||
|
|
||||||
ALOGI("%s", __FUNCTION__);
|
ALOGV("%s", __FUNCTION__);
|
||||||
|
|
||||||
android::Mutex::Autolock lock(gCameraWrapperLock);
|
Mutex::Autolock lock(gCameraWrapperLock);
|
||||||
|
|
||||||
if (!device) {
|
if (!device) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
@ -548,73 +497,74 @@ done:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
* implementation of camera_module functions
|
* Implementation of camera_module functions
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
|
|
||||||
/* open device handle to one of the cameras
|
/*
|
||||||
|
* Open device handle to one of the cameras
|
||||||
*
|
*
|
||||||
* assume camera service will keep singleton of each camera
|
* Assume camera service will keep singleton of each camera
|
||||||
* so this function will always only be called once per camera instance
|
* 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)
|
hw_device_t **device)
|
||||||
{
|
{
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
int num_cameras = 0;
|
int num_cameras = 0;
|
||||||
int cameraid;
|
int camera_id;
|
||||||
wrapper_camera_device_t* camera_device = NULL;
|
wrapper_camera_device_t *camera_device = NULL;
|
||||||
camera_device_ops_t* camera_ops = NULL;
|
camera_device_ops_t *camera_ops = NULL;
|
||||||
|
|
||||||
android::Mutex::Autolock lock(gCameraWrapperLock);
|
Mutex::Autolock lock(gCameraWrapperLock);
|
||||||
|
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
ALOGV("%s", __FUNCTION__);
|
||||||
ALOGI("camera_device open");
|
|
||||||
|
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
if (check_vendor_module())
|
if (check_vendor_module())
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
cameraid = atoi(name);
|
camera_id = atoi(name);
|
||||||
num_cameras = gVendorModule->get_number_of_cameras();
|
num_cameras = gVendorModule->get_number_of_cameras();
|
||||||
|
|
||||||
fixed_set_params = (char **) malloc(sizeof(char *) * num_cameras);
|
fixed_set_params = (char **) malloc(sizeof(char *) *num_cameras);
|
||||||
if (!fixed_set_params) {
|
if (!fixed_set_params) {
|
||||||
ALOGE("parameter memory allocation fail");
|
ALOGE("Parameter memory allocation fail");
|
||||||
rv = -ENOMEM;
|
rv = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
memset(fixed_set_params, 0, sizeof(char *) * num_cameras);
|
memset(fixed_set_params, 0, sizeof(char *) * num_cameras);
|
||||||
|
|
||||||
if(cameraid > num_cameras)
|
if (camera_id > num_cameras) {
|
||||||
{
|
ALOGE("Camera service provided camera_id out of bounds, "
|
||||||
ALOGE("camera service provided cameraid out of bounds, "
|
"camera_id = %d, num supported = %d",
|
||||||
"cameraid = %d, num supported = %d",
|
camera_id, num_cameras);
|
||||||
cameraid, num_cameras);
|
|
||||||
rv = -EINVAL;
|
rv = -EINVAL;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
camera_device = (wrapper_camera_device_t*)malloc(sizeof(*camera_device));
|
camera_device = (wrapper_camera_device_t*)
|
||||||
if(!camera_device)
|
malloc(sizeof(*camera_device));
|
||||||
{
|
if (!camera_device) {
|
||||||
ALOGE("camera_device allocation fail");
|
ALOGE("camera_device allocation fail");
|
||||||
rv = -ENOMEM;
|
rv = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
memset(camera_device, 0, sizeof(*camera_device));
|
memset(camera_device, 0, sizeof(*camera_device));
|
||||||
camera_device->id = cameraid;
|
camera_device->id = camera_id;
|
||||||
|
|
||||||
rv = gVendorModule->common.methods->open((const hw_module_t*)gVendorModule, name, (hw_device_t**)&(camera_device->vendor));
|
rv = gVendorModule->common.methods->open(
|
||||||
|
(const hw_module_t*)gVendorModule, name,
|
||||||
|
(hw_device_t**)&(camera_device->vendor));
|
||||||
if (rv) {
|
if (rv) {
|
||||||
ALOGE("vendor camera open fail");
|
ALOGE("Vendor camera open fail");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
ALOGI("%s: got vendor camera device 0x%08X", __FUNCTION__, (uintptr_t)(camera_device->vendor));
|
ALOGV("%s: Got vendor camera device 0x%08X",
|
||||||
|
__FUNCTION__, (uintptr_t)(camera_device->vendor));
|
||||||
|
|
||||||
camera_ops = (camera_device_ops_t*)malloc(sizeof(*camera_ops));
|
camera_ops = (camera_device_ops_t*)malloc(sizeof(*camera_ops));
|
||||||
if(!camera_ops)
|
if (!camera_ops) {
|
||||||
{
|
|
||||||
ALOGE("camera_ops allocation fail");
|
ALOGE("camera_ops allocation fail");
|
||||||
rv = -ENOMEM;
|
rv = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -623,7 +573,7 @@ int camera_device_open(const hw_module_t* module, const char* name,
|
|||||||
memset(camera_ops, 0, sizeof(*camera_ops));
|
memset(camera_ops, 0, sizeof(*camera_ops));
|
||||||
|
|
||||||
camera_device->base.common.tag = HARDWARE_DEVICE_TAG;
|
camera_device->base.common.tag = HARDWARE_DEVICE_TAG;
|
||||||
camera_device->base.common.version = 0;
|
camera_device->base.common.version = CAMERA_DEVICE_API_VERSION_1_0;
|
||||||
camera_device->base.common.module = (hw_module_t *)(module);
|
camera_device->base.common.module = (hw_module_t *)(module);
|
||||||
camera_device->base.common.close = camera_device_close;
|
camera_device->base.common.close = camera_device_close;
|
||||||
camera_device->base.ops = camera_ops;
|
camera_device->base.ops = camera_ops;
|
||||||
@ -658,11 +608,11 @@ int camera_device_open(const hw_module_t* module, const char* name,
|
|||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if(camera_device) {
|
if (camera_device) {
|
||||||
free(camera_device);
|
free(camera_device);
|
||||||
camera_device = NULL;
|
camera_device = NULL;
|
||||||
}
|
}
|
||||||
if(camera_ops) {
|
if (camera_ops) {
|
||||||
free(camera_ops);
|
free(camera_ops);
|
||||||
camera_ops = NULL;
|
camera_ops = NULL;
|
||||||
}
|
}
|
||||||
@ -670,23 +620,19 @@ fail:
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int camera_get_number_of_cameras(void)
|
static int camera_get_number_of_cameras(void)
|
||||||
{
|
{
|
||||||
int numberOfCameras = 0;
|
ALOGV("%s", __FUNCTION__);
|
||||||
ALOGE("%s:%u ->", __func__,__LINE__);
|
|
||||||
|
|
||||||
if (check_vendor_module())
|
if (check_vendor_module())
|
||||||
return 0;
|
return 0;
|
||||||
|
return gVendorModule->get_number_of_cameras();
|
||||||
numberOfCameras = gVendorModule->get_number_of_cameras();
|
|
||||||
ALOGE("%s:%u <- %d", __func__,__LINE__, numberOfCameras);
|
|
||||||
return numberOfCameras;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
ALOGE("%s:%u", __func__,__LINE__);
|
ALOGV("%s", __FUNCTION__);
|
||||||
if (check_vendor_module())
|
if (check_vendor_module())
|
||||||
return 0;
|
return 0;
|
||||||
return gVendorModule->get_camera_info(camera_id, info);
|
return gVendorModule->get_camera_info(camera_id, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user