Created
January 14, 2017 20:44
-
-
Save invisiblek/5215d0f6854803e8c5df279374d22f59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk | |
index 865ea10..dbe9b8d 100644 | |
--- a/BoardConfigCommon.mk | |
+++ b/BoardConfigCommon.mk | |
@@ -57,6 +57,11 @@ BOARD_HAVE_BLUETOOTH := true | |
BOARD_HAVE_BLUETOOTH_BCM := true | |
# Camera | |
+TARGET_HAS_LEGACY_CAMERA_HAL1 := true | |
+BOARD_GLOBAL_CFLAGS += -DDECAY_TIME_DEFAULT=0 | |
+MALLOC_SVELTE := true | |
+TARGET_NEEDS_GCC_LIBC := true | |
+TARGET_NEEDS_PLATFORM_TEXT_RELOCATIONS := true | |
TARGET_PROVIDES_CAMERA_HAL := true | |
USE_DEVICE_SPECIFIC_CAMERA := true | |
diff --git a/camera/Android.mk b/camera/Android.mk | |
index f4ec731..15743f0 100644 | |
--- a/camera/Android.mk | |
+++ b/camera/Android.mk | |
@@ -1,6 +1,10 @@ | |
LOCAL_PATH := $(call my-dir) | |
include $(CLEAR_VARS) | |
+LOCAL_CLANG := false | |
+ | |
+LOCAL_CFLAGS += -Os | |
+ | |
LOCAL_C_INCLUDES += \ | |
system/media/camera/include | |
diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp | |
index 6393de2..ad9087d 100644 | |
--- a/camera/CameraWrapper.cpp | |
+++ b/camera/CameraWrapper.cpp | |
@@ -1,5 +1,7 @@ | |
+ | |
/* | |
- * Copyright (C) 2012-2016, The CyanogenMod Project | |
+ * Copyright (C) 2012-2015, The CyanogenMod Project | |
+ * Copyright (C) 2016, JDCTeam | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
@@ -18,19 +20,24 @@ | |
* @file CameraWrapper.cpp | |
* | |
* This file wraps a vendor camera module. | |
+* | |
*/ | |
-#define LOG_TAG "CameraWrapper" | |
+#define LOG_NDEBUG 0 | |
+#define LOG_PARAMETERS | |
-#include <camera/CameraParameters.h> | |
-#include <camera/Camera.h> | |
+#define LOG_TAG "CameraWrapper" | |
#include <cutils/log.h> | |
-#include <hardware/camera.h> | |
-#include <hardware/hardware.h> | |
-#include <utils/String8.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 <dlfcn.h> | |
-#define REAR_CAMERA_ID 0 | |
+#define BACK_CAMERA_ID 0 | |
#define FRONT_CAMERA_ID 1 | |
using namespace android; | |
@@ -40,13 +47,17 @@ static camera_module_t *gVendorModule = 0; | |
static char **fixed_set_params = NULL; | |
+ | |
static int camera_device_open(const hw_module_t *module, const char *name, | |
hw_device_t **device); | |
static int camera_get_number_of_cameras(void); | |
+static int camera_device_close(hw_device_t* device); | |
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, | |
+ .open = camera_device_open | |
}; | |
camera_module_t HAL_MODULE_INFO_SYM = { | |
@@ -55,20 +66,20 @@ camera_module_t HAL_MODULE_INFO_SYM = { | |
.module_api_version = CAMERA_MODULE_API_VERSION_1_0, | |
.hal_api_version = HARDWARE_HAL_API_VERSION, | |
.id = CAMERA_HARDWARE_MODULE_ID, | |
- .name = "JF Camera Wrapper", | |
+ .name = "Samsung jf Camera Wrapper", | |
.author = "The CyanogenMod Project", | |
.methods = &camera_module_methods, | |
- .dso = NULL, | |
- .reserved = {0}, | |
+ .dso = NULL, /* remove compilation warnings */ | |
+ .reserved = {0}, /* remove compilation warnings */ | |
}, | |
.get_number_of_cameras = camera_get_number_of_cameras, | |
.get_camera_info = camera_get_camera_info, | |
- .set_callbacks = NULL, | |
- .get_vendor_tag_ops = NULL, | |
- .open_legacy = NULL, | |
- .set_torch_mode = NULL, | |
- .init = NULL, | |
- .reserved = {0}, | |
+ .set_callbacks = NULL, /* remove compilation warnings */ | |
+ .get_vendor_tag_ops = NULL, /* remove compilation warnings */ | |
+ .open_legacy = NULL, /* remove compilation warnings */ | |
+ .set_torch_mode = NULL, /* remove compilation warnings */ | |
+ .init = NULL, /* remove compilation warnings */ | |
+ .reserved = {0}, /* remove compilation warnings */ | |
}; | |
typedef struct wrapper_camera_device { | |
@@ -82,107 +93,37 @@ typedef struct wrapper_camera_device { | |
__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 char *camera_get_parameters(struct camera_device *device); | |
+static int camera_set_parameters(struct camera_device *device, | |
+ const char *params); | |
+ | |
+const static char * iso_values[] = {"auto,ISO_HJR,ISO100,ISO200,ISO400,ISO800,ISO1600,auto"}; | |
static int check_vendor_module() | |
{ | |
- int rv; | |
- ALOGV("%s", __FUNCTION__); | |
- | |
if (gVendorModule) | |
return 0; | |
+ int rv = 0; | |
rv = hw_get_module_by_class("camera", "vendor", | |
(const hw_module_t**)&gVendorModule); | |
- if (rv) | |
- ALOGE("Failed to open vendor camera module %d", rv); | |
return rv; | |
} | |
-static char *camera_fixup_getparams(int id, const char *settings) | |
-{ | |
- CameraParameters params; | |
- params.unflatten(String8(settings)); | |
- | |
- ALOGV("%s: Original parameters:", __FUNCTION__); | |
- params.dump(); | |
- | |
- /* Rear photos: Remove HDR scene mode */ | |
- if (id == REAR_CAMERA_ID) { | |
- params.set(CameraParameters::KEY_SUPPORTED_SCENE_MODES, | |
- "auto,action,night,sunset,party"); | |
- } | |
- | |
- /* Photos: Correct exposed ISO values */ | |
- params.set(CameraParameters::KEY_SUPPORTED_ISO_MODES, | |
- "auto,ISO_HJR,ISO100,ISO200,ISO400,ISO800,ISO1600"); | |
- | |
- ALOGV("%s: Fixed parameters:", __FUNCTION__); | |
- params.dump(); | |
- | |
- String8 strParams = params.flatten(); | |
- char *ret = strdup(strParams.string()); | |
- | |
- return ret; | |
-} | |
- | |
-static char *camera_fixup_setparams(int id, const char *settings) | |
-{ | |
- CameraParameters params; | |
- params.unflatten(String8(settings)); | |
- | |
- ALOGV("%s: Original parameters:", __FUNCTION__); | |
- params.dump(); | |
- | |
- const char *recordHint = params.get(CameraParameters::KEY_RECORDING_HINT); | |
- bool isVideo = recordHint && !strcmp(recordHint, "true"); | |
- | |
- /* Rear videos: Correct camera mode to 0 */ | |
- if (isVideo && id == REAR_CAMERA_ID) { | |
- params.set(CameraParameters::KEY_CAMERA_MODE, "0"); | |
- } | |
- | |
- /* Photos: Map the corrected ISO values to the ones in the HAL */ | |
- const char *isoMode = params.get(CameraParameters::KEY_ISO_MODE); | |
- if (isoMode) { | |
- if (!strcmp(isoMode, "ISO100")) | |
- params.set(CameraParameters::KEY_ISO_MODE, "100"); | |
- else if (!strcmp(isoMode, "ISO200")) | |
- params.set(CameraParameters::KEY_ISO_MODE, "200"); | |
- else if (!strcmp(isoMode, "ISO400")) | |
- params.set(CameraParameters::KEY_ISO_MODE, "400"); | |
- else if (!strcmp(isoMode, "ISO800")) | |
- params.set(CameraParameters::KEY_ISO_MODE, "800"); | |
- else if (!strcmp(isoMode, "ISO1600")) | |
- params.set(CameraParameters::KEY_ISO_MODE, "1600"); | |
- } | |
- | |
- ALOGV("%s: Fixed parameters:", __FUNCTION__); | |
- params.dump(); | |
- | |
- String8 strParams = params.flatten(); | |
- if (fixed_set_params[id]) | |
- free(fixed_set_params[id]); | |
- fixed_set_params[id] = strdup(strParams.string()); | |
- char *ret = fixed_set_params[id]; | |
- | |
- return ret; | |
-} | |
- | |
/******************************************************************* | |
- * Implementation of camera_device_ops functions | |
+ * implementation of camera_device_ops functions | |
*******************************************************************/ | |
static int camera_set_preview_window(struct camera_device *device, | |
struct preview_stream_ops *window) | |
{ | |
+ | |
if (!device) | |
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); | |
} | |
@@ -193,12 +134,11 @@ static void camera_set_callbacks(struct camera_device *device, | |
camera_request_memory get_memory, | |
void *user) | |
{ | |
+ | |
+ | |
if (!device) | |
return; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
VENDOR_CALL(device, set_callbacks, notify_cb, data_cb, data_cb_timestamp, | |
get_memory, user); | |
} | |
@@ -206,12 +146,11 @@ static void camera_set_callbacks(struct camera_device *device, | |
static void camera_enable_msg_type(struct camera_device *device, | |
int32_t msg_type) | |
{ | |
+ | |
+ | |
if (!device) | |
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); | |
} | |
@@ -221,9 +160,6 @@ static void camera_disable_msg_type(struct camera_device *device, | |
if (!device) | |
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); | |
} | |
@@ -233,9 +169,6 @@ static int camera_msg_type_enabled(struct camera_device *device, | |
if (!device) | |
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); | |
} | |
@@ -244,9 +177,6 @@ static int camera_start_preview(struct camera_device *device) | |
if (!device) | |
return -EINVAL; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
return VENDOR_CALL(device, start_preview); | |
} | |
@@ -255,9 +185,6 @@ static void camera_stop_preview(struct camera_device *device) | |
if (!device) | |
return; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
VENDOR_CALL(device, stop_preview); | |
} | |
@@ -266,9 +193,6 @@ static int camera_preview_enabled(struct camera_device *device) | |
if (!device) | |
return -EINVAL; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
return VENDOR_CALL(device, preview_enabled); | |
} | |
@@ -278,54 +202,43 @@ static int camera_store_meta_data_in_buffers(struct camera_device *device, | |
if (!device) | |
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); | |
} | |
static int camera_start_recording(struct camera_device *device) | |
{ | |
+ | |
if (!device) | |
return EINVAL; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
return VENDOR_CALL(device, start_recording); | |
} | |
static void camera_stop_recording(struct camera_device *device) | |
{ | |
+ | |
if (!device) | |
return; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
VENDOR_CALL(device, stop_recording); | |
} | |
static int camera_recording_enabled(struct camera_device *device) | |
{ | |
+ | |
if (!device) | |
return -EINVAL; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
return VENDOR_CALL(device, recording_enabled); | |
} | |
static void camera_release_recording_frame(struct camera_device *device, | |
const void *opaque) | |
{ | |
+ | |
if (!device) | |
return; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
VENDOR_CALL(device, release_recording_frame, opaque); | |
} | |
@@ -334,21 +247,17 @@ static int camera_auto_focus(struct camera_device *device) | |
if (!device) | |
return -EINVAL; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
return VENDOR_CALL(device, auto_focus); | |
} | |
static int camera_cancel_auto_focus(struct camera_device *device) | |
{ | |
+ int ret = 0; | |
+ | |
if (!device) | |
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 ret; | |
} | |
static int camera_take_picture(struct camera_device *device) | |
@@ -356,9 +265,6 @@ static int camera_take_picture(struct camera_device *device) | |
if (!device) | |
return -EINVAL; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
return VENDOR_CALL(device, take_picture); | |
} | |
@@ -367,9 +273,6 @@ static int camera_cancel_picture(struct camera_device *device) | |
if (!device) | |
return -EINVAL; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
return VENDOR_CALL(device, cancel_picture); | |
} | |
@@ -379,80 +282,129 @@ static int camera_set_parameters(struct camera_device *device, | |
if (!device) | |
return -EINVAL; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
+ int id = CAMERA_ID(device); | |
+ CameraParameters _params; | |
+ _params.unflatten(android::String8(params)); | |
+ | |
+ // jactive device camera doesn't seem to have recording hint param, so read it safely | |
+ const char* recordingHint = _params.get(android::CameraParameters::KEY_RECORDING_HINT); | |
+ bool isVideo = false; | |
+ if (recordingHint) | |
+ isVideo = !strcmp(recordingHint, "true"); | |
+ | |
+ // fix params here | |
+ // No need to fix-up ISO_HJR, it is the same for userspace and the camera lib | |
+ if(_params.get("iso")) { | |
+ const char* isoMode = _params.get(android::CameraParameters::KEY_ISO_MODE); | |
+ if(strcmp(isoMode, "ISO100") == 0) | |
+ _params.set(android::CameraParameters::KEY_ISO_MODE, "100"); | |
+ else if(strcmp(isoMode, "ISO200") == 0) | |
+ _params.set(android::CameraParameters::KEY_ISO_MODE, "200"); | |
+ else if(strcmp(isoMode, "ISO400") == 0) | |
+ _params.set(android::CameraParameters::KEY_ISO_MODE, "400"); | |
+ else if(strcmp(isoMode, "ISO800") == 0) | |
+ _params.set(android::CameraParameters::KEY_ISO_MODE, "800"); | |
+ else if(strcmp(isoMode, "ISO1600") == 0) | |
+ _params.set(android::CameraParameters::KEY_ISO_MODE, "1600"); | |
+ } | |
+ | |
+ _params.set(android::CameraParameters::KEY_ZSL, isVideo ? "off" : "on"); | |
+ _params.set(android::CameraParameters::KEY_CAMERA_MODE, isVideo ? "0" : "1"); | |
+ | |
+ String8 strParams = _params.flatten(); | |
+ | |
+ if (fixed_set_params[id]) | |
+ delete fixed_set_params[id]; | |
+ fixed_set_params[id] = strdup(strParams.string()); | |
+ | |
+ char *tmp = fixed_set_params[id]; | |
- char *tmp = camera_fixup_setparams(CAMERA_ID(device), params); | |
+ int ret = VENDOR_CALL(device, set_parameters, tmp); | |
+ return ret; | |
- return VENDOR_CALL(device, set_parameters, tmp); | |
} | |
+ | |
static char *camera_get_parameters(struct camera_device *device) | |
{ | |
+ | |
if (!device) | |
return NULL; | |
- 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* params = VENDOR_CALL(device, get_parameters); | |
+ int id = CAMERA_ID(device); | |
+ | |
+ //=============start of fixup | |
+ | |
+ android::CameraParameters _params; | |
+ _params.unflatten(android::String8(params)); | |
+ | |
+ // fix params here | |
+ _params.set(android::CameraParameters::KEY_SUPPORTED_ISO_MODES, iso_values[id]); | |
+ | |
+ /* Remove HDR on rear cam */ | |
+ if (id != 1) { | |
+ _params.set(android::CameraParameters::KEY_SUPPORTED_SCENE_MODES, "auto,action,night,sunset,party"); | |
+ } | |
+ | |
+ /* Enforce video-snapshot-supported to true */ | |
+ _params.set(android::CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED, "true"); | |
+ | |
+ String8 strParams = _params.flatten(); | |
+ char *ret = strdup(strParams.string()); | |
+ | |
+ //=============end of fixup | |
+ char * tmp = ret; | |
+ | |
VENDOR_CALL(device, put_parameters, params); | |
- params = tmp; | |
- | |
+ params = tmp; | |
+ | |
return params; | |
} | |
-static void camera_put_parameters(__unused struct camera_device *device, | |
- char *params) | |
+static void camera_put_parameters(struct camera_device *device, char *params) | |
{ | |
- if (params) | |
- free(params); | |
+ if (params) { | |
+ delete params; | |
+ } | |
} | |
static int camera_send_command(struct camera_device *device, | |
int32_t cmd, int32_t arg1, int32_t arg2) | |
{ | |
+ | |
if (!device) | |
return -EINVAL; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
+ if(cmd == CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG) | |
+ return 0; | |
+ | |
return VENDOR_CALL(device, send_command, cmd, arg1, arg2); | |
} | |
static void camera_release(struct camera_device *device) | |
{ | |
+ | |
if (!device) | |
return; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
VENDOR_CALL(device, release); | |
} | |
static int camera_dump(struct camera_device *device, int fd) | |
{ | |
+ | |
if (!device) | |
return -EINVAL; | |
- ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, | |
- (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); | |
- | |
return VENDOR_CALL(device, dump, fd); | |
} | |
-extern "C" void heaptracker_free_leaked_memory(void); | |
- | |
static int camera_device_close(hw_device_t *device) | |
{ | |
int ret = 0; | |
wrapper_camera_device_t *wrapper_dev = NULL; | |
- ALOGV("%s", __FUNCTION__); | |
Mutex::Autolock lock(gCameraWrapperLock); | |
@@ -463,31 +415,26 @@ static int camera_device_close(hw_device_t *device) | |
for (int i = 0; i < camera_get_number_of_cameras(); i++) { | |
if (fixed_set_params[i]) | |
- free(fixed_set_params[i]); | |
+ delete fixed_set_params[i]; | |
} | |
- | |
+ | |
wrapper_dev = (wrapper_camera_device_t*) device; | |
wrapper_dev->vendor->common.close((hw_device_t*)wrapper_dev->vendor); | |
if (wrapper_dev->base.ops) | |
- free(wrapper_dev->base.ops); | |
- free(wrapper_dev); | |
- | |
+ delete wrapper_dev->base.ops; | |
+ delete wrapper_dev; | |
done: | |
-#ifdef HEAPTRACKER | |
- heaptracker_free_leaked_memory(); | |
-#endif | |
return ret; | |
} | |
/******************************************************************* | |
- * 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 | |
*/ | |
@@ -496,60 +443,49 @@ static int camera_device_open(const hw_module_t *module, const char *name, | |
{ | |
int rv = 0; | |
int num_cameras = 0; | |
- int camera_id; | |
+ int cameraid; | |
wrapper_camera_device_t *camera_device = NULL; | |
camera_device_ops_t *camera_ops = NULL; | |
Mutex::Autolock lock(gCameraWrapperLock); | |
- ALOGV("%s", __FUNCTION__); | |
if (name != NULL) { | |
if (check_vendor_module()) | |
return -EINVAL; | |
- camera_id = atoi(name); | |
+ cameraid = atoi(name); | |
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) { | |
- ALOGE("Parameter memory allocation fail"); | |
rv = -ENOMEM; | |
goto fail; | |
} | |
memset(fixed_set_params, 0, sizeof(char *) * num_cameras); | |
- | |
- if (camera_id > num_cameras) { | |
- ALOGE("Camera service provided camera_id out of bounds, " | |
- "camera_id = %d, num supported = %d", | |
- camera_id, num_cameras); | |
+ | |
+ if (cameraid > num_cameras) { | |
rv = -EINVAL; | |
goto fail; | |
} | |
- camera_device = (wrapper_camera_device_t*) | |
- malloc(sizeof(*camera_device)); | |
+ camera_device = (wrapper_camera_device_t*)malloc(sizeof(*camera_device)); | |
if (!camera_device) { | |
- ALOGE("camera_device allocation fail"); | |
rv = -ENOMEM; | |
goto fail; | |
} | |
memset(camera_device, 0, sizeof(*camera_device)); | |
- camera_device->id = camera_id; | |
+ camera_device->id = cameraid; | |
rv = gVendorModule->common.methods->open( | |
(const hw_module_t*)gVendorModule, name, | |
(hw_device_t**)&(camera_device->vendor)); | |
if (rv) { | |
- ALOGE("Vendor camera open fail"); | |
goto fail; | |
} | |
- 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) { | |
- ALOGE("camera_ops allocation fail"); | |
rv = -ENOMEM; | |
goto fail; | |
} | |
@@ -567,22 +503,28 @@ static int camera_device_open(const hw_module_t *module, const char *name, | |
camera_ops->enable_msg_type = camera_enable_msg_type; | |
camera_ops->disable_msg_type = camera_disable_msg_type; | |
camera_ops->msg_type_enabled = camera_msg_type_enabled; | |
+ | |
camera_ops->start_preview = camera_start_preview; | |
camera_ops->stop_preview = camera_stop_preview; | |
camera_ops->preview_enabled = camera_preview_enabled; | |
camera_ops->store_meta_data_in_buffers = camera_store_meta_data_in_buffers; | |
+ | |
camera_ops->start_recording = camera_start_recording; | |
camera_ops->stop_recording = camera_stop_recording; | |
camera_ops->recording_enabled = camera_recording_enabled; | |
camera_ops->release_recording_frame = camera_release_recording_frame; | |
+ | |
camera_ops->auto_focus = camera_auto_focus; | |
camera_ops->cancel_auto_focus = camera_cancel_auto_focus; | |
+ | |
camera_ops->take_picture = camera_take_picture; | |
camera_ops->cancel_picture = camera_cancel_picture; | |
+ | |
camera_ops->set_parameters = camera_set_parameters; | |
camera_ops->get_parameters = camera_get_parameters; | |
camera_ops->put_parameters = camera_put_parameters; | |
camera_ops->send_command = camera_send_command; | |
+ | |
camera_ops->release = camera_release; | |
camera_ops->dump = camera_dump; | |
@@ -593,20 +535,22 @@ static int camera_device_open(const hw_module_t *module, const char *name, | |
fail: | |
if (camera_device) { | |
- free(camera_device); | |
camera_device = NULL; | |
+ delete camera_device; | |
} | |
if (camera_ops) { | |
- free(camera_ops); | |
camera_ops = NULL; | |
+ delete camera_ops; | |
} | |
*device = NULL; | |
+ delete device; | |
+ delete name; | |
+ delete module; | |
return rv; | |
} | |
static int camera_get_number_of_cameras(void) | |
{ | |
- ALOGV("%s", __FUNCTION__); | |
if (check_vendor_module()) | |
return 0; | |
return gVendorModule->get_number_of_cameras(); | |
@@ -614,7 +558,6 @@ static int camera_get_number_of_cameras(void) | |
static int camera_get_camera_info(int camera_id, struct camera_info *info) | |
{ | |
- ALOGV("%s", __FUNCTION__); | |
if (check_vendor_module()) | |
return 0; | |
return gVendorModule->get_camera_info(camera_id, info); | |
diff --git a/include/camera/CameraParametersExtra.h b/include/camera/CameraParametersExtra.h | |
index c545a6c..302d07a 100644 | |
--- a/include/camera/CameraParametersExtra.h | |
+++ b/include/camera/CameraParametersExtra.h | |
@@ -15,11 +15,19 @@ | |
*/ | |
#define CAMERA_PARAMETERS_EXTRA_C \ | |
-const char CameraParameters::KEY_CAMERA_MODE[] = "camera-mode"; \ | |
+const char CameraParameters::KEY_SUPPORTED_ISO_MODES[] = "iso-values"; \ | |
+const char CameraParameters::KEY_FACE_DETECTION[] = "face-detection"; \ | |
+const char CameraParameters::KEY_SUPPORTED_FACE_DETECTION[] = "face-detection-values"; \ | |
+const char CameraParameters::KEY_ZSL[] = "zsl"; \ | |
const char CameraParameters::KEY_ISO_MODE[] = "iso"; \ | |
-const char CameraParameters::KEY_SUPPORTED_ISO_MODES[] = "iso-values"; | |
+const char CameraParameters::KEY_CAMERA_MODE[] = "camera-mode"; \ | |
+const char CameraParameters::KEY_SAMSUNG_CAMERA_MODE[] = "cam_mode"; | |
#define CAMERA_PARAMETERS_EXTRA_H \ | |
- static const char KEY_CAMERA_MODE[]; \ | |
+ static const char KEY_SUPPORTED_ISO_MODES[]; \ | |
+ static const char KEY_FACE_DETECTION[]; \ | |
+ static const char KEY_SUPPORTED_FACE_DETECTION[]; \ | |
+ static const char KEY_ZSL[]; \ | |
static const char KEY_ISO_MODE[]; \ | |
- static const char KEY_SUPPORTED_ISO_MODES[]; | |
+ static const char KEY_CAMERA_MODE[]; \ | |
+ static const char KEY_SAMSUNG_CAMERA_MODE[]; | |
diff --git a/jf-common.mk b/jf-common.mk | |
index dbfdd3b..7f83bc3 100644 | |
--- a/jf-common.mk | |
+++ b/jf-common.mk | |
@@ -160,6 +160,9 @@ PRODUCT_COPY_FILES += \ | |
$(LOCAL_PATH)/configs/libnfc-brcm.conf:system/etc/libnfc-brcm.conf \ | |
$(LOCAL_PATH)/configs/nfcee_access.xml:system/etc/nfcee_access.xml | |
+PRODUCT_PROPERTY_OVERRIDES += \ | |
+ camera2.portability.force_api=1 | |
+ | |
# OMX | |
PRODUCT_PACKAGES += \ | |
libOmxCore \ | |
diff --git a/overlay/packages/apps/Snap/res/values/config.xml b/overlay/packages/apps/Snap/res/values/config.xml | |
index cd34d0c..7a7c1df 100644 | |
--- a/overlay/packages/apps/Snap/res/values/config.xml | |
+++ b/overlay/packages/apps/Snap/res/values/config.xml | |
@@ -18,6 +18,9 @@ | |
<!-- Restart preview for back camera onPictureTaken --> | |
<bool name="back_camera_restart_preview_onPictureTaken">true</bool> | |
+ <!-- Restart preview for front camera onPictureTaken --> | |
+ <bool name="front_camera_restart_preview_onPictureTaken">true</bool> | |
+ | |
<!-- Opens back camera using openLegacy() --> | |
<bool name="back_camera_open_legacy">false</bool> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment