mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-11 05:17:10 +09:00
add boardconfig for gsensor orientation
This commit is contained in:
@@ -477,6 +477,10 @@ static int mma8452_init_platform_hw(void)
|
||||
static struct mma8452_platform_data mma8452_info = {
|
||||
.model= 8452,
|
||||
.swap_xy = 0,
|
||||
.swap_xyz = 1,
|
||||
.orientation = {0,1,0,
|
||||
0,0,-1,
|
||||
1,0,0},
|
||||
.init_platform_hw= mma8452_init_platform_hw,
|
||||
|
||||
};
|
||||
|
||||
@@ -184,6 +184,8 @@ struct synaptics_platform_data {
|
||||
struct mma8452_platform_data {
|
||||
u16 model;
|
||||
u16 swap_xy;
|
||||
u16 swap_xyz;
|
||||
signed char orientation[9];
|
||||
int (*get_pendown_state)(void);
|
||||
int (*init_platform_hw)(void);
|
||||
int (*mma8452_platform_sleep)(void);
|
||||
|
||||
@@ -358,6 +358,7 @@ static int mma8452_get_data(struct i2c_client *client)
|
||||
struct mma8452_data* mma8452 = i2c_get_clientdata(client);
|
||||
char buffer[6];
|
||||
int ret;
|
||||
int x,y,z;
|
||||
struct mma8452_axis axis;
|
||||
struct mma8452_platform_data *pdata = pdata = client->dev.platform_data;
|
||||
|
||||
@@ -371,11 +372,22 @@ static int mma8452_get_data(struct i2c_client *client)
|
||||
} while (0);
|
||||
|
||||
mmaprintkd("0x%02x 0x%02x 0x%02x \n",buffer[0],buffer[1],buffer[2]);
|
||||
|
||||
x = mma8452_convert_to_int(buffer[0]);
|
||||
y = mma8452_convert_to_int(buffer[1]);
|
||||
z = mma8452_convert_to_int(buffer[2]);
|
||||
|
||||
axis.x = mma8452_convert_to_int(buffer[0]);
|
||||
axis.y = mma8452_convert_to_int(buffer[1]);
|
||||
axis.z = mma8452_convert_to_int(buffer[2]);
|
||||
|
||||
if (pdata->swap_xyz) {
|
||||
axis.x = (pdata->orientation[0])*x + (pdata->orientation[1])*y + (pdata->orientation[2])*z;
|
||||
axis.y = (pdata->orientation[3])*x + (pdata->orientation[4])*y + (pdata->orientation[5])*z;
|
||||
axis.z = (pdata->orientation[6])*x + (pdata->orientation[7])*y + (pdata->orientation[8])*z;
|
||||
}
|
||||
else {
|
||||
axis.x = x;
|
||||
axis.y = y;
|
||||
axis.z = z;
|
||||
}
|
||||
|
||||
if(pdata->swap_xy)
|
||||
{
|
||||
axis.y = -axis.y;
|
||||
|
||||
Reference in New Issue
Block a user