From 6014a8f2648911e7e0f5ba9256afa1a7a9eaf526 Mon Sep 17 00:00:00 2001 From: James Dong Date: Tue, 15 Nov 2011 19:54:06 -0800 Subject: When camera.flash_off is 1, disable camera flash. This is for testing purpose only Change-Id: Idf0a6d5d52daeb4b5ff7576d0119868bdeff40eb related-to-bug: 5617451 --- camera/OMXCameraAdapter/OMX3A.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'camera') diff --git a/camera/OMXCameraAdapter/OMX3A.cpp b/camera/OMXCameraAdapter/OMX3A.cpp index 6b4aa63..be4c0e7 100644 --- a/camera/OMXCameraAdapter/OMX3A.cpp +++ b/camera/OMXCameraAdapter/OMX3A.cpp @@ -29,6 +29,8 @@ #include "OMXCameraAdapter.h" #include "ErrorUtils.h" +#include + #undef TRUE #undef FALSE #define TRUE "true" @@ -475,6 +477,22 @@ status_t OMXCameraAdapter::setExposureMode(Gen3A_settings& Gen3A) return ErrorUtils::omxToAndroidError(eError); } +static bool isFlashDisabled() { +#if (PROPERTY_VALUE_MAX < 5) +#error "PROPERTY_VALUE_MAX must be at least 5" +#endif + + char value[PROPERTY_VALUE_MAX]; + if (property_get("camera.flash_off", value, NULL) && + (!strcasecmp(value, "true") || !strcasecmp(value, "1"))) { + LOGW("flash is turned off"); + return true; + } + + LOGI("flash is turned on"); + return false; +} + status_t OMXCameraAdapter::setFlashMode(Gen3A_settings& Gen3A) { status_t ret = NO_ERROR; @@ -492,7 +510,12 @@ status_t OMXCameraAdapter::setFlashMode(Gen3A_settings& Gen3A) OMX_INIT_STRUCT_PTR (&flash, OMX_IMAGE_PARAM_FLASHCONTROLTYPE); flash.nPortIndex = OMX_ALL; - flash.eFlashControl = ( OMX_IMAGE_FLASHCONTROLTYPE ) Gen3A.FlashMode; + + if (isFlashDisabled()) { + flash.eFlashControl = ( OMX_IMAGE_FLASHCONTROLTYPE ) OMX_IMAGE_FlashControlOff; + } else { + flash.eFlashControl = ( OMX_IMAGE_FLASHCONTROLTYPE ) Gen3A.FlashMode; + } CAMHAL_LOGDB("Configuring flash mode 0x%x", flash.eFlashControl); eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, -- cgit v1.1