OSDN Git Service

android-x86/hardware-intel-libsensors.git
9 years agoIRDA-3621: Fix a bug where accel and gyro get stuck at 200 Hz
Patrick Porlan [Wed, 11 Feb 2015 09:40:36 +0000 (10:40 +0100)]
IRDA-3621: Fix a bug where accel and gyro get stuck at 200 Hz

This is happening on Malata because the MPU-6050 driver exposes
both the accel and gyro on the same iio device, with a single
frequency knob for both. With the current code the accel would
be bumped up to 200 Hz if the gyro was configured at 200 Hz, but
would not go back when a lower sampling rate was selected because
the accel would appear to require 200 Hz.

Change-Id: Ied0c1c94c278be180a22fd537f8e82f0e8f7adbd
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoFix a warning
Patrick Porlan [Wed, 11 Feb 2015 09:20:10 +0000 (10:20 +0100)]
Fix a warning

Change-Id: Ic4aa8c634509f481d265c4729e9aa36a1e97df75
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoGet max frequency from property if it's present.
Adriana Reus [Tue, 10 Feb 2015 08:33:11 +0000 (10:33 +0200)]
Get max frequency from property if it's present.

If we have a poll mode sensor and we don't have a list of
available frequencies, check out if we have a value specified in
the "max_freq" property. If we don't fall back to the cdd values.

Fixes Cts Verifier fail.

Tracked-On: https://jira01.devtools.intel.com/browse/IRDA-3195
Change-Id: Idb718bc792a2fb11c9dd62a3b99c8ed11083545f
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoChecking raw and input paths on enumeration
Viorel Suman [Mon, 9 Feb 2015 16:52:24 +0000 (18:52 +0200)]
Checking raw and input paths on enumeration

Raw and input path checks introduced on enumeration
in order to avoid continuous reading of these files
while acquiring immediate values.

Change-Id: Ia5c4b21a3c6d95f2c99ef60f17fd3a4b968f0c82
Signed-off-by: Viorel Suman <viorel.suman@intel.com>
9 years agoUtils review - numerical write functions
Viorel Suman [Fri, 6 Feb 2015 12:16:13 +0000 (14:16 +0200)]
Utils review - numerical write functions

Numerical write functions updated in order to use
the just introduced basic file write function.

Change-Id: Id77bef1501b4f988929b7b06f44a6c8f2387d354
Signed-off-by: Viorel Suman <viorel.suman@intel.com>
9 years agoUtils review - numerical read functions
Viorel Suman [Fri, 6 Feb 2015 13:47:51 +0000 (15:47 +0200)]
Utils review - numerical read functions

All numerical read functions decomposed
into two phases - "read" phase and "convert" phase.
The "read" phase is same for all types, the only
difference is the type specific conversion function.

Change-Id: I6358d593e3804c2a00a0252f0c3bd0e18c67b9b9
Signed-off-by: Viorel Suman <viorel.suman@intel.com>
9 years agoUtils review - string read/write functions
Viorel Suman [Fri, 6 Feb 2015 09:20:47 +0000 (11:20 +0200)]
Utils review - string read/write functions

String read/write functions updated in order to
use the just introduced basic file read and write
functions.

Change-Id: I56103f7ae01d66259177dd0acd29bc48261882c0
Signed-off-by: Viorel Suman <viorel.suman@intel.com>
9 years agoUtils review - introducing base read and write functions
Viorel Suman [Fri, 6 Feb 2015 09:14:09 +0000 (11:14 +0200)]
Utils review - introducing base read and write functions

The patch introduces the basic file read and write
functions that will be used lately by type specific
read and write functions.

Change-Id: Ib06d7ca9104d6f3111f6f8796acd58e6959dcaa1
Signed-off-by: Viorel Suman <viorel.suman@intel.com>
9 years agoPass iio provided timestamps without further processing.
Adriana Reus [Thu, 5 Feb 2015 15:40:17 +0000 (17:40 +0200)]
Pass iio provided timestamps without further processing.

Change-Id: Iebcca183362929fdd189eeb6ffe82b44edc90b9e
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoUnbreak branch
Patrick Porlan [Fri, 6 Feb 2015 14:14:07 +0000 (15:14 +0100)]
Unbreak branch

Change-Id: I36fa31bc870354ac6f727b4140b0e158e6cb04aa
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoBulk-extend copyright headers to 2015
Patrick Porlan [Fri, 6 Feb 2015 13:43:06 +0000 (14:43 +0100)]
Bulk-extend copyright headers to 2015

Change-Id: I22221862ce66c9c84260d83cc9f238f41efda0b0
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoiio-sensors: Add suport for STEP_DETECTOR sensor
Daniel Baluta [Tue, 3 Feb 2015 16:13:03 +0000 (18:13 +0200)]
iio-sensors: Add suport for STEP_DETECTOR sensor

The step detector is a sensor that will trigger an event every
time the user takes a step. More information on the step detector
can be found in Google's documentation:
http://source.android.com/devices/sensors/composite_sensors.html#detector.

The iio interface for the step detector is available with commit
a88bfe785 ("iio: core: Introduce STEPS channel, ENABLE mask and INSTANCE
event") soon to be found in linux kernel 3.20. Also the interface is
documented under Documentation/ABI/testing/sysfs-bus-iio

This is how the interface should be used:
- to enable the step detector, we need to write 1 to events/in_steps_instance_en
- each time a step is detected, an iio event will be generated
- to disable the step detector, we need to write 0 to events/in_steps_instance_en

This patch adds support for the step counter in the HAL:
- add helper functions for iio events
- add support for the step detector sensor

Change-Id: I658b537773c6d9a1cafe3a47f3804034b358a125
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
9 years agoiio-sensors: Add infrastructure for IIO events
Daniel Baluta [Thu, 29 Jan 2015 12:16:26 +0000 (14:16 +0200)]
iio-sensors: Add infrastructure for IIO events

This introduces event_descriptor_t to represent an event.
Each channel can have multiple events attached.

Activating a sensor of type EVENT implies:
* retrieving associated event_fd file descriptor (see. IIO_GET_EVENT_FD_IOCTL)
* adding event_fd to the watched fds poll set
* enabling IIO event, usually writing 1 to iio:deviceX/events/in_<event_name>_en

Deactivation does the above operations in reverse order.

Change-Id: I305f28456b43ea8a662e49c2c3aa8febd0d7d84f
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
9 years agoiio-sensors: Add support for STEP_COUNTER sensor
Daniel Baluta [Thu, 29 Jan 2015 10:20:33 +0000 (12:20 +0200)]
iio-sensors: Add support for STEP_COUNTER sensor

The step counter is a sensor that will count using a hardware
register the number of steps taken by the user since the last
reboot while activated. More information on the step counter in
Android can be found in Google's documentation:
http://source.android.com/devices/sensors/composite_sensors.html#counter.

The iio interface for the step counter is available with commit
a88bfe785 ("iio: core: Introduce STEPS channel, ENABLE mask and INSTANCE
event") soon to be found in linux kernel 3.20. Also the interface is
documented under Documentation/ABI/testing/sysfs-bus-iio

This is how the interface should be used:
- to enable the step counter, we need to write 1 to in_steps_en
- the current number of steps can be read from in_steps_input
- to disable the step counter, we need to write 0 to in_steps_en

This patch adds support for the step counter in the HAL.
The main difference from the other sensors is that the data
returned by the step counter is uint64_t, while other sensors
return float. This patch adds support for uint64_t return values
and adds the STEP_COUNTER in the supported sensors list.

Change-Id: I21a1288a9bf5ea02ae12176d1853dcd71e714bc9
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
9 years agoiio-sensors: Add sensor mode parameter
Daniel Baluta [Wed, 28 Jan 2015 10:03:09 +0000 (12:03 +0200)]
iio-sensors: Add sensor mode parameter

Currently the difference between a polled and a triggered sensor
is done using sensor_info[s].is_polling. If this is 1, the sensor
is polled, otherwise it is triggered.

If we need to handle more sensor types (e.g. sensors based on iio
events), this mode of differentiation is no longer sufficient.

Add a mode field to indicate the usage mode of the sensor: polled
or triggered. This will be later extended with other types (e.g.
event).

Change-Id: I3a6914a87413e6c8eb662e44f21b91a681e0643a
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
9 years agoiio-sensors: Refactor sensor_catalog definition
Daniel Baluta [Thu, 11 Dec 2014 13:57:32 +0000 (15:57 +0200)]
iio-sensors: Refactor sensor_catalog definition

Next patches will introduce event support to IIO sensor catalog.
Following the current approach that uses DECLARE_SENSOR_X for
a sensor with X channels, we will have to introduce a macro like
DECLARE_SENSOR_X_Y for a sensor with X channels, each channel having
Y events. But this isn't scalable!

So, instead of using macros for sensor catalog entries lets keep it
simple and use inline definition for each channel. The same will be
done for events.

Change-Id: I12ac7ba07a3115ae85f7ebab835a73fd738bace2
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
9 years agoenumeration: Refactor discover sensors code
Daniel Baluta [Tue, 27 Jan 2015 16:23:57 +0000 (18:23 +0200)]
enumeration: Refactor discover sensors code

The functions for discovering poll sensors (discover_poll_sensors)
and trigger sensors (discover_trig_sensors) contain duplicate
code. If more sensor types need to be discovered (e.g. event sensors),
this would add even more duplicate code.

Refactor these two functions to minimize code duplication.

Change-Id: I92ac6f8c6a54afbce5a3ffb45d4b011204e8c754
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
9 years agoiio-sensors: Fix build warnings
Irina Tirdea [Thu, 9 Oct 2014 14:05:50 +0000 (17:05 +0300)]
iio-sensors: Fix build warnings

This patch fixed the following build warnings:

enumeration.c: In function ‘setup_trigger_names’:
enumeration.c:687:6: warning: unused variable ‘len’ [-Wunused-variable]

control.c: In function ‘start_acquisition_thread’:
control.c:560:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]

control.c: In function ‘reapply_sampling_rates’:
control.c:846:18: warning: unused variable ‘user’ [-Wunused-variable]

control.c: In function ‘sensor_poll’:
control.c:1348:6: warning: unused variable ‘uncal_start’ [-Wunused-variable]

gyro-calibration.c: In function ‘gyro_cal_init’:
gyro-calibration.c:33:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]

filtering.c: In function ‘denoise_median’:
filtering.c:111:8: warning: unused variable ‘scale’ [-Wunused-variable]
filtering.c:110:14: warning: unused variable ‘z’ [-Wunused-variable]
filtering.c:110:11: warning: unused variable ‘y’ [-Wunused-variable]
filtering.c:110:8: warning: unused variable ‘x’ [-Wunused-variable]

filtering.c: In function ‘denoise_average’:
filtering.c:144:6: warning: unused variable ‘i’ [-Wunused-variable]

sens.c: In function ‘main’:
sens.c:507:19: warning: unused variable ‘tmp’ [-Wunused-variable]

Change-Id: I856b6ebe7869ddb8e9e38907483ec2750c9ae48e
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
9 years agosens: enable build warnings
Irina Tirdea [Thu, 9 Oct 2014 13:49:56 +0000 (16:49 +0300)]
sens: enable build warnings

Change-Id: I4ceb0d49c9e8912885509e8466c2228364b65c81
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
9 years agoMerge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin...
Adriana Reus [Tue, 3 Feb 2015 12:08:07 +0000 (14:08 +0200)]
Merge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin/l-dev/master

git log --pretty=format:"%h %ad | %s%d [%an]" m/abt/topic/gmin/l-dev/master..origin/abt/topic/gmin/l-dev/sensors/master:
  907d33f Mon Feb 2 11:51:21 2015 +0100 | Fix incorrect timestamp on Malata accelerometer samples (origin/abt/topic/gmin/l-dev/sensors/master) [Patrick Porlan]
  b8ba9bd Mon Feb 2 11:35:12 2015 +0100 | Don't propagate timestamps to colocated poll mode sensors [Patrick Porlan]
  6613293 Thu Jan 29 15:11:10 2015 +0100 | IRDA-2849: Add support for optional calibscale properties [Patrick Porlan]
  241eb56 Wed Jan 28 16:25:24 2015 +0100 | IRDA-3484: Optionally read window size from filter specification [Patrick Porlan]
  29f6a18 Wed Jan 28 11:55:23 2015 +0100 | IRDA-3484: Shift the moving average filter fields to a dedicated structure [Patrick Porlan]
  812d2e7 Tue Jan 27 16:34:59 2015 +0100 | IRDA-3484: Add support for filter property [Patrick Porlan]

git diff --stat m/abt/topic/gmin/l-dev/master..HEAD:
  common.h      |  17 +++--
  control.c     |   6 +-
  description.c |   2 +-
  description.h |   1 +
  enumeration.c |  23 +++++++
  filtering.c   | 194 +++++++++++++++++++++++++++++++++++++++++++---------------
  transform.c   |   8 +--
  7 files changed, 184 insertions(+), 67 deletions(-)

Change-Id: I4d3f68c374d489bf18399436cb16a9e0fdb886c1
Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-5672
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoFix incorrect timestamp on Malata accelerometer samples
Patrick Porlan [Mon, 2 Feb 2015 10:51:21 +0000 (11:51 +0100)]
Fix incorrect timestamp on Malata accelerometer samples

Both accel and gyro samples are co-located on the same iio
device with the MPU-6050 drivers, all channels are enabled
at boot, so take them into account as the iio report size
is stable.

Change-Id: I678bed09b80d3565f81e9ef6db810d0da911c543
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoDon't propagate timestamps to colocated poll mode sensors
Patrick Porlan [Mon, 2 Feb 2015 10:35:12 +0000 (11:35 +0100)]
Don't propagate timestamps to colocated poll mode sensors

Case study: we have incorrect timestamps on the Malata accelerometer
at the moment, and they are being forwarded to the poll-mode
thermometer that is associated to the same (MPU) iio device.
Simply rely on the timestamps constructed in the acquisition thread.

Change-Id: I7d803c71d1d4018fca3c5a8c7ca52fb05422eb0c
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoIRDA-2849: Add support for optional calibscale properties
Patrick Porlan [Thu, 29 Jan 2015 14:11:10 +0000 (15:11 +0100)]
IRDA-2849: Add support for optional calibscale properties

If something like ro.iio.accel.x.calib_bias = -1015 is found,
and non-zero, store it in the relevant sysfs file, e.g. something
like /sys/bus/iio/devices/iio:deviceX/in_accel_x_calibbias.

The driver is then responsible for using that data as it wishes.

Change-Id: I7cfb21f00533d03f5a5b93cfe32f56c1e1fb9c37
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
Tracked-On: https://jira01.devtools.intel.com/browse/IRDA-2849
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoIRDA-3484: Optionally read window size from filter specification
Patrick Porlan [Wed, 28 Jan 2015 15:25:24 +0000 (16:25 +0100)]
IRDA-3484: Optionally read window size from filter specification

I.e. filter=average,10 would supersede the default moving average
window size for a specific sensor.

Change-Id: I6d55f1e7b653a99f5eb4cc2ac4b124131ee876e4
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
Tracked-On: https://jira01.devtools.intel.com/browse/IRDA-3484
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoIRDA-3484: Shift the moving average filter fields to a dedicated structure
Patrick Porlan [Wed, 28 Jan 2015 10:55:23 +0000 (11:55 +0100)]
IRDA-3484: Shift the moving average filter fields to a dedicated structure

This uniformizes handling of filters, and will make it easier
to handle filters parameters in a unified way, as well as adding
filter types in the future.

Change-Id: Ib8e137bfd3db6bea2538ca0c0cd611446f6f934a
Tracked-On: https://jira01.devtools.intel.com/browse/IRDA-3484
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoIRDA-3484: Add support for filter property
Patrick Porlan [Tue, 27 Jan 2015 15:34:59 +0000 (16:34 +0100)]
IRDA-3484: Add support for filter property

As of today, filtering is only engaged if a sensor has the noisy
quirk. If it is, we use median filtering for gyroscopes and moving
average for magnetometers. Let's allow for a filter configuration
item that would force any of the available filters selectively.

filter=median
filter=average

will supersede the default choice. There's no reason to support
a none setting, as it's the default.

Change-Id: I7f85738e3b770d86efe9a709495c08ca36ba4024
Tracked-On: https://jira01.devtools.intel.com/browse/IRDA-3484
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoMerge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin...
Adriana Reus [Mon, 12 Jan 2015 10:41:07 +0000 (12:41 +0200)]
Merge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin/l-dev/master

git log --pretty=format:"%h %ad | %s%d [%an]" m/abt/topic/gmin/l-dev/master..origin/abt/topic/gmin/l-dev/sensors/master:
  739ada1 Thu Jan 8 11:12:04 2015 +0200 | Remove useless log. (origin/abt/topic/gmin/l-dev/sensors/master) [Adriana Reus]
  50085d7 Fri Dec 19 11:16:47 2014 +0200 | Add the TYPE_MAGNETIC_FIELD_UNCALIBRATED sensor [Adriana Reus]

git diff --stat m/abt/topic/gmin/l-dev/master..HEAD:
  control.c     | 87 +++++++++++++++++++++++++++++--------------------------
  description.c |  6 ++--
  enumeration.c | 93 +++++++++++++++++++++++++----------------------------------
  transform.c   | 30 ++++++++++++++++---
  4 files changed, 115 insertions(+), 101 deletions(-)
~
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-5103
Change-Id: Ib5be41558f51f558caf0ae3548a2896be18439e1

9 years agoRemove useless log.
Adriana Reus [Thu, 8 Jan 2015 09:12:04 +0000 (11:12 +0200)]
Remove useless log.

Change-Id: If161e4c5f7284099a138bfa983d21ea12dfe9421
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoAdd the TYPE_MAGNETIC_FIELD_UNCALIBRATED sensor
Adriana Reus [Fri, 19 Dec 2014 09:16:47 +0000 (11:16 +0200)]
Add the TYPE_MAGNETIC_FIELD_UNCALIBRATED sensor

Add the uncalibrated magnetometer type.
Added a single function for checking and adding virtual sensors.
Moved the timestamp handling for polling sensors so that we get a
timestamp before finalize is called.
Also moved the event drop (for sensors not directly enabled)
from finalize to propagate_sensor_report because for polling
sensors we need to signal an fd when we have an event,
and this is made by looking at the finalize return value.

Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-2744
Change-Id: I12abd38329ef7f59b2b13427c47a235b54f75fb2
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoMerge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin...
Adriana Reus [Mon, 5 Jan 2015 12:36:52 +0000 (14:36 +0200)]
Merge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin/l-dev/master

  8cefd8e Fri Dec 19 16:40:50 2014 +0200 | cleanup: Remove handling for continous sensors when setting flags [Adriana Reus]
  8a7e617 Fri Dec 19 14:14:07 2014 +0100 | Winter cleanup: reorganize line breaks in filtering.c [Patrick Porlan]
  0c5d4d4 Fri Dec 19 11:34:15 2014 +0100 | Winter cleanup: revisit enable_buffer function [Patrick Porlan]
  d6349f6 Fri Dec 19 10:29:33 2014 +0100 | Winter cleanup: add a specific is_polling flag to the sensor structure [Patrick Porlan]
  45c9688 Thu Dec 18 17:12:39 2014 +0100 | Fix min & max sampling rate for on-change sensors [Patrick Porlan]
  4d8f316 Thu Dec 18 15:50:46 2014 +0100 | Shift max and min rate calculations to enumeration stage [Patrick Porlan]
  3025276 Thu Dec 18 15:20:43 2014 +0100 | Winter cleanup: remove old debugging code from compass-calibration.c [Patrick Porlan]
  5cd8699 Thu Dec 18 14:41:00 2014 +0100 | Winter cleanup: straighten up a few long untouched files [Patrick Porlan]
  cc449e6 Thu Dec 18 11:40:04 2014 +0100 | Winter cleanup: switch to 160 characters lines [Patrick Porlan]
  cae87f2 Thu Dec 18 10:34:12 2014 +0100 | Winter cleanup: use typedef on our own types [Patrick Porlan]
  14261d3 Wed Dec 17 16:35:34 2014 +0100 | Revisit sampling rate arbitration [Patrick Porlan]
  d554e08 Thu Dec 18 10:04:06 2014 +0100 | Tweak a few traces [Patrick Porlan]
  60bf469 Wed Dec 17 17:32:23 2014 +0100 | Winter cleanup: use consistent types for constants [Patrick Porlan]
  1f86600 Wed Dec 17 16:27:04 2014 +0100 | Rework a little bit sensor_activate_virtual [Patrick Porlan]
  de50236 Wed Dec 17 16:19:12 2014 +0100 | Move sensor_activate_virtual next to sensor_activate function [Patrick Porlan]
  8c1267b Wed Dec 17 16:14:07 2014 +0100 | Rename setup_delay_sysfs to sensor_set_rate [Patrick Porlan]
  d9ac41e Wed Dec 17 15:58:51 2014 +0100 | Rework a little bit the end cases in check_state_change [Patrick Porlan]
  9072170 Wed Dec 17 15:54:52 2014 +0100 | Better coordinate frequencies of co-located iio sensors [Patrick Porlan]
  6c1dfd5 Wed Dec 17 15:49:03 2014 +0100 | Only signal an acquisition thread if the target sensor is enabled [Patrick Porlan]
  cce276f Wed Dec 17 15:42:16 2014 +0100 | Allow for a slight difference when parsing available frequencies [Patrick Porlan]
  a4acc70 Wed Dec 17 15:16:37 2014 +0100 | Winter cleanup: rephrase traces and comments, rename vars, fix whitespaces [Patrick Porlan]
  a0caca2 Wed Dec 17 15:03:12 2014 +0100 | Rename MAX_REAL_DEP to MAX_BASE_SENSORS and base_idx to base [Patrick Porlan]
  67ff046 Mon Dec 15 17:44:56 2014 +0100 | Winter cleanup: tidy up enumeration.c [Patrick Porlan]
  0f08a52 Mon Dec 15 11:48:23 2014 +0100 | Winter cleanup: Harmonize spacing before functions [Patrick Porlan]
  0bb03ae Mon Dec 15 10:58:28 2014 +0100 | Winter cleanup: suffix our own types with _t [Patrick Porlan]
  3848e24 Mon Dec 15 10:31:39 2014 +0100 | Winter cleanup: comment harmonization, space shuffling, etc. [Patrick Porlan]
  5d0800d Mon Dec 15 10:11:20 2014 +0100 | Winter cleanup: move iio type field decoding out of utils.c [Patrick Porlan]
  11ed1a2 Mon Dec 15 10:07:26 2014 +0100 | Winter cleanup: remove superfluous volatile specifier [Patrick Porlan]
  2d5e6c1 Mon Dec 15 09:58:20 2014 +0100 | Winter cleanup: sensor_info[] -> sensor[] [Patrick Porlan]
  8aa6c4c Tue Dec 9 09:07:08 2014 +0200 | Better support for virtual sensors [Adriana Reus]

git diff --stat m/abt/topic/gmin/l-dev/master..HEAD:
  calibration.h         |   27 +-
  common.h              |  189 ++++----
  compass-calibration.c |  204 +++------
  control.c             | 1183 +++++++++++++++++++++++++------------------------
  control.h             |    6 +-
  description.c         |  267 +++++++----
  description.h         |   10 +-
  entry.c               |   21 +-
  enumeration.c         |  396 ++++++++---------
  enumeration.h         |   17 +-
  filtering.c           |  117 +++--
  filtering.h           |    8 +-
  gyro-calibration.c    |   50 +--
  matrix-ops.c          |   14 +-
  transform.c           |  447 +++++++++----------
  utils.c               |   33 --
  utils.h               |    3 -
  17 files changed, 1502 insertions(+), 1490 deletions(-)

Change-Id: If4a7af961dc5970ff5fd8cead24fe0c1723cad45
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoTransmit the entire sensor_event_t structure from acquisition thread
Patrick Porlan [Fri, 19 Dec 2014 14:23:38 +0000 (15:23 +0100)]
Transmit the entire sensor_event_t structure from acquisition thread

We were losing the magnetometer accuracy indicator because of the
wish to limit the amount of data we're transmitting accross threads,
but the volume of data itself is not so different this way. There
should be no impact on performance whatsoever, and this will likely
avoid future bugs.

Change-Id: I55c18553467b442a25a61d29ffaba40eb4fba708
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agocleanup: Remove handling for continous sensors when setting flags
Adriana Reus [Fri, 19 Dec 2014 14:40:50 +0000 (16:40 +0200)]
cleanup: Remove handling for continous sensors when setting flags

This is for nothing, that flag is zero.

Change-Id: I46d71728b30ab7167f4b1ef05f43f0e5662423b0
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoWinter cleanup: reorganize line breaks in filtering.c
Patrick Porlan [Fri, 19 Dec 2014 13:14:07 +0000 (14:14 +0100)]
Winter cleanup: reorganize line breaks in filtering.c

Only cosmetic fixes in there.

Change-Id: I4f6bde87e8e61a98feccac22dfdc428ad65cab1f
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: revisit enable_buffer function
Patrick Porlan [Fri, 19 Dec 2014 10:34:15 +0000 (11:34 +0100)]
Winter cleanup: revisit enable_buffer function

Can't help from tweaking whitespaces too.

Change-Id: I3e5fcf3f364e082ccf0173b75da0691cc26a42b3
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: add a specific is_polling flag to the sensor structure
Patrick Porlan [Fri, 19 Dec 2014 09:29:33 +0000 (10:29 +0100)]
Winter cleanup: add a specific is_polling flag to the sensor structure

Add a dedicated flag telling whether a sensor is triggered or polling.
Checking for the number of channels always felt unnatural.

Change-Id: I03eab9c5bce7c63a90301cfc735afbf72fd780d6
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoFix min & max sampling rate for on-change sensors
Patrick Porlan [Thu, 18 Dec 2014 16:12:39 +0000 (17:12 +0100)]
Fix min & max sampling rate for on-change sensors

The BMG160 thermometer was adopting the gyro min sampling rate of
100, which is kind of wasteful in terms of acquisition thread
activity. Same for BMC150 therm (using 15.6 Hz min). The ALS was
probably causing more thread switches than necessary, even if in
the end no event was being reported to Android if the value was
the same as the last measured one.

So, say it's fine to use on change sensors as a frequency as low
as 0.1 Hz, and report 5 Hz the maximum rate we can handle.

Change-Id: I7bd4a8ef97bffd5a0deb17cf581286214ce8a1a4
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoShift max and min rate calculations to enumeration stage
Patrick Porlan [Thu, 18 Dec 2014 14:50:46 +0000 (15:50 +0100)]
Shift max and min rate calculations to enumeration stage

It doesn't make sense te recompute this stuff over and over.
We might even want to use the ones gathered in the min/max
delay routines eventually, to avoid rounding errors.

Change-Id: I3bc6dfa39459b5b88552a9b716d04d6fdffda7af
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: remove old debugging code from compass-calibration.c
Patrick Porlan [Thu, 18 Dec 2014 14:20:43 +0000 (15:20 +0100)]
Winter cleanup: remove old debugging code from compass-calibration.c

Spread harmony too.

Change-Id: Ieb306cc6039478ace05ad8f327a354cd3b4d0c28
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: straighten up a few long untouched files
Patrick Porlan [Thu, 18 Dec 2014 13:41:00 +0000 (14:41 +0100)]
Winter cleanup: straighten up a few long untouched files

Lots of mindless cosmetic fixes.

Change-Id: I8ac28ac57a2186f460df8d82921d32b5b6ffbbe9
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: switch to 160 characters lines
Patrick Porlan [Thu, 18 Dec 2014 10:40:04 +0000 (11:40 +0100)]
Winter cleanup: switch to 160 characters lines

This allows for nicer traces, comments, and test conditions.

Change-Id: Ie477ab33d090bce0ffecf252e13885f384909771
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: use typedef on our own types
Patrick Porlan [Thu, 18 Dec 2014 09:34:12 +0000 (10:34 +0100)]
Winter cleanup: use typedef on our own types

All these explicit structs ended up being noisy for little benefit.

Change-Id: I0b7ace85ab8a7644d3895e3e45e97ff0e14c5cfc
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoRevisit sampling rate arbitration
Patrick Porlan [Wed, 17 Dec 2014 15:35:34 +0000 (16:35 +0100)]
Revisit sampling rate arbitration

The previous code was generating superfluous sysfs activity,
and induced failures such as:

W/Sensors: Cannot write 1 (1 bytes) to /sys/bus/iio/devices/
                iio:device1/buffer/enable (Invalid argument)
E/Sensors: Failed enabling buffer, retrying
E/Sensors: Could not enable buffer

Change-Id: I5a0f824880faf09fce3012de64da3eb4100d3213
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoTweak a few traces
Patrick Porlan [Thu, 18 Dec 2014 09:04:06 +0000 (10:04 +0100)]
Tweak a few traces

%f -> %g (don't need all these digits)
ALOGI -> ALOGV (a matter of taste)

Change-Id: Ib65ac6a0fea186cb52da9fa235932b2026bca42b
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: use consistent types for constants
Patrick Porlan [Wed, 17 Dec 2014 16:32:23 +0000 (17:32 +0100)]
Winter cleanup: use consistent types for constants

LL is 64 bits
.0 is double
f is float

Change-Id: Ib19b8e09e767ed69c97f973797451156af2cb7b5
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoRework a little bit sensor_activate_virtual
Patrick Porlan [Wed, 17 Dec 2014 15:27:04 +0000 (16:27 +0100)]
Rework a little bit sensor_activate_virtual

Mostly cosmetic. Added a couple of traces too.

Change-Id: Ia8b8a0474421a25e077975d926d6a39518870297
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoMove sensor_activate_virtual next to sensor_activate function
Patrick Porlan [Wed, 17 Dec 2014 15:19:12 +0000 (16:19 +0100)]
Move sensor_activate_virtual next to sensor_activate function

It just makes sense.

Change-Id: I7dd5bd36c7f1a9b10092671f5cddba65bc92c32d
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoRename setup_delay_sysfs to sensor_set_rate
Patrick Porlan [Wed, 17 Dec 2014 15:14:07 +0000 (16:14 +0100)]
Rename setup_delay_sysfs to sensor_set_rate

Because a) it's a sampling rate, and b) it's not necessarily sysfs.

Change-Id: I21e0cd355089845a51b98966b812727ea990a110
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoRework a little bit the end cases in check_state_change
Patrick Porlan [Wed, 17 Dec 2014 14:58:51 +0000 (15:58 +0100)]
Rework a little bit the end cases in check_state_change

The new version is equivalent but a little bit clearer.

Change-Id: I8606a3e10007d60bac895f0ad12f4fd40f2fb2c7
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoBetter coordinate frequencies of co-located iio sensors
Patrick Porlan [Wed, 17 Dec 2014 14:54:52 +0000 (15:54 +0100)]
Better coordinate frequencies of co-located iio sensors

This is in the case where several sensors share a single frequency
knob (that was the case on the Invensense MPU chip used by the T100)
rather than have differenciated rate settings.

Change-Id: Id92c6f0b2811a76eb4550fd801e0bee2bb70a48b
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoOnly signal an acquisition thread if the target sensor is enabled
Patrick Porlan [Wed, 17 Dec 2014 14:49:03 +0000 (15:49 +0100)]
Only signal an acquisition thread if the target sensor is enabled

Otherwise the variable is invalid.

Change-Id: I54c6411b29fd3d10f454e17e46ea6d8dbcc228c6
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoAllow for a slight difference when parsing available frequencies
Patrick Porlan [Wed, 17 Dec 2014 14:42:16 +0000 (15:42 +0100)]
Allow for a slight difference when parsing available frequencies

I'm seeing missed matches due to rounding errors (accelerometer
set at 31.26 Hz because 15.62 is lower than the minimum 15.6201).

Change-Id: I16593fc51e2b88bc140d0b6f264fe833b3ec1c8d
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: rephrase traces and comments, rename vars, fix whitespaces
Patrick Porlan [Wed, 17 Dec 2014 14:16:37 +0000 (15:16 +0100)]
Winter cleanup: rephrase traces and comments, rename vars, fix whitespaces

Change-Id: I37da40035cf427d0352663c4ec936540935dca2a
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoRename MAX_REAL_DEP to MAX_BASE_SENSORS and base_idx to base
Patrick Porlan [Wed, 17 Dec 2014 14:03:12 +0000 (15:03 +0100)]
Rename MAX_REAL_DEP to MAX_BASE_SENSORS and base_idx to base

All your base are belong to us.

Besides, it's simpler.

Change-Id: I6e3711230fbf76d600b3cbbbba91e7528a256062
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: tidy up enumeration.c
Patrick Porlan [Mon, 15 Dec 2014 16:44:56 +0000 (17:44 +0100)]
Winter cleanup: tidy up enumeration.c

Minor cosmetic code changes and factorization.

Change-Id: I4b37a43b44bb3abfff832d57b2ce860c4f9de40f
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: Harmonize spacing before functions
Patrick Porlan [Mon, 15 Dec 2014 10:48:23 +0000 (11:48 +0100)]
Winter cleanup: Harmonize spacing before functions

Avoid inconsistency whenever possible.

Change-Id: I548ea4d9a6a0e1e36e25855a5fc97270f14ac91d
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: suffix our own types with _t
Patrick Porlan [Mon, 15 Dec 2014 09:58:28 +0000 (10:58 +0100)]
Winter cleanup: suffix our own types with _t

I slightly rearranged areas using these types, too.

Change-Id: Id3e6cd845cc6caf85dbc1c26d656faa3835126f9
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: comment harmonization, space shuffling, etc.
Patrick Porlan [Mon, 15 Dec 2014 09:31:39 +0000 (10:31 +0100)]
Winter cleanup: comment harmonization, space shuffling, etc.

Let's be consistent throughtout the code, unless there's a reason
to do thing differently.

Change-Id: I8aef25020b272d9e1e0210652758c0ce3d4d560c
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: move iio type field decoding out of utils.c
Patrick Porlan [Mon, 15 Dec 2014 09:11:20 +0000 (10:11 +0100)]
Winter cleanup: move iio type field decoding out of utils.c

It's a very specialized function, which only makes sense in
the file where it's used. Let's not mix it with general
toolbox pieces.

Change-Id: I9915f380bd75394a4ea98a425a5fdcb0f287ebc6
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: remove superfluous volatile specifier
Patrick Porlan [Mon, 15 Dec 2014 09:07:26 +0000 (10:07 +0100)]
Winter cleanup: remove superfluous volatile specifier

It's not needed (at least on x86), so let's remove it.

Change-Id: Ib5aef13e4fd6db73df8e072ede7b8829706ba6b9
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoWinter cleanup: sensor_info[] -> sensor[]
Patrick Porlan [Mon, 15 Dec 2014 08:58:20 +0000 (09:58 +0100)]
Winter cleanup: sensor_info[] -> sensor[]

It makes code more legible, and is simply more logical.
Besides, it appears 374 times.

Change-Id: I1a9056b829569d159a7b23b24ceff0a1e9d796a6
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoBetter support for virtual sensors
Adriana Reus [Tue, 9 Dec 2014 07:07:08 +0000 (09:07 +0200)]
Better support for virtual sensors

Re-work for the gyro uncalibrated implementation. Instead from reading from the device directly it is now built on top of the 'real' sensor.
The re-work is more general and can be used to construct virtual sensors on top of real ones more easily.

Change-Id: Ife169e860674f3ceec1d22dbb4ac9db278d6762d
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoMerge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin...
Adriana Reus [Wed, 3 Dec 2014 14:38:54 +0000 (16:38 +0200)]
Merge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin/l-dev/master

git log --pretty=format:"%h %ad | %s%d [%an]" m/abt/topic/gmin/l-dev/master..origin/abt/topic/gmin/l-dev/sensors/master:
  819f41c Fri Nov 28 15:44:07 2014 +0200 | Additional calibration validation (origin/abt/topic/gmin/l-dev/sensors/master) [Adriana Reus]
  9616608 Wed Nov 26 12:45:28 2014 +0200 | Remove accel special case for managing timestamps [Adriana Reus]
  c6f0e4e Mon Nov 24 15:47:27 2014 +0200 | sens: fix server crash after stopping the poll client [Octavian Purdila]
  48e21a6 Mon Nov 24 13:33:53 2014 +0200 | sens: simplify the server dispatch routine [Octavian Purdila]
  9069fc7 Thu Nov 20 14:26:29 2014 +0200 | Fix Linux build [Octavian Purdila]
  615308b Thu Nov 20 15:22:43 2014 +0200 | sens: mark parameter as unused [Octavian Purdila]
  6fcd893 Thu Nov 20 15:21:22 2014 +0200 | sens: remove unused parameter in dispatch_cmd [Octavian Purdila]
  558ac66 Thu Nov 20 15:15:24 2014 +0200 | sens: trim command buffer [Octavian Purdila]
  b27f9ea Thu Nov 20 15:12:41 2014 +0200 | sens: use strncat and strncpy when composing the command buffer [Octavian Purdila]

git diff --stat m/abt/topic/gmin/l-dev/master..HEAD:
  calibration.h               |  1 +
  compass-calibration.c       | 33 +++++++++++++++-
  control.c                   |  5 +--
  linux/linux/android_alarm.h |  7 ++++
  linux/utils/Atomic.h        | 17 +++++++++
  sens.c                      | 93 +++++++++++++++++++++++++++------------------
  6 files changed, 115 insertions(+), 41 deletions(-)

Change-Id: Iacba7d2b91f1843d4ebb7db29b104103559389e9
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoAdditional calibration validation
Adriana Reus [Fri, 28 Nov 2014 13:44:07 +0000 (15:44 +0200)]
Additional calibration validation

Change-Id: I081391d086980bec97ae271ff89ecfce6ea8451f
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoRemove accel special case for managing timestamps
Adriana Reus [Wed, 26 Nov 2014 10:45:28 +0000 (12:45 +0200)]
Remove accel special case for managing timestamps

Change-Id: I966919ccae5144850279736af16df471bc1b38f2
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agosens: fix server crash after stopping the poll client
Octavian Purdila [Mon, 24 Nov 2014 13:47:27 +0000 (15:47 +0200)]
sens: fix server crash after stopping the poll client

If the poll client is stopped (killed) the server will crash due to
SIGPIPE. Fix this by intercepting SIGPIPE and clearing the client file
to avoid further prints to it.

Change-Id: I588b9c098634e2eb5cec9dd003e4f9a3be188c3f
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
9 years agosens: simplify the server dispatch routine
Octavian Purdila [Mon, 24 Nov 2014 11:33:53 +0000 (13:33 +0200)]
sens: simplify the server dispatch routine

Simplify the server dispatch routine so that it supports only one
command per connection. This also fixes the issue of not being able to
issue commands after poll.

Change-Id: I02932ca7c3aad0c6f46f80f547e8e515c085e763
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
9 years agoFix Linux build
Octavian Purdila [Thu, 20 Nov 2014 12:26:29 +0000 (14:26 +0200)]
Fix Linux build

Add Atomic.h and android_alarm.h stubs.

Change-Id: I5e044de52ab7ab5f8b68e3361f327adb61b5f3a0
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
9 years agosens: mark parameter as unused
Octavian Purdila [Thu, 20 Nov 2014 13:22:43 +0000 (15:22 +0200)]
sens: mark parameter as unused

Mark parameter of run_sensors_thread as unused, to silence compile
warnings.

Change-Id: I3b19445381c52f5e5bfef09ef3249f31e6a3f22d
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
9 years agosens: remove unused parameter in dispatch_cmd
Octavian Purdila [Thu, 20 Nov 2014 13:21:22 +0000 (15:21 +0200)]
sens: remove unused parameter in dispatch_cmd

We already assume that cmd is NULL terminated, so lets remove the unused
cmd_len. Add check to verify that the received command is NULL
terminated.

Change-Id: I1da3cdf8005b778d7e3e37fe7b2e3ca4b9322801
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
9 years agosens: trim command buffer
Octavian Purdila [Thu, 20 Nov 2014 13:15:24 +0000 (15:15 +0200)]
sens: trim command buffer

Right now we always send 1024 bytes for every command. We can trim the
buffer size to its length + 1 for the NULL terminator.

Change-Id: Ie707a607dd9e267e1dcbc47d97c42ab4816eab2c
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
9 years agosens: use strncat and strncpy when composing the command buffer
Octavian Purdila [Thu, 20 Nov 2014 13:12:41 +0000 (15:12 +0200)]
sens: use strncat and strncpy when composing the command buffer

Avoid buffer overflows when composing the command buffer by using
strncat and strncpy.

Change-Id: Ic0ad357168c230496e9358c877b7a01345cc53f3
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
9 years agoMerge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin...
Adriana Reus [Tue, 25 Nov 2014 15:48:27 +0000 (17:48 +0200)]
Merge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin/l-dev/master

git log --pretty=format:"%h %ad | %s%d [%an]" m/abt/topic/gmin/l-dev/master..origin/abt/topic/gmin/l-dev/sensors/master:
  9c98e64 Tue Nov 25 15:13:41 2014 +0100 | Don't use the timestamp channel in any-motion mode (origin/abt/topic/gmin/l-dev/sensors/master) [Patrick Porlan]
  3dd743f Tue Nov 25 09:50:10 2014 +0100 | Small timestamps fixes [Patrick Porlan]
  9cf6760 Mon Nov 24 15:17:49 2014 +0100 | Reinstate monotonic timestamp in data acquisition threads [Patrick Porlan]
  08e484e Mon Nov 24 14:40:16 2014 +0100 | Make sure the deadlines we set are interpreted in CLOCK_BOOTTIME [Patrick Porlan]
  00f369d Mon Nov 24 13:59:14 2014 +0100 | Recompute the boot to realtime delta at iio ts channel read time [Patrick Porlan]
  2fffc09 Mon Nov 24 11:52:50 2014 +0100 | Standardize timestamps on CLOCK_BOOTTIME [Patrick Porlan]
  281581c Fri Nov 21 17:58:37 2014 +0100 | Additional fixes to time stamps code [Patrick Porlan]
  416a770 Fri Nov 21 16:23:50 2014 +0100 | Correct timestamps read from the timestamp iio channel [Patrick Porlan]
  bbcca49 Fri Nov 21 11:53:15 2014 +0100 | Be more careful with the amount of data we read from the iio dev fd [Patrick Porlan]
  802446d Fri Nov 21 10:05:17 2014 +0100 | Moping the floor: hamonize comments delimiters [Patrick Porlan]
  8f338ec Fri Nov 21 10:01:21 2014 +0100 | Moping the floor: remove superfluous f type specifiers [Patrick Porlan]
  2effc32 Fri Nov 21 09:47:35 2014 +0100 | Shift gyro drop count from common.h to filtering.h [Patrick Porlan]
  aa74040 Mon Nov 17 17:43:53 2014 +0100 | Use the driver provided timestamp channel if possible [Patrick Porlan]
  77dea6d Tue Nov 18 16:46:22 2014 +0200 | Magnetometer ts improvements [Adriana Reus]
  48779ad Thu Nov 20 17:51:17 2014 +0200 | Populate quirks at enumeration [Adriana Reus]

git diff --stat m/abt/topic/gmin/l-dev/master..HEAD:
  common.h              |   6 +-
  compass-calibration.c |   8 ++-
  control.c             | 160 +++++++++++++++++++++++++++++++++++++++++++-------
  enumeration.c         |   3 +
  filtering.h           |   2 +
  gyro-calibration.c    |   2 +-
  transform.c           |  40 ++++++-------
  utils.c               |  43 +++++---------
  utils.h               |   8 +--
  9 files changed, 188 insertions(+), 84 deletions(-)

Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-4395
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Change-Id: I546ec0b54639511f90a7346b82969f055a3f1866

9 years agoDon't use the timestamp channel in any-motion mode
Patrick Porlan [Tue, 25 Nov 2014 14:13:41 +0000 (15:13 +0100)]
Don't use the timestamp channel in any-motion mode

That seems to create out of order timestamps issues in the
CTS Verifier Single Sensor Tests, and as it's a degraded, low
accuracy mode anyway, we are probably perfectly fine with the
usermode, HAL-level, timestamp.

Change-Id: I771c7e81916ae8ccf207ba3b213f9bc7525de362
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoSmall timestamps fixes
Patrick Porlan [Tue, 25 Nov 2014 08:50:10 +0000 (09:50 +0100)]
Small timestamps fixes

Swap the two clock_gettime calls we use to compute the offset
between realtime and boottime clock so there is no risk that
the timestamp appears in the future (e.g. if the calling thread
gets scheduled out between the calls).

Change-Id: Iad37015a873f7cf7c9b84d05a999eb42c0bb270a
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoReinstate monotonic timestamp in data acquisition threads
Patrick Porlan [Mon, 24 Nov 2014 14:17:49 +0000 (15:17 +0100)]
Reinstate monotonic timestamp in data acquisition threads

Only for the target time used by pthread routines though, as they
unfortunately don't seem to support the boot time clock.

Change-Id: I258d78c1c7e249f7bc3629ba864bee01a761cd57
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoMake sure the deadlines we set are interpreted in CLOCK_BOOTTIME
Patrick Porlan [Mon, 24 Nov 2014 13:40:16 +0000 (14:40 +0100)]
Make sure the deadlines we set are interpreted in CLOCK_BOOTTIME

By default pthread_cond_timedwait uses the monotonic time source.

Change-Id: I22acbe17ffc11fc936f362ec37e3f42499fe16d4
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoRecompute the boot to realtime delta at iio ts channel read time
Patrick Porlan [Mon, 24 Nov 2014 12:59:14 +0000 (13:59 +0100)]
Recompute the boot to realtime delta at iio ts channel read time

The RTC can be moved backward or forward at any time... err on
the side of safety, even if there are still potential issues with
this implementation (delay between kernel calls, possibility that
we get scheduled out, or that the clock is adjusted after the iio
buffer was stored...).

Change-Id: If1a517e8e2273ef479bd6095975df26d4aa4d2cd
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoStandardize timestamps on CLOCK_BOOTTIME
Patrick Porlan [Mon, 24 Nov 2014 10:52:50 +0000 (11:52 +0100)]
Standardize timestamps on CLOCK_BOOTTIME

That's time since boot, including sleep, and should match the CDD
5.0 requirement to sync with elapsedRealtimeNanos (which is what
we were doing anyway).

The iio timestamp channel provides timestamps based on the output
of iio_get_time_ns however, which is based on ktime_get_real_ns,
so we have no choice bu periodically recompute the difference
between these.

Change-Id: I1db6c1cea89d8507e1557412267d67756eba5749
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoAdditional fixes to time stamps code
Patrick Porlan [Fri, 21 Nov 2014 16:58:37 +0000 (17:58 +0100)]
Additional fixes to time stamps code

Looks like I did not commit exactly what I tested :)

Change-Id: Id5dddb2a8330a23ad0fac8aadcf5c0a6110c8bf1
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoCorrect timestamps read from the timestamp iio channel
Patrick Porlan [Fri, 21 Nov 2014 15:23:50 +0000 (16:23 +0100)]
Correct timestamps read from the timestamp iio channel

These use the realtime clock, whereas Android expects the
system clock to be used as reference.

Change-Id: I90cb68042a7519570bb97995920a15c03f136fb4
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoBe more careful with the amount of data we read from the iio dev fd
Patrick Porlan [Fri, 21 Nov 2014 10:53:15 +0000 (11:53 +0100)]
Be more careful with the amount of data we read from the iio dev fd

The iio drivers we have operate with a buffer length set at 2, and
can be set at larger sizes, however the current event integration
code path only handles a iio device report per loop.

For now, simply make sure we only read a single "scan", a.k.a. iio
device report, per loop. This could avoid dropping events if the
driver is producing them faster than we can consume them.

Change-Id: Ibfad7abbd445d6aae0345e2c828ca72c555c42ea
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoMoping the floor: hamonize comments delimiters
Patrick Porlan [Fri, 21 Nov 2014 09:05:17 +0000 (10:05 +0100)]
Moping the floor: hamonize comments delimiters

// is fine, and I like it, but I like consistency even more

Change-Id: I906c5adc00f4ebe1cbe46e69248a3c80a0aa9403
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoMoping the floor: remove superfluous f type specifiers
Patrick Porlan [Fri, 21 Nov 2014 09:01:21 +0000 (10:01 +0100)]
Moping the floor: remove superfluous f type specifiers

... as well as whitespaces, parentheses, etc.

Change-Id: I9f511420ae9dd783955e0f73d51e384712f98075
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoShift gyro drop count from common.h to filtering.h
Patrick Porlan [Fri, 21 Nov 2014 08:47:35 +0000 (09:47 +0100)]
Shift gyro drop count from common.h to filtering.h

Also, rename it with a more specific name.

Change-Id: Id87ad267b25949699cc29dcdd4cac28a5d572fbb
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoMerge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin...
Adriana Reus [Fri, 21 Nov 2014 08:27:51 +0000 (10:27 +0200)]
Merge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin/l-dev/master

git log --pretty=format:"%h %ad | %s%d [%an]" m/abt/topic/gmin/l-dev/master..origin/abt/topic/gmin/l-dev/sensors/master:
  222bad1 Thu Nov 20 15:30:26 2014 +0200 | Move defines to appropriate c files (origin/abt/topic/gmin/l-dev/sensors/master) [Adriana Reus]
  ca985fc Thu Nov 20 14:52:50 2014 +0200 | Don't setup an upper limit for the magnetometer sanity_norm [Adriana Reus]
  1fdbe72 Wed Nov 19 14:28:11 2014 +0100 | Warning removal round [Patrick Porlan]

git diff --stat m/abt/topic/gmin/l-dev/master..HEAD:
  calibration.h         | 24 ++++--------------------
  compass-calibration.c | 51 +++++++++++++++++++++++++++++----------------------
  description.c         |  2 +-
  entry.c               | 25 ++++++++++++++++---------
  enumeration.c         |  4 ++--
  gyro-calibration.c    |  5 +++++
  transform.c           |  2 +-
  7 files changed, 58 insertions(+), 55 deletions(-)

Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-4280
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Change-Id: Ifbca09ec6aa18eb8d45c8b41fb4fa1cd1cd36f2f

9 years agoUse the driver provided timestamp channel if possible
Patrick Porlan [Mon, 17 Nov 2014 16:43:53 +0000 (17:43 +0100)]
Use the driver provided timestamp channel if possible

There are several conditions though:
- a suitable iio channel is detected
- it can be enabled
- the scan report are of the expected size
- timestamps aren't nil

Change-Id: I7ee5aebd952225dacab170b9349640def4ddc892
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoMagnetometer ts improvements
Adriana Reus [Tue, 18 Nov 2014 14:46:22 +0000 (16:46 +0200)]
Magnetometer ts improvements

Attempt to better estimate timestamps for polling sensors.
Seems to slightly improve jitter on magnetometer, although
not in a very significant manner.

Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-4216
Change-Id: I29bf0f4c100f3072b0cca9f1564518c37939ce20
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Reviewed-on: https://android.intel.com:443/302236

9 years agoPopulate quirks at enumeration
Adriana Reus [Thu, 20 Nov 2014 15:51:17 +0000 (17:51 +0200)]
Populate quirks at enumeration

Currently quirks are populated when Android asks for activation.
This can be troublesome if we're enabling a virtual
sensor before the base sensor.

Change-Id: Ib988559a0e5e44767187380b928e7862adc40d4a
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Reviewed-on: https://android.intel.com:443/303492

9 years agoMove defines to appropriate c files
Adriana Reus [Thu, 20 Nov 2014 13:30:26 +0000 (15:30 +0200)]
Move defines to appropriate c files

Some clean-up

Change-Id: I5d04f329d0ee965ba6e9c943baf6682209922060
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoDon't setup an upper limit for the magnetometer sanity_norm
Adriana Reus [Thu, 20 Nov 2014 12:52:50 +0000 (14:52 +0200)]
Don't setup an upper limit for the magnetometer sanity_norm

CDD requires a minimum capability of 900 mT and this limits it.

Change-Id: I81596da46a944c4c99cd92498b72b2ebe914f19a
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoWarning removal round
Patrick Porlan [Wed, 19 Nov 2014 13:28:11 +0000 (14:28 +0100)]
Warning removal round

- mark unused parameters as such if we can't delete them
- delete truly unused parameters (ts in magneto calibration)

Change-Id: I9e1a17c962fb06f2ea08dc709ea4d295e4aaf70d
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
Reviewed-on: https://android.intel.com:443/302995

9 years agoMerge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin...
Adriana Reus [Mon, 17 Nov 2014 11:17:07 +0000 (13:17 +0200)]
Merge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin/l-dev/master

git log --pretty=format:"%h %ad | %s%d [%an]" m/abt/topic/gmin/l-dev/master..origin/abt/topic/gmin/l-dev/sensors/master:
  a60517d Mon Nov 17 12:41:39 2014 +0200 | Fix for broken indexes in compass calibration (origin/abt/topic/gmin/l-dev/sensors/master) [Adriana Reus]

git diff --stat m/abt/topic/gmin/l-dev/master..HEAD:
  compass-calibration.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)

Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-4125
Change-Id: Iacd7781f98f6bb6c4944b1edb8b7ec7ef8ebdc6a
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoFix for broken indexes in compass calibration
Adriana Reus [Mon, 17 Nov 2014 10:41:39 +0000 (12:41 +0200)]
Fix for broken indexes in compass calibration

My previous patch (Validate old cal_level) introduced an error
in the calibration level logic.

Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-4108
Change-Id: I159cc1d5330147333eb25501525773db78b57573
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoMerge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin...
Adriana Reus [Fri, 14 Nov 2014 16:42:29 +0000 (18:42 +0200)]
Merge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin/l-dev/master

git log --pretty=format:"%h %ad | %s%d [%an]" m/abt/topic/gmin/l-dev/master..origin/abt/topic/gmin/l-dev/sensors/master:
  bd8906e Fri Nov 14 16:31:49 2014 +0200 | Validate old cal_level (origin/abt/topic/gmin/l-dev/sensors/master) [Adriana Reus]
  41fef7b Fri Nov 14 16:33:42 2014 +0100 | GMINL-3234: Reduce magneto and gyro filter windows [Patrick Porlan]
  11fddd8 Fri Nov 14 15:43:44 2014 +0100 | GMINL-3234: Refactor a little bit our filtering code [Patrick Porlan]
  33fd15a Fri Nov 14 14:36:54 2014 +0100 | GMINL-3234: Reorganize filters a litle [Patrick Porlan]

git diff --stat m/abt/topic/gmin/l-dev/master..HEAD:
  compass-calibration.c |  16 +++--
  control.c             |  17 ++---
  enumeration.c         |   7 +-
  filtering.c           | 173 +++++++++++++++++++++++++++++++++++++++++++-------
  filtering.h           |  10 ++-
  transform.c           |  82 ++----------------------
  6 files changed, 176 insertions(+), 129 deletions(-)

Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-4053
Change-Id: Ic521c3932544e8e1b853570c9b6f226618f73172

9 years agoValidate old cal_level
Adriana Reus [Fri, 14 Nov 2014 14:31:49 +0000 (16:31 +0200)]
Validate old cal_level

In case we play with the cal level setting for a platform
it's best to check that the old one is not in fact outdated.
For example we lowered it for the ecs so the check is to make
sure this takes effect in case of an OTA update for example.

Change-Id: I78cba3722edd15ca23dc5f8c75bd8f0eef74d50e
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoGMINL-3234: Reduce magneto and gyro filter windows
Patrick Porlan [Fri, 14 Nov 2014 15:33:42 +0000 (16:33 +0100)]
GMINL-3234: Reduce magneto and gyro filter windows

Use 20 samples for the magnetometer moving average, rather than
the previous 30. I believe that reduces latency that the camera
is sensitive to.

Also reduce the median filter set to 5 samples, rather than 7,
in the goal of increasing the "freshness" of gyro readings, with
an increase of noise level though.

At some point in the future we should make these per-sensor params.

Change-Id: I772c1fb720b5a1ebd9ed3d376bb038a1d0fed615
Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-3234
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoGMINL-3234: Refactor a little bit our filtering code
Patrick Porlan [Fri, 14 Nov 2014 14:43:44 +0000 (15:43 +0100)]
GMINL-3234: Refactor a little bit our filtering code

filtering.h has a simpler interface now, and filtering structures
are now uniformly allocated/cleaned on enable/disable, for sensors
marked as noisy.

This paves the way for per-sensor filter type and parameters.

Change-Id: I1e867570e79c3a56bac0734307a023c1101bb826
Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-3234
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoGMINL-3234: Reorganize filters a litle
Patrick Porlan [Fri, 14 Nov 2014 13:36:54 +0000 (14:36 +0100)]
GMINL-3234: Reorganize filters a litle

The moving average filter has a new home: was transform.c, now
filtering.c, with a new name also.

Change-Id: I9670dc687f883bba205ee2525ff364d628d54828
Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-3234
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
9 years agoMerge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin...
Adriana Reus [Thu, 13 Nov 2014 13:18:55 +0000 (15:18 +0200)]
Merge remote-tracking branch 'origin/abt/topic/gmin/l-dev/sensors/master' into gmin/l-dev/master

git log --pretty=format:"%h %ad | %s%d [%an]" m/abt/topic/gmin/l-dev/master..origin/abt/topic/gmin/l-dev/sensors/master:
  55a8356 Wed Nov 12 17:53:07 2014 +0100 | GMINL-3234: Temporarily remove uncalibrated gyroscope (origin/abt/topic/gmin/l-dev/sensors/master) [Patrick Porlan]
  89dc581 Wed Nov 12 15:02:07 2014 +0100 | GMINL-3234: Allow for a minimal sensor sampling rate [Patrick Porlan]
  e66ecb2 Tue Nov 11 18:21:14 2014 +0200 | Compass calibration minor fixes [Adriana Reus]
  f2f754d Wed Nov 12 14:56:28 2014 +0100 | GMINL-3234: Tweak magneto filter window size [Patrick Porlan]
  0813206 Tue Nov 11 12:37:29 2014 +0200 | Configurable calibration steps [Adriana Reus]
  fdb0f76 Mon Nov 10 19:56:36 2014 +0200 | Don't let the timestamp get too far behind [Adriana Reus]

git diff --stat m/abt/topic/gmin/l-dev/master..HEAD:
  common.h              |  3 +++
  compass-calibration.c | 16 ++++++++++++++--
  control.c             |  4 ++++
  description.c         | 36 +++++++++++++++++++++++++++++++++++-
  description.h         |  1 +
  enumeration.c         | 10 ++++++++--
  transform.c           |  2 +-
  7 files changed, 66 insertions(+), 6 deletions(-)

Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-4014
Change-Id: Ib0eb72773199038832c11be6024e7c0c1e3ee09c
Signed-off-by: Adriana Reus <adriana.reus@intel.com>
9 years agoGMINL-3234: Temporarily remove uncalibrated gyroscope
Patrick Porlan [Wed, 12 Nov 2014 16:53:07 +0000 (17:53 +0100)]
GMINL-3234: Temporarily remove uncalibrated gyroscope

The camera app seem to be opening both gyros during panorama
creation, and I suspect that this is causing problems, even
though I can't confirm it, and I don't understand why. As
this sensor type is simply a nice-to-have, I prefer disabling
it pending further investigation.

Change-Id: I01b6324fb8c0e3d01c1dbc71096bee17e766c333
Tracked-On: https://jira01.devtools.intel.com/browse/GMINL-3234
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>