summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2012-10-16 10:17:30 -0700
committerEino-Ville Talvala <etalvala@google.com>2012-10-16 10:23:05 -0700
commitd6cc4a62f3d94cad4dd36bd0a844ba8764177d26 (patch)
treefbd68ee26548cd153119df2b42900c7f19bacd1c
parentb4a55269a5b39c73de2cc1d4013d0631ef18c77d (diff)
Camera2: When focus is already locked in CAF mode, do not trigger HAL.
In HAL2 CAF modes, once focus is locked by an AF trigger, additional triggers will not cause AF notifications, since the state will not change again until a cancelAutofocus call. Since the old API still expects to see a notification, short-circuit this at the service and send an immediate success notification. Bug: 7318298 Change-Id: Ib209a24eaf2a35a247d06aea671efe80a33d751e
-rw-r--r--services/camera/libcameraservice/Camera2Client.cpp39
-rw-r--r--services/camera/libcameraservice/camera2/Parameters.cpp4
-rw-r--r--services/camera/libcameraservice/camera2/Parameters.h2
3 files changed, 41 insertions, 4 deletions
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp
index 72906637..c5ea3ed4 100644
--- a/services/camera/libcameraservice/Camera2Client.cpp
+++ b/services/camera/libcameraservice/Camera2Client.cpp
@@ -267,6 +267,17 @@ status_t Camera2Client::dump(int fd, const Vector<String16>& args) {
default: result.append("UNKNOWN\n");
}
+ result.append(" Focus state: ");
+ switch (p.focusState) {
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_INACTIVE)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED)
+ default: result.append("UNKNOWN\n");
+ }
+
result.append(" Focusing areas:\n");
for (size_t i = 0; i < p.focusingAreas.size(); i++) {
result.appendFormat(" [ (%d, %d, %d, %d), weight %d ]\n",
@@ -952,6 +963,8 @@ status_t Camera2Client::autoFocus() {
if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
int triggerId;
+ bool notifyImmediately = false;
+ bool notifySuccess = false;
{
SharedParameters::Lock l(mParameters);
if (l.mParameters.state < Parameters::PREVIEW) {
@@ -964,15 +977,34 @@ status_t Camera2Client::autoFocus() {
* with a fake value of success set to true.
*/
if (l.mParameters.focusMode == Parameters::FOCUS_MODE_FIXED) {
+ notifyImmediately = true;
+ notifySuccess = true;
+ }
+ /**
+ * If we're in CAF mode, and AF has already been locked, just fire back
+ * the callback right away; the HAL would not send a notification since
+ * no state change would happen on a AF trigger.
+ */
+ if ( (l.mParameters.focusMode == Parameters::FOCUS_MODE_CONTINUOUS_PICTURE ||
+ l.mParameters.focusMode == Parameters::FOCUS_MODE_CONTINUOUS_VIDEO) &&
+ l.mParameters.focusState == ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED ) {
+ notifyImmediately = true;
+ notifySuccess = true;
+ }
+ /**
+ * Send immediate notification back to client
+ */
+ if (notifyImmediately) {
SharedCameraClient::Lock l(mSharedCameraClient);
if (l.mCameraClient != 0) {
l.mCameraClient->notifyCallback(CAMERA_MSG_FOCUS,
- /*success*/1, 0);
+ notifySuccess ? 1 : 0, 0);
}
-
return OK;
}
-
+ /**
+ * Handle quirk mode for AF in scene modes
+ */
if (l.mParameters.quirks.triggerAfWithAuto &&
l.mParameters.sceneMode != ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED &&
l.mParameters.focusMode != Parameters::FOCUS_MODE_AUTO) {
@@ -1303,6 +1335,7 @@ void Camera2Client::notifyAutoFocus(uint8_t newState, int triggerId) {
bool afInMotion = false;
{
SharedParameters::Lock l(mParameters);
+ l.mParameters.focusState = newState;
switch (l.mParameters.focusMode) {
case Parameters::FOCUS_MODE_AUTO:
case Parameters::FOCUS_MODE_MACRO:
diff --git a/services/camera/libcameraservice/camera2/Parameters.cpp b/services/camera/libcameraservice/camera2/Parameters.cpp
index 3c679da3..9a0083ac 100644
--- a/services/camera/libcameraservice/camera2/Parameters.cpp
+++ b/services/camera/libcameraservice/camera2/Parameters.cpp
@@ -633,6 +633,7 @@ status_t Parameters::initialize(const CameraMetadata *info) {
params.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES,
supportedFocusModes);
}
+ focusState = ANDROID_CONTROL_AF_STATE_INACTIVE;
shadowFocusMode = FOCUS_MODE_INVALID;
camera_metadata_ro_entry_t max3aRegions =
@@ -1462,8 +1463,9 @@ status_t Parameters::set(const String8& paramString) {
}
}
}
+ validatedParams.focusState = ANDROID_CONTROL_AF_STATE_INACTIVE;
// Always reset shadow focus mode to avoid reverting settings
- shadowFocusMode = FOCUS_MODE_INVALID;
+ validatedParams.shadowFocusMode = FOCUS_MODE_INVALID;
// Update in case of override
newParams.set(CameraParameters::KEY_FOCUS_MODE,
focusModeEnumToString(validatedParams.focusMode));
diff --git a/services/camera/libcameraservice/camera2/Parameters.h b/services/camera/libcameraservice/camera2/Parameters.h
index fd02744e..8a8645ee 100644
--- a/services/camera/libcameraservice/camera2/Parameters.h
+++ b/services/camera/libcameraservice/camera2/Parameters.h
@@ -88,6 +88,8 @@ struct Parameters {
FOCUS_MODE_INVALID = -1
} focusMode;
+ uint8_t focusState; // Latest focus state from HAL
+
// For use with triggerAfWithAuto quirk
focusMode_t shadowFocusMode;