OSDN Git Service

Experimental accelerometer calibration routine
[android-x86/hardware-intel-libsensors.git] / transform.c
index ffbe917..25094f6 100644 (file)
@@ -299,6 +299,8 @@ static int finalize_sample_default (int s, sensors_event_t* data)
                case SENSOR_TYPE_ACCELEROMETER:
                        /* Always consider the accelerometer accurate */
                        data->acceleration.status = SENSOR_STATUS_ACCURACY_HIGH;
+                       if (sensor[s].quirks & QUIRK_BIASED)
+                               calibrate_accel(s, data);
                        denoise(s, data);
                        break;
 
@@ -515,15 +517,15 @@ float acquire_immediate_float_value (int s, int c)
 
        /* Acquire a sample value for sensor s / channel c through sysfs */
 
-       if (input_path[0]) {
+       if (sensor[s].channel[c].input_path_present) {
                sprintf(sysfs_path, BASE_PATH "%s", dev_num, input_path);
                ret = sysfs_read_float(sysfs_path, &val);
 
                if (!ret)
                        return val * correction;
-       };
+       }
 
-       if (!raw_path[0])
+       if (!sensor[s].channel[c].raw_path_present)
                return 0;
 
        sprintf(sysfs_path, BASE_PATH "%s", dev_num, raw_path);
@@ -561,7 +563,7 @@ uint64_t acquire_immediate_uint64_value (int s, int c)
 
        /* Acquire a sample value for sensor s / channel c through sysfs */
 
-       if (input_path[0]) {
+       if (sensor[s].channel[c].input_path_present) {
                sprintf(sysfs_path, BASE_PATH "%s", dev_num, input_path);
                ret = sysfs_read_uint64(sysfs_path, &val);
 
@@ -569,7 +571,7 @@ uint64_t acquire_immediate_uint64_value (int s, int c)
                        return val * correction;
        };
 
-       if (!raw_path[0])
+       if (!sensor[s].channel[c].raw_path_present)
                return 0;
 
        sprintf(sysfs_path, BASE_PATH "%s", dev_num, raw_path);