diff options
-rw-r--r-- | libsensors_iio/src/SensorHAL.cpp | 6 | ||||
-rw-r--r-- | libsensors_iio/src/sensor_cal.c | 14 | ||||
-rw-r--r-- | libsensors_iio/src/sensor_cal.h | 17 |
3 files changed, 26 insertions, 11 deletions
diff --git a/libsensors_iio/src/SensorHAL.cpp b/libsensors_iio/src/SensorHAL.cpp index 213cb85..15366db 100644 --- a/libsensors_iio/src/SensorHAL.cpp +++ b/libsensors_iio/src/SensorHAL.cpp @@ -749,8 +749,10 @@ static int st_hal_open_sensors(const struct hw_module_t *module, hal_data->poll_device.batch = st_hal_dev_batch; hal_data->poll_device.flush = st_hal_dev_flush; - do_cal_data_loading(ACCEL_SINDEX); - do_cal_data_loading(GYRO_SINDEX); + do_cal_data_loading(ACCEL_SINDEX, NON_WAKEUP); + do_cal_data_loading(ACCEL_SINDEX, WAKEUP); + do_cal_data_loading(GYRO_SINDEX, NON_WAKEUP); + do_cal_data_loading(GYRO_SINDEX, WAKEUP); *device = &hal_data->poll_device.common; diff --git a/libsensors_iio/src/sensor_cal.c b/libsensors_iio/src/sensor_cal.c index 1d14611..94fae63 100644 --- a/libsensors_iio/src/sensor_cal.c +++ b/libsensors_iio/src/sensor_cal.c @@ -23,6 +23,10 @@ int load_cali_data(const int sindex) int err = 0, num, sum; FILE *filp; + if (((sindex == ACCEL_SINDEX) && accl_cal_data_loaded) || + ((sindex == GYRO_SINDEX) && gyro_cal_data_loaded)) + return 0; + filp = fopen(sensor_cali_data_path[sindex], "r"); if (filp == NULL) { err = -errno; @@ -51,7 +55,7 @@ out: } /* Write calibration data to iio channel offset */ -void set_cali_offset(const int sindex) +void set_cali_offset(const int sindex, const bool wakeup) { #define MAX_BUF_LEN 64 int err, j; @@ -60,10 +64,10 @@ void set_cali_offset(const int sindex) for (j = 0; j < (Z_AXIS_INDEX + 1); j++) { err = snprintf(buf, MAX_BUF_LEN, "%s/%s", - sensor_sysfs_dir[sindex], sensor_offset[sindex][j]); + sensor_sysfs_dir[sindex][wakeup], sensor_offset[sindex][j]); if (err < 0) { ALOGE("%s/%s snprintf err=%d", - sensor_sysfs_dir[sindex], sensor_offset[sindex][j], err); + sensor_sysfs_dir[sindex][wakeup], sensor_offset[sindex][j], err); return; } filp = fopen(buf, "w"); @@ -82,7 +86,7 @@ void set_cali_offset(const int sindex) } -void do_cal_data_loading(const int sindex) +void do_cal_data_loading(const int sindex, const bool wakeup) { int err; @@ -90,6 +94,6 @@ void do_cal_data_loading(const int sindex) if (err != 0) return; - set_cali_offset(sindex); + set_cali_offset(sindex, wakeup); } diff --git a/libsensors_iio/src/sensor_cal.h b/libsensors_iio/src/sensor_cal.h index 3102b9d..5b0ba40 100644 --- a/libsensors_iio/src/sensor_cal.h +++ b/libsensors_iio/src/sensor_cal.h @@ -20,6 +20,9 @@ #include <stdio.h> #include <stdbool.h> +#define NON_WAKEUP 0 +#define WAKEUP 1 + enum SENSOR_INDEX { ACCEL_SINDEX = 0, GYRO_SINDEX, @@ -36,9 +39,15 @@ static const char * const sensor_cali_data_path[] = { [GYRO_SINDEX] = "/config/sensor/gyro_cali", }; -static const char * const sensor_sysfs_dir[] = { - [ACCEL_SINDEX] = "/sys/devices/iio:device1", - [GYRO_SINDEX] = "/sys/devices/iio:device2", +static const char * const sensor_sysfs_dir[][2] = { + { + [NON_WAKEUP] = "/sys/devices/iio:device1", + [WAKEUP] = "/sys/devices/iio:device2", + }, + { + [NON_WAKEUP] = "/sys/devices/iio:device3", + [WAKEUP] = "/sys/devices/iio:device4", + }, }; static const char * const sensor_offset[][3] = { @@ -58,6 +67,6 @@ static bool accl_cal_data_loaded; static bool gyro_cal_data_loaded; static int cal_data[2][3]; -void do_cal_data_loading(const int sindex); +void do_cal_data_loading(const int sindex, const bool wakeup); #endif |