diff options
author | Andrew Dodd <atd7@cornell.edu> | 2012-04-24 18:42:19 -0400 |
---|---|---|
committer | Andrew Dodd <atd7@cornell.edu> | 2012-04-24 18:42:19 -0400 |
commit | 6e35180562a82545e11afa56b0b40f946c47a937 (patch) | |
tree | 1697c2aa5d051a6e79f34b18e5f84af6744fdf21 /camera | |
parent | 99d5d64d2b276e45e7f7bf9c7587e75acccc4f7e (diff) | |
download | device_samsung_n7000-6e35180562a82545e11afa56b0b40f946c47a937.zip device_samsung_n7000-6e35180562a82545e11afa56b0b40f946c47a937.tar.gz device_samsung_n7000-6e35180562a82545e11afa56b0b40f946c47a937.tar.bz2 |
camera: Bring in latest galaxys2 camera wrapper
We use the same BFC/FFC as galaxys2
Change-Id: I5ae1d567a47860d1350f4ab3cb8c85312838a634
Diffstat (limited to 'camera')
-rw-r--r-- | camera/Android.mk | 12 | ||||
-rw-r--r-- | camera/CameraWrapper.cpp | 99 |
2 files changed, 91 insertions, 20 deletions
diff --git a/camera/Android.mk b/camera/Android.mk index 6005a54..46cce24 100644 --- a/camera/Android.mk +++ b/camera/Android.mk @@ -1,15 +1,15 @@ -LOCAL_PATH:= $(call my-dir) +LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_SRC_FILES:= \ +LOCAL_SRC_FILES := \ CameraWrapper.cpp -LOCAL_SHARED_LIBRARIES:= \ - libhardware liblog +LOCAL_SHARED_LIBRARIES := \ + libhardware liblog libcamera_client libutils LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw -LOCAL_MODULE:= camera.$(TARGET_BOARD_PLATFORM) -LOCAL_MODULE_TAGS:= optional +LOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM) +LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) #include $(BUILD_HEAPTRACKED_SHARED_LIBRARY) diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp index c1f066d..144b5d3 100644 --- a/camera/CameraWrapper.cpp +++ b/camera/CameraWrapper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) Hacsksung + * Copyright (C) 2012, The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,13 +21,19 @@ * */ +/* #define LOG_NDEBUG 0 +#define LOG_PARAMETERS +*/ #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> static android::Mutex gCameraWrapperLock; static camera_module_t *gVendorModule = 0; @@ -49,7 +55,7 @@ camera_module_t HAL_MODULE_INFO_SYM = { version_minor: 0, id: CAMERA_HARDWARE_MODULE_ID, name: "Exynos Camera Wrapper", - author: "Hacksung", + author: "Teamhacksung <info@teamhacksung.org>", methods: &camera_module_methods, dso: NULL, /* remove compilation warnings */ reserved: {0}, /* remove compilation warnings */ @@ -60,6 +66,7 @@ camera_module_t HAL_MODULE_INFO_SYM = { typedef struct wrapper_camera_device { camera_device_t base; + int id; camera_device_t *vendor; } wrapper_camera_device_t; @@ -68,6 +75,8 @@ 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) + static int check_vendor_module() { int rv = 0; @@ -82,6 +91,52 @@ static int check_vendor_module() return rv; } +const static char * video_preview_sizes[] = { + "1920x1080,1280x720,640x480", + "640x480,352x288,320x240,176x144" +}; + +static char * camera_fixup_getparams(int id, const char * settings) +{ + android::CameraParameters params; + params.unflatten(android::String8(settings)); + + params.remove(android::CameraParameters::KEY_SUPPORTED_VIDEO_SIZES); + + if(params.get("cam_mode")) + { + params.set(android::CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, video_preview_sizes[id]); + const char* videoSize = params.get(android::CameraParameters::KEY_VIDEO_SIZE); + params.set(android::CameraParameters::KEY_PREVIEW_SIZE, videoSize); + } + + android::String8 strParams = params.flatten(); + char *ret = strdup(strParams.string()); + + LOGD("%s: get parameters fixed up", __FUNCTION__); + return ret; +} + +char * camera_fixup_setparams(int id, const char * settings) +{ + android::CameraParameters params; + params.unflatten(android::String8(settings)); + + if(params.get("cam_mode")) + { + const char* previewSize = params.get(android::CameraParameters::KEY_PREVIEW_SIZE); + params.set(android::CameraParameters::KEY_VIDEO_SIZE, previewSize); + params.set(android::CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO, previewSize); + params.set(android::CameraParameters::KEY_SUPPORTED_VIDEO_SIZES, video_preview_sizes[id]); + } + + android::String8 strParams = params.flatten(); + char *ret = strdup(strParams.string()); + + LOGD("%s: set parameters fixed up", __FUNCTION__); + return ret; +} + /******************************************************************* * implementation of camera_device_ops functions *******************************************************************/ @@ -290,7 +345,15 @@ int camera_set_parameters(struct camera_device * device, const char *params) if(!device) return -EINVAL; - return VENDOR_CALL(device, set_parameters, params); + char *tmp = NULL; + tmp = camera_fixup_setparams(CAMERA_ID(device), params); + +#ifdef LOG_PARAMETERS + __android_log_write(ANDROID_LOG_VERBOSE, LOG_TAG, tmp); +#endif + + int ret = VENDOR_CALL(device, set_parameters, tmp); + return ret; } char* camera_get_parameters(struct camera_device * device) @@ -301,18 +364,30 @@ char* camera_get_parameters(struct camera_device * device) if(!device) return NULL; - return VENDOR_CALL(device, get_parameters); + char* params = VENDOR_CALL(device, get_parameters); + +#ifdef LOG_PARAMETERS + __android_log_write(ANDROID_LOG_VERBOSE, LOG_TAG, params); +#endif + + char * tmp = camera_fixup_getparams(CAMERA_ID(device), params); + VENDOR_CALL(device, put_parameters, params); + params = tmp; + +#ifdef LOG_PARAMETERS + __android_log_write(ANDROID_LOG_VERBOSE, LOG_TAG, params); +#endif + + return params; } -static void camera_put_parameters(struct camera_device *device, char *parms) +static void camera_put_parameters(struct camera_device *device, char *params) { LOGV("%s", __FUNCTION__); LOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device, (uintptr_t)(((wrapper_camera_device_t*)device)->vendor)); - if(!device) - return; - - VENDOR_CALL(device, put_parameters, parms); + if(params) + free(params); } int camera_send_command(struct camera_device * device, @@ -422,6 +497,7 @@ int camera_device_open(const hw_module_t* module, const char* name, goto fail; } memset(camera_device, 0, sizeof(*camera_device)); + camera_device->id = cameraid; if(rv = gVendorModule->common.methods->open((const hw_module_t*)gVendorModule, name, (hw_device_t**)&(camera_device->vendor))) { @@ -503,8 +579,3 @@ int camera_get_camera_info(int camera_id, struct camera_info *info) return 0; return gVendorModule->get_camera_info(camera_id, info); } - - - - - |