#define DEVICE_SAMPLING_PATH BASE_PATH "sampling_frequency"
#define DEVICE_AVAIL_FREQ_PATH BASE_PATH "sampling_frequency_available"
#define ILLUMINATION_CALIBPATH BASE_PATH "in_illuminance_calibscale"
+#define SENSOR_CALIB_BIAS_PATH BASE_PATH "in_%s_calibbias"
#define PROP_BASE "ro.iio.%s.%s" /* Note: PROPERTY_KEY_MAX is small */
{
int offset; /* Offset in bytes within the iio character device report */
int size; /* Field size in bytes */
- float scale; /* scale for each channel */
+ float scale; /* Scale for each channel */
char type_spec[MAX_TYPE_SPEC_LEN]; /* From driver; ex: le:u10/16>>0 */
datum_info_t type_info; /* Decoded contents of type spec */
float opt_scale; /*
const char* ch_name;
int num_channels;
char suffix[MAX_NAME_SIZE + 8];
+ int calib_bias;
if (sensor_count == MAX_SENSORS) {
ALOGE("Too many sensors!\n");
}
}
+ /*
+ * See if we have optional calibration biases for each of the channels of this sensor. These would be expressed using properties like
+ * iio.accel.y.calib_bias = -1, or possibly something like iio.temp.calib_bias if the sensor has a single channel. This value gets stored in the
+ * relevant calibbias sysfs file if that file can be located and then used internally by the iio sensor driver.
+ */
+
+ if (num_channels) {
+ for (c = 0; c < num_channels; c++) {
+ ch_name = sensor_catalog[catalog_index].channel[c].name;
+ sprintf(suffix, "%s.calib_bias", ch_name);
+ if (!sensor_get_prop(s, suffix, &calib_bias) && calib_bias) {
+ sprintf(suffix, "%s_%s", prefix, sensor_catalog[catalog_index].channel[c].name);
+ sprintf(sysfs_path, SENSOR_CALIB_BIAS_PATH, dev_num, suffix);
+ sysfs_write_int(sysfs_path, calib_bias);
+ }
+ }
+ } else
+ if (!sensor_get_prop(s, "calib_bias", &calib_bias) && calib_bias) {
+ sprintf(sysfs_path, SENSOR_CALIB_BIAS_PATH, dev_num, prefix);
+ sysfs_write_int(sysfs_path, calib_bias);
+ }
+
/* Read name attribute, if available */
sprintf(sysfs_path, NAME_PATH, dev_num);
sysfs_read_str(sysfs_path, sensor[s].internal_name, MAX_NAME_SIZE);