aboutsummaryrefslogtreecommitdiff
path: root/sensors/CalibrationModule.h
blob: 1226c24caf1c8d86222bc4adb0c8d9d8ac32e339 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*--------------------------------------------------------------------------
Copyright (c) 2014, The Linux Foundation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.
    * Neither the name of The Linux Foundation nor the names of its
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------*/

#ifndef _SENSOR_CAL_H
#define _SENSOR_CAL_H

#include <sys/cdefs.h>
#include <hardware/hardware.h>
#include <hardware/sensors.h>

__BEGIN_DECLS

#define ACCELEROMETER_NAME	"accelerometer"
#define COMPASS_NAME		"compass"
#define ORIENTATION_NAME	"orientation"
#define GYROSCOPE_NAME		"gyroscope"
#define LIGHT_NAME		"light"
#define PRESSURE_NAME		"pressure"
#define TEMPERATURE_NAME	"temperature"
#define PROXIMITY_NAME		"proximity"
#define GRAVITY_NAME		"gravity"
#define LINEAR_ACCELERATION_NAME	"liner_acceleration"
#define ROTATION_VECTOR_NAME	"rotation_vector"
#define RELATIVE_HUMIDITY_NAME	"relative_humidity"
#define AMBIENT_TEMPERATURE_NAME	"ambient_temperature"
#define MAGNETIC_FIELD_UNCALIBRATED_NAME	"magnetic_field_uncalibrated"
#define GAME_ROTATION_VECTOR_NAME	"game_rotation_vector"
#define GYROSCOPE_UNCALIBRATED_NAME	"gyroscope_uncalibrated"
#define SIGNIFICANT_MOTION_NAME		"significant_motion"
#define STEP_COUNTER_NAME		"step_counter"
#define STEP_DETECTOR_NAME		"step_detector"
#define GEOMAGNETIC_ROTATION_VECTOR_NAME	"geomagnetic_field"

/* TAG for the module. Should be "scmt" */
#define SENSOR_CAL_MODULE_TAG	0x746d6373
#define SENSOR_CAL_ALGO_TAG	0x74616373

/* Super symbol of the calibration lib */
#define SENSOR_CAL_MODULE_INFO	scmi
#define SENSOR_CAL_MODULE_INFO_AS_STR	"scmi"

#define SENSOR_CAL_MODULE_VERSION	1

enum {
	CMD_ENABLE = 0, /* Enable status changed */
	CMD_DELAY, /* Polling rate changed */
	CMD_BATCH, /* Batching parameter changed */
};

struct sensor_cal_algo_t;
struct sensor_cal_module_t;

struct sensor_algo_args {
	int enable;
	int delay_ms;
};

struct compass_algo_args {
	struct sensor_algo_args common;
	uint32_t reserved[16];
};

struct sensor_algo_methods_t {
	int (*convert)(sensors_event_t *raw, sensors_event_t *result, struct sensor_algo_args *args);
	/* Note that the config callback is called from a different thread as convert */
	int (*config)(int cmd, struct sensor_algo_args *args);
};

struct sensor_cal_methods_t {
	int (*init)(const struct sensor_cal_module_t* module);
	void (*deinit)();
	/* Return 0 on success */
	int (*get_algo_list)(const struct sensor_cal_algo_t **algo);
};

struct sensor_cal_algo_t {
	/* Tag of the algo */
	int		tag;
	/* Version of the algo */
	int		version;
	/* Type of sensor this algo supported*/
	int		type;
	/* The compatible sensors */
	const char	**compatible;
	/* Sensor calibration module */
	struct sensor_cal_module_t	*module;
	/* Sensor algo methods */
	struct sensor_algo_methods_t	*methods;
};

struct sensor_cal_module_t {
	/* Tag of the module */
	uint32_t	tag;
	/* Id of the module */
	char		*id;
	/* Version of the calibration module */
	uint32_t	version;
	/* Vendor of the calibration lib */
	char		*vendor;
	/* Point to the handle of this module */
	void		*dso;
	/* Number of algos */
	uint32_t	number;
	/* Callbacks of the calibration lib provided */
	struct sensor_cal_methods_t	*methods;
	/* The compatible sensors list for this library */
	int		reserved[6];
};

__END_DECLS
#endif