/* * (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 */ #include #define MAX_AXIS_REMAP_TAB_SZ 8 /*P0~P7*/ static const struct bosch_sensor_axis_remap bst_axis_remap_tab_dft[MAX_AXIS_REMAP_TAB_SZ] = { /* src_x src_y src_z sign_x sign_y sign_z */ { 0, 1, 2, 1, 1, 1 }, /* P0 */ { 1, 0, 2, 1, -1, 1 }, /* P1 */ { 0, 1, 2, -1, -1, 1 }, /* P2 */ { 1, 0, 2, -1, 1, 1 }, /* P3 */ { 0, 1, 2, -1, 1, -1 }, /* P4 */ { 1, 0, 2, -1, -1, -1 }, /* P5 */ { 0, 1, 2, 1, -1, -1 }, /* P6 */ { 1, 0, 2, 1, 1, -1 }, /* P7 */ }; void bst_remap_sensor_data(struct bosch_sensor_data *data, const struct bosch_sensor_axis_remap *remap) { struct bosch_sensor_data tmp; tmp.x = data->v[remap->src_x] * remap->sign_x; tmp.y = data->v[remap->src_y] * remap->sign_y; tmp.z = data->v[remap->src_z] * remap->sign_z; memcpy(data, &tmp, sizeof(*data)); } EXPORT_SYMBOL(bst_remap_sensor_data); void bst_remap_sensor_data_dft_tab(struct bosch_sensor_data *data, int place) { /* sensor with place 0 needs not to be remapped */ if ((place <= 0) || (place >= MAX_AXIS_REMAP_TAB_SZ)) return; bst_remap_sensor_data(data, &bst_axis_remap_tab_dft[place]); } EXPORT_SYMBOL(bst_remap_sensor_data_dft_tab); MODULE_LICENSE("GPL");