From 1387bda01b089d8e8df06339d9c15d53b3de6725 Mon Sep 17 00:00:00 2001 From: Patrick Benavoli Date: Wed, 31 Aug 2011 11:23:24 +0200 Subject: Min/max value computation; Tuning lock handling BZ: 7466 - Min/max values are now correctly computed. They concern integer and fixed point parameters - tuning mode lock issue solved: created an AutoLock class for safe lock handling - added configuration files for a demo on Ubuntu environment - had AMIXER subsystem plugin compliant for derivation - LPE library: add carriage return on logs - removed obsolete files - some cosmetics Change-Id: Ife7a4799fd48dd4a1ca25dae666c4e453815881e Orig-Change-Id: I72fc5c1ff6abf638b43266a75bc00e21ad412349 Signed-off-by: Patrick Benavoli Reviewed-on: http://android.intel.com:8080/16880 Reviewed-by: Mahe, Erwan Tested-by: Barthes, FabienX Reviewed-by: buildbot Tested-by: buildbot --- parameter/IntegerParameterType.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'parameter/IntegerParameterType.cpp') diff --git a/parameter/IntegerParameterType.cpp b/parameter/IntegerParameterType.cpp index 1f20c93..f3e447e 100644 --- a/parameter/IntegerParameterType.cpp +++ b/parameter/IntegerParameterType.cpp @@ -74,21 +74,30 @@ bool CIntegerParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializi // Size setSize(xmlElement.getAttributeInteger("Size") / 8); + // Size in bits + uint32_t uiUtilSizeInBits = getSize() << 3; + // Min / Max if (_bSigned) { + + // Signed means we have one less util bit + uiUtilSizeInBits--; + if (xmlElement.hasAttribute("Min")) { _uiMin = (uint32_t)xmlElement.getAttributeSignedInteger("Min"); } else { - _uiMin = 1UL << 31; + _uiMin = 1UL << uiUtilSizeInBits; + + signExtend((int32_t&)_uiMin); } if (xmlElement.hasAttribute("Max")) { _uiMax = (uint32_t)xmlElement.getAttributeSignedInteger("Max"); } else { - _uiMax = (1UL << 31) - 1; + _uiMax = (1UL << uiUtilSizeInBits) - 1; } } else { if (xmlElement.hasAttribute("Min")) { @@ -103,7 +112,7 @@ bool CIntegerParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializi _uiMax = xmlElement.getAttributeInteger("Max"); } else { - _uiMax = (uint32_t)-1; + _uiMax = (uint32_t)((1UL << uiUtilSizeInBits) - 1); } } -- cgit v1.1