The Dynamic Android Sensor HAL
Clone or download
Pull request Compare This branch is 9 commits ahead, 18 commits behind sonyxperiadev:master.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Add AK09911/AK09912 modules and OSS orientation sensor module. Jan 16, 2015
libs Add oss library. Jan 16, 2015
sensors Add AK09911/AK09912 modules and OSS orientation sensor module. Jan 16, 2015
test Initial commit Jun 13, 2012
Android.mk Use environmental variable for build module name. Dec 30, 2014
NOTICE Initial commit Jun 13, 2012
README Fix typos and spelling mistakes in README May 31, 2013
sensor_api.h Initial commit Jun 13, 2012
sensors_config.c Rename log macros for Jelly Bean support Aug 13, 2012
sensors_config.h Initial commit Jun 13, 2012
sensors_fifo.c Add header to clear license and copyright. Jan 16, 2015
sensors_fifo.h Initial commit Jun 13, 2012
sensors_id.h Add new sensors HANDLE for KK. Dec 30, 2014
sensors_input_cache.c Add header to clear license and copyright. Jan 16, 2015
sensors_input_cache.h Add header to clear license and copyright. Jan 16, 2015
sensors_list.c Rename log macros for Jelly Bean support Aug 13, 2012
sensors_list.h Initial commit Jun 13, 2012
sensors_log.h Rename log macros for Jelly Bean support Aug 13, 2012
sensors_module.c Set version number of sensor module. Dec 30, 2014
sensors_select.c Suppress DEBUG log message. Dec 30, 2014
sensors_select.h Initial commit Jun 13, 2012
sensors_sysfs.c Clarify dash module log name. Jan 16, 2015
sensors_sysfs.h Add header to clear license and copyright. Jan 16, 2015
sensors_worker.c Fix sensors_worker for big delays. Oct 18, 2012
sensors_worker.h Initial commit Jun 13, 2012
sensors_wrapper.c Clarify dash module log name. Jan 16, 2015
sensors_wrapper.h sensors_wrapper: move NO_RATE to header file Oct 1, 2012

README

		Dynamic Android Sensor HAL
		      D * A * S * H

Copyright (C) Sony Mobile Communications 2012


Table of contents
-----------------

1 ............ Description
2 ............ File overview
3 ............ License


1 Description
-------------

This sensor HAL implementation makes it possible to use one generic piece
of code to satisfy multiple product requirements. By adding the possibility
to enable sensors at compile-time it's simply a matter of specifying which
sensors the product uses.

The implementation also adds support for configuring the sensors at run-time
using a configuration file. This makes it possible to, e.g. set PCB mounting
coordinates of the sensors.

The DASH is the only sensor HAL implementation that is needed and hence the
maintenance work is kept to a minimal.


2 File overview
---------------

2.1 Control
File: sensors_module.c

This file implements the sensor HAL interface. It traverses the enabled sensors
and routes incoming requests to the right sensor.


2.2 Sensor list
File: sensors_list.c

Each sensor registers to this list at linking of the library using gcc
constructors. This makes it possible to decide at compile-time which sensors
should be supported.

The module provides an interface for fetching and iterating over sensors.


2.3 Sensor API
File: sensor_api.h

This defines the abstraction of a sensor. A sensor supports: init, activate,
set_delay and close.


2.4 Sensor implementations
File: sensors/*.c

Each sensor is an implementation of the sensor abstraction (see Sensor API).

At startup of the library each sensor implementation has to register to the
sensor list (see Sensor list). This is done using the macro list_constructor().

Each sensor implementation will create a thread using either a sensor worker
(see Polling sensor) or a select thread (see Interrupt driven sensor).

When data has been collected it is written to the FIFO by issuing a
sensors_fifo_put-call.

In the file sensor_util.c some generic helper functions have been gathered.


2.5 Polling sensor
File: sensors_worker.c

A polling sensor implementation has to own its own thread since each sensor
can run at a different poll rate. A thread is created by instantiating a sensor
worker using sensors_worker_init().

The sensors_worker will then call the provided work_func at the delay specified
by the set_delay()-call.


2.6 Interrupt driven sensor
File: sensors_select.c

An interrupt-driven sensor can report data when it gets an interrupt that there
is new data to be collected. This can save some clock cycles and battery time.

By instantiating a sensors_select-worker by calling sensors_select_init(), one
will get a call to the select_func when there is new data to be read on the
provided file descriptor.


2.7 Sensor config
File: sensors_config.c

This module can be used by the sensor implementations to read configuration
parameters from a file.

Each parameter should have the following format:
<sensor name>_<parameter name> = <value>

A sensor implementation reads out the value with the function
sensors_config_get_key().


2.8 Some utility stuff
File: sensors/sensor_util.c

In the file sensor_util there is some code to be used by the sensor
implementations. It contains code for transforming coordinates and some
functions for reading time.


2.9 Vendor libraries
Directory: libs/

Some sensors need vendor libraries to calibrate their output. These will
be put in the libs directory.


2.10 ASCII Design

       A N D R O I D
------------------------------------------------------------
			  |
                   +---------------+
		   | sensors_module|
		   +---------------+
		          |
		     +------------+
		     |sensors_list|
		     +------------+		 +--------+
		      /          \ 		 | Vendor |
		  +--------+       +--------+	 | libs   |
		  |sensor 1|  ...  |sensor N| -- |	  |
		  +--------+       +--------+    |	  |
		      |                |	 +--------+
------------------------------------------------------------
       L I N U X

		+------------+       +------------+
		|sensor dev 1|  ...  |sensor dev N|
		+------------+       +------------+


3 License
---------

The license for all code in this project is specified in the NOTICE file.
Please refer to this file for further details.