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
|
/*
* (C) Copyright 2013 Bosch Sensortec GmbH * All Rights Reserved
*
* This software program is licensed subject to the GNU General Public License
* (GPL).Version 2,June 1991, available at http://www.fsf.org/copyleft/gpl.html
*
* @date Sep 19th, 2012
* @version v1.0
* @brief Common APIs for Bosch MEMS sensor drivers
*/
#ifndef __BOSCH_SENSOR_COMMON_H
#define __BOSCH_SENSOR_COMMON_H
#ifdef __KERNEL__
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/unistd.h>
#include <linux/types.h>
#include <linux/string.h>
#else
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#endif
/*!
* @Description:
* definitions of placement of sensors
* P0 - P3: view from top of device
* P4 - P7: view from bottom of device
*
* P0 / P4:
* Y of device aligned with Y of OS (i.e: Android)
* y
* ^
* |
* |
* |
* o------> x
*
*
* P1 / P5:
* Y of device aligned with Y of OS (i.e.: Android)
* rotated by 90 degrees clockwise
*
* o------> y
* |
* |
* |
* v x
*
*
* P2 / P6:
* Y of device aligned with Y of OS (i.e.: Android)
* rotated by 180 degrees clockwise
*
* x <------o
* |
* |
* |
* v
* y
*
*
* P3 / P7:
* Y of device aligned with Y of OS (i.e.: Android)
* rotated by 270 degrees clockwise
*
* x
* ^
* |
* |
* |
* y <------o
*
*/
struct bosch_sensor_specific {
char *name;
/* 0 to 7 */
unsigned int place:3;
int irq;
};
/*!
* we use a typedef to hide the detail,
* because this type might be changed
*/
struct bosch_sensor_axis_remap {
/* src means which source will be mapped to target x, y, z axis */
/* if an target OS axis is remapped from (-)x,
* src is 0, sign_* is (-)1 */
/* if an target OS axis is remapped from (-)y,
* src is 1, sign_* is (-)1 */
/* if an target OS axis is remapped from (-)z,
* src is 2, sign_* is (-)1 */
int src_x:3;
int src_y:3;
int src_z:3;
int sign_x:2;
int sign_y:2;
int sign_z:2;
};
struct bosch_sensor_data {
union {
int32_t v[3];
struct {
int32_t x;
int32_t y;
int32_t z;
};
};
};
void bst_remap_sensor_data(struct bosch_sensor_data *data,
const struct bosch_sensor_axis_remap *remap);
void bst_remap_sensor_data_dft_tab(struct bosch_sensor_data *data,
int place);
#define BOSCH_SENSOR_PLACE_UNKNOWN (-1)
#endif
|