sensor_info[s].dev_num = dev_num;
sensor_info[s].catalog_index = catalog_index;
+ sensor_info[s].type = sensor_type;
num_channels = sensor_catalog[catalog_index].num_channels;
* receiving the illumination sensor calibration inputs from
* the Android properties and setting it within sysfs
*/
- if (sensor_catalog[catalog_index].type == SENSOR_TYPE_LIGHT) {
+ if (sensor_type == SENSOR_TYPE_LIGHT) {
retval = sensor_get_illumincalib(s);
if (retval > 0) {
sprintf(sysfs_path, ILLUMINATION_CALIBPATH, dev_num);
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",
*/
sensor_desc[s].requiredPermission = "";
sensor_desc[s].flags = sensor_get_flags(s);
+ sensor_desc[s].minDelay = sensor_get_min_delay(s);
sensor_desc[s].maxDelay = sensor_get_max_delay(s);
+ ALOGI("Sensor %d (%s) type(%d) minD(%d) maxD(%d) flags(%2.2x)\n",
+ s, sensor_info[s].friendly_name, sensor_desc[s].type,
+ sensor_desc[s].minDelay, sensor_desc[s].maxDelay, sensor_desc[s].flags);
+
+ /* We currently do not implement batching when we'll so
+ * these should be overriden appropriately
+ */
+ 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') {
/*
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);
int catalog_size = CATALOG_SIZE;
for (i=0; i<sensor_count; i++)
- switch (sensor_catalog[sensor_info[i].catalog_index].type) {
+ switch (sensor_info[i].type) {
case SENSOR_TYPE_ACCELEROMETER:
has_acc = 1;
break;
}
}
-static int is_continuous (int s)
-{
- /* Is sensor s of the continous trigger type kind? */
-
- int catalog_index = sensor_info[s].catalog_index;
- int sensor_type = sensor_catalog[catalog_index].type;
-
- switch (sensor_type) {
- case SENSOR_TYPE_ACCELEROMETER:
- case SENSOR_TYPE_MAGNETIC_FIELD:
- case SENSOR_TYPE_ORIENTATION:
- case SENSOR_TYPE_GYROSCOPE:
- case SENSOR_TYPE_PRESSURE:
- case SENSOR_TYPE_GRAVITY:
- case SENSOR_TYPE_LINEAR_ACCELERATION:
- case SENSOR_TYPE_ROTATION_VECTOR:
- case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED:
- case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
- case SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR:
- return 1;
-
- default:
- return 0;
- }
-}
-
-
static void propose_new_trigger (int s, char trigger_name[MAX_NAME_SIZE],
int sensor_name_len)
{
if (!memcmp(suffix, "dev", 3))
return;
- /*
- * If we found any-motion trigger, record it and force the sensor to
- * automatic intermediate event generation mode, at least if it is of a
- * continuously firing sensor type.
- */
+ /* If we found any-motion trigger, record it */
- if (!memcmp(suffix, "any-motion-", 11) && is_continuous(s)) {
- /* Update the any-motion trigger name to use for this sensor */
+ if (!memcmp(suffix, "any-motion-", 11)) {
strcpy(sensor_info[s].motion_trigger_name, trigger_name);
return;
}
- /* Update the initial trigger name to use for this sensor */
+ /*
+ * It's neither the default "dev" nor an "any-motion" one. Make sure we
+ * use this though, as we may not have any other indication of the name
+ * of the trigger to use with this sensor.
+ */
strcpy(sensor_info[s].init_trigger_name, trigger_name);
}
update_sensor_matching_trigger_name(buf);
}
+ /*
+ * Certain drivers expose only motion triggers even though they should
+ * be continous. For these, use the default trigger name as the motion
+ * trigger. The code generating intermediate events is dependent on
+ * motion_trigger_name being set to a non empty string.
+ */
+
+ for (s=0; s<sensor_count; s++)
+ if ((sensor_info[s].quirks & QUIRK_TERSE_DRIVER) &&
+ sensor_info[s].motion_trigger_name[0] == '\0')
+ strcpy( sensor_info[s].motion_trigger_name,
+ sensor_info[s].init_trigger_name);
+
for (s=0; s<sensor_count; s++)
if (sensor_info[s].num_channels) {
- ALOGI( "Sensor %d (%s) default trigger: %s\n", s,
+ ALOGI("Sensor %d (%s) default trigger: %s\n", s,
sensor_info[s].friendly_name,
sensor_info[s].init_trigger_name);
if (sensor_info[s].motion_trigger_name[0])
- ALOGI( "Sensor %d (%s) motion trigger: %s\n",
+ ALOGI("Sensor %d (%s) motion trigger: %s\n",
s, sensor_info[s].friendly_name,
sensor_info[s].motion_trigger_name);
}
/* Checking to see if we have a gyroscope - we can only have uncal if we have the base sensor */
for (i=0; i < sensor_count; i++)
- if(sensor_catalog[sensor_info[i].catalog_index].type == SENSOR_TYPE_GYROSCOPE)
- {
+ if (sensor_info[i].type == SENSOR_TYPE_GYROSCOPE) {
has_gyr=1;
dev_num = sensor_info[i].dev_num;
is_poll_sensor = !sensor_info[i].num_channels;
* 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(); */
}
void delete_enumeration_data (void)
{
-
int i;
for (i = 0; i < sensor_count; i++)
- switch (sensor_catalog[sensor_info[i].catalog_index].type) {
+ switch (sensor_info[i].type) {
case SENSOR_TYPE_MAGNETIC_FIELD:
+ if (sensor_info[i].cal_data != NULL) {
+ free(sensor_info[i].cal_data);
+ sensor_info[i].cal_data = NULL;
+ sensor_info[i].cal_level = 0;
+ }
+ break;
+
case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED:
case SENSOR_TYPE_GYROSCOPE:
if (sensor_info[i].cal_data != NULL) {
sensor_info[i].cal_level = 0;
}
break;
+
default:
break;
}
}
-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;