summaryrefslogtreecommitdiffstats
path: root/libcamera
diff options
context:
space:
mode:
authorJeong-Seok Yang <jseok.yang@samsung.com>2011-06-08 19:26:44 +0900
committerWu-cheng Li <wuchengli@google.com>2011-06-28 15:13:15 +0800
commit0f98ce33ae0003bfff7b6140e22614d5b7b0ba26 (patch)
treeb5408d484eabdaa6e9a22fe4a98d51c02f1d4dc8 /libcamera
parentb8e27e28cb86bc1b26b021ba5b59d1cbf8cf2f33 (diff)
downloaddevice_samsung_crespo-0f98ce33ae0003bfff7b6140e22614d5b7b0ba26.zip
device_samsung_crespo-0f98ce33ae0003bfff7b6140e22614d5b7b0ba26.tar.gz
device_samsung_crespo-0f98ce33ae0003bfff7b6140e22614d5b7b0ba26.tar.bz2
libcamera: for checking invalid parameters
bug:4353744 android.hardware.cts.CameraTest#testInvalidParameters fails must fix android.hardware.cts.CameraTest#testInvalidParameters was failed when checking focus mode with invalid parameter because if the camera didn't set scene mode, libcamera didn't check if the focus mode is valid or not. Add checking the parameter at that time. Change-Id: I22fb02b7fcfcdb7f5638adf91d5bfd881c0d89e1 Signed-off-by: Jeong-Seok Yang <jseok.yang@samsung.com>
Diffstat (limited to 'libcamera')
-rw-r--r--libcamera/SecCameraHWInterface.cpp39
-rw-r--r--libcamera/SecCameraHWInterface.h2
2 files changed, 38 insertions, 3 deletions
diff --git a/libcamera/SecCameraHWInterface.cpp b/libcamera/SecCameraHWInterface.cpp
index 1dbf1e3..c736e8b 100644
--- a/libcamera/SecCameraHWInterface.cpp
+++ b/libcamera/SecCameraHWInterface.cpp
@@ -1564,6 +1564,33 @@ bool CameraHardwareSec::isSupportedPreviewSize(const int width,
return false;
}
+bool CameraHardwareSec::isSupportedParameter(const char * const parm,
+ const char * const supported_parm) const
+{
+ const char *pStart;
+ const char *pEnd;
+
+ if (!parm || !supported_parm)
+ return false;
+
+ pStart = supported_parm;
+
+ while (true) {
+ pEnd = strchr(pStart, ',');
+ if (!pEnd) {
+ if (!strcmp(parm, pStart))
+ return true;
+ else
+ return false;
+ }
+ if (!strncmp(parm, pStart, pEnd - pStart)) {
+ return true;
+ }
+ pStart = pEnd + 1;
+ }
+ /* NOTREACHED */
+}
+
status_t CameraHardwareSec::setParameters(const CameraParameters& params)
{
LOGV("%s :", __func__);
@@ -1847,13 +1874,13 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
ret = UNKNOWN_ERROR;
}
- if (new_scene_mode_str != NULL) {
+ const char *new_focus_mode_str = params.get(CameraParameters::KEY_FOCUS_MODE);
+
+ if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK) {
int new_scene_mode = -1;
const char *new_flash_mode_str = params.get(CameraParameters::KEY_FLASH_MODE);
- const char *new_focus_mode_str;
- new_focus_mode_str = params.get(CameraParameters::KEY_FOCUS_MODE);
// fps range is (15000,30000) by default.
mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, "(15000,30000)");
mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE,
@@ -1981,6 +2008,12 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
mParameters.set(CameraParameters::KEY_SCENE_MODE, new_scene_mode_str);
}
}
+ } else {
+ if (!isSupportedParameter(new_focus_mode_str,
+ mParameters.get(CameraParameters::KEY_SUPPORTED_FOCUS_MODES))) {
+ LOGE("%s: Unsupported focus mode: %s", __func__, new_focus_mode_str);
+ ret = UNKNOWN_ERROR;
+ }
}
// ---------------------------------------------------------------------------
diff --git a/libcamera/SecCameraHWInterface.h b/libcamera/SecCameraHWInterface.h
index 6a8fcef..6b10b6b 100644
--- a/libcamera/SecCameraHWInterface.h
+++ b/libcamera/SecCameraHWInterface.h
@@ -154,6 +154,8 @@ private:
void setSkipFrame(int frame);
bool isSupportedPreviewSize(const int width,
const int height) const;
+ bool isSupportedParameter(const char * const parm,
+ const char * const supported_parm) const;
/* used by auto focus thread to block until it's told to run */
mutable Mutex mFocusLock;
mutable Condition mFocusCondition;