summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
authorEmilian Peev <epeev@mm-sol.com>2012-02-07 19:13:36 +0200
committerWu-cheng Li <wuchengli@google.com>2012-02-11 02:52:10 +0800
commitac0cf36b98237ec911f49e7b1b93ef6464666e48 (patch)
tree06a68b2ed1c5b1cbbce6c1d254c61bce79d90fdb /camera
parentc1b78765729c878af2016c05e6a036e688191f95 (diff)
downloadhardware_ti_omap4xxx-ac0cf36b98237ec911f49e7b1b93ef6464666e48.zip
hardware_ti_omap4xxx-ac0cf36b98237ec911f49e7b1b93ef6464666e48.tar.gz
hardware_ti_omap4xxx-ac0cf36b98237ec911f49e7b1b93ef6464666e48.tar.bz2
CameraHal: Various AF related fixes
- In case of AF timeout the focus callback was being disabled. This callback will not get re-enabled again until preview is restarted. - Cancel AF is not working properly. Depending on the timing the off status event might not reach 'doAutoFocus()'. - This change also replaces the 'mDoAFSem' semaphore with a condition variable. Change-Id: I2ab7d87a05d97435aa6e67a122cc37a975794fc2 Signed-off-by: Emilian Peev <epeev@mm-sol.com>
Diffstat (limited to 'camera')
-rwxr-xr-xcamera/OMXCameraAdapter/OMXCameraAdapter.cpp1
-rw-r--r--camera/OMXCameraAdapter/OMXFocus.cpp49
-rw-r--r--camera/inc/OMXCameraAdapter/OMXCameraAdapter.h4
3 files changed, 24 insertions, 30 deletions
diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
index eb4fa00..f20ded7 100755
--- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
+++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
@@ -3461,7 +3461,6 @@ OMXCameraAdapter::OMXCameraAdapter(size_t sensor_index)
mTimeSourceDelta = 0;
onlyOnce = true;
- mDoAFSem.Create(0);
mInitSem.Create(0);
mFlushSem.Create(0);
mUsePreviewDataSem.Create(0);
diff --git a/camera/OMXCameraAdapter/OMXFocus.cpp b/camera/OMXCameraAdapter/OMXFocus.cpp
index c99b620..089d376 100644
--- a/camera/OMXCameraAdapter/OMXFocus.cpp
+++ b/camera/OMXCameraAdapter/OMXFocus.cpp
@@ -84,7 +84,7 @@ status_t OMXCameraAdapter::doAutoFocus()
OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE focusControl;
OMX_PARAM_FOCUSSTATUSTYPE focusStatus;
OMX_CONFIG_BOOLEANTYPE bOMX;
- int timeout = 0;
+ nsecs_t timeout = 0;
LOG_FUNCTION_NAME;
@@ -102,11 +102,6 @@ status_t OMXCameraAdapter::doAutoFocus()
return NO_ERROR;
}
- if ( 0 != mDoAFSem.Count() )
- {
- CAMHAL_LOGEB("Error mDoAFSem semaphore count %d", mDoAFSem.Count());
- return NO_INIT;
- }
if( ((AF_ACTIVE & getState()) != AF_ACTIVE) && ((AF_ACTIVE & getNextState()) != AF_ACTIVE) ) {
CAMHAL_LOGDA("Auto focus got canceled before doAutoFocus could be called");
@@ -187,9 +182,15 @@ status_t OMXCameraAdapter::doAutoFocus()
}
// configure focus timeout based on capture mode
- timeout = (mCapMode == VIDEO_MODE) ? AF_VIDEO_CALLBACK_TIMEOUT : AF_IMAGE_CALLBACK_TIMEOUT;
+ timeout = (mCapMode == VIDEO_MODE) ?
+ ( ( nsecs_t ) AF_VIDEO_CALLBACK_TIMEOUT * 1000 ) :
+ ( ( nsecs_t ) AF_IMAGE_CALLBACK_TIMEOUT * 1000 );
+
+ {
+ Mutex::Autolock lock(mDoAFMutex);
+ ret = mDoAFCond.waitRelative(mDoAFMutex, timeout);
+ }
- ret = mDoAFSem.WaitTimeout(timeout);
//If somethiing bad happened while we wait
if (mComponentState == OMX_StateInvalid) {
CAMHAL_LOGEA("Invalid State after Auto Focus Exitting!!!");
@@ -197,8 +198,6 @@ status_t OMXCameraAdapter::doAutoFocus()
}
if(ret != NO_ERROR) {
- //Disable auto focus callback from Ducati
- setFocusCallback(false);
CAMHAL_LOGEA("Autofocus callback timeout expired");
ret = returnFocusStatus(true);
} else {
@@ -206,7 +205,7 @@ status_t OMXCameraAdapter::doAutoFocus()
}
} else { // Focus mode in continuous
if ( NO_ERROR == ret ) {
- ret = returnFocusStatus(false);
+ ret = returnFocusStatus(true);
mPending3Asettings |= SetFocus;
}
}
@@ -307,14 +306,6 @@ status_t OMXCameraAdapter::cancelAutoFocus()
( focusMode.eFocusControl != ( OMX_IMAGE_FOCUSCONTROLTYPE )
OMX_IMAGE_FocusControlAutoInfinity ) ) {
stopAutoFocus();
- //Signal a dummy AF event so that in case the callback from ducati
- //does come then it doesnt crash after
- //exiting this function since eventSem will go out of scope.
- ret |= SignalEvent(mCameraAdapterParameters.mHandleComp,
- (OMX_EVENTTYPE) OMX_EventIndexSettingChanged,
- OMX_ALL,
- OMX_IndexConfigCommonFocusStatus,
- NULL );
} else if (focusMode.eFocusControl == OMX_IMAGE_FocusControlAuto) {
// re-apply CAF after unlocking and canceling
mPending3Asettings |= SetFocus;
@@ -435,7 +426,8 @@ status_t OMXCameraAdapter::returnFocusStatus(bool timeoutReached)
focusStatus = CameraHalEvent::FOCUS_STATUS_SUCCESS;
break;
}
- case OMX_FocusStatusOff:
+ case OMX_FocusStatusOff: // AF got canceled
+ return NO_ERROR;
case OMX_FocusStatusUnableToReach:
case OMX_FocusStatusRequest:
default:
@@ -450,9 +442,9 @@ status_t OMXCameraAdapter::returnFocusStatus(bool timeoutReached)
} else {
CAMHAL_LOGDA("Focus locked. Applied focus locks successfully");
}
-
stopAutoFocus();
}
+
//Query current focus distance after AF is complete
updateFocusDistances(mParameters);
}
@@ -802,17 +794,18 @@ void OMXCameraAdapter::handleFocusCallback() {
CAMHAL_LOGEA("Focus status check failed!");
// signal and unblock doAutoFocus
if (AF_ACTIVE & nextState) {
- mDoAFSem.Signal();
+ Mutex::Autolock lock(mDoAFMutex);
+ mDoAFCond.broadcast();
}
return;
- } else if (AF_ACTIVE & nextState) { // Handling for AF callback
+ }
+
+ if (eFocusStatus.eFocusStatus != OMX_FocusStatusRequest) {
// signal doAutoFocus when a end of scan message comes
// ignore start of scan
- if (eFocusStatus.eFocusStatus != OMX_FocusStatusRequest) {
- mDoAFSem.Signal();
- }
- return;
- }
+ Mutex::Autolock lock(mDoAFMutex);
+ mDoAFCond.broadcast();
+ }
if (mParameters3A.Focus != (OMX_IMAGE_FOCUSCONTROLTYPE) OMX_IMAGE_FocusControlAuto) {
CAMHAL_LOGDA("unregistered focus callback when not in CAF or doAutoFocus... not handling");
diff --git a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
index 2ab0b25..2924b1c 100644
--- a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
+++ b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h
@@ -894,7 +894,6 @@ private:
bool mFirstTimeInit;
///Semaphores used internally
- Semaphore mDoAFSem;
Semaphore mInitSem;
Semaphore mFlushSem;
Semaphore mUsePreviewDataSem;
@@ -933,6 +932,9 @@ private:
Mutex mFrameCountMutex;
Condition mFirstFrameCondition;
+ Mutex mDoAFMutex;
+ Condition mDoAFCond;
+
size_t mSensorIndex;
CodingMode mCodingMode;