diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2014-11-29 14:24:42 +0100 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2014-11-29 14:24:42 +0100 |
commit | 177f42554e832dd4d3595ef7c0baecaf18fb8566 (patch) | |
tree | 0c360db925c272f4c4275066e3003c244769459f | |
parent | e21b4f364ea2a36ed70c588b17d24a52d7c0b771 (diff) | |
download | device_samsung_n7100-replicant-4.2.zip device_samsung_n7100-replicant-4.2.tar.gz device_samsung_n7100-replicant-4.2.tar.bz2 |
sensors: AKM8963 data is signedreplicant-4.2-0004replicant-4.2-0003replicant-4.2
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r-- | sensors/akm8963.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sensors/akm8963.c b/sensors/akm8963.c index 96d35ca..d5cad3f 100644 --- a/sensors/akm8963.c +++ b/sensors/akm8963.c @@ -36,11 +36,11 @@ struct akm8963_data { struct smdk4x12_sensors_handlers *orientation_sensor; sensors_vec_t magnetic; - unsigned short magnetic_data[4][3]; + short magnetic_data[4][3]; int magnetic_data_count; int magnetic_data_index; - unsigned short magnetic_extrema[2][3]; + short magnetic_extrema[2][3]; unsigned char asa[3]; int ho[3]; @@ -74,8 +74,8 @@ int akm8963_magnetic_extrema(struct akm8963_data *data, int index) return -EINVAL; // Calculate the extrema from HO (software offset) - data->magnetic_extrema[0][index] = (unsigned short) ((-45.0f + 0.06 * data->ho[index]) / (0.15f * (((data->asa[index] - 128) * 0.5f) / 128 + 1))); - data->magnetic_extrema[1][index] = (unsigned short) ((45.0f + 0.06 * data->ho[index]) / (0.15f * (((data->asa[index] - 128) * 0.5f) / 128 + 1))); + data->magnetic_extrema[0][index] = (short) ((-45.0f + 0.06 * data->ho[index]) / (0.15f * (((data->asa[index] - 128) * 0.5f) / 128 + 1))); + data->magnetic_extrema[1][index] = (short) ((45.0f + 0.06 * data->ho[index]) / (0.15f * (((data->asa[index] - 128) * 0.5f) / 128 + 1))); return 0; } @@ -206,7 +206,7 @@ complete: } int akm8963_ho_calibration(struct akm8963_data *data, - unsigned short *magnetic_data, size_t magnetic_data_size) + short *magnetic_data, size_t magnetic_data_size) { float ho[2]; int gain_index; @@ -286,7 +286,7 @@ void *akm8963_thread(void *thread_data) struct input_event event; struct timeval time; unsigned char i2c_data[8] = { 0 }; - unsigned short magnetic_data[3] = { 0 }; + short magnetic_data[3] = { 0 }; int index; long int before, after; int diff; @@ -332,9 +332,9 @@ void *akm8963_thread(void *thread_data) goto next; } - magnetic_data[0] = (unsigned short) ((i2c_data[2] << 8) | (i2c_data[1] & 0xff)); - magnetic_data[1] = (unsigned short) ((i2c_data[4] << 8) | (i2c_data[3] & 0xff)); - magnetic_data[2] = (unsigned short) ((i2c_data[6] << 8) | (i2c_data[5] & 0xff)); + magnetic_data[0] = (short) ((i2c_data[2] << 8) | (i2c_data[1] & 0xff)); + magnetic_data[1] = (short) ((i2c_data[4] << 8) | (i2c_data[3] & 0xff)); + magnetic_data[2] = (short) ((i2c_data[6] << 8) | (i2c_data[5] & 0xff)); index = data->magnetic_data_index; @@ -345,7 +345,7 @@ void *akm8963_thread(void *thread_data) data->magnetic_data_index = (index + 1) % 4; data->magnetic_data_count++; - rc = akm8963_ho_calibration(data, (unsigned short *) &magnetic_data, sizeof(magnetic_data)); + rc = akm8963_ho_calibration(data, (short *) &magnetic_data, sizeof(magnetic_data)); if (rc < 0) { ALOGE("%s: Unable to calibrate akm8963 HO", __func__); goto next; |