OSDN Git Service

Camera2: improve ZSL candidate selection logic
authorYin-Chia Yeh <yinchiayeh@google.com>
Wed, 10 Sep 2014 22:14:18 +0000 (15:14 -0700)
committerYin-Chia Yeh <yinchiayeh@google.com>
Thu, 11 Sep 2014 17:05:27 +0000 (10:05 -0700)
1. Clear ZSL queue when focus mode is changed and autoFocus is
   cancelled.
2. Do not check focus state is focus mode is fixed.

Bug: 17185356
Change-Id: I2cb10fb457b080f0db950c894e56995f638e147b

services/camera/libcameraservice/api1/Camera2Client.cpp
services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp
services/camera/libcameraservice/api1/client2/ZslProcessor3.h

index 36a93b2..6f4a507 100644 (file)
@@ -1291,6 +1291,9 @@ status_t Camera2Client::cancelAutoFocus() {
 
             return OK;
         }
+        if (l.mParameters.zslMode) {
+            mZslProcessor->clearZslQueue();
+        }
     }
     syncWithDevice();
 
@@ -1379,8 +1382,14 @@ status_t Camera2Client::setParameters(const String8& params) {
 
     SharedParameters::Lock l(mParameters);
 
+    Parameters::focusMode_t focusModeBefore = l.mParameters.focusMode;
     res = l.mParameters.set(params);
     if (res != OK) return res;
+    Parameters::focusMode_t focusModeAfter = l.mParameters.focusMode;
+
+    if (l.mParameters.zslMode && focusModeAfter != focusModeBefore) {
+        mZslProcessor->clearZslQueue();
+    }
 
     res = updateRequests(l.mParameters);
 
index 2d31275..608550b 100644 (file)
@@ -454,6 +454,23 @@ void ZslProcessor3::dumpZslQueue(int fd) const {
     }
 }
 
+bool ZslProcessor3::isFixedFocusMode(uint8_t afMode) const {
+    switch (afMode) {
+        case ANDROID_CONTROL_AF_MODE_AUTO:
+        case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO:
+        case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE:
+        case ANDROID_CONTROL_AF_MODE_MACRO:
+            return false;
+            break;
+        case ANDROID_CONTROL_AF_MODE_OFF:
+        case ANDROID_CONTROL_AF_MODE_EDOF:
+            return true;
+        default:
+            ALOGE("%s: unknown focus mode %d", __FUNCTION__, afMode);
+            return false;
+    }
+}
+
 nsecs_t ZslProcessor3::getCandidateTimestampLocked(size_t* metadataIdx) const {
     /**
      * Find the smallest timestamp we know about so far
@@ -499,8 +516,16 @@ nsecs_t ZslProcessor3::getCandidateTimestampLocked(size_t* metadataIdx) const {
                     continue;
                 }
 
-                // Check AF state if device has focuser
-                if (mHasFocuser) {
+                entry = frame.find(ANDROID_CONTROL_AF_MODE);
+                if (entry.count == 0) {
+                    ALOGW("%s: ZSL queue frame has no AF mode field!",
+                            __FUNCTION__);
+                    continue;
+                }
+                uint8_t afMode = entry.data.u8[0];
+
+                // Check AF state if device has focuser and focus mode isn't fixed
+                if (mHasFocuser && !isFixedFocusMode(afMode)) {
                     // Make sure the candidate frame has good focus.
                     entry = frame.find(ANDROID_CONTROL_AF_STATE);
                     if (entry.count == 0) {
index daa352b..76707fa 100644 (file)
@@ -132,6 +132,8 @@ class ZslProcessor3 :
     void dumpZslQueue(int id) const;
 
     nsecs_t getCandidateTimestampLocked(size_t* metadataIdx) const;
+
+    bool isFixedFocusMode(uint8_t afMode) const;
 };