diff options
author | Tyler Luu <tluu@ti.com> | 2011-08-29 16:37:11 +0300 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2011-08-31 20:02:33 -0700 |
commit | 8bb8a56a981380ed19ee62ba9beeea69dc13556b (patch) | |
tree | 291862c4690752bf21856d2894a2ddf05c46232e /camera/CameraHal.cpp | |
parent | 12df644ebd89272557b128ab167e8427425fb707 (diff) | |
download | hardware_ti_omap4-8bb8a56a981380ed19ee62ba9beeea69dc13556b.zip hardware_ti_omap4-8bb8a56a981380ed19ee62ba9beeea69dc13556b.tar.gz hardware_ti_omap4-8bb8a56a981380ed19ee62ba9beeea69dc13556b.tar.bz2 |
CameraHal: Fixes related to CTS #testPreviewPictureSizesCombination
- This test depends on the following camera functionality.
After image capture is done, the camera client should be
able to switch the preview resolution without first
calling 'stopPreview()'. The patch adds the neccessary
logic for recognizing this particular case and accordingly
restarts the preview internally.
Change-Id: I3648ba9259d3a4720a12c7a1242d62b670e5dfdc
Original-author: Emilian Peev <epeev@mm-sol.com>
Signed-off-by: Emilian Peev <epeev@mm-sol.com>
Signed-off-by: Tyler Luu <tluu@ti.com>
Diffstat (limited to 'camera/CameraHal.cpp')
-rw-r--r-- | camera/CameraHal.cpp | 121 |
1 files changed, 71 insertions, 50 deletions
diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp index 49b149c..2f291c6 100644 --- a/camera/CameraHal.cpp +++ b/camera/CameraHal.cpp @@ -263,55 +263,14 @@ int CameraHal::setParameters(const CameraParameters& params) CAMHAL_LOGDB("PreviewFormat %s", params.getPreviewFormat()); - if ((valstr = params.getPreviewFormat()) != NULL) { - if ( isParameterValid(valstr, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FORMATS))) { - mParameters.setPreviewFormat(valstr); - } else { - CAMHAL_LOGEB("Invalid preview format.Supported: %s", mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FORMATS)); - return -EINVAL; - } - } - - params.getPreviewSize(&w, &h); - if (w == -1 && h == -1) { - CAMHAL_LOGEA("Unable to get preview size"); - return -EINVAL; - } - - int orientation =0; - if((valstr = params.get(TICameraParameters::KEY_SENSOR_ORIENTATION)) != NULL) - { - CAMHAL_LOGDB("Sensor Orientation is set to %s", params.get(TICameraParameters::KEY_SENSOR_ORIENTATION)); - mParameters.set(TICameraParameters::KEY_SENSOR_ORIENTATION, valstr); - orientation = params.getInt(TICameraParameters::KEY_SENSOR_ORIENTATION); - } - - if(orientation ==90 || orientation ==270) - { - if ( !isResolutionValid(h,w, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_SIZES))) - { - CAMHAL_LOGEB("Invalid preview resolution %d x %d", w, h); - return -EINVAL; - } - else - { - mParameters.setPreviewSize(w, h); - } - } - else - { - if ( !isResolutionValid(w, h, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_SIZES))) - { - CAMHAL_LOGEB("Invalid preview resolution %d x %d", w, h); - return -EINVAL; - } - else - { - mParameters.setPreviewSize(w, h); + if ((valstr = params.getPreviewFormat()) != NULL) { + if ( isParameterValid(valstr, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FORMATS))) { + mParameters.setPreviewFormat(valstr); + } else { + CAMHAL_LOGEB("Invalid preview format.Supported: %s", mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FORMATS)); + return -EINVAL; } - } - - CAMHAL_LOGDB("PreviewResolution by App %d x %d", w, h); + } if ((valstr = params.get(TICameraParameters::KEY_VNF)) != NULL) { if ( (params.getInt(TICameraParameters::KEY_VNF)==0) || (params.getInt(TICameraParameters::KEY_VNF)==1) ) { @@ -363,6 +322,60 @@ int CameraHal::setParameters(const CameraParameters& params) } + //CTS requirement, we should be able to change the preview resolution + //while in paused display state + if ( !previewEnabled() || mDisplayPaused ) + { + params.getPreviewSize(&w, &h); + if (w == -1 && h == -1) { + CAMHAL_LOGEA("Unable to get preview size"); + return -EINVAL; + } + + int oldWidth, oldHeight; + mParameters.getPreviewSize(&oldWidth, &oldHeight); + + int orientation =0; + if((valstr = params.get(TICameraParameters::KEY_SENSOR_ORIENTATION)) != NULL) + { + CAMHAL_LOGDB("Sensor Orientation is set to %s", params.get(TICameraParameters::KEY_SENSOR_ORIENTATION)); + mParameters.set(TICameraParameters::KEY_SENSOR_ORIENTATION, valstr); + orientation = params.getInt(TICameraParameters::KEY_SENSOR_ORIENTATION); + } + + if(orientation ==90 || orientation ==270) + { + if ( !isResolutionValid(h,w, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_SIZES))) + { + CAMHAL_LOGEB("Invalid preview resolution %d x %d", w, h); + return -EINVAL; + } + else + { + mParameters.setPreviewSize(w, h); + } + } + else + { + if ( !isResolutionValid(w, h, mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_SIZES))) + { + CAMHAL_LOGEB("Invalid preview resolution %d x %d", w, h); + return -EINVAL; + } + else + { + mParameters.setPreviewSize(w, h); + } + } + + if ( ( oldWidth != w ) || ( oldHeight != h ) ) + { + mDynamicPreviewSwitch = true; + } + + CAMHAL_LOGDB("PreviewResolution by App %d x %d", w, h); + } + // Handle RECORDING_HINT to Set/Reset Video Mode Parameters valstr = params.get(CameraParameters::KEY_RECORDING_HINT); if(valstr != NULL) @@ -1276,8 +1289,15 @@ status_t CameraHal::startPreview() { mAppCallbackNotifier->enableMsgType (CAMERA_MSG_PREVIEW_FRAME); } - return ret; - + if ( mDynamicPreviewSwitch ) + { + forceStopPreview(); + mDynamicPreviewSwitch = false; + } + else + { + return ret; + } } /// Ensure that buffers for preview are allocated before we start the camera @@ -2553,6 +2573,7 @@ CameraHal::CameraHal(int cameraId) mRecordingEnabled = 0; mRecordEnabled = 0; mSensorListener = NULL; + mDynamicPreviewSwitch = false; #if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS |