diff options
author | Daniel Levin <dendy@ti.com> | 2012-05-31 11:22:16 +0300 |
---|---|---|
committer | Daniel Levin <dendy@ti.com> | 2012-07-25 08:56:45 -0500 |
commit | f998f57b85b1a6eda8ea1c4b511199eb2d122a9f (patch) | |
tree | 9079a0baa12bb29b2b3d260ad00ac3810f869dd9 /camera | |
parent | bf05c17fc0d1daf5129781373e34e9d67bf02f2e (diff) | |
download | hardware_ti_omap4-f998f57b85b1a6eda8ea1c4b511199eb2d122a9f.zip hardware_ti_omap4-f998f57b85b1a6eda8ea1c4b511199eb2d122a9f.tar.gz hardware_ti_omap4-f998f57b85b1a6eda8ea1c4b511199eb2d122a9f.tar.bz2 |
CameraHAL: Portability changes
1. Moved common definitions to Global.h header:
- CAMHAL_LOG* macros (also added CAMHAL_LOGI and CAMHAL_LOGW)
- CAMHAL_ASSERT* macros
- CAMHAL_UNUSED macro
2. Renamed NV12_resize.c to NV12_resize.cpp
3. Added common math functions into UtilsGlobal.h header:
- min(a, b) - returns min of a and b
- max(a, b) - returns max of a and b
- bound(min, a, max) - return nearest value to a in scope [min..max]
- floor(a) - round a to lower integer
- round(a) - round a to nearest integer
4. Portability:
- Fixed LOG* macros to use appropriate CAMHAL_LOG* wrappers.
- Reworked the Android.mk to include proper directories depending
on current pastry.
Change-Id: I6fbd1ee02d8af2195b91cc357ddcf554fe77f495
Signed-off-by: Daniel Levin <dendy@ti.com>
Diffstat (limited to 'camera')
24 files changed, 242 insertions, 247 deletions
diff --git a/camera/ANativeWindowDisplayAdapter.cpp b/camera/ANativeWindowDisplayAdapter.cpp index 6e1ff0d..95914a5 100644 --- a/camera/ANativeWindowDisplayAdapter.cpp +++ b/camera/ANativeWindowDisplayAdapter.cpp @@ -578,7 +578,7 @@ CameraBuffer* ANativeWindowDisplayAdapter::allocateBufferList(int width, int hei /*toOMXPixFormat(format)*/HAL_PIXEL_FORMAT_TI_NV12); // Gralloc only supports NV12 alloc! if ( NO_ERROR != err ) { - LOGE("native_window_set_buffers_geometry failed: %s (%d)", strerror(-err), -err); + CAMHAL_LOGE("native_window_set_buffers_geometry failed: %s (%d)", strerror(-err), -err); if ( NO_INIT == err ) { CAMHAL_LOGEA("Preview surface abandoned!"); @@ -869,7 +869,7 @@ status_t ANativeWindowDisplayAdapter::returnBuffersToWindow() } } else - LOGE("mANativeWindow is NULL"); + CAMHAL_LOGE("mANativeWindow is NULL"); ///Clear the frames with camera adapter map mFramesWithCameraAdapterMap.clear(); diff --git a/camera/Android.mk b/camera/Android.mk index b60cd9d..3f18f17 100644 --- a/camera/Android.mk +++ b/camera/Android.mk @@ -39,7 +39,19 @@ endif CAMERAHAL_CFLAGS += -DLOG_TAG=\"CameraHal\" -OMAP4_CAMERA_HAL_SRC := \ +TI_CAMERAHAL_COMMON_INCLUDES := \ + hardware/ti/omap4xxx/tiler \ + hardware/ti/omap4xxx/hwc \ + external/jpeg \ + external/jhead \ + $(LOCAL_PATH)/../libtiutils \ + $(LOCAL_PATH)/inc + +TI_CAMERAHAL_COMMON_INCLUDES += \ + frameworks/base/include/media/stagefright \ + hardware/ti/omap4xxx/include + +TI_CAMERAHAL_COMMON_SRC := \ CameraHal_Module.cpp \ CameraHal.cpp \ CameraHalUtilClasses.cpp \ @@ -51,14 +63,12 @@ OMAP4_CAMERA_HAL_SRC := \ MemoryManager.cpp \ Encoder_libjpeg.cpp \ SensorListener.cpp \ - NV12_resize.c - -OMAP4_CAMERA_COMMON_SRC:= \ + NV12_resize.cpp \ CameraParameters.cpp \ TICameraParameters.cpp \ CameraHalCommon.cpp -OMAP4_CAMERA_OMX_SRC:= \ +TI_CAMERAHAL_OMX_SRC := \ OMXCameraAdapter/OMX3A.cpp \ OMXCameraAdapter/OMXAlgo.cpp \ OMXCameraAdapter/OMXCameraAdapter.cpp \ @@ -73,55 +83,49 @@ OMAP4_CAMERA_OMX_SRC:= \ OMXCameraAdapter/OMXZoom.cpp \ OMXCameraAdapter/OMXDccDataSave.cpp -OMAP4_CAMERA_USB_SRC:= \ +TI_CAMERAHAL_USB_SRC := \ V4LCameraAdapter/V4LCameraAdapter.cpp \ - V4LCameraAdapter/V4LCapabilities.cpp \ + V4LCameraAdapter/V4LCapabilities.cpp + +TI_CAMERAHAL_COMMON_SHARED_LIBRARIES := \ + libui \ + libbinder \ + libutils \ + libcutils \ + libtiutils \ + libcamera_client \ + libgui \ + libion \ + libjpeg \ + libexif + -# -# OMX Camera HAL -# +# ==================== +# OMX Camera Adapter +# -------------------- ifeq ($(OMAP4_CAMERA_HAL_USES),OMX) include $(CLEAR_VARS) +CAMERAHAL_CFLAGS += -DOMX_CAMERA_ADAPTER + LOCAL_SRC_FILES:= \ - $(OMAP4_CAMERA_HAL_SRC) \ - $(OMAP4_CAMERA_OMX_SRC) \ - $(OMAP4_CAMERA_COMMON_SRC) + $(TI_CAMERAHAL_COMMON_SRC) \ + $(TI_CAMERAHAL_OMX_SRC) LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/inc/ \ - $(LOCAL_PATH)/../hwc \ - $(LOCAL_PATH)/../include \ - $(LOCAL_PATH)/inc/OMXCameraAdapter \ - $(LOCAL_PATH)/../libtiutils \ - hardware/ti/omap4xxx/tiler \ - frameworks/base/include/ui \ - frameworks/base/include/utils \ + $(TI_CAMERAHAL_COMMON_INCLUDES) \ $(DOMX_PATH)/omx_core/inc \ $(DOMX_PATH)/mm_osal/inc \ - frameworks/base/include/media/stagefright \ - frameworks/base/include/media/stagefright/openmax \ - external/jpeg \ - external/jhead + $(LOCAL_PATH)/inc/OMXCameraAdapter LOCAL_SHARED_LIBRARIES:= \ - libui \ - libbinder \ - libutils \ - libcutils \ - libtiutils \ + $(TI_CAMERAHAL_COMMON_SHARED_LIBRARIES) \ libmm_osal \ libOMX_Core \ - libcamera_client \ - libgui \ - libdomx \ - libion \ - libjpeg \ - libexif + libdomx -CAMERAHAL_CFLAGS += -DOMX_CAMERA_ADAPTER LOCAL_CFLAGS := -fno-short-enums -DCOPY_IMAGE_BUFFER $(CAMERAHAL_CFLAGS) LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw @@ -133,44 +137,25 @@ include $(BUILD_HEAPTRACKED_SHARED_LIBRARY) else ifeq ($(OMAP4_CAMERA_HAL_USES),USB) -# -# USB Camera Adapter -# + +# ==================== +# USB Camera Adapter +# -------------------- include $(CLEAR_VARS) CAMERAHAL_CFLAGS += -DV4L_CAMERA_ADAPTER LOCAL_SRC_FILES:= \ - $(OMAP4_CAMERA_HAL_SRC) \ - $(OMAP4_CAMERA_USB_SRC) \ - $(OMAP4_CAMERA_COMMON_SRC) + $(TI_CAMERAHAL_COMMON_SRC) \ + $(TI_CAMERAHAL_USB_SRC) LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/inc/ \ - $(LOCAL_PATH)/../hwc \ - $(LOCAL_PATH)/../include \ - $(LOCAL_PATH)/inc/V4LCameraAdapter \ - $(LOCAL_PATH)/../libtiutils \ - hardware/ti/omap4xxx/tiler \ - frameworks/base/include/ui \ - frameworks/base/include/utils \ - frameworks/base/include/media/stagefright \ - frameworks/base/include/media/stagefright/openmax \ - external/jpeg \ - external/jhead + $(TI_CAMERAHAL_COMMON_INCLUDES) \ + $(LOCAL_PATH)/inc/V4LCameraAdapter LOCAL_SHARED_LIBRARIES:= \ - libui \ - libbinder \ - libutils \ - libcutils \ - libtiutils \ - libcamera_client \ - libgui \ - libion \ - libjpeg \ - libexif + $(TI_CAMERAHAL_COMMON_SHARED_LIBRARIES) LOCAL_CFLAGS := -fno-short-enums -DCOPY_IMAGE_BUFFER $(CAMERAHAL_CFLAGS) @@ -183,47 +168,33 @@ include $(BUILD_HEAPTRACKED_SHARED_LIBRARY) else ifeq ($(OMAP4_CAMERA_HAL_USES),ALL) + +# ===================== +# ALL Camera Adapters +# --------------------- + include $(CLEAR_VARS) +CAMERAHAL_CFLAGS += -DOMX_CAMERA_ADAPTER -DV4L_CAMERA_ADAPTER + LOCAL_SRC_FILES:= \ - $(OMAP4_CAMERA_HAL_SRC) \ - $(OMAP4_CAMERA_OMX_SRC) \ - $(OMAP4_CAMERA_USB_SRC) \ - $(OMAP4_CAMERA_COMMON_SRC) + $(TI_CAMERAHAL_COMMON_SRC) \ + $(TI_CAMERAHAL_OMX_SRC) \ + $(TI_CAMERAHAL_USB_SRC) LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/inc/ \ - $(LOCAL_PATH)/../hwc \ - $(LOCAL_PATH)/../include \ - $(LOCAL_PATH)/inc/OMXCameraAdapter \ - $(LOCAL_PATH)/inc/V4LCameraAdapter \ - $(LOCAL_PATH)/../libtiutils \ - hardware/ti/omap4xxx/tiler \ - frameworks/base/include/ui \ - frameworks/base/include/utils \ + $(TI_CAMERAHAL_COMMON_INCLUDES) \ $(DOMX_PATH)/omx_core/inc \ $(DOMX_PATH)/mm_osal/inc \ - frameworks/base/include/media/stagefright \ - frameworks/base/include/media/stagefright/openmax \ - external/jpeg \ - external/jhead + $(LOCAL_PATH)/inc/OMXCameraAdapter \ + $(LOCAL_PATH)/inc/V4LCameraAdapter LOCAL_SHARED_LIBRARIES:= \ - libui \ - libbinder \ - libutils \ - libcutils \ - libtiutils \ + $(TI_CAMERAHAL_COMMON_SHARED_LIBRARIES) \ libmm_osal \ libOMX_Core \ - libcamera_client \ - libgui \ - libdomx \ - libion \ - libjpeg \ - libexif + libdomx -CAMERAHAL_CFLAGS += -DOMX_CAMERA_ADAPTER -DV4L_CAMERA_ADAPTER LOCAL_CFLAGS := -fno-short-enums -DCOPY_IMAGE_BUFFER $(CAMERAHAL_CFLAGS) LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw diff --git a/camera/BaseCameraAdapter.cpp b/camera/BaseCameraAdapter.cpp index ad3ea38..a05cac5 100644 --- a/camera/BaseCameraAdapter.cpp +++ b/camera/BaseCameraAdapter.cpp @@ -391,8 +391,8 @@ void BaseCameraAdapter::returnFrame(CameraBuffer * frameBuf, CameraFrame::FrameT ((CameraFrame::PREVIEW_FRAME_SYNC == frameType) || (CameraFrame::SNAPSHOT_FRAME == frameType))) { - LOGE("Buffer already with Ducati!! 0x%x", frameBuf); - for(int i=0;i<mBuffersWithDucati.size();i++) LOGE("0x%x", mBuffersWithDucati.keyAt(i)); + CAMHAL_LOGE("Buffer already with Ducati!! 0x%x", frameBuf); + for(int i=0;i<mBuffersWithDucati.size();i++) CAMHAL_LOGE("0x%x", mBuffersWithDucati.keyAt(i)); } mBuffersWithDucati.add((int)camera_buffer_get_omx_ptr(frameBuf),1); #endif diff --git a/camera/CameraHalCommon.cpp b/camera/CameraHalCommon.cpp index 6d4ea2c..ea97e84 100644 --- a/camera/CameraHalCommon.cpp +++ b/camera/CameraHalCommon.cpp @@ -76,7 +76,7 @@ void CameraHal::PPM(const char* str){ absolute *= 1000; absolute += ppm.tv_usec /1000; - LOGD("PPM: %s :%llu.%llu ms : %llu ms", str, ( elapsed /1000 ), ( elapsed % 1000 ), absolute); + CAMHAL_LOGD("PPM: %s :%llu.%llu ms : %llu ms", str, ( elapsed /1000 ), ( elapsed % 1000 ), absolute); } #endif @@ -109,7 +109,7 @@ void CameraHal::PPM(const char* str, struct timeval* ppm_first, ...){ ppm.tv_sec = ppm.tv_sec * 1000000; ppm.tv_sec = ppm.tv_sec + ppm.tv_usec - ppm_first->tv_usec; - LOGD("PPM: %s :%ld.%ld ms : %llu ms", temp_str, ( ppm.tv_sec /1000 ), ( ppm.tv_sec % 1000 ), absolute); + CAMHAL_LOGD("PPM: %s :%ld.%ld ms : %llu ms", temp_str, ( ppm.tv_sec /1000 ), ( ppm.tv_sec % 1000 ), absolute); va_end(args); } diff --git a/camera/CameraHal_Module.cpp b/camera/CameraHal_Module.cpp index ba45a06..eb4a475 100644 --- a/camera/CameraHal_Module.cpp +++ b/camera/CameraHal_Module.cpp @@ -28,6 +28,13 @@ #include "TICameraParameters.h" +#ifdef CAMERAHAL_DEBUG_VERBOSE +# define CAMHAL_LOG_MODULE_FUNCTION_NAME LOG_FUNCTION_NAME +#else +# define CAMHAL_LOG_MODULE_FUNCTION_NAME +#endif + + static android::CameraProperties gCameraProperties; static android::CameraHal* gCameraHals[MAX_CAMERAS_SUPPORTED]; static unsigned int gCamerasOpen = 0; @@ -73,11 +80,11 @@ typedef struct ti_camera_device { int camera_set_preview_window(struct camera_device * device, struct preview_stream_ops *window) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -93,11 +100,11 @@ int camera_set_buffer_source(struct camera_device * device, struct preview_stream_ops *tapin, struct preview_stream_ops *tapout) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -116,9 +123,9 @@ void camera_set_callbacks(struct camera_device * device, camera_request_memory get_memory, void *user) { - ti_camera_device_t* ti_dev = NULL; + CAMHAL_LOG_MODULE_FUNCTION_NAME; - LOGV("%s", __FUNCTION__); + ti_camera_device_t* ti_dev = NULL; if(!device) return; @@ -130,9 +137,9 @@ void camera_set_callbacks(struct camera_device * device, void camera_enable_msg_type(struct camera_device * device, int32_t msg_type) { - ti_camera_device_t* ti_dev = NULL; + CAMHAL_LOG_MODULE_FUNCTION_NAME; - LOGV("%s", __FUNCTION__); + ti_camera_device_t* ti_dev = NULL; if(!device) return; @@ -144,9 +151,9 @@ void camera_enable_msg_type(struct camera_device * device, int32_t msg_type) void camera_disable_msg_type(struct camera_device * device, int32_t msg_type) { - ti_camera_device_t* ti_dev = NULL; + CAMHAL_LOG_MODULE_FUNCTION_NAME; - LOGV("%s", __FUNCTION__); + ti_camera_device_t* ti_dev = NULL; if(!device) return; @@ -158,9 +165,9 @@ void camera_disable_msg_type(struct camera_device * device, int32_t msg_type) int camera_msg_type_enabled(struct camera_device * device, int32_t msg_type) { - ti_camera_device_t* ti_dev = NULL; + CAMHAL_LOG_MODULE_FUNCTION_NAME; - LOGV("%s", __FUNCTION__); + ti_camera_device_t* ti_dev = NULL; if(!device) return 0; @@ -172,11 +179,11 @@ int camera_msg_type_enabled(struct camera_device * device, int32_t msg_type) int camera_start_preview(struct camera_device * device) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -189,9 +196,9 @@ int camera_start_preview(struct camera_device * device) void camera_stop_preview(struct camera_device * device) { - ti_camera_device_t* ti_dev = NULL; + CAMHAL_LOG_MODULE_FUNCTION_NAME; - LOGV("%s", __FUNCTION__); + ti_camera_device_t* ti_dev = NULL; if(!device) return; @@ -203,11 +210,11 @@ void camera_stop_preview(struct camera_device * device) int camera_preview_enabled(struct camera_device * device) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -219,11 +226,11 @@ int camera_preview_enabled(struct camera_device * device) int camera_store_meta_data_in_buffers(struct camera_device * device, int enable) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -237,11 +244,11 @@ int camera_store_meta_data_in_buffers(struct camera_device * device, int enable) int camera_start_recording(struct camera_device * device) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -253,9 +260,9 @@ int camera_start_recording(struct camera_device * device) void camera_stop_recording(struct camera_device * device) { - ti_camera_device_t* ti_dev = NULL; + CAMHAL_LOG_MODULE_FUNCTION_NAME; - LOGV("%s", __FUNCTION__); + ti_camera_device_t* ti_dev = NULL; if(!device) return; @@ -267,11 +274,11 @@ void camera_stop_recording(struct camera_device * device) int camera_recording_enabled(struct camera_device * device) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -284,9 +291,9 @@ int camera_recording_enabled(struct camera_device * device) void camera_release_recording_frame(struct camera_device * device, const void *opaque) { - ti_camera_device_t* ti_dev = NULL; + CAMHAL_LOG_MODULE_FUNCTION_NAME; - LOGV("%s", __FUNCTION__); + ti_camera_device_t* ti_dev = NULL; if(!device) return; @@ -298,11 +305,11 @@ void camera_release_recording_frame(struct camera_device * device, int camera_auto_focus(struct camera_device * device) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -314,11 +321,11 @@ int camera_auto_focus(struct camera_device * device) int camera_cancel_auto_focus(struct camera_device * device) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -334,14 +341,14 @@ int camera_take_picture(struct camera_device * device, const char *params) int camera_take_picture(struct camera_device * device) #endif { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; #ifndef OMAP_ENHANCEMENT_CPCAM const char* params = NULL; #endif - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -353,11 +360,11 @@ int camera_take_picture(struct camera_device * device) int camera_cancel_picture(struct camera_device * device) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -370,11 +377,11 @@ int camera_cancel_picture(struct camera_device * device) #ifdef OMAP_ENHANCEMENT_CPCAM int camera_reprocess(struct camera_device * device, const char *params) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -386,11 +393,11 @@ int camera_reprocess(struct camera_device * device, const char *params) int camera_cancel_reprocess(struct camera_device * device) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -403,11 +410,11 @@ int camera_cancel_reprocess(struct camera_device * device) int camera_set_parameters(struct camera_device * device, const char *params) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -419,11 +426,11 @@ int camera_set_parameters(struct camera_device * device, const char *params) char* camera_get_parameters(struct camera_device * device) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + char* param = NULL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return NULL; @@ -436,9 +443,9 @@ char* camera_get_parameters(struct camera_device * device) static void camera_put_parameters(struct camera_device *device, char *parms) { - ti_camera_device_t* ti_dev = NULL; + CAMHAL_LOG_MODULE_FUNCTION_NAME; - LOGV("%s", __FUNCTION__); + ti_camera_device_t* ti_dev = NULL; if(!device) return; @@ -451,11 +458,11 @@ static void camera_put_parameters(struct camera_device *device, char *parms) int camera_send_command(struct camera_device * device, int32_t cmd, int32_t arg1, int32_t arg2) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - if(!device) return rv; @@ -467,9 +474,9 @@ int camera_send_command(struct camera_device * device, void camera_release(struct camera_device * device) { - ti_camera_device_t* ti_dev = NULL; + CAMHAL_LOG_MODULE_FUNCTION_NAME; - LOGV("%s", __FUNCTION__); + ti_camera_device_t* ti_dev = NULL; if(!device) return; @@ -481,6 +488,8 @@ void camera_release(struct camera_device * device) int camera_dump(struct camera_device * device, int fd) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int rv = -EINVAL; ti_camera_device_t* ti_dev = NULL; @@ -497,11 +506,11 @@ extern "C" void heaptracker_free_leaked_memory(void); int camera_device_close(hw_device_t* device) { + CAMHAL_LOG_MODULE_FUNCTION_NAME; + int ret = 0; ti_camera_device_t* ti_dev = NULL; - LOGV("%s", __FUNCTION__); - android::Mutex::Autolock lock(gCameraHalDeviceLock); if (!device) { @@ -561,7 +570,7 @@ int camera_device_open(const hw_module_t* module, const char* name, if(cameraid > num_cameras) { - LOGE("camera service provided cameraid out of bounds, " + CAMHAL_LOGE("camera service provided cameraid out of bounds, " "cameraid = %d, num supported = %d", cameraid, num_cameras); rv = -EINVAL; @@ -570,7 +579,7 @@ int camera_device_open(const hw_module_t* module, const char* name, if(gCamerasOpen >= MAX_SIMUL_CAMERAS_SUPPORTED) { - LOGE("maximum number of cameras already open"); + CAMHAL_LOGE("maximum number of cameras already open"); rv = -ENOMEM; goto fail; } @@ -578,7 +587,7 @@ int camera_device_open(const hw_module_t* module, const char* name, camera_device = (ti_camera_device_t*)malloc(sizeof(*camera_device)); if(!camera_device) { - LOGE("camera_device allocation fail"); + CAMHAL_LOGE("camera_device allocation fail"); rv = -ENOMEM; goto fail; } @@ -586,7 +595,7 @@ int camera_device_open(const hw_module_t* module, const char* name, camera_ops = (camera_device_ops_t*)malloc(sizeof(*camera_ops)); if(!camera_ops) { - LOGE("camera_ops allocation fail"); + CAMHAL_LOGE("camera_ops allocation fail"); rv = -ENOMEM; goto fail; } @@ -639,7 +648,7 @@ int camera_device_open(const hw_module_t* module, const char* name, if(gCameraProperties.getProperties(cameraid, &properties) < 0) { - LOGE("Couldn't get camera properties"); + CAMHAL_LOGE("Couldn't get camera properties"); rv = -ENOMEM; goto fail; } @@ -648,14 +657,14 @@ int camera_device_open(const hw_module_t* module, const char* name, if(!camera) { - LOGE("Couldn't create instance of CameraHal class"); + CAMHAL_LOGE("Couldn't create instance of CameraHal class"); rv = -ENOMEM; goto fail; } if(properties && (camera->initialize(properties) != android::NO_ERROR)) { - LOGE("Couldn't initialize camera instance"); + CAMHAL_LOGE("Couldn't initialize camera instance"); rv = -ENODEV; goto fail; } @@ -720,7 +729,7 @@ int camera_get_camera_info(int camera_id, struct camera_info *info) //Get camera properties for camera index if(gCameraProperties.getProperties(camera_id, &properties) < 0) { - LOGE("Couldn't get camera properties"); + CAMHAL_LOGE("Couldn't get camera properties"); rv = -EINVAL; goto end; } diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp index f9a444b..a809115 100644 --- a/camera/CameraParameters.cpp +++ b/camera/CameraParameters.cpp @@ -21,7 +21,6 @@ * */ -#include "CameraHal.h" #include "CameraProperties.h" namespace android { diff --git a/camera/CameraProperties.cpp b/camera/CameraProperties.cpp index a533d5a..c0a1934 100644 --- a/camera/CameraProperties.cpp +++ b/camera/CameraProperties.cpp @@ -21,10 +21,6 @@ * */ -//#include "CameraHal.h" -#include <utils/threads.h> - -#include "DebugUtils.h" #include "CameraProperties.h" #define CAMERA_ROOT "CameraRoot" @@ -105,16 +101,16 @@ status_t CameraProperties::loadProperties() MAX_CAMERAS_SUPPORTED, mCamerasSupported); if(err != NO_ERROR) { - LOGE("error while getting capabilities"); + CAMHAL_LOGE("error while getting capabilities"); ret = UNKNOWN_ERROR; } else if (mCamerasSupported == 0) { - LOGE("camera busy. properties not loaded. num_cameras = %d", mCamerasSupported); + CAMHAL_LOGE("camera busy. properties not loaded. num_cameras = %d", mCamerasSupported); ret = UNKNOWN_ERROR; } else if (mCamerasSupported > MAX_CAMERAS_SUPPORTED) { - LOGE("returned too many adapaters"); + CAMHAL_LOGE("returned too many adapaters"); ret = UNKNOWN_ERROR; } else { - LOGI("num_cameras = %d", mCamerasSupported); + CAMHAL_LOGI("num_cameras = %d", mCamerasSupported); for (int i = 0; i < mCamerasSupported; i++) { mCameraProps[i].setSensorIndex(i); @@ -122,7 +118,7 @@ status_t CameraProperties::loadProperties() } } - LOGV("mCamerasSupported = %d", mCamerasSupported); + CAMHAL_LOGV("mCamerasSupported = %d", mCamerasSupported); LOG_FUNCTION_NAME_EXIT; return ret; } diff --git a/camera/Encoder_libjpeg.cpp b/camera/Encoder_libjpeg.cpp index e64af8e..6db9e7e 100644 --- a/camera/Encoder_libjpeg.cpp +++ b/camera/Encoder_libjpeg.cpp @@ -23,7 +23,6 @@ * */ -#include "CameraHal.h" #include "Encoder_libjpeg.h" #include "NV12_resize.h" #include "TICameraParameters.h" diff --git a/camera/MemoryManager.cpp b/camera/MemoryManager.cpp index f42ede3..f9c12c1 100644 --- a/camera/MemoryManager.cpp +++ b/camera/MemoryManager.cpp @@ -127,7 +127,7 @@ CameraBuffer* MemoryManager::allocateBufferList(int width, int height, const cha error: - LOGE("Freeing buffers already allocated after error occurred"); + CAMHAL_LOGE("Freeing buffers already allocated after error occurred"); if(buffers) freeBufferList(buffers); diff --git a/camera/NV12_resize.c b/camera/NV12_resize.cpp index 132becb..2ce6c0c 100644 --- a/camera/NV12_resize.c +++ b/camera/NV12_resize.cpp @@ -10,7 +10,6 @@ #define LOG_TAG "NV12_resize" #define STRIDE 4096 -#include <utils/Log.h> /*---------------------------------------------------------------------------- Define : TRUE/FALSE for boolean operations @@ -51,7 +50,7 @@ VT_resizeFrame_Video_opt2_lp mmUint16 dummy /* Transparent pixel value */ ) { - LOGV("VT_resizeFrame_Video_opt2_lp+"); + CAMHAL_LOGV("VT_resizeFrame_Video_opt2_lp+"); mmUint16 row,col; mmUint32 resizeFactorX; @@ -75,19 +74,19 @@ VT_resizeFrame_Video_opt2_lp { if(i_img_ptr->uHeight == o_img_ptr->uHeight) { - LOGV("************************f(i_img_ptr->uHeight == o_img_ptr->uHeight) are same *********************\n"); - LOGV("************************(i_img_ptr->width == %d" , i_img_ptr->uWidth ); - LOGV("************************(i_img_ptr->uHeight == %d" , i_img_ptr->uHeight ); - LOGV("************************(o_img_ptr->width == %d" ,o_img_ptr->uWidth ); - LOGV("************************(o_img_ptr->uHeight == %d" , o_img_ptr->uHeight ); + CAMHAL_LOGV("************************f(i_img_ptr->uHeight == o_img_ptr->uHeight) are same *********************\n"); + CAMHAL_LOGV("************************(i_img_ptr->width == %d" , i_img_ptr->uWidth ); + CAMHAL_LOGV("************************(i_img_ptr->uHeight == %d" , i_img_ptr->uHeight ); + CAMHAL_LOGV("************************(o_img_ptr->width == %d" ,o_img_ptr->uWidth ); + CAMHAL_LOGV("************************(o_img_ptr->uHeight == %d" , o_img_ptr->uHeight ); } } if (!i_img_ptr || !i_img_ptr->imgPtr || !o_img_ptr || !o_img_ptr->imgPtr) { - LOGE("Image Point NULL"); - LOGV("VT_resizeFrame_Video_opt2_lp-"); + CAMHAL_LOGE("Image Point NULL"); + CAMHAL_LOGV("VT_resizeFrame_Video_opt2_lp-"); return FALSE; } @@ -115,8 +114,8 @@ VT_resizeFrame_Video_opt2_lp /* make sure valid input size */ if (idx < 1 || idy < 1 || i_img_ptr->uStride < 1) { - LOGE("idx or idy less then 1 idx = %d idy = %d stride = %d", idx, idy, i_img_ptr->uStride); - LOGV("VT_resizeFrame_Video_opt2_lp-"); + CAMHAL_LOGE("idx or idy less then 1 idx = %d idy = %d stride = %d", idx, idy, i_img_ptr->uStride); + CAMHAL_LOGV("VT_resizeFrame_Video_opt2_lp-"); return FALSE; } @@ -317,11 +316,11 @@ VT_resizeFrame_Video_opt2_lp } else { - LOGE("eFormat not supported"); - LOGV("VT_resizeFrame_Video_opt2_lp-"); + CAMHAL_LOGE("eFormat not supported"); + CAMHAL_LOGV("VT_resizeFrame_Video_opt2_lp-"); return FALSE; } - LOGV("success"); - LOGV("VT_resizeFrame_Video_opt2_lp-"); + CAMHAL_LOGV("success"); + CAMHAL_LOGV("VT_resizeFrame_Video_opt2_lp-"); return TRUE; } diff --git a/camera/OMXCameraAdapter/OMX3A.cpp b/camera/OMXCameraAdapter/OMX3A.cpp index 34247ca..79e6aac 100644 --- a/camera/OMXCameraAdapter/OMX3A.cpp +++ b/camera/OMXCameraAdapter/OMX3A.cpp @@ -514,7 +514,7 @@ static bool isFlashDisabled() { char value[PROPERTY_VALUE_MAX]; if (property_get("camera.flash_off", value, NULL) && (!strcasecmp(value, CameraParameters::TRUE) || !strcasecmp(value, "1"))) { - LOGW("flash is disabled for testing purpose"); + CAMHAL_LOGW("flash is disabled for testing purpose"); return true; } diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp index af700e3..575b33b 100644 --- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp +++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp @@ -703,7 +703,7 @@ void saveFile(unsigned char *buff, int width, int height, int format) { sprintf(fn, "/preview%03d.yuv", counter); fd = open(fn, O_CREAT | O_WRONLY | O_SYNC | O_TRUNC, 0777); if(fd < 0) { - LOGE("Unable to open file %s: %s", fn, strerror(fd)); + CAMHAL_LOGE("Unable to open file %s: %s", fn, strerror(fd)); return; } @@ -3294,7 +3294,7 @@ static void debugShowFPS() mFps = ((mFrameCount - mLastFrameCount) * float(s2ns(1))) / diff; mLastFpsTime = now; mLastFrameCount = mFrameCount; - LOGD("Camera %d Frames, %f FPS", mFrameCount, mFps); + CAMHAL_LOGD("Camera %d Frames, %f FPS", mFrameCount, mFps); } // XXX: mFPS has the value we want } @@ -3473,7 +3473,7 @@ OMX_ERRORTYPE OMXCameraAdapter::OMXCameraAdapterFillBufferDone(OMX_IN OMX_HANDLE mFramesWithEncoder++; } - //LOGV("FBD pBuffer = 0x%x", pBuffHeader->pBuffer); + //CAMHAL_LOGV("FBD pBuffer = 0x%x", pBuffHeader->pBuffer); if( mWaitingForSnapshot ) { @@ -3494,8 +3494,8 @@ OMX_ERRORTYPE OMXCameraAdapter::OMXCameraAdapterFillBufferDone(OMX_IN OMX_HANDLE #ifdef CAMERAHAL_DEBUG if(mBuffersWithDucati.indexOfKey((uint32_t)pBuffHeader->pBuffer)<0) { - LOGE("Buffer was never with Ducati!! %p", pBuffHeader->pBuffer); - for(unsigned int i=0;i<mBuffersWithDucati.size();i++) LOGE("0x%x", mBuffersWithDucati.keyAt(i)); + CAMHAL_LOGE("Buffer was never with Ducati!! %p", pBuffHeader->pBuffer); + for(unsigned int i=0;i<mBuffersWithDucati.size();i++) CAMHAL_LOGE("0x%x", mBuffersWithDucati.keyAt(i)); } mBuffersWithDucati.removeItem((int)pBuffHeader->pBuffer); #endif diff --git a/camera/OMXCameraAdapter/OMXCapabilities.cpp b/camera/OMXCameraAdapter/OMXCapabilities.cpp index 5e2ea13..a87c8b5 100644 --- a/camera/OMXCameraAdapter/OMXCapabilities.cpp +++ b/camera/OMXCameraAdapter/OMXCapabilities.cpp @@ -406,17 +406,6 @@ status_t OMXCameraAdapter::encodePixelformatCap(OMX_COLOR_FORMATTYPE format, return ret; } -// TODO: Move the min() and max() functions globally. -template <typename T> -inline const T & min(const T & a, const T & b) { - return a < b ? a : b; -} - -template <typename T> -inline const T & max(const T & a, const T & b) { - return a < b ? b : a; -} - void OMXCameraAdapter::encodeFrameRates(const int minFrameRate, const int maxFrameRate, const OMX_TI_CAPTYPE & caps, const CapFramerate * const fixedFrameRates, const int frameRateCount, Vector<FpsRange> & fpsRanges) { diff --git a/camera/OMXCameraAdapter/OMXExif.cpp b/camera/OMXCameraAdapter/OMXExif.cpp index efb627e..8cd86ea 100644 --- a/camera/OMXCameraAdapter/OMXExif.cpp +++ b/camera/OMXCameraAdapter/OMXExif.cpp @@ -813,7 +813,7 @@ status_t OMXCameraAdapter::convertGPSCoord(double coord, if ( coord == 0 ) { - LOGE("Invalid GPS coordinate"); + CAMHAL_LOGE("Invalid GPS coordinate"); return -EINVAL; } diff --git a/camera/SensorListener.cpp b/camera/SensorListener.cpp index 00835b3..a5ddbd5 100644 --- a/camera/SensorListener.cpp +++ b/camera/SensorListener.cpp @@ -22,7 +22,6 @@ */ #include "SensorListener.h" -#include "CameraHal.h" #include <stdint.h> #include <math.h> diff --git a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp index 1cbc40d..503d3dd 100644 --- a/camera/V4LCameraAdapter/V4LCameraAdapter.cpp +++ b/camera/V4LCameraAdapter/V4LCameraAdapter.cpp @@ -836,7 +836,7 @@ static void debugShowFPS() mFps = ((mFrameCount - mLastFrameCount) * float(s2ns(1))) / diff; mLastFpsTime = now; mLastFrameCount = mFrameCount; - LOGD("Camera %d Frames, %f FPS", mFrameCount, mFps); + CAMHAL_LOGD("Camera %d Frames, %f FPS", mFrameCount, mFps); } } } @@ -1091,7 +1091,7 @@ void saveFile(unsigned char* buff, int buff_size) { fd = open(fn, O_CREAT | O_WRONLY | O_SYNC | O_TRUNC, 0777); if(fd < 0) { - LOGE("Unable to open file %s: %s", fn, strerror(fd)); + CAMHAL_LOGE("Unable to open file %s: %s", fn, strerror(fd)); return; } diff --git a/camera/inc/ANativeWindowDisplayAdapter.h b/camera/inc/ANativeWindowDisplayAdapter.h index a97bee6..29379c7 100644 --- a/camera/inc/ANativeWindowDisplayAdapter.h +++ b/camera/inc/ANativeWindowDisplayAdapter.h @@ -17,7 +17,6 @@ #include "CameraHal.h" -#include <ui/egl/android_natives.h> #include <ui/GraphicBufferMapper.h> #include <hal_public.h> diff --git a/camera/inc/BufferSourceAdapter.h b/camera/inc/BufferSourceAdapter.h index c852288..2973d7e 100644 --- a/camera/inc/BufferSourceAdapter.h +++ b/camera/inc/BufferSourceAdapter.h @@ -20,7 +20,6 @@ #ifdef OMAP_ENHANCEMENT_CPCAM #include "CameraHal.h" -#include <ui/egl/android_natives.h> #include <ui/GraphicBufferMapper.h> #include <hal_public.h> diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h index 7c95ed0..44b2fbb 100644 --- a/camera/inc/CameraHal.h +++ b/camera/inc/CameraHal.h @@ -45,16 +45,15 @@ #include <ui/GraphicBuffer.h> /* For IMG_native_handle_t */ -#include <ui/egl/android_natives.h> #include <ui/GraphicBufferMapper.h> #include <hal_public.h> #include <ion/ion.h> +#include "Common.h" #include "MessageQueue.h" #include "Semaphore.h" #include "CameraProperties.h" -#include "DebugUtils.h" #include "SensorListener.h" //temporarily define format here @@ -95,41 +94,6 @@ #define LOCK_BUFFER_TRIES 5 #define HAL_PIXEL_FORMAT_NV12 0x100 -#define CAMHAL_LOGI LOGI - -// logging functions -#ifdef CAMERAHAL_DEBUG -# define CAMHAL_LOGD DBGUTILS_LOGD -# define CAMHAL_LOGDA DBGUTILS_LOGDA -# define CAMHAL_LOGDB DBGUTILS_LOGDB -# ifdef CAMERAHAL_DEBUG_VERBOSE -# define CAMHAL_LOGV DBGUTILS_LOGV -# define CAMHAL_LOGVA DBGUTILS_LOGVA -# define CAMHAL_LOGVB DBGUTILS_LOGVB -# else -# define CAMHAL_LOGV(...) -# define CAMHAL_LOGVA(str) -# define CAMHAL_LOGVB(str, ...) -# endif -#else -# define CAMHAL_LOGD(...) -# define CAMHAL_LOGDA(str) -# define CAMHAL_LOGDB(str, ...) -# define CAMHAL_LOGV(...) -# define CAMHAL_LOGVA(str) -# define CAMHAL_LOGVB(str, ...) -#endif - -#define CAMHAL_LOGE DBGUTILS_LOGE -#define CAMHAL_LOGEA DBGUTILS_LOGEA -#define CAMHAL_LOGEB DBGUTILS_LOGEB -#define CAMHAL_LOGF DBGUTILS_LOGF - -#define CAMHAL_ASSERT DBGUTILS_ASSERT -#define CAMHAL_ASSERT_X DBGUTILS_ASSERT_X - -#define CAMHAL_UNUSED(x) (void)x - #define NONNEG_ASSIGN(x,y) \ if(x > -1) \ y = x diff --git a/camera/inc/CameraProperties.h b/camera/inc/CameraProperties.h index dcfc2c7..4763b10 100644 --- a/camera/inc/CameraProperties.h +++ b/camera/inc/CameraProperties.h @@ -30,6 +30,8 @@ #include <ctype.h> #include "cutils/properties.h" +#include "Common.h" + namespace android { #define MAX_CAMERAS_SUPPORTED 3 diff --git a/camera/inc/Common.h b/camera/inc/Common.h new file mode 100644 index 0000000..232dbbf --- /dev/null +++ b/camera/inc/Common.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) Texas Instruments - http://www.ti.com/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAMERAHAL_COMMON_H +#define CAMERAHAL_COMMON_H + +#include "UtilsCommon.h" +#include "DebugUtils.h" + + + + +// logging functions +#ifdef CAMERAHAL_DEBUG +# define CAMHAL_LOGD DBGUTILS_LOGD +# define CAMHAL_LOGDA DBGUTILS_LOGDA +# define CAMHAL_LOGDB DBGUTILS_LOGDB +# ifdef CAMERAHAL_DEBUG_VERBOSE +# define CAMHAL_LOGV DBGUTILS_LOGV +# define CAMHAL_LOGVA DBGUTILS_LOGVA +# define CAMHAL_LOGVB DBGUTILS_LOGVB +# else +# define CAMHAL_LOGV(...) +# define CAMHAL_LOGVA(str) +# define CAMHAL_LOGVB(str, ...) +# endif +#else +# define CAMHAL_LOGD(...) +# define CAMHAL_LOGDA(str) +# define CAMHAL_LOGDB(str, ...) +# define CAMHAL_LOGV(...) +# define CAMHAL_LOGVA(str) +# define CAMHAL_LOGVB(str, ...) +#endif + +#define CAMHAL_LOGI DBGUTILS_LOGI +#define CAMHAL_LOGW DBGUTILS_LOGW +#define CAMHAL_LOGE DBGUTILS_LOGE +#define CAMHAL_LOGEA DBGUTILS_LOGEA +#define CAMHAL_LOGEB DBGUTILS_LOGEB +#define CAMHAL_LOGF DBGUTILS_LOGF + +#define CAMHAL_ASSERT DBGUTILS_ASSERT +#define CAMHAL_ASSERT_X DBGUTILS_ASSERT_X + +#define CAMHAL_UNUSED(x) (void)x + + + + +#endif // CAMERAHAL_COMMON_H diff --git a/camera/inc/Encoder_libjpeg.h b/camera/inc/Encoder_libjpeg.h index abd8b7d..7a8e06a 100644 --- a/camera/inc/Encoder_libjpeg.h +++ b/camera/inc/Encoder_libjpeg.h @@ -35,6 +35,8 @@ extern "C" { } +#include "CameraHal.h" + #define CANCEL_TIMEOUT 5000000 // 5 seconds namespace android { diff --git a/camera/inc/NV12_resize.h b/camera/inc/NV12_resize.h index ba18614..019b9eb 100644 --- a/camera/inc/NV12_resize.h +++ b/camera/inc/NV12_resize.h @@ -1,6 +1,8 @@ #ifndef NV12_RESIZE_H_ #define NV12_RESIZE_H_ +#include "Common.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/camera/inc/SensorListener.h b/camera/inc/SensorListener.h index 913eb95..f36ea0d 100644 --- a/camera/inc/SensorListener.h +++ b/camera/inc/SensorListener.h @@ -30,6 +30,8 @@ #include <gui/SensorEventQueue.h> #include <utils/Looper.h> +#include "Common.h" + namespace android { /** |