summaryrefslogtreecommitdiffstats
path: root/camera/CameraHal.cpp
diff options
context:
space:
mode:
authorSundar Raman <sunds@ti.com>2011-09-14 21:05:42 -0700
committerIliyan Malchev <malchev@google.com>2011-09-19 22:29:04 -0700
commit797f2045d2e972e5dc08cf0eff63a0415730aba4 (patch)
treef2b4806ccc63fd5f094f49669f8fa8a6c83d8dd8 /camera/CameraHal.cpp
parentec04f2cba99eb1e58886650f336605385ba502b0 (diff)
downloadhardware_ti_omap4-797f2045d2e972e5dc08cf0eff63a0415730aba4.zip
hardware_ti_omap4-797f2045d2e972e5dc08cf0eff63a0415730aba4.tar.gz
hardware_ti_omap4-797f2045d2e972e5dc08cf0eff63a0415730aba4.tar.bz2
CameraHAL: Fixes for FPS range configuration
Change-Id: Idfc506812d6e0f1d88bdc5d7d62c159f9c9ad642 Signed-off-by: Sundar Raman <sunds@ti.com>
Diffstat (limited to 'camera/CameraHal.cpp')
-rw-r--r--camera/CameraHal.cpp139
1 files changed, 66 insertions, 73 deletions
diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp
index 7da6af4..794297a 100644
--- a/camera/CameraHal.cpp
+++ b/camera/CameraHal.cpp
@@ -255,6 +255,7 @@ int CameraHal::setParameters(const CameraParameters& params)
bool updateRequired = false;
CameraParameters oldParams(mParameters.flatten());
bool videoMode = false;
+ char range[MAX_PROP_VALUE_LENGTH];
{
Mutex::Autolock lock(mLock);
@@ -443,98 +444,94 @@ int CameraHal::setParameters(const CameraParameters& params)
}
framerate = params.getPreviewFrameRate();
+ valstr = params.get(CameraParameters::KEY_PREVIEW_FPS_RANGE);
CAMHAL_LOGDB("FRAMERATE %d", framerate);
+ CAMHAL_LOGVB("Passed FRR: %s, Supported FRR %s", valstr
+ , mCameraProperties->get(CameraProperties::FRAMERATE_RANGE_SUPPORTED));
+ CAMHAL_LOGVB("Passed FR: %d, Supported FR %s", framerate
+ , mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES));
+
+
+ //Perform parameter validation
+ if(!isParameterValid(valstr
+ , mCameraProperties->get(CameraProperties::FRAMERATE_RANGE_SUPPORTED))
+ || !isParameterValid(framerate,
+ mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES)))
+ {
+ CAMHAL_LOGEA("Invalid frame rate range or frame rate");
+ return -EINVAL;
+ }
+
// Variable framerate ranges have higher priority over
// deprecated constant FPS. "KEY_PREVIEW_FPS_RANGE" should
// be cleared by the client in order for constant FPS to get
// applied.
- if ( (valstr = params.get(CameraParameters::KEY_PREVIEW_FPS_RANGE) ) != NULL )
+ if ( strcmp(valstr, mCameraProperties->get(CameraProperties::FRAMERATE_RANGE)) != 0)
{
- CAMHAL_LOGDB("FPS Range = %s", valstr);
- CAMHAL_LOGDB("DEFAULT FPS Range = %s", mCameraProperties->get(CameraProperties::FRAMERATE_RANGE));
-
+ // APP wants to set FPS range
+ //Set framerate = MAXFPS
+ CAMHAL_LOGDA("APP IS CHANGING FRAME RATE RANGE");
params.getPreviewFpsRange(&minFPS, &maxFPS);
- if (videoMode)
- {
- mCameraProperties->set(CameraProperties::FRAMERATE_RANGE, CameraProperties::DEFAULT_VIDEO_FPS_RANGE);
- valstr = mCameraProperties->get(CameraProperties::FRAMERATE_RANGE);
- mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, valstr);
- mParameters.getPreviewFpsRange(&minFPS, &maxFPS);
- }
-
if ( ( 0 > minFPS ) || ( 0 > maxFPS ) )
{
CAMHAL_LOGEA("ERROR: FPS Range is negative!");
- ret = -EINVAL;
+ return -EINVAL;
}
- minFPS /= CameraHal::VFR_SCALE;
- maxFPS /= CameraHal::VFR_SCALE;
+ framerate = maxFPS /CameraHal::VFR_SCALE;
- if ( ( 0 == minFPS ) || ( 0 == maxFPS ) )
+ }
+ else
+ {
+ if ( framerate != atoi(mCameraProperties->get(CameraProperties::PREVIEW_FRAME_RATE)) )
{
- CAMHAL_LOGEA("ERROR: FPS Range is invalid!");
- ret = -EINVAL;
+ selectFPSRange(framerate, &minFPS, &maxFPS);
}
+ else
+ {
+ if (videoMode) {
+ valstr = mCameraProperties->get(CameraProperties::FRAMERATE_RANGE_VIDEO);
+ CameraParameters temp;
+ temp.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, valstr);
+ temp.getPreviewFpsRange(&minFPS, &maxFPS);
+ }
+ else {
+ valstr = mCameraProperties->get(CameraProperties::FRAMERATE_RANGE_IMAGE);
+ CameraParameters temp;
+ temp.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, valstr);
+ temp.getPreviewFpsRange(&minFPS, &maxFPS);
+ }
- if ( maxFPS < minFPS )
- {
- CAMHAL_LOGEA("ERROR: Max FPS is smaller than Min FPS!");
- ret = -EINVAL;
- }
+ framerate = maxFPS / CameraHal::VFR_SCALE;
+ }
- if ( strcmp(valstr, mCameraProperties->get(CameraProperties::FRAMERATE_RANGE)) != 0)
- {
- // APP wants to set FPS range
- //Set framerate = MAXFPS
- CAMHAL_LOGDA("APP IS CHANGING FRAME RATE RANGE");
- framerate = maxFPS ;
- }
- else if ( framerate != atoi(mCameraProperties->get(CameraProperties::PREVIEW_FRAME_RATE)) )
- {
- //APP wants to set framerate
- //Change FPS range to match framerate
- //MAXFPS = Framerate
- if ( isParameterValid(framerate,
- mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES)) )
- {
- CAMHAL_LOGDA("APP IS CHANGING FRAME RATE");
- selectFPSRange(framerate, &minFPS, &maxFPS);
- }
- else
- {
- CAMHAL_LOGEA("Framerate NOT Supported!");
- return -EINVAL;
- }
- }
+ }
- CAMHAL_LOGDB("SET FRAMERATE %d", framerate);
- mParameters.setPreviewFrameRate(framerate);
+ CAMHAL_LOGDB("FPS Range = %s", valstr);
+ CAMHAL_LOGDB("DEFAULT FPS Range = %s", mCameraProperties->get(CameraProperties::FRAMERATE_RANGE));
- CAMHAL_LOGDB("FPS Range [%d, %d]", minFPS, maxFPS);
- mParameters.set(TICameraParameters::KEY_MINFRAMERATE, minFPS);
- mParameters.set(TICameraParameters::KEY_MAXFRAMERATE, maxFPS);
- mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, valstr);
- }
- else if ( isParameterValid(framerate,
- mCameraProperties->get(CameraProperties::SUPPORTED_PREVIEW_FRAME_RATES)) )
+ minFPS /= CameraHal::VFR_SCALE;
+ maxFPS /= CameraHal::VFR_SCALE;
+
+ if ( ( 0 == minFPS ) || ( 0 == maxFPS ) )
{
- minFPS = framerate;
- maxFPS = framerate;
- mParameters.setPreviewFrameRate(framerate);
-
- CAMHAL_LOGDB("FPS Range [%d, %d]", minFPS, maxFPS);
- mParameters.set(TICameraParameters::KEY_MINFRAMERATE, minFPS);
- mParameters.set(TICameraParameters::KEY_MAXFRAMERATE, maxFPS);
- mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE,
- params.get(CameraParameters::KEY_PREVIEW_FPS_RANGE));
+ CAMHAL_LOGEA("ERROR: FPS Range is invalid!");
+ ret = -EINVAL;
}
- else
+
+ if ( maxFPS < minFPS )
{
- return -EINVAL;
+ CAMHAL_LOGEA("ERROR: Max FPS is smaller than Min FPS!");
+ ret = -EINVAL;
}
+ CAMHAL_LOGDB("SET FRAMERATE %d", framerate);
+ mParameters.setPreviewFrameRate(framerate);
+
+ CAMHAL_LOGDB("FPS Range [%d, %d]", minFPS, maxFPS);
+ mParameters.set(TICameraParameters::KEY_MINFRAMERATE, minFPS);
+ mParameters.set(TICameraParameters::KEY_MAXFRAMERATE, maxFPS);
if( ( valstr = params.get(TICameraParameters::KEY_GBCE) ) != NULL )
{
@@ -555,12 +552,6 @@ int CameraHal::setParameters(const CameraParameters& params)
mParameters.set(TICameraParameters::KEY_AUTOCONVERGENCE, valstr);
}
- // if(params.get(TICameraParameters::KEY_AUTOCONVERGENCE_MODE)!=NULL)
- // {
- // CAMHAL_LOGDB("AutoConvergence Mode is set = %s", params.get(TICameraParameters::KEY_AUTOCONVERGENCE_MODE));
- // mParameters.set(TICameraParameters::KEY_AUTOCONVERGENCE_MODE, params.get(TICameraParameters::KEY_AUTOCONVERGENCE_MODE));
- // }
-
if( (valstr = params.get(TICameraParameters::KEY_MANUALCONVERGENCE_VALUES)) !=NULL )
{
CAMHAL_LOGDB("ManualConvergence Value = %s", params.get(TICameraParameters::KEY_MANUALCONVERGENCE_VALUES));
@@ -2465,7 +2456,9 @@ char* CameraHal::getParameters()
mCameraAdapter->getParameters(mParameters);
}
+
params_str8 = mParameters.flatten();
+
// camera service frees this string...
params_string = (char*) malloc(sizeof(char) * (params_str8.length()+1));
strcpy(params_string, params_str8.string());