From 2136042f80a20aeeef3ece24bab027c401426334 Mon Sep 17 00:00:00 2001 From: Milen Mitkov Date: Mon, 24 Oct 2011 13:44:28 +0300 Subject: CameraHAL: Setting focus mode shouldnt start focus scanning Part of the fix for b/5591797. Use the new index OMX_TI_IndexAutofocusEnable to control the AF algorithm when it should start scanning. Until now, setting the focus to almost any mode caused (unwanted) scanning. Also, "Infinity" focus should actually have the ability to perform scanning. Change-Id: Iaa0f46a17d63acdd8f43b4b2b011f68fc7506165 Signed-off-by: Milen Mitkov Signed-off-by: Iliyan Malchev --- camera/OMXCameraAdapter/OMX3A.cpp | 36 ++++++++++++++++++++++++++++++------ camera/OMXCameraAdapter/OMXFocus.cpp | 8 ++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) (limited to 'camera') diff --git a/camera/OMXCameraAdapter/OMX3A.cpp b/camera/OMXCameraAdapter/OMX3A.cpp index 73f3714..6b4aa63 100644 --- a/camera/OMXCameraAdapter/OMX3A.cpp +++ b/camera/OMXCameraAdapter/OMX3A.cpp @@ -210,12 +210,7 @@ status_t OMXCameraAdapter::setParameters3A(const CameraParameters ¶ms, mode = getLUTvalue_HALtoOMX(str, FocusLUT); if ( (mFirstTimeInit || ((str != NULL) && (mParameters3A.Focus != mode)))) { - //Apply focus mode immediatly only if CAF or Inifinity are selected - if ( ( mode == OMX_IMAGE_FocusControlAuto ) || - ( mode == OMX_IMAGE_FocusControlAutoInfinity ) ) - { - mPending3Asettings |= SetFocus; - } + mPending3Asettings |= SetFocus; mParameters3A.Focus = mode; @@ -582,6 +577,7 @@ status_t OMXCameraAdapter::setFocusMode(Gen3A_settings& Gen3A) OMX_ERRORTYPE eError = OMX_ErrorNone; OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE focus; size_t top, left, width, height, weight; + OMX_CONFIG_BOOLEANTYPE bOMX; LOG_FUNCTION_NAME; @@ -635,6 +631,34 @@ status_t OMXCameraAdapter::setFocusMode(Gen3A_settings& Gen3A) if ( NO_ERROR == ret && ((state & AF_ACTIVE) == 0) ) { + OMX_INIT_STRUCT_PTR (&bOMX, OMX_CONFIG_BOOLEANTYPE); + + if ( Gen3A.Focus == OMX_IMAGE_FocusControlAutoInfinity) + { + // Don't lock at infinity, otherwise the AF cannot drive + // the lens at infinity position + if( set3ALock(mUserSetExpLock, mUserSetWbLock, OMX_FALSE) != NO_ERROR) + { + CAMHAL_LOGEA("Error Applying 3A locks"); + } else { + CAMHAL_LOGDA("Focus locked. Applied focus locks successfully"); + } + } + if ( Gen3A.Focus == OMX_IMAGE_FocusControlAuto || + Gen3A.Focus == OMX_IMAGE_FocusControlAutoInfinity) + { + // Run focus scanning if switching to continuous infinity focus mode + bOMX.bEnabled = OMX_TRUE; + } + else + { + bOMX.bEnabled = OMX_FALSE; + } + + eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, + (OMX_INDEXTYPE)OMX_TI_IndexConfigAutofocusEnable, + &bOMX); + OMX_INIT_STRUCT_PTR (&focus, OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE); focus.nPortIndex = mCameraAdapterParameters.mPrevPortIndex; focus.eFocusControl = (OMX_IMAGE_FOCUSCONTROLTYPE)Gen3A.Focus; diff --git a/camera/OMXCameraAdapter/OMXFocus.cpp b/camera/OMXCameraAdapter/OMXFocus.cpp index 7655d90..ce569ec 100644 --- a/camera/OMXCameraAdapter/OMXFocus.cpp +++ b/camera/OMXCameraAdapter/OMXFocus.cpp @@ -82,6 +82,7 @@ status_t OMXCameraAdapter::doAutoFocus() OMX_ERRORTYPE eError = OMX_ErrorNone; OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE focusControl; OMX_PARAM_FOCUSSTATUSTYPE focusStatus; + OMX_CONFIG_BOOLEANTYPE bOMX; LOG_FUNCTION_NAME; @@ -153,6 +154,13 @@ status_t OMXCameraAdapter::doAutoFocus() && focusStatus.eFocusStatus == OMX_FocusStatusRequest) || (mParameters3A.Focus != (OMX_IMAGE_FOCUSCONTROLTYPE)OMX_IMAGE_FocusControlAuto) ) { + OMX_INIT_STRUCT_PTR (&bOMX, OMX_CONFIG_BOOLEANTYPE); + bOMX.bEnabled = OMX_TRUE; + + //Enable focus scanning + eError = OMX_SetConfig(mCameraAdapterParameters.mHandleComp, + (OMX_INDEXTYPE)OMX_TI_IndexConfigAutofocusEnable, + &bOMX); ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp, (OMX_EVENTTYPE) OMX_EventIndexSettingChanged, -- cgit v1.1