diff options
author | Tyler Luu <tluu@ti.com> | 2011-10-21 00:36:22 -0500 |
---|---|---|
committer | James Dong <jdong@google.com> | 2011-10-26 14:29:10 -0700 |
commit | fd705eb8b757a4f3d1d80b736cf20cade04524d7 (patch) | |
tree | 3431416f492463b55cc2dbd0e754a4f870b74842 /camera/OMXCameraAdapter | |
parent | 20107c0eaacde4f440d84f0643515451545ef601 (diff) | |
download | hardware_ti_omap4xxx-fd705eb8b757a4f3d1d80b736cf20cade04524d7.zip hardware_ti_omap4xxx-fd705eb8b757a4f3d1d80b736cf20cade04524d7.tar.gz hardware_ti_omap4xxx-fd705eb8b757a4f3d1d80b736cf20cade04524d7.tar.bz2 |
CameraHal: Fixes for #testFocusDistance
1. Seperate OMXCameraAdapter cancelAutoFocus with unsetting focus
lock. Adding new internal parameter to unlock focus from the
cancelAutoFocus in CameraHal. We need to cancel auto focus during
stop preview in case it is still running. If we do the unlock in
OMXCameraAdapter then, focus distance can change after stopPreview.
2. If autoFocus or takePicture comes after startPreview but before
the first preview frame comes, then sometimes the focus distance
queried after the calls won't be correct since OMX camera might
still be transitioning.
3. Update focus distances when focus is running.
b/5473673
Change-Id: I5a27d78aef437a1601a68e8c08fa860f04fc0c55
Signed-off-by: Tyler Luu <tluu@ti.com>
Diffstat (limited to 'camera/OMXCameraAdapter')
-rw-r--r-- | camera/OMXCameraAdapter/OMX3A.cpp | 17 | ||||
-rwxr-xr-x | camera/OMXCameraAdapter/OMXCameraAdapter.cpp | 62 | ||||
-rw-r--r-- | camera/OMXCameraAdapter/OMXCapture.cpp | 13 | ||||
-rw-r--r-- | camera/OMXCameraAdapter/OMXFocus.cpp | 14 |
4 files changed, 84 insertions, 22 deletions
diff --git a/camera/OMXCameraAdapter/OMX3A.cpp b/camera/OMXCameraAdapter/OMX3A.cpp index 75f514d..73f3714 100644 --- a/camera/OMXCameraAdapter/OMX3A.cpp +++ b/camera/OMXCameraAdapter/OMX3A.cpp @@ -218,6 +218,12 @@ status_t OMXCameraAdapter::setParameters3A(const CameraParameters ¶ms, } mParameters3A.Focus = mode; + + // if focus mode is set to infinity...update focus distance immediately + if (mode == OMX_IMAGE_FocusControlAutoInfinity) { + updateFocusDistances(mParameters); + } + CAMHAL_LOGDB("Focus %x", mParameters3A.Focus); } @@ -313,6 +319,17 @@ status_t OMXCameraAdapter::setParameters3A(const CameraParameters ¶ms, } } + str = params.get(TICameraParameters::KEY_AUTO_FOCUS_LOCK); + if (str && (strcmp(str, TRUE) == 0) && (mParameters3A.FocusLock != OMX_TRUE)) { + CAMHAL_LOGVA("Locking Focus"); + mParameters3A.FocusLock = OMX_TRUE; + setFocusLock(mParameters3A); + } else if (str && (strcmp(str, FALSE) == 0) && (mParameters3A.FocusLock != OMX_FALSE)) { + CAMHAL_LOGVA("UnLocking Focus"); + mParameters3A.FocusLock = OMX_FALSE; + setFocusLock(mParameters3A); + } + str = params.get(CameraParameters::KEY_METERING_AREAS); if ( (str != NULL) ) { size_t MAX_METERING_AREAS; diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp index c3feeee..6dab841 100755 --- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp +++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp @@ -664,11 +664,8 @@ void OMXCameraAdapter::getParameters(CameraParameters& params) params.set(CameraParameters::KEY_FOCUS_MODE, valstr); } - //Query focus distances only during CAF, Infinity - //or when focus is running + //Query focus distances only when focus is running if ( ( AF_ACTIVE & state ) || - ( mParameters3A.Focus == OMX_IMAGE_FocusControlAuto ) || - ( mParameters3A.Focus == OMX_IMAGE_FocusControlAutoInfinity ) || ( NULL == mParameters.get(CameraParameters::KEY_FOCUS_DISTANCES) ) ) { updateFocusDistances(params); @@ -1863,14 +1860,17 @@ status_t OMXCameraAdapter::startPreview() if ( mPending3Asettings ) apply3Asettings(mParameters3A); - //Query current focus distance after - //starting the preview - updateFocusDistances(mParameters); - //reset frame rate estimates mFPS = 0.0f; mLastFPS = 0.0f; - mFrameCount = 0; + // start frame count from 0. i.e first frame after + // startPreview will be the 0th reference frame + // this way we will wait for second frame until + // takePicture/autoFocus is allowed to run. we + // are seeing SetConfig/GetConfig fail after + // calling after the first frame and not failing + // after the second frame + mFrameCount = -1; mLastFrameCount = 0; mIter = 1; mLastFPSTime = systemTime(); @@ -1911,6 +1911,12 @@ status_t OMXCameraAdapter::stopPreview() return NO_INIT; } + { + Mutex::Autolock lock(mFrameCountMutex); + mFrameCount = 0; + mFirstFrameCondition.broadcast(); + } + ret = cancelAutoFocus(); if(ret!=NO_ERROR) { @@ -2208,10 +2214,25 @@ status_t OMXCameraAdapter::autoFocus() LOG_FUNCTION_NAME; + { + Mutex::Autolock lock(mFrameCountMutex); + if (mFrameCount < 1) { + // first frame may time some time to come...so wait for an adequate amount of time + // which 2 * OMX_CAPTURE_TIMEOUT * 1000 will cover. + ret = mFirstFrameCondition.waitRelative(mFrameCountMutex, + (nsecs_t) 2 * OMX_CAPTURE_TIMEOUT * 1000); + if ((NO_ERROR != ret) || (mFrameCount == 0)) { + goto EXIT; + } + } + } + msg.command = CommandHandler::CAMERA_PERFORM_AUTOFOCUS; msg.arg1 = mErrorNotifier; ret = mCommandHandler->put(&msg); + EXIT: + LOG_FUNCTION_NAME; return ret; @@ -2224,10 +2245,24 @@ status_t OMXCameraAdapter::takePicture() LOG_FUNCTION_NAME; + { + Mutex::Autolock lock(mFrameCountMutex); + if (mFrameCount < 1) { + // first frame may time some time to come...so wait for an adequate amount of time + // which 2 * OMX_CAPTURE_TIMEOUT * 1000 will cover. + ret = mFirstFrameCondition.waitRelative(mFrameCountMutex, + (nsecs_t) 2 * OMX_CAPTURE_TIMEOUT * 1000); + if ((NO_ERROR != ret) || (mFrameCount == 0)) { + goto EXIT; + } + } + } + msg.command = CommandHandler::CAMERA_START_IMAGE_CAPTURE; msg.arg1 = mErrorNotifier; ret = mCommandHandler->put(&msg); + EXIT: LOG_FUNCTION_NAME_EXIT; return ret; @@ -2929,7 +2964,6 @@ OMX_ERRORTYPE OMXCameraAdapter::OMXCameraAdapterFillBufferDone(OMX_IN OMX_HANDLE { apply3Asettings(mParameters3A); } - } else if( pBuffHeader->nOutputPortIndex == OMX_CAMERA_PORT_VIDEO_OUT_MEASUREMENT ) { @@ -3041,7 +3075,13 @@ status_t OMXCameraAdapter::recalculateFPS() { float currentFPS; - mFrameCount++; + { + Mutex::Autolock lock(mFrameCountMutex); + mFrameCount++; + if (mFrameCount == 1) { + mFirstFrameCondition.broadcast(); + } + } if ( ( mFrameCount % FPS_PERIOD ) == 0 ) { diff --git a/camera/OMXCameraAdapter/OMXCapture.cpp b/camera/OMXCameraAdapter/OMXCapture.cpp index 5a83169..379cf48 100644 --- a/camera/OMXCameraAdapter/OMXCapture.cpp +++ b/camera/OMXCameraAdapter/OMXCapture.cpp @@ -953,6 +953,12 @@ status_t OMXCameraAdapter::stopImageCapture() mCaptureSignalled = true; //set this to true if we exited because of timeout + { + Mutex::Autolock lock(mFrameCountMutex); + mFrameCount = 0; + mFirstFrameCondition.broadcast(); + } + return (ret | ErrorUtils::omxToAndroidError(eError)); EXIT: @@ -961,6 +967,13 @@ EXIT: if ( NULL != mReleaseImageBuffersCallback ) { mReleaseImageBuffersCallback(mReleaseData); } + + { + Mutex::Autolock lock(mFrameCountMutex); + mFrameCount = 0; + mFirstFrameCondition.broadcast(); + } + performCleanupAfterError(); LOG_FUNCTION_NAME_EXIT; return (ret | ErrorUtils::omxToAndroidError(eError)); diff --git a/camera/OMXCameraAdapter/OMXFocus.cpp b/camera/OMXCameraAdapter/OMXFocus.cpp index 4746602..6b94140 100644 --- a/camera/OMXCameraAdapter/OMXFocus.cpp +++ b/camera/OMXCameraAdapter/OMXFocus.cpp @@ -236,9 +236,6 @@ status_t OMXCameraAdapter::stopAutoFocus() } } - //Query current focus distance after AF is complete - updateFocusDistances(mParameters); - LOG_FUNCTION_NAME_EXIT; return ret; @@ -278,13 +275,6 @@ status_t OMXCameraAdapter::cancelAutoFocus() OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE focusMode; LOG_FUNCTION_NAME; - // Unlock 3A locks since they were locked by AF conditionally - if( set3ALock(mUserSetExpLock, mUserSetWbLock, OMX_FALSE) != NO_ERROR) { - CAMHAL_LOGEA("Error Unlocking 3A locks"); - } - else{ - CAMHAL_LOGDA("AE/AWB unlocked successfully"); - } ret = getFocusMode(focusMode); if ( NO_ERROR != ret ) { @@ -436,7 +426,9 @@ status_t OMXCameraAdapter::returnFocusStatus(bool timeoutReached) stopAutoFocus(); } - } + //Query current focus distance after AF is complete + updateFocusDistances(mParameters); + } ret = BaseCameraAdapter::setState(CAMERA_CANCEL_AUTOFOCUS); if ( NO_ERROR == ret ) |