#include <utils/Log.h>
#include "calibration.h"
#include "matrix-ops.h"
-
+#include "description.h"
#ifdef DBG_RAW_DATA
#define MAX_RAW_DATA_COUNT 2000
event->magnetic.z = event->data[2] = result[2][0];
}
+static inline float get_error_threshold (struct sensor_info_t* info)
+{
+ if (info->calibrated)
+ return MAX_SQR_ERR;
+
+ if (info->quirks & QUIRK_NOISY)
+ return FIRST_MAX_SQR_ERR * 2;
+
+ return FIRST_MAX_SQR_ERR;
+}
+
static int compass_ready (struct sensor_info_t* info)
{
mat_input_t mat;
if (cal_data->sample_count < DS_SIZE)
return info->calibrated;
- max_sqr_err = info->calibrated ? MAX_SQR_ERR : FIRST_MAX_SQR_ERR;
+ max_sqr_err = get_error_threshold(info);
/* enough points have been collected, do the ellipsoid calibration */
for (i = 0; i < DS_SIZE; i++) {
continue;
/* If the sensor can generate duplicates, leave it alone */
- if (!(sensor_info[s].quirks & QUIRK_TERSE_DRIVER))
+ if (!(sensor_info[s].quirks & QUIRK_TERSE_DRIVER))
continue;
/* If we haven't seen a sample, there's nothing to duplicate */
* when the sensor reports a change. The HAL then periodically generates
* duplicate events so the sensor behaves as a continously firing one.
*
+ * The "noisy" quirk indicates that the underlying driver has a unusually high
+ * level of noise in its readings, and that the HAL has to accomodate it
+ * somehow, e.g. in the magnetometer calibration code path.
+ *
* This one is used specifically to pass a calibration scale to ALS drivers:
*
* ro.iio.illuminance.name = CPLM3218x Ambient Light Sensor
if (strstr(quirks_buf, "terse"))
sensor_info[s].quirks |= QUIRK_TERSE_DRIVER;
- ;
+
+ if (strstr(quirks_buf, "noisy"))
+ sensor_info[s].quirks |= QUIRK_NOISY;
sensor_info[s].quirks |= QUIRKS_ALREADY_DECODED;
}
#include "common.h"
-#define QUIRKS_ALREADY_DECODED 0x1 /* Sensor quirks have been read */
-#define QUIRKS_INITIAL_RATE 0x2 /* Force initial sensor sampling rate */
-#define QUIRK_TERSE_DRIVER 0x8 /* Force duplicate events generation */
+#define QUIRKS_ALREADY_DECODED 0x01 /* Sensor quirks have been read */
+#define QUIRKS_INITIAL_RATE 0x02 /* Force initial sensor sampling rate */
+#define QUIRK_TERSE_DRIVER 0x08 /* Force duplicate events generation */
+#define QUIRK_NOISY 0x10 /* High noise level on readings */
char* sensor_get_name (int handle);
char* sensor_get_vendor (int handle);