From dec84fb1c687509c3125acac76e0af80e4e0afbd Mon Sep 17 00:00:00 2001 From: Yin-Chia Yeh Date: Wed, 10 Sep 2014 15:14:18 -0700 Subject: Camera2: improve ZSL candidate selection logic 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 --- .../api1/client2/ZslProcessor3.cpp | 29 ++++++++++++++++++++-- .../libcameraservice/api1/client2/ZslProcessor3.h | 2 ++ 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'services/camera/libcameraservice/api1/client2') diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp index 2d31275..608550b 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor3.cpp @@ -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) { diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h b/services/camera/libcameraservice/api1/client2/ZslProcessor3.h index daa352b..76707fa 100644 --- a/services/camera/libcameraservice/api1/client2/ZslProcessor3.h +++ b/services/camera/libcameraservice/api1/client2/ZslProcessor3.h @@ -132,6 +132,8 @@ class ZslProcessor3 : void dumpZslQueue(int id) const; nsecs_t getCandidateTimestampLocked(size_t* metadataIdx) const; + + bool isFixedFocusMode(uint8_t afMode) const; }; -- cgit v1.1