summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2011-10-21 00:36:22 -0500
committerJames Dong <jdong@google.com>2011-10-26 14:29:10 -0700
commitfd705eb8b757a4f3d1d80b736cf20cade04524d7 (patch)
tree3431416f492463b55cc2dbd0e754a4f870b74842
parent20107c0eaacde4f440d84f0643515451545ef601 (diff)
downloadhardware_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>
-rw-r--r--camera/CameraHal.cpp7
-rw-r--r--camera/OMXCameraAdapter/OMX3A.cpp17
-rwxr-xr-xcamera/OMXCameraAdapter/OMXCameraAdapter.cpp62
-rw-r--r--camera/OMXCameraAdapter/OMXCapture.cpp13
-rw-r--r--camera/OMXCameraAdapter/OMXFocus.cpp14
-rw-r--r--camera/TICameraParameters.cpp1
-rw-r--r--camera/inc/OMXCameraAdapter/OMXCameraAdapter.h2
-rw-r--r--camera/inc/TICameraParameters.h2
8 files changed, 93 insertions, 25 deletions
diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp
index 8d20891..dd505d8 100644
--- a/camera/CameraHal.cpp
+++ b/camera/CameraHal.cpp
@@ -2213,15 +2213,17 @@ status_t CameraHal::cancelAutoFocus()
{
LOG_FUNCTION_NAME;
- {
Mutex::Autolock lock(mLock);
+ CameraParameters adapterParams = mParameters;
mMsgEnabled &= ~CAMERA_MSG_FOCUS;
- }
if( NULL != mCameraAdapter )
{
+ adapterParams.set(TICameraParameters::KEY_AUTO_FOCUS_LOCK, CameraParameters::FALSE);
+ mCameraAdapter->setParameters(adapterParams);
mCameraAdapter->sendCommand(CameraAdapter::CAMERA_CANCEL_AUTOFOCUS);
}
+
LOG_FUNCTION_NAME_EXIT;
return NO_ERROR;
}
@@ -2630,6 +2632,7 @@ char* CameraHal::getParameters()
// do not send internal parameters to upper layers
mParams.remove(TICameraParameters::KEY_RECORDING_HINT);
+ mParams.remove(TICameraParameters::KEY_AUTO_FOCUS_LOCK);
params_str8 = mParams.flatten();
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 &params,
}
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 &params,
}
}
+ 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 )
diff --git a/camera/TICameraParameters.cpp b/camera/TICameraParameters.cpp
index 720d72a..221cff4 100644
--- a/camera/TICameraParameters.cpp
+++ b/camera/TICameraParameters.cpp
@@ -69,6 +69,7 @@ const char TICameraParameters::KEY_SENSOR_ORIENTATION_VALUES[] = "sensor-orienta
const char TICameraParameters::KEY_MINFRAMERATE[] = "min-framerate";
const char TICameraParameters::KEY_MAXFRAMERATE[] = "max-framerate";
const char TICameraParameters::KEY_RECORDING_HINT[] = "internal-recording-hint";
+const char TICameraParameters::KEY_AUTO_FOCUS_LOCK[] = "auto-focus-lock";
//TI extensions for enabling/disabling GLBCE
const char TICameraParameters::GLBCE_ENABLE[] = "enable";
diff --git a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
index f4814c6..2f17ba8 100644
--- a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
+++ b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
@@ -905,6 +905,8 @@ private:
int mLastFrameCount;
unsigned int mIter;
nsecs_t mLastFPSTime;
+ Mutex mFrameCountMutex;
+ Condition mFirstFrameCondition;
size_t mSensorIndex;
CodingMode mCodingMode;
diff --git a/camera/inc/TICameraParameters.h b/camera/inc/TICameraParameters.h
index 3150398..633e5b6 100644
--- a/camera/inc/TICameraParameters.h
+++ b/camera/inc/TICameraParameters.h
@@ -68,7 +68,7 @@ static const char KEY_MAXFRAMERATE[];
// TI recording hint to notify camera adapters of possible recording
static const char KEY_RECORDING_HINT[];
-
+static const char KEY_AUTO_FOCUS_LOCK[];
static const char KEY_CURRENT_ISO[];
static const char KEY_SENSOR_ORIENTATION[];