summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2014-08-21 19:24:12 -0700
committerIgor Murashkin <iam@google.com>2014-08-22 13:24:46 -0700
commit555a14617e31e0e5945ce5bdac1b05fc416a7227 (patch)
treee6d4d394a22c4a137e5c6306916d7caaf47be45c
parentabc1855b0386eee4704b34551cb87021e12145fa (diff)
downloadmako-555a14617e31e0e5945ce5bdac1b05fc416a7227.tar.gz
camera: Fix onAutoFocus never sent back to camera service during CAF
Fix a bug where if autoFocus was sent to HAL very close to a setParameters, that the setParameters would override the "AF is running" state and drop the onAutoFocus callback. Bug: 17096480 Change-Id: Iec137084e0fb019a233e3c7d26abd84e1c736757
-rwxr-xr-xcamera/QCameraHWI.cpp3
-rw-r--r--camera/QCameraHWI_Parm.cpp17
2 files changed, 19 insertions, 1 deletions
diff --git a/camera/QCameraHWI.cpp b/camera/QCameraHWI.cpp
index 5fe7352..f3608f8 100755
--- a/camera/QCameraHWI.cpp
+++ b/camera/QCameraHWI.cpp
@@ -1888,6 +1888,8 @@ status_t QCameraHardwareInterface::autoFocus()
bool status = true;
isp3a_af_mode_t afMode = getAutoFocusMode(mParameters);
+ Mutex::Autolock afLock(mAutofocusLock);
+
if(mAutoFocusRunning==true){
ALOGV("%s:AF already running should not have got this call",__func__);
return NO_ERROR;
@@ -1933,6 +1935,7 @@ status_t QCameraHardwareInterface::cancelAutoFocus()
mAutofocusLock.lock();
if(mAutoFocusRunning || mNeedToUnlockCaf) {
+ ALOGV("%s:Af either running or CAF needs unlocking", __func__);
mNeedToUnlockCaf = false;
mAutoFocusRunning = false;
mAutofocusLock.unlock();
diff --git a/camera/QCameraHWI_Parm.cpp b/camera/QCameraHWI_Parm.cpp
index b959d78..7285ddd 100644
--- a/camera/QCameraHWI_Parm.cpp
+++ b/camera/QCameraHWI_Parm.cpp
@@ -2066,9 +2066,10 @@ status_t QCameraHardwareInterface::setFocusMode(const QCameraParameters& params)
{
const char *str = params.get(QCameraParameters::KEY_FOCUS_MODE);
const char *prev_str = mParameters.get(QCameraParameters::KEY_FOCUS_MODE);
+ bool modesAreSame = strcmp(str, prev_str) == 0;
ALOGV("%s",__func__);
if (str != NULL) {
- ALOGV("Focus mode %s",str);
+ ALOGV("Focus mode '%s', previous focus mode '%s' (cmp %d)",str, prev_str, strcmp(str, prev_str));
int32_t value;
@@ -2089,6 +2090,17 @@ status_t QCameraHardwareInterface::setFocusMode(const QCameraParameters& params)
return UNKNOWN_ERROR;
}
mParameters.set(QCameraParameters::KEY_FOCUS_DISTANCES, mFocusDistance.string());
+
+ // Do not set the AF state to 'not running';
+ // this prevents a bug where an autoFocus followed by a setParameters
+ // with the same exact focus mode resulting in dropping the autoFocusEvent
+ if(modesAreSame) {
+ ALOGV("AF mode unchanged (still '%s'); don't touch CAF", str);
+ return NO_ERROR;
+ } else {
+ ALOGV("AF made has changed to '%s'", str);
+ }
+
if(mHasAutoFocusSupport){
bool ret = native_set_parms(MM_CAMERA_PARM_FOCUS_MODE,
sizeof(value),
@@ -2113,8 +2125,11 @@ status_t QCameraHardwareInterface::setFocusMode(const QCameraParameters& params)
}
ALOGV("caf_type %d rc %d", caf_type, rc);
}
+
+
ALOGV("Continuous Auto Focus %d", cafSupport);
if(mAutoFocusRunning && cafSupport){
+ ALOGV("Set auto focus running to false");
mAutoFocusRunning = false;
if(MM_CAMERA_OK!=cam_ops_action(mCameraId,false,MM_CAMERA_OPS_FOCUS,NULL )) {
ALOGE("%s: AF command failed err:%d error %s",__func__, errno,strerror(errno));