Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
am fcba370: Merge "libcamera: Add checking of preview sizes on settin…
Browse files Browse the repository at this point in the history
…g parameters" into gingerbread

* commit 'fcba3707358783f0b311c750a3d5637f0517066f':
  libcamera: Add checking of preview sizes on setting parameters
  • Loading branch information
Wu-cheng Li authored and Android Git Automerger committed Feb 24, 2011
2 parents 5c24b74 + fcba370 commit 5efdae1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
25 changes: 24 additions & 1 deletion libcamera/SecCameraHWInterface.cpp
Expand Up @@ -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,
Expand Down Expand Up @@ -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__);
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions libcamera/SecCameraHWInterface.h
Expand Up @@ -156,6 +156,8 @@ class CameraHardwareSec : public CameraHardwareInterface {
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;
Expand Down Expand Up @@ -205,6 +207,8 @@ class CameraHardwareSec : public CameraHardwareInterface {
int mPostViewWidth;
int mPostViewHeight;
int mPostViewSize;

Vector<Size> mSupportedPreviewSizes;
};

}; // namespace android
Expand Down

0 comments on commit 5efdae1

Please sign in to comment.