diff options
author | Wu-cheng Li <wuchengli@google.com> | 2011-02-24 02:37:42 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-02-24 02:37:42 -0800 |
commit | cb301f250da295926b7b3ac64be564fb2f4f0ac0 (patch) | |
tree | 7fb5694c021d125dbdb755672f043e8388c4081f /libcamera | |
parent | 609f668560e9d7f818d4bb32004546706c9c0860 (diff) | |
parent | 5efdae1f12dd66b9a93ce27953bab8b77927e3b7 (diff) | |
download | device_samsung_crespo-cb301f250da295926b7b3ac64be564fb2f4f0ac0.zip device_samsung_crespo-cb301f250da295926b7b3ac64be564fb2f4f0ac0.tar.gz device_samsung_crespo-cb301f250da295926b7b3ac64be564fb2f4f0ac0.tar.bz2 |
am 5efdae1f: am fcba3707: Merge "libcamera: Add checking of preview sizes on setting parameters" into gingerbread
* commit '5efdae1f12dd66b9a93ce27953bab8b77927e3b7':
libcamera: Add checking of preview sizes on setting parameters
Diffstat (limited to 'libcamera')
-rw-r--r-- | libcamera/SecCameraHWInterface.cpp | 25 | ||||
-rw-r--r-- | libcamera/SecCameraHWInterface.h | 4 |
2 files changed, 28 insertions, 1 deletions
diff --git a/libcamera/SecCameraHWInterface.cpp b/libcamera/SecCameraHWInterface.cpp index fcd8390..fffe15b 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, @@ -1406,6 +1408,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__); @@ -1432,7 +1448,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, @@ -1468,6 +1486,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 e309ae5..97c0a35 100644 --- a/libcamera/SecCameraHWInterface.h +++ b/libcamera/SecCameraHWInterface.h @@ -157,6 +157,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; @@ -206,6 +208,8 @@ private: int mPostViewWidth; int mPostViewHeight; int mPostViewSize; + + Vector<Size> mSupportedPreviewSizes; }; }; // namespace android |