add boardconfig for gsensor orientation
authorlyx <lyx@rock-chips.com>
Tue, 24 May 2011 08:49:21 +0000 (01:49 -0700)
committerlyx <lyx@rock-chips.com>
Wed, 25 May 2011 04:36:14 +0000 (21:36 -0700)
arch/arm/mach-rk29/board-rk29-a22.c
arch/arm/mach-rk29/include/mach/board.h
drivers/input/gsensor/mma8452.c

index 3044a2af0dc828e103881331c996c38cd4785006..aa0116d6996cc6fd5d989aa02e5d530c9400f763 100755 (executable)
@@ -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,
 
 };
index 7d3654e176ddff418236fa23569938be72d1d29c..a761ee53520e02d8c2d5959edeb77de3b8e83048 100755 (executable)
@@ -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);
index ffa42b1aba9804dd0f9d81af91197373f082cf44..cbcf6f5f4ecfaa8927438ba0b5ecea6827d2a187 100755 (executable)
@@ -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]);
-
-       axis.x = mma8452_convert_to_int(buffer[0]);
-       axis.y = mma8452_convert_to_int(buffer[1]);
-       axis.z = mma8452_convert_to_int(buffer[2]);
-
+       
+       x = mma8452_convert_to_int(buffer[0]);
+       y = mma8452_convert_to_int(buffer[1]);
+       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;