From 4c843702c7c2d2ca951e25bc54787c68c2071a8b Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Thu, 4 Oct 2012 00:56:40 -0700 Subject: [PATCH] Camera2: Use the triggerAfWithAuto quirk When this quirk is set, and a scene mode is enabled, do AF calls with AF mode AUTO instead of whatever the scene more override AF mode is. Bug: 7159577 Change-Id: I3ea6b8386abc0968047fc9bba3a35c5db5bdcfd3 --- services/camera/libcameraservice/Camera2Client.cpp | 20 ++++++++++++++++++++ .../camera/libcameraservice/camera2/Parameters.cpp | 3 +++ .../camera/libcameraservice/camera2/Parameters.h | 3 +++ 3 files changed, 26 insertions(+) diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp index 9bcaef1ecb..ed4567edef 100644 --- a/services/camera/libcameraservice/Camera2Client.cpp +++ b/services/camera/libcameraservice/Camera2Client.cpp @@ -956,6 +956,16 @@ status_t Camera2Client::autoFocus() { return INVALID_OPERATION; } + if (l.mParameters.quirks.triggerAfWithAuto && + l.mParameters.sceneMode != ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED && + l.mParameters.focusMode != Parameters::FOCUS_MODE_AUTO) { + ALOGV("%s: Quirk: Switching from focusMode %d to AUTO", + __FUNCTION__, l.mParameters.focusMode); + l.mParameters.shadowFocusMode = l.mParameters.focusMode; + l.mParameters.focusMode = Parameters::FOCUS_MODE_AUTO; + updateRequests(l.mParameters); + } + l.mParameters.currentAfTriggerId = ++l.mParameters.afTriggerCounter; triggerId = l.mParameters.currentAfTriggerId; } @@ -977,6 +987,16 @@ status_t Camera2Client::cancelAutoFocus() { { SharedParameters::Lock l(mParameters); triggerId = ++l.mParameters.afTriggerCounter; + + // When using triggerAfWithAuto quirk, may need to reset focus mode to + // the real state at this point. + if (l.mParameters.shadowFocusMode != Parameters::FOCUS_MODE_INVALID) { + ALOGV("%s: Quirk: Restoring focus mode to %d", __FUNCTION__, + l.mParameters.shadowFocusMode); + l.mParameters.focusMode = l.mParameters.shadowFocusMode; + l.mParameters.shadowFocusMode = Parameters::FOCUS_MODE_INVALID; + updateRequests(l.mParameters); + } } syncWithDevice(); diff --git a/services/camera/libcameraservice/camera2/Parameters.cpp b/services/camera/libcameraservice/camera2/Parameters.cpp index 7740df27fc..b05cdaf6fc 100644 --- a/services/camera/libcameraservice/camera2/Parameters.cpp +++ b/services/camera/libcameraservice/camera2/Parameters.cpp @@ -607,6 +607,7 @@ status_t Parameters::initialize(const CameraMetadata *info) { params.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES, supportedFocusModes); } + shadowFocusMode = FOCUS_MODE_INVALID; camera_metadata_ro_entry_t max3aRegions = staticInfo(ANDROID_CONTROL_MAX_REGIONS, 1, 1); @@ -1363,6 +1364,8 @@ status_t Parameters::set(const String8& paramString) { } } } + // Always reset shadow focus mode to avoid reverting settings + 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 a85500f18c..53ddf99472 100644 --- a/services/camera/libcameraservice/camera2/Parameters.h +++ b/services/camera/libcameraservice/camera2/Parameters.h @@ -88,6 +88,9 @@ struct Parameters { FOCUS_MODE_INVALID = -1 } focusMode; + // For use with triggerAfWithAuto quirk + focusMode_t shadowFocusMode; + struct Area { int left, top, right, bottom; int weight; -- 2.11.0