summaryrefslogtreecommitdiffstats
path: root/libcamera
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-02-24 02:18:19 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-02-24 02:18:19 -0800
commitfcba3707358783f0b311c750a3d5637f0517066f (patch)
treefb8f7e2902e0d5f0bbe15e3ff959ef4454ad66a2 /libcamera
parent2c6102e3f2da0b38467aa51f8cd1d7acd9310cfc (diff)
parent23ce2f833b0dfa8df423195a63877f9565a96d24 (diff)
downloaddevice_samsung_crespo-fcba3707358783f0b311c750a3d5637f0517066f.zip
device_samsung_crespo-fcba3707358783f0b311c750a3d5637f0517066f.tar.gz
device_samsung_crespo-fcba3707358783f0b311c750a3d5637f0517066f.tar.bz2
Merge "libcamera: Add checking of preview sizes on setting parameters" into gingerbread
Diffstat (limited to 'libcamera')
-rw-r--r--libcamera/SecCameraHWInterface.cpp25
-rw-r--r--libcamera/SecCameraHWInterface.h4
2 files changed, 28 insertions, 1 deletions
diff --git a/libcamera/SecCameraHWInterface.cpp b/libcamera/SecCameraHWInterface.cpp
index 50d43a0..137653a 100644
--- a/libcamera/SecCameraHWInterface.cpp
+++ b/libcamera/SecCameraHWInterface.cpp
@@ -170,6 +170,8 @@ void CameraHardwareSec::initDefaultParameters(int cameraId)
"640x480");
}
+ p.getSupportedPreviewSizes(mSupportedPreviewSizes);
+
// If these fail, then we are using an invalid cameraId and we'll leave the
// sizes at zero to catch the error.
if (mSecCamera->getPreviewMaxSize(&preview_max_width,
@@ -1401,6 +1403,20 @@ status_t CameraHardwareSec::dump(int fd, const Vector<String16>& args) const
return NO_ERROR;
}
+bool CameraHardwareSec::isSupportedPreviewSize(const int width,
+ const int height) const
+{
+ unsigned int i;
+
+ for (i = 0; i < mSupportedPreviewSizes.size(); i++) {
+ if (mSupportedPreviewSizes[i].width == width &&
+ mSupportedPreviewSizes[i].height == height)
+ return true;
+ }
+
+ return false;
+}
+
status_t CameraHardwareSec::setParameters(const CameraParameters& params)
{
LOGV("%s :", __func__);
@@ -1427,7 +1443,9 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
LOGV("%s : new_preview_width x new_preview_height = %dx%d, format = %s",
__func__, new_preview_width, new_preview_height, new_str_preview_format);
- if (0 < new_preview_width && 0 < new_preview_height && new_str_preview_format != NULL) {
+ if (0 < new_preview_width && 0 < new_preview_height &&
+ new_str_preview_format != NULL &&
+ isSupportedPreviewSize(new_preview_width, new_preview_height)) {
int new_preview_format = 0;
if (!strcmp(new_str_preview_format,
@@ -1463,6 +1481,11 @@ status_t CameraHardwareSec::setParameters(const CameraParameters& params)
}
}
#endif
+ } else {
+ LOGE("%s: Invalid preview size(%dx%d)",
+ __func__, new_preview_width, new_preview_height);
+
+ ret = INVALID_OPERATION;
}
int new_picture_width = 0;
diff --git a/libcamera/SecCameraHWInterface.h b/libcamera/SecCameraHWInterface.h
index 75526c6..0a948db 100644
--- a/libcamera/SecCameraHWInterface.h
+++ b/libcamera/SecCameraHWInterface.h
@@ -156,6 +156,8 @@ private:
int *pdwJPEGSize, void *pVideo,
int *pdwVideoSize);
void setSkipFrame(int frame);
+ bool isSupportedPreviewSize(const int width,
+ const int height) const;
/* used by auto focus thread to block until it's told to run */
mutable Mutex mFocusLock;
mutable Condition mFocusCondition;
@@ -205,6 +207,8 @@ private:
int mPostViewWidth;
int mPostViewHeight;
int mPostViewSize;
+
+ Vector<Size> mSupportedPreviewSizes;
};
}; // namespace android