OSDN Git Service

Reinstate monotonic timestamp in data acquisition threads
[android-x86/hardware-intel-libsensors.git] / enumeration.c
index d9f93c0..c6fd7a3 100644 (file)
@@ -14,7 +14,6 @@
 #include "description.h"
 #include "control.h"
 #include "calibration.h"
-#include "filtering.h"
 
 /*
  * This table maps syfs entries in scan_elements directories to sensor types,
@@ -264,6 +263,25 @@ static void add_sensor (int dev_num, int catalog_index, int use_polling)
        sysfs_read_float(sysfs_path, &sensor_info[s].offset);
 
        sprintf(sysfs_path, SENSOR_SCALE_PATH, dev_num, prefix);
+       if (!sensor_get_fl_prop(s, "scale", &scale)) {
+               /*
+                * There is a chip preferred scale specified,
+                * so try to store it in sensor's scale file
+                */
+               if (sysfs_write_float(sysfs_path, scale) == -1 && errno == ENOENT) {
+                       ALOGE("Failed to store scale[%f] into %s - file is missing", scale, sysfs_path);
+                       /* Store failed, try to store the scale into channel specific file */
+                       for (c = 0; c < num_channels; c++)
+                       {
+                               sprintf(sysfs_path, BASE_PATH "%s", dev_num,
+                                       sensor_catalog[catalog_index].channel[c].scale_path);
+                               if (sysfs_write_float(sysfs_path, scale) == -1)
+                                       ALOGE("Failed to store scale[%f] into %s", scale, sysfs_path);
+                        }
+                }
+       }
+
+       sprintf(sysfs_path, SENSOR_SCALE_PATH, dev_num, prefix);
        if (!sysfs_read_float(sysfs_path, &scale)) {
                 sensor_info[s].scale = scale;
                ALOGI("Scale path:%s scale:%f dev_num:%d\n",
@@ -346,6 +364,9 @@ static void add_sensor (int dev_num, int catalog_index, int use_polling)
        sensor_desc[s].fifoReservedEventCount = 0;
        sensor_desc[s].fifoMaxEventCount = 0;
 
+       /* Populate the quirks array */
+       sensor_get_quirks(s);
+
        if (sensor_info[s].internal_name[0] == '\0') {
                /*
                 * In case the kernel-mode driver doesn't expose a name for
@@ -360,14 +381,13 @@ static void add_sensor (int dev_num, int catalog_index, int use_polling)
                sensor_type == SENSOR_TYPE_GYROSCOPE_UNCALIBRATED) {
                struct gyro_cal* calibration_data = calloc(1, sizeof(struct gyro_cal));
                sensor_info[s].cal_data = calibration_data;
-               denoise_median_init(s, 7, 3);
        }
 
        if (sensor_type == SENSOR_TYPE_MAGNETIC_FIELD) {
                struct compass_cal* calibration_data = calloc(1, sizeof(struct compass_cal));
                sensor_info[s].cal_data = calibration_data;
        }
-
+       sensor_info[s].max_cal_level = sensor_get_cal_steps(s);
        /* Select one of the available sensor sample processing styles */
        select_transform(s);
 
@@ -376,9 +396,6 @@ static void add_sensor (int dev_num, int catalog_index, int use_polling)
        sensor_info[s].thread_data_fd[1]  = -1;
        sensor_info[s].acquisition_thread = -1;
 
-       sensor_info[s].meta_data_pending = 0;
-       sensor_info[s].event_count = 0;
-
        /* Check if we have a special ordering property on this sensor */
        if (sensor_get_order(s, sensor_info[s].order))
                sensor_info[s].quirks |= QUIRK_FIELD_ORDERING;
@@ -763,7 +780,13 @@ void enumerate_sensors (void)
         * Create the uncalibrated counterpart to the compensated gyroscope.
         * This is is a new sensor type in Android 4.4.
         */
-       uncalibrated_gyro_check();
+
+       /*
+        * Patrick Porlan 11/12/2014 - Disabled for now due to a possible
+        * relation with GMINL-3234 Panorama Drift. I take full responsability
+        * for this.
+        *
+        * uncalibrated_gyro_check(); */
 }
 
 
@@ -779,6 +802,7 @@ void delete_enumeration_data (void)
                                sensor_info[i].cal_level = 0;
                        }
                        break;
+
                case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
                case SENSOR_TYPE_GYROSCOPE:
                        if (sensor_info[i].cal_data != NULL) {
@@ -787,9 +811,7 @@ void delete_enumeration_data (void)
                                sensor_info[i].cal_level = 0;
                        }
                        break;
-                       if (sensor_info[i].filter != NULL) {
-                               denoise_median_release(i);
-                       }
+
                default:
                        break;
        }
@@ -798,8 +820,8 @@ void delete_enumeration_data (void)
 }
 
 
-int get_sensors_list struct sensors_module_t* module,
-                       struct sensor_t const** list)
+int get_sensors_list (__attribute__((unused)) struct sensors_module_t* module,
+                     struct sensor_t const** list)
 {
        *list = sensor_desc;
        return sensor_count;