diff options
| author | Yuval Adam <_@yuv.al> | 2017-08-30 08:25:59 +0000 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2017-08-30 08:25:59 +0000 |
| commit | 8e4bff4cab0ddac6060645b0715210484d02ff40 (patch) | |
| tree | 3a5c3024371a04692a3a6d9974d001cdff8ebf84 /include/linux/bst_sensor_common.h | |
Diffstat (limited to 'include/linux/bst_sensor_common.h')
| -rw-r--r-- | include/linux/bst_sensor_common.h | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/include/linux/bst_sensor_common.h b/include/linux/bst_sensor_common.h new file mode 100644 index 00000000..9d27bae3 --- /dev/null +++ b/include/linux/bst_sensor_common.h @@ -0,0 +1,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 |
