summaryrefslogtreecommitdiffstats
path: root/camera/CameraHal.cpp
diff options
context:
space:
mode:
authorPavel Nedev <pnedev@mm-sol.com>2012-02-28 12:18:29 +0200
committerDaniel Levin <dendy@ti.com>2012-07-25 08:55:42 -0500
commit0536f25d2a2b295d79f4a87de5ec0964ea728e2b (patch)
treef5ad3975ad88e0393537cde96b16a5ff20128c0f /camera/CameraHal.cpp
parent77fece1e657f5a999a83f6054d992af6d7aa7ef5 (diff)
downloadhardware_ti_omap4-0536f25d2a2b295d79f4a87de5ec0964ea728e2b.zip
hardware_ti_omap4-0536f25d2a2b295d79f4a87de5ec0964ea728e2b.tar.gz
hardware_ti_omap4-0536f25d2a2b295d79f4a87de5ec0964ea728e2b.tar.bz2
CameraHAL: Proper isSupported param checking
isParameterValid() function implementation changed. If supported parameters were 30,15,10 for example and the checked param was 5 previous implementation would return true because strstr() would find 5 in 30,15,10. Now each supported entry is first derived and then it is checked against the param to be set. Code style also fixed. Change-Id: I37d700833934c1c01685ccef962d26bcace078bf Signed-off-by: Pavel Nedev <pnedev@mm-sol.com>
Diffstat (limited to 'camera/CameraHal.cpp')
-rw-r--r--camera/CameraHal.cpp94
1 files changed, 32 insertions, 62 deletions
diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp
index a4b9326..0cfb94b 100644
--- a/camera/CameraHal.cpp
+++ b/camera/CameraHal.cpp
@@ -3140,40 +3140,27 @@ status_t CameraHal::initialize(CameraProperties::Properties* properties)
bool CameraHal::isResolutionValid(unsigned int width, unsigned int height, const char *supportedResolutions)
{
- bool ret = true;
+ bool ret = false;
status_t status = NO_ERROR;
- char tmpBuffer[PARAM_BUFFER + 1];
+ char tmpBuffer[MAX_PROP_VALUE_LENGTH];
char *pos = NULL;
LOG_FUNCTION_NAME;
- if ( NULL == supportedResolutions )
- {
+ if (NULL == supportedResolutions) {
CAMHAL_LOGEA("Invalid supported resolutions string");
- ret = false;
goto exit;
- }
+ }
- status = snprintf(tmpBuffer, PARAM_BUFFER, "%dx%d", width, height);
- if ( 0 > status )
- {
+ status = snprintf(tmpBuffer, MAX_PROP_VALUE_LENGTH - 1, "%dx%d", width, height);
+ if (0 > status) {
CAMHAL_LOGEA("Error encountered while generating validation string");
- ret = false;
goto exit;
- }
+ }
- pos = strstr(supportedResolutions, tmpBuffer);
- if ( NULL == pos )
- {
- ret = false;
- }
- else
- {
- ret = true;
- }
+ ret = isParameterValid(tmpBuffer, supportedResolutions);
exit:
-
LOG_FUNCTION_NAME_EXIT;
return ret;
@@ -3219,37 +3206,34 @@ bool CameraHal::isFpsRangeValid(int fpsMin, int fpsMax, const char *supportedFps
bool CameraHal::isParameterValid(const char *param, const char *supportedParams)
{
- bool ret = true;
- char *pos = NULL;
+ bool ret = false;
+ char *pos;
+ char supported[MAX_PROP_VALUE_LENGTH];
LOG_FUNCTION_NAME;
- if ( NULL == supportedParams )
- {
+ if (NULL == supportedParams) {
CAMHAL_LOGEA("Invalid supported parameters string");
- ret = false;
goto exit;
- }
+ }
- if ( NULL == param )
- {
+ if (NULL == param) {
CAMHAL_LOGEA("Invalid parameter string");
- ret = false;
goto exit;
- }
+ }
- pos = strstr(supportedParams, param);
- if ( NULL == pos )
- {
- ret = false;
- }
- else
- {
- ret = true;
+ strncpy(supported, supportedParams, MAX_PROP_VALUE_LENGTH - 1);
+
+ pos = strtok(supported, ",");
+ while (pos != NULL) {
+ if (!strcmp(pos, param)) {
+ ret = true;
+ break;
}
+ pos = strtok(NULL, ",");
+ }
exit:
-
LOG_FUNCTION_NAME_EXIT;
return ret;
@@ -3257,40 +3241,26 @@ exit:
bool CameraHal::isParameterValid(int param, const char *supportedParams)
{
- bool ret = true;
- char *pos = NULL;
+ bool ret = false;
status_t status;
- char tmpBuffer[PARAM_BUFFER + 1];
+ char tmpBuffer[MAX_PROP_VALUE_LENGTH];
LOG_FUNCTION_NAME;
- if ( NULL == supportedParams )
- {
+ if (NULL == supportedParams) {
CAMHAL_LOGEA("Invalid supported parameters string");
- ret = false;
goto exit;
- }
+ }
- status = snprintf(tmpBuffer, PARAM_BUFFER, "%d", param);
- if ( 0 > status )
- {
+ status = snprintf(tmpBuffer, MAX_PROP_VALUE_LENGTH - 1, "%d", param);
+ if (0 > status) {
CAMHAL_LOGEA("Error encountered while generating validation string");
- ret = false;
goto exit;
- }
+ }
- pos = strstr(supportedParams, tmpBuffer);
- if ( NULL == pos )
- {
- ret = false;
- }
- else
- {
- ret = true;
- }
+ ret = isParameterValid(tmpBuffer, supportedParams);
exit:
-
LOG_FUNCTION_NAME_EXIT;
return ret;