X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=description.c;h=a4dd2df8168b380e115e9381b6bd80562aa96794;hb=d3a01e8c2e558a87892467848aa3a2483a75f004;hp=39cc7251fc579feb355ffc0e4507999cd3a6fc00;hpb=f6247c02f6441d692833f7275898c6b0d7e99158;p=android-x86%2Fhardware-intel-libsensors.git diff --git a/description.c b/description.c index 39cc725..a4dd2df 100644 --- a/description.c +++ b/description.c @@ -397,6 +397,12 @@ uint32_t sensor_get_quirks (int s) if (strstr(quirks_buf, "no-poll")) sensor[s].quirks |= QUIRK_NO_POLL_MODE; + if (strstr(quirks_buf, "hrtimer")) + sensor[s].quirks |= QUIRK_HRTIMER; + + if (strstr(quirks_buf, "secondary")) + sensor[s].quirks |= QUIRK_SECONDARY; + sensor[s].quirks |= QUIRK_ALREADY_DECODED; } @@ -427,6 +433,54 @@ int sensor_get_order (int s, unsigned char map[MAX_CHANNELS]) return 1; /* OK to use modified ordering map */ } +int sensor_get_mounting_matrix (int s, float mm[9]) +{ + int dev_num = sensor[s].dev_num, err, i; + char mm_path[PATH_MAX], mm_buf[100]; + char *tmp1 = mm_buf, *tmp2; + + switch (sensor[s].type) { + case SENSOR_TYPE_ACCELEROMETER: + case SENSOR_TYPE_MAGNETIC_FIELD: + case SENSOR_TYPE_GYROSCOPE: + case SENSOR_TYPE_PROXIMITY: + break; + default: + return 0; + } + + sprintf(mm_path, MOUNTING_MATRIX_PATH, dev_num); + + err = sysfs_read_str(mm_path, mm_buf, sizeof(mm_buf)); + if (err < 0) + return 0; + + for(i = 0; i < 9; i++) { + float f; + + f = strtof(tmp1, &tmp2); + if (!f && tmp1 == tmp2) + return 0; + mm[i] = f; + tmp1 = tmp2 + 1; + } + + /* + * For proximity sensors, interpret a negative final z value as a hint that the sensor is back mounted. In that case, mark the sensor as secondary to + * ensure that it gets listed after other sensors of same type that would be front-mounted. Most applications will only ask for the default proximity + * sensor and it makes more sense to point to, say, the IR based proximity sensor rather than SAR based one if we have both, as on SoFIA LTE MRD boards. + */ + if (sensor[s].type == SENSOR_TYPE_PROXIMITY) { + if (mm[8] < 0) { + sensor[s].quirks |= QUIRK_SECONDARY; + } + return 0; + } + + ALOGI("%s: %f %f %f %f %f %f %f %f %f\n", __func__, mm[0], mm[1], mm[2], mm[3], mm[4], mm[5], mm[6], mm[7], mm[8]); + return 1; +} + char* sensor_get_string_type (int s) { @@ -535,7 +589,7 @@ max_delay_t sensor_get_max_delay (int s) int dev_num = sensor[s].dev_num; char freqs_buf[100]; char* cursor; - float min_supported_rate = 1000; + float min_supported_rate; float rate_cap; float sr; @@ -564,31 +618,42 @@ max_delay_t sensor_get_max_delay (int s) return 0; } } - sprintf(avail_sysfs_path, DEVICE_AVAIL_FREQ_PATH, dev_num); - if (sysfs_read_str(avail_sysfs_path, freqs_buf, sizeof(freqs_buf)) < 0) { - if (sensor[s].mode == MODE_POLL) { - /* The must rate */ - min_supported_rate = get_cdd_freq(s, 1); - } - } else { - cursor = freqs_buf; - while (*cursor && cursor[0]) { + switch (sensor[s].mode) { + case MODE_TRIGGER: + /* For interrupt-based devices, obey the list of supported sampling rates */ + sprintf(avail_sysfs_path, DEVICE_AVAIL_FREQ_PATH, dev_num); + if (sysfs_read_str(avail_sysfs_path, freqs_buf, sizeof(freqs_buf)) > 0) { - /* Decode a single value */ - sr = strtod(cursor, NULL); + min_supported_rate = 1000; + cursor = freqs_buf; - if (sr < min_supported_rate) - min_supported_rate = sr; + while (*cursor && cursor[0]) { - /* Skip digits */ - while (cursor[0] && !isspace(cursor[0])) - cursor++; + /* Decode a single value */ + sr = strtod(cursor, NULL); - /* Skip spaces */ - while (cursor[0] && isspace(cursor[0])) - cursor++; - } + if (sr < min_supported_rate) + min_supported_rate = sr; + + /* Skip digits */ + while (cursor[0] && !isspace(cursor[0])) + cursor++; + + /* Skip spaces */ + while (cursor[0] && isspace(cursor[0])) + cursor++; + } + + break; + } + + /* Fall through ... */ + + default: + /* Report 1 Hz */ + min_supported_rate = 1; + break; } /* Check if a minimum rate was specified for this sensor */