summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-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 7290663..c5ea3ed 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 3c679da..9a0083a 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 fd02744..8a8645e 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;