summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRosa Chow <rchow@invensense.com>2012-03-15 10:52:52 -0700
committerJP Abgrall <jpa@google.com>2012-06-29 13:03:42 -0700
commita45503dc4dc8d9331bbc9e3fce1b1c35cb57c39f (patch)
treed00916dda47dd39f3d625c834e2f2e04782559f1
parentac5129a60eb420290835e7cb39f7f577a0b83f70 (diff)
downloadandroid_hardware_invensense-a45503dc4dc8d9331bbc9e3fce1b1c35cb57c39f.tar.gz
android_hardware_invensense-a45503dc4dc8d9331bbc9e3fce1b1c35cb57c39f.tar.bz2
android_hardware_invensense-a45503dc4dc8d9331bbc9e3fce1b1c35cb57c39f.zip
Fixed crash when accel is not functional or present.
Samsung [Issue 6119492] in Buganizer.
-rw-r--r--mlsdk/mllite/dmpDefault.c1
-rw-r--r--mlsdk/mllite/ml.c41
-rw-r--r--mlsdk/mllite/mldmp.c4
3 files changed, 30 insertions, 16 deletions
diff --git a/mlsdk/mllite/dmpDefault.c b/mlsdk/mllite/dmpDefault.c
index fe29376..6620d14 100644
--- a/mlsdk/mllite/dmpDefault.c
+++ b/mlsdk/mllite/dmpDefault.c
@@ -357,6 +357,7 @@ inv_error_t inv_setup_dmp(void)
return result;
}
+ if (inv_accel_present())
{
struct ext_slave_config config;
long odr;
diff --git a/mlsdk/mllite/ml.c b/mlsdk/mllite/ml.c
index 0489f5b..3328edd 100644
--- a/mlsdk/mllite/ml.c
+++ b/mlsdk/mllite/ml.c
@@ -201,8 +201,12 @@ inv_error_t inv_apply_calibration(void)
for (ii = 0; ii < 9; ii++) {
gyroCal[ii] = mldl_cfg->pdata->orientation[ii];
- accelCal[ii] = mldl_cfg->pdata->accel.orientation[ii];
- magCal[ii] = mldl_cfg->pdata->compass.orientation[ii];
+ if (NULL != mldl_cfg->accel){
+ accelCal[ii] = mldl_cfg->pdata->accel.orientation[ii];
+ }
+ if (NULL != mldl_cfg->compass){
+ magCal[ii] = mldl_cfg->pdata->compass.orientation[ii];
+ }
}
switch (mldl_cfg->full_scale) {
@@ -225,8 +229,9 @@ inv_error_t inv_apply_calibration(void)
break;
}
- RANGE_FIXEDPOINT_TO_FLOAT(mldl_cfg->accel->range, accelScale);
- inv_obj.accel_sens = (long)(accelScale * 65536L);
+ if (NULL != mldl_cfg->accel){
+ RANGE_FIXEDPOINT_TO_FLOAT(mldl_cfg->accel->range, accelScale);
+ inv_obj.accel_sens = (long)(accelScale * 65536L);
/* sensitivity adjustment, typically = 2 (for +/- 2 gee) */
#if defined CONFIG_MPU_SENSORS_MPU6050A2 || \
defined CONFIG_MPU_SENSORS_MPU6050B1
@@ -234,9 +239,11 @@ inv_error_t inv_apply_calibration(void)
#else
inv_obj.accel_sens /= 2;
#endif
-
- RANGE_FIXEDPOINT_TO_FLOAT(mldl_cfg->compass->range, magScale);
- inv_obj.compass_sens = (long)(magScale * 32768);
+ }
+ if (NULL != mldl_cfg->compass){
+ RANGE_FIXEDPOINT_TO_FLOAT(mldl_cfg->compass->range, magScale);
+ inv_obj.compass_sens = (long)(magScale * 32768);
+ }
if (inv_get_state() == INV_STATE_DMP_OPENED) {
result = inv_set_gyro_calibration(gyroScale, gyroCal);
@@ -244,15 +251,19 @@ inv_error_t inv_apply_calibration(void)
MPL_LOGE("Unable to set Gyro Calibration\n");
return result;
}
- result = inv_set_accel_calibration(accelScale, accelCal);
- if (INV_SUCCESS != result) {
- MPL_LOGE("Unable to set Accel Calibration\n");
- return result;
+ if (NULL != mldl_cfg->accel){
+ result = inv_set_accel_calibration(accelScale, accelCal);
+ if (INV_SUCCESS != result) {
+ MPL_LOGE("Unable to set Accel Calibration\n");
+ return result;
+ }
}
- result = inv_set_compass_calibration(magScale, magCal);
- if (INV_SUCCESS != result) {
- MPL_LOGE("Unable to set Mag Calibration\n");
- return result;
+ if (NULL != mldl_cfg->compass){
+ result = inv_set_compass_calibration(magScale, magCal);
+ if (INV_SUCCESS != result) {
+ MPL_LOGE("Unable to set Mag Calibration\n");
+ return result;
+ }
}
}
return INV_SUCCESS;
diff --git a/mlsdk/mllite/mldmp.c b/mlsdk/mllite/mldmp.c
index 200d0d1..7381dd4 100644
--- a/mlsdk/mllite/mldmp.c
+++ b/mlsdk/mllite/mldmp.c
@@ -152,7 +152,9 @@ inv_error_t inv_dmp_open(void)
LOG_RESULT_LOCATION(result);
return result;
}
- result = inv_apply_endian_accel();
+ if (NULL != mldl_cfg->accel){
+ result = inv_apply_endian_accel();
+ }
return result;
}