Add support for InvenSense mpu3050/6000 Gyroscope chip

The driver is used to support gyroscope device, and it provides an interface to 
control accelerometer and e-compass (optional).

The driver also provides sysfs and input event for Meego's sensor framework.

Based on linux-kernel-2.6.35 doesn't have support for gyroscope device, would 
Meego accept this patch into mid-ref tree?


Signed-off-by: Joseph, Lai <[email protected]>

Index: linux-2.6.35/include/linux/mpu3050.h
===================================================================
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.35/include/linux/mpu3050.h        2010-12-22 14:09:28.000000000 
+0800
@@ -0,0 +1,256 @@
+
+/*
+ $License:
+    Copyright (C) 2010 InvenSense Corporation, All Rights Reserved.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  $
+ */
+
+#ifndef __MPU3050_H_
+#define __MPU3050_H_
+
+#ifdef __KERNEL__
+#include <linux/types.h>
+#endif
+
+#ifdef M_HW
+#error MPU6000 build including MPU3050 header
+#endif
+
+#define MPU_NAME "mpu3050"
+#define DEFAULT_MPU_SLAVEADDR       0x68
+
+/*==== MPU REGISTER SET ====*/
+enum mpu_register {
+       MPUREG_WHO_AM_I = 0,    /* 00 0x00 */
+       MPUREG_PRODUCT_ID,      /* 01 0x01 */
+       MPUREG_02_RSVD,         /* 02 0x02 */
+       MPUREG_03_RSVD,         /* 03 0x03 */
+       MPUREG_04_RSVD,         /* 04 0x04 */
+       MPUREG_XG_OFFS_TC,      /* 05 0x05 */
+       MPUREG_06_RSVD,         /* 06 0x06 */
+       MPUREG_07_RSVD,         /* 07 0x07 */
+       MPUREG_YG_OFFS_TC,      /* 08 0x08 */
+       MPUREG_09_RSVD,         /* 09 0x09 */
+       MPUREG_0A_RSVD,         /* 10 0x0a */
+       MPUREG_ZG_OFFS_TC,      /* 11 0x0b */
+       MPUREG_X_OFFS_USRH,     /* 12 0x0c */
+       MPUREG_X_OFFS_USRL,     /* 13 0x0d */
+       MPUREG_Y_OFFS_USRH,     /* 14 0x0e */
+       MPUREG_Y_OFFS_USRL,     /* 15 0x0f */
+       MPUREG_Z_OFFS_USRH,     /* 16 0x10 */
+       MPUREG_Z_OFFS_USRL,     /* 17 0x11 */
+       MPUREG_FIFO_EN1,        /* 18 0x12 */
+       MPUREG_FIFO_EN2,        /* 19 0x13 */
+       MPUREG_AUX_SLV_ADDR,    /* 20 0x14 */
+       MPUREG_SMPLRT_DIV,      /* 21 0x15 */
+       MPUREG_DLPF_FS_SYNC,    /* 22 0x16 */
+       MPUREG_INT_CFG,         /* 23 0x17 */
+       MPUREG_ACCEL_BURST_ADDR,/* 24 0x18 */
+       MPUREG_19_RSVD,         /* 25 0x19 */
+       MPUREG_INT_STATUS,      /* 26 0x1a */
+       MPUREG_TEMP_OUT_H,      /* 27 0x1b */
+       MPUREG_TEMP_OUT_L,      /* 28 0x1c */
+       MPUREG_GYRO_XOUT_H,     /* 29 0x1d */
+       MPUREG_GYRO_XOUT_L,     /* 30 0x1e */
+       MPUREG_GYRO_YOUT_H,     /* 31 0x1f */
+       MPUREG_GYRO_YOUT_L,     /* 32 0x20 */
+       MPUREG_GYRO_ZOUT_H,     /* 33 0x21 */
+       MPUREG_GYRO_ZOUT_L,     /* 34 0x22 */
+       MPUREG_23_RSVD,         /* 35 0x23 */
+       MPUREG_24_RSVD,         /* 36 0x24 */
+       MPUREG_25_RSVD,         /* 37 0x25 */
+       MPUREG_26_RSVD,         /* 38 0x26 */
+       MPUREG_27_RSVD,         /* 39 0x27 */
+       MPUREG_28_RSVD,         /* 40 0x28 */
+       MPUREG_29_RSVD,         /* 41 0x29 */
+       MPUREG_2A_RSVD,         /* 42 0x2a */
+       MPUREG_2B_RSVD,         /* 43 0x2b */
+       MPUREG_2C_RSVD,         /* 44 0x2c */
+       MPUREG_2D_RSVD,         /* 45 0x2d */
+       MPUREG_2E_RSVD,         /* 46 0x2e */
+       MPUREG_2F_RSVD,         /* 47 0x2f */
+       MPUREG_30_RSVD,         /* 48 0x30 */
+       MPUREG_31_RSVD,         /* 49 0x31 */
+       MPUREG_32_RSVD,         /* 50 0x32 */
+       MPUREG_33_RSVD,         /* 51 0x33 */
+       MPUREG_34_RSVD,         /* 52 0x34 */
+       MPUREG_DMP_CFG_1,       /* 53 0x35 */
+       MPUREG_DMP_CFG_2,       /* 54 0x36 */
+       MPUREG_BANK_SEL,        /* 55 0x37 */
+       MPUREG_MEM_START_ADDR,  /* 56 0x38 */
+       MPUREG_MEM_R_W,         /* 57 0x39 */
+       MPUREG_FIFO_COUNTH,     /* 58 0x3a */
+       MPUREG_FIFO_COUNTL,     /* 59 0x3b */
+       MPUREG_FIFO_R_W,        /* 60 0x3c */
+       MPUREG_USER_CTRL,       /* 61 0x3d */
+       MPUREG_PWR_MGM,         /* 62 0x3e */
+       MPUREG_3F_RSVD,         /* 63 0x3f */
+       NUM_OF_MPU_REGISTERS    /* 64 0x40 */
+};
+
+/*==== BITS FOR MPU ====*/
+
+/*---- MPU 'FIFO_EN1' register (12) ----*/
+#define BIT_TEMP_OUT                0x80
+#define BIT_GYRO_XOUT               0x40
+#define BIT_GYRO_YOUT               0x20
+#define BIT_GYRO_ZOUT               0x10
+#define BIT_ACCEL_XOUT              0x08
+#define BIT_ACCEL_YOUT              0x04
+#define BIT_ACCEL_ZOUT              0x02
+#define BIT_AUX_1OUT                0x01
+/*---- MPU 'FIFO_EN2' register (13) ----*/
+#define BIT_AUX_2OUT                0x02
+#define BIT_AUX_3OUT                0x01
+/*---- MPU 'DLPF_FS_SYNC' register (16) ----*/
+#define BITS_EXT_SYNC_NONE          0x00
+#define BITS_EXT_SYNC_TEMP          0x20
+#define BITS_EXT_SYNC_GYROX         0x40
+#define BITS_EXT_SYNC_GYROY         0x60
+#define BITS_EXT_SYNC_GYROZ         0x80
+#define BITS_EXT_SYNC_ACCELX        0xA0
+#define BITS_EXT_SYNC_ACCELY        0xC0
+#define BITS_EXT_SYNC_ACCELZ        0xE0
+#define BITS_EXT_SYNC_MASK          0xE0
+#define BITS_FS_250DPS              0x00
+#define BITS_FS_500DPS              0x08
+#define BITS_FS_1000DPS             0x10
+#define BITS_FS_2000DPS             0x18
+#define BITS_FS_MASK                0x18
+#define BITS_DLPF_CFG_256HZ_NOLPF2  0x00
+#define BITS_DLPF_CFG_188HZ         0x01
+#define BITS_DLPF_CFG_98HZ          0x02
+#define BITS_DLPF_CFG_42HZ          0x03
+#define BITS_DLPF_CFG_20HZ          0x04
+#define BITS_DLPF_CFG_10HZ          0x05
+#define BITS_DLPF_CFG_5HZ           0x06
+#define BITS_DLPF_CFG_2100HZ_NOLPF  0x07
+#define BITS_DLPF_CFG_MASK          0x07
+/*---- MPU 'INT_CFG' register (17) ----*/
+#define BIT_ACTL                    0x80
+#define BIT_ACTL_LOW                0x80
+#define BIT_ACTL_HIGH               0x00
+#define BIT_OPEN                    0x40
+#define BIT_OPEN_DRAIN              0x40
+#define BIT_PUSH_PULL               0x00
+#define BIT_LATCH_INT_EN            0x20
+#define BIT_LATCH_INT_EN            0x20
+#define BIT_INT_PULSE_WIDTH_50US    0x00
+#define BIT_INT_ANYRD_2CLEAR        0x10
+#define BIT_INT_STAT_READ_2CLEAR    0x00
+#define BIT_MPU_RDY_EN              0x04
+#define BIT_DMP_INT_EN              0x02
+#define BIT_RAW_RDY_EN              0x01
+/*---- MPU 'INT_STATUS' register (1A) ----*/
+#define BIT_INT_STATUS_FIFO_OVERLOW 0x80
+#define BIT_MPU_RDY                 0x04
+#define BIT_DMP_INT                 0x02
+#define BIT_RAW_RDY                 0x01
+/*---- MPU 'BANK_SEL' register (37) ----*/
+#define BIT_PRFTCH_EN               0x20
+#define BIT_CFG_USER_BANK           0x10
+#define BITS_MEM_SEL                0x0f
+/*---- MPU 'USER_CTRL' register (3D) ----*/
+#define BIT_DMP_EN                  0x80
+#define BIT_FIFO_EN                 0x40
+#define BIT_AUX_IF_EN               0x20
+#define BIT_AUX_RD_LENG             0x10
+#define BIT_AUX_IF_RST              0x08
+#define BIT_DMP_RST                 0x04
+#define BIT_FIFO_RST                0x02
+#define BIT_GYRO_RST                0x01
+/*---- MPU 'PWR_MGM' register (3E) ----*/
+#define BIT_H_RESET                 0x80
+#define BIT_SLEEP                   0x40
+#define BIT_STBY_XG                 0x20
+#define BIT_STBY_YG                 0x10
+#define BIT_STBY_ZG                 0x08
+#define BITS_CLKSEL                 0x07
+
+/*---- MPU Silicon Revision ----*/
+#define MPU_SILICON_REV_A4           1 /* MPU A4 Device */
+#define MPU_SILICON_REV_B1           2 /* MPU B1 Device */
+#define MPU_SILICON_REV_B4           3 /* MPU B4 Device */
+#define MPU_SILICON_REV_B6           4 /* MPU B6 Device */
+
+/*---- MPU Memory ----*/
+#define MPU_MEM_BANK_SIZE           (256)
+#define FIFO_HW_SIZE                (512)
+
+enum MPU_MEMORY_BANKS {
+       MPU_MEM_RAM_BANK_0 = 0,
+       MPU_MEM_RAM_BANK_1,
+       MPU_MEM_RAM_BANK_2,
+       MPU_MEM_RAM_BANK_3,
+       MPU_MEM_NUM_RAM_BANKS,
+       MPU_MEM_OTP_BANK_0 = MPU_MEM_NUM_RAM_BANKS,
+       /* This one is always last */
+       MPU_MEM_NUM_BANKS
+};
+
+#define MPU_NUM_AXES (3)
+
+/*---- structure containing control variables used by MLDL ----*/
+/*---- MPU clock source settings ----*/
+/*---- MPU filter selections ----*/
+enum mpu_filter {
+       MPU_FILTER_256HZ_NOLPF2 = 0,
+       MPU_FILTER_188HZ,
+       MPU_FILTER_98HZ,
+       MPU_FILTER_42HZ,
+       MPU_FILTER_20HZ,
+       MPU_FILTER_10HZ,
+       MPU_FILTER_5HZ,
+       MPU_FILTER_2100HZ_NOLPF,
+       NUM_MPU_FILTER
+};
+
+enum mpu_fullscale {
+       MPU_FS_250DPS = 0,
+       MPU_FS_500DPS,
+       MPU_FS_1000DPS,
+       MPU_FS_2000DPS,
+       NUM_MPU_FS
+};
+
+enum mpu_clock_sel {
+       MPU_CLK_SEL_INTERNAL = 0,
+       MPU_CLK_SEL_PLLGYROX,
+       MPU_CLK_SEL_PLLGYROY,
+       MPU_CLK_SEL_PLLGYROZ,
+       MPU_CLK_SEL_PLLEXT32K,
+       MPU_CLK_SEL_PLLEXT19M,
+       MPU_CLK_SEL_RESERVED,
+       MPU_CLK_SEL_STOP,
+       NUM_CLK_SEL
+};
+
+enum mpu_ext_sync {
+       MPU_EXT_SYNC_NONE = 0,
+       MPU_EXT_SYNC_TEMP,
+       MPU_EXT_SYNC_GYROX,
+       MPU_EXT_SYNC_GYROY,
+       MPU_EXT_SYNC_GYROZ,
+       MPU_EXT_SYNC_ACCELX,
+       MPU_EXT_SYNC_ACCELY,
+       MPU_EXT_SYNC_ACCELZ,
+       NUM_MPU_EXT_SYNC
+};
+
+#define DLPF_FS_SYNC_VALUE(ext_sync, full_scale, lpf) \
+    ((ext_sync << 5) | (full_scale << 3) | lpf)
+
+#endif                         /* __MPU3050_H_ */
Index: linux-2.6.35/drivers/misc/Kconfig
===================================================================
--- linux-2.6.35.orig/drivers/misc/Kconfig      2010-12-22 14:09:27.000000000 
+0800
+++ linux-2.6.35/drivers/misc/Kconfig   2010-12-22 14:09:47.000000000 +0800
@@ -459,5 +459,6 @@
 source "drivers/misc/cb710/Kconfig"
 source "drivers/misc/iwmc3200top/Kconfig"
 source "drivers/misc/ti-st/Kconfig"
+source "drivers/misc/mpu3050/Kconfig"
 
 endif # MISC_DEVICES
Index: linux-2.6.35/drivers/misc/mpu3050/Kconfig
===================================================================
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.35/drivers/misc/mpu3050/Kconfig   2010-12-22 14:09:28.000000000 
+0800
@@ -0,0 +1,175 @@
+
+menu "Motion Sensors Support"
+
+choice
+    tristate "Motion Processing Unit"
+    depends on I2C
+    default SENSORS_MPU3050
+
+config MPU_NONE
+    bool "None"
+    help
+      This disables support for motion processing using the MPU family of 
+      motion processing units.
+
+config SENSORS_MPU3050
+    tristate "MPU3050"
+    depends on I2C
+    help
+      If you say yes here you get support for the MPU3050 Gyroscope driver
+      This driver can also be built as a module.  If so, the module
+      will be called mpu3050.
+
+config SENSORS_MPU6000
+    tristate "MPU6000"
+    depends on I2C
+    help
+      If you say yes here you get support for the MPU6000 Gyroscope driver
+      This driver can also be built as a module.  If so, the module
+      will be called mpu6000.
+
+endchoice
+
+choice
+    prompt "Accelerometer Type"
+    depends on SENSORS_MPU3050
+    default SENSORS_BMA023
+
+config SENSORS_ACCELEROMETER_NONE
+    bool "NONE"
+    depends on SENSORS_MPU3050 || SENSORS_MPU6000
+    help
+      This disables accelerometer support for the MPU3050
+
+config SENSORS_ADXL346
+    bool "ADI adxl346"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the ADI adxl346 accelerometer
+
+config SENSORS_BMA023
+    bool "Bosch BMA023"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the Bosch BMA023 accelerometer
+ 
+config SENSORS_BMA150
+    bool "Bosch BMA150"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the Bosch BMA150 accelerometer
+ 
+config SENSORS_BMA222
+    bool "Bosch BMA222"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the Bosch BMA222 accelerometer
+      
+config SENSORS_KXSD9
+    bool "Kionix KXSD9"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the Kionix KXSD9 accelerometer
+
+config SENSORS_KXTF9
+    bool "Kionix KXTF9"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the Kionix KXFT9 accelerometer
+
+config SENSORS_LIS331DLH
+    bool "ST lis331dlh"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the ST lis331dlh accelerometer
+
+config SENSORS_LSM303DLHA
+    bool "ST lsm303dlh"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the ST lsm303dlh accelerometer
+
+config SENSORS_MMA8450
+    bool "Freescale mma8450"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the Freescale mma8450 accelerometer
+
+config SENSORS_MMA8451
+    bool "Freescale mma8451"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the Freescale mma8451 accelerometer
+
+endchoice
+
+choice
+    prompt "Compass Type"
+    depends on SENSORS_MPU6000 || SENSORS_MPU3050
+    default SENSORS_COMPASS_NONE
+
+config SENSORS_COMPASS_NONE
+    bool "NONE"
+    depends on SENSORS_MPU6000 || SENSORS_MPU3050
+    help
+      This disables compass support for the MPU6000
+
+config SENSORS_AK8975
+    bool "AKM ak8975"
+    depends on SENSORS_MPU6000 || SENSORS_MPU3050
+    help
+      This enables support for the AKM ak8975 compass
+
+config SENSORS_MMC314X
+    bool "MEMSIC mmc314x"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the MEMSIC mmc314x compass
+
+config SENSORS_AMI304
+    bool "Aichi Steel ami304"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the Aichi Steel ami304 compass
+
+config SENSORS_HMC5883
+    bool "Honeywell hmc5883"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the Honeywell hmc5883 compass
+
+config SENSORS_LSM303DLHM
+    bool "ST lsm303dlh"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the ST lsm303dlh compass
+
+config SENSORS_MMC314X
+    bool "MEMSIC mmc314xMS"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the MEMSIC mmc314xMS compass
+
+config SENSORS_YAS529
+    bool "Yamaha yas529"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the Yamaha yas529 compass
+
+config SENSORS_HSCDTD002B
+    bool "Alps hscdtd002b"
+    depends on SENSORS_MPU3050
+    help
+      This enables support for the Alps hscdtd002b compass
+
+endchoice
+
+config SENSORS_MPU_DEBUG
+    bool "MPU debug"
+    depends on SENSORS_MPU3050 || SENSORS_MPU6000
+    help
+      If you say yes here you get extra debug messages from the MPU3050
+      and other slave sensors.
+
+endmenu
+
Index: linux-2.6.35/drivers/misc/mpu3050/mltypes.h
===================================================================
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.35/drivers/misc/mpu3050/mltypes.h 2010-12-22 14:09:28.000000000 
+0800
@@ -0,0 +1,201 @@
+/*
+ $License:
+    Copyright (C) 2010 InvenSense Corporation, All Rights Reserved.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  $
+ */
+/**
+ *  @defgroup MLERROR
+ *  @brief  Motion Library - Error definitions.
+ *          Definition of the error codes used within the MPL and returned
+ *          to the user.
+ *          Every function tries to return a meaningful error code basing
+ *          on the occuring error condition. The error code is numeric.
+ *
+ *          The available error codes and their associated values are:
+ *          - (0)       ML_SUCCESS
+ *          - (1)       ML_ERROR
+ *          - (2)       ML_ERROR_INVALID_PARAMETER
+ *          - (3)       ML_ERROR_FEATURE_NOT_ENABLED
+ *          - (4)       ML_ERROR_FEATURE_NOT_IMPLEMENTED
+ *          - (6)       ML_ERROR_DMP_NOT_STARTED
+ *          - (7)       ML_ERROR_DMP_STARTED
+ *          - (8)       ML_ERROR_NOT_OPENED
+ *          - (9)       ML_ERROR_OPENED
+ *          - (10)      ML_ERROR_INVALID_MODULE
+ *          - (11)      ML_ERROR_MEMORY_EXAUSTED
+ *          - (12)      ML_ERROR_DIVIDE_BY_ZERO
+ *          - (13)      ML_ERROR_ASSERTION_FAILURE
+ *          - (14)      ML_ERROR_FILE_OPEN
+ *          - (15)      ML_ERROR_FILE_READ
+ *          - (16)      ML_ERROR_FILE_WRITE
+ *          - (20)      ML_ERROR_SERIAL_CLOSED
+ *          - (21)      ML_ERROR_SERIAL_OPEN_ERROR
+ *          - (22)      ML_ERROR_SERIAL_READ
+ *          - (23)      ML_ERROR_SERIAL_WRITE
+ *          - (24)      ML_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED
+ *          - (25)      ML_ERROR_SM_TRANSITION
+ *          - (26)      ML_ERROR_SM_IMPROPER_STATE
+ *          - (30)      ML_ERROR_FIFO_OVERFLOW
+ *          - (31)      ML_ERROR_FIFO_FOOTER
+ *          - (32)      ML_ERROR_FIFO_READ_COUNT
+ *          - (33)      ML_ERROR_FIFO_READ_DATA
+ *          - (40)      ML_ERROR_MEMORY_SET
+ *          - (50)      ML_ERROR_LOG_MEMORY_ERROR
+ *          - (51)      ML_ERROR_LOG_OUTPUT_ERROR
+ *          - (60)      ML_ERROR_OS_BAD_PTR
+ *          - (61)      ML_ERROR_OS_BAD_HANDLE
+ *          - (62)      ML_ERROR_OS_CREATE_FAILED
+ *          - (63)      ML_ERROR_OS_LOCK_FAILED
+ *          - (70)      ML_ERROR_COMPASS_DATA_OVERFLOW
+ *          - (71)      ML_ERROR_COMPASS_DATA_UNDERFLOW
+ *          - (72)      ML_ERROR_COMPASS_DATA_NOT_READY
+ *
+ *  @{
+ *      @file mltypes.h
+ *  @}
+ */
+
+#ifndef MLTYPES_H
+#define MLTYPES_H
+
+#ifdef __KERNEL__
+#include <linux/types.h>
+#else
+#include "stdint_invensense.h"
+#endif
+#include "log.h"
+
+/*---------------------------
+    ML Types
+---------------------------*/
+
+/**
+ * @struct tMLError The MPL Error Code return type.
+ *
+ * @code
+ *      typedef unsigned char tMLError;
+ * @endcode
+ */
+typedef unsigned char tMLError;
+
+#if defined(LINUX) || defined(__KERNEL__)
+typedef unsigned int HANDLE;
+#endif
+
+#ifdef __KERNEL__
+typedef HANDLE FILE;
+#endif
+
+#ifndef __cplusplus
+#ifndef __KERNEL__
+typedef int_fast8_t bool;
+#endif
+#endif
+
+/*---------------------------
+    ML Defines
+---------------------------*/
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+/* Dimension of an array */
+#ifndef DIM
+#define DIM(array) (sizeof(array)/sizeof((array)[0]))
+#endif
+
+/* - ML Errors. - */
+#define ERROR_NAME(x)   (#x)
+#define ERROR_CHECK(x)                                                  \
+       {                                                               \
+               if (ML_SUCCESS != x) {                                  \
+                       MPL_LOGE("%s|%s|%d returning %d\n",             \
+                               __FILE__, __func__, __LINE__, x);       \
+                       return x;                                       \
+               }                                                       \
+       }
+
+#define ERROR_CHECK_FIRST(first, x)  { if (ML_SUCCESS == first) first = x; }
+
+#define ML_SUCCESS                       (0)
+/* Generic Error code.  Proprietary Error Codes only */
+#define ML_ERROR                         (1)
+
+/* Compatibility and other generic error codes */
+#define ML_ERROR_INVALID_PARAMETER       (2)
+#define ML_ERROR_FEATURE_NOT_ENABLED     (3)
+#define ML_ERROR_FEATURE_NOT_IMPLEMENTED (4)
+#define ML_ERROR_DMP_NOT_STARTED         (6)
+#define ML_ERROR_DMP_STARTED             (7)
+#define ML_ERROR_NOT_OPENED              (8)
+#define ML_ERROR_OPENED                  (9)
+#define ML_ERROR_INVALID_MODULE         (10)
+#define ML_ERROR_MEMORY_EXAUSTED        (11)
+#define ML_ERROR_DIVIDE_BY_ZERO         (12)
+#define ML_ERROR_ASSERTION_FAILURE      (13)
+#define ML_ERROR_FILE_OPEN              (14)
+#define ML_ERROR_FILE_READ              (15)
+#define ML_ERROR_FILE_WRITE             (16)
+#define ML_ERROR_INVALID_CONFIGURATION  (17)
+
+/* Serial Communication */
+#define ML_ERROR_SERIAL_CLOSED          (20)
+#define ML_ERROR_SERIAL_OPEN_ERROR      (21)
+#define ML_ERROR_SERIAL_READ            (22)
+#define ML_ERROR_SERIAL_WRITE           (23)
+#define ML_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED  (24)
+
+/* SM = State Machine */
+#define ML_ERROR_SM_TRANSITION          (25)
+#define ML_ERROR_SM_IMPROPER_STATE      (26)
+
+/* Fifo */
+#define ML_ERROR_FIFO_OVERFLOW          (30)
+#define ML_ERROR_FIFO_FOOTER            (31)
+#define ML_ERROR_FIFO_READ_COUNT        (32)
+#define ML_ERROR_FIFO_READ_DATA         (33)
+
+/* Memory & Registers, Set & Get */
+#define ML_ERROR_MEMORY_SET             (40)
+
+#define ML_ERROR_LOG_MEMORY_ERROR       (50)
+#define ML_ERROR_LOG_OUTPUT_ERROR       (51)
+
+/*OS interface errors */
+#define ML_ERROR_OS_BAD_PTR             (60)
+#define ML_ERROR_OS_BAD_HANDLE          (61)
+#define ML_ERROR_OS_CREATE_FAILED       (62)
+#define ML_ERROR_OS_LOCK_FAILED         (63)
+
+/* Compass errors */
+#define ML_ERROR_COMPASS_DATA_OVERFLOW  (70)
+#define ML_ERROR_COMPASS_DATA_UNDERFLOW (71)
+#define ML_ERROR_COMPASS_DATA_NOT_READY (72)
+
+/*---------------------------
+    p-Types
+---------------------------*/
+
+#endif                         /* MLTYPES_H */

 
_______________________________________________
MeeGo-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel

Reply via email to