From 40e99e22e1a45d36b7fac9c4452aa1d74550b424 Mon Sep 17 00:00:00 2001 From: Pawit Pornkitprasan Date: Fri, 23 Sep 2011 21:18:27 +0700 Subject: Fix taking a photo after taking a video. libsamsungcamera.so requires that the focus mode be changed after turning off continuous autofocus for autofocus to work. Change-Id: I27f8a976af4fabf78c803c53b6d4f713d77d9859 --- libcamera/LibCameraWrapper.cpp | 28 +++++++++++++++++++++++++--- libcamera/LibCameraWrapper.h | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'libcamera') diff --git a/libcamera/LibCameraWrapper.cpp b/libcamera/LibCameraWrapper.cpp index 3ccf332..a34c9b2 100644 --- a/libcamera/LibCameraWrapper.cpp +++ b/libcamera/LibCameraWrapper.cpp @@ -105,6 +105,7 @@ LibCameraWrapper::LibCameraWrapper(int cameraId) : mCameraId(cameraId), mVideoMode(false), mContinuousAf(false), + mFixFocus(false), mTouchFocus(false) { LOGV("%s :", __func__); @@ -164,7 +165,22 @@ status_t LibCameraWrapper::startPreview() { LOGV("%s :", __func__); - return mLibInterface->startPreview(); + status_t ret = mLibInterface->startPreview(); + + if (mFixFocus) { + LOGV("Fix focus mode"); + // We need to switch the focus mode once after switching from video or the camera won't work. + // Note: If the previous mode was macro, then it actually doesn't matter since the bug doesn't affect that case. + CameraParameters pars = mLibInterface->getParameters(); + const char *prevFocusMode = pars.get("focus-mode"); + pars.set("focus-mode", "macro"); + mLibInterface->setParameters(pars); + pars.set("focus-mode", prevFocusMode); + mLibInterface->setParameters(pars); + mFixFocus = false; + } + + return ret; } bool @@ -261,6 +277,7 @@ LibCameraWrapper::setParameters(const CameraParameters& params) const char *metering; const char *conAf; const char *touchCoordinate; + bool prevContinuousAf; /* * getInt returns -1 if the value isn't present and 0 on parse failure, @@ -281,11 +298,16 @@ LibCameraWrapper::setParameters(const CameraParameters& params) pars.set("slow_ae", "off"); } - // Parse continuous autofoucs into a format the driver understands + // Parse continuous autofocus into a format the driver understands conAf = pars.get("enable-caf"); + prevContinuousAf = mContinuousAf; mContinuousAf = (conAf != 0 && strcmp(conAf, "on") == 0); pars.set("continuous_af", mContinuousAf ? 1 : 0); + if (prevContinuousAf && !mContinuousAf) { + mFixFocus = true; + } + // Always set antibanding to 50hz pars.set("antibanding", "50hz"); @@ -301,7 +323,7 @@ LibCameraWrapper::setParameters(const CameraParameters& params) else if (strcmp(metering, "meter-matrix") == 0) { pars.set("metering", "matrix"); } - pars.remove("auto-exposure"); + pars.remove("meter-mode"); } // Read touch-to-focus diff --git a/libcamera/LibCameraWrapper.h b/libcamera/LibCameraWrapper.h index e999706..79c7586 100644 --- a/libcamera/LibCameraWrapper.h +++ b/libcamera/LibCameraWrapper.h @@ -51,6 +51,7 @@ private: int mCameraId; bool mVideoMode; bool mContinuousAf; + bool mFixFocus; bool mTouchFocus; int mTouchFocusX; int mTouchFocusY; -- cgit v1.1