Merge tag 'v4.4-rc2'
[firefly-linux-kernel-4.4.55.git] / drivers / misc / inv_mpu / mltypes.h
1 /*
2         $License:
3         Copyright (C) 2011 InvenSense Corporation, All Rights Reserved.
4
5         This program is free software; you can redistribute it and/or modify
6         it under the terms of the GNU General Public License as published by
7         the Free Software Foundation; either version 2 of the License, or
8         (at your option) any later version.
9
10         This program is distributed in the hope that it will be useful,
11         but WITHOUT ANY WARRANTY; without even the implied warranty of
12         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13         GNU General Public License for more details.
14
15         You should have received a copy of the GNU General Public License
16         along with this program.  If not, see <http://www.gnu.org/licenses/>.
17         $
18  */
19
20 /**
21  *  @defgroup MLERROR
22  *  @brief  Definition of the error codes used within the MPL and
23  *          returned to the user.
24  *          Every function tries to return a meaningful error code basing
25  *          on the occuring error condition. The error code is numeric.
26  *
27  *          The available error codes and their associated values are:
28  *          - (0)               INV_SUCCESS
29  *          - (32)              INV_ERROR
30  *          - (22 / EINVAL)     INV_ERROR_INVALID_PARAMETER
31  *          - (1  / EPERM)      INV_ERROR_FEATURE_NOT_ENABLED
32  *          - (36)              INV_ERROR_FEATURE_NOT_IMPLEMENTED
33  *          - (38)              INV_ERROR_DMP_NOT_STARTED
34  *          - (39)              INV_ERROR_DMP_STARTED
35  *          - (40)              INV_ERROR_NOT_OPENED
36  *          - (41)              INV_ERROR_OPENED
37  *          - (19 / ENODEV)     INV_ERROR_INVALID_MODULE
38  *          - (12 / ENOMEM)     INV_ERROR_MEMORY_EXAUSTED
39  *          - (44)              INV_ERROR_DIVIDE_BY_ZERO
40  *          - (45)              INV_ERROR_ASSERTION_FAILURE
41  *          - (46)              INV_ERROR_FILE_OPEN
42  *          - (47)              INV_ERROR_FILE_READ
43  *          - (48)              INV_ERROR_FILE_WRITE
44  *          - (49)              INV_ERROR_INVALID_CONFIGURATION
45  *          - (52)              INV_ERROR_SERIAL_CLOSED
46  *          - (53)              INV_ERROR_SERIAL_OPEN_ERROR
47  *          - (54)              INV_ERROR_SERIAL_READ
48  *          - (55)              INV_ERROR_SERIAL_WRITE
49  *          - (56)              INV_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED
50  *          - (57)              INV_ERROR_SM_TRANSITION
51  *          - (58)              INV_ERROR_SM_IMPROPER_STATE
52  *          - (62)              INV_ERROR_FIFO_OVERFLOW
53  *          - (63)              INV_ERROR_FIFO_FOOTER
54  *          - (64)              INV_ERROR_FIFO_READ_COUNT
55  *          - (65)              INV_ERROR_FIFO_READ_DATA
56  *          - (72)              INV_ERROR_MEMORY_SET
57  *          - (82)              INV_ERROR_LOG_MEMORY_ERROR
58  *          - (83)              INV_ERROR_LOG_OUTPUT_ERROR
59  *          - (92)              INV_ERROR_OS_BAD_PTR
60  *          - (93)              INV_ERROR_OS_BAD_HANDLE
61  *          - (94)              INV_ERROR_OS_CREATE_FAILED
62  *          - (95)              INV_ERROR_OS_LOCK_FAILED
63  *          - (102)             INV_ERROR_COMPASS_DATA_OVERFLOW
64  *          - (103)             INV_ERROR_COMPASS_DATA_UNDERFLOW
65  *          - (104)             INV_ERROR_COMPASS_DATA_NOT_READY
66  *          - (105)             INV_ERROR_COMPASS_DATA_ERROR
67  *          - (107)             INV_ERROR_CALIBRATION_LOAD
68  *          - (108)             INV_ERROR_CALIBRATION_STORE
69  *          - (109)             INV_ERROR_CALIBRATION_LEN
70  *          - (110)             INV_ERROR_CALIBRATION_CHECKSUM
71  *          - (111)             INV_ERROR_ACCEL_DATA_OVERFLOW
72  *          - (112)             INV_ERROR_ACCEL_DATA_UNDERFLOW
73  *          - (113)             INV_ERROR_ACCEL_DATA_NOT_READY
74  *          - (114)             INV_ERROR_ACCEL_DATA_ERROR
75  *
76  *          The available warning codes and their associated values are:
77  *          - (115)             INV_WARNING_MOTION_RACE
78  *          - (116)             INV_WARNING_QUAT_TRASHED
79  *
80  *  @{
81  *      @file mltypes.h
82  *  @}
83  */
84
85 #ifndef MLTYPES_H
86 #define MLTYPES_H
87
88 #include <linux/types.h>
89 #include <asm-generic/errno-base.h>
90
91
92
93
94 /*---------------------------
95  *    ML Defines
96  *--------------------------*/
97
98 #ifndef NULL
99 #define NULL 0
100 #endif
101
102 /* - ML Errors. - */
103 #define ERROR_NAME(x)   (#x)
104 #define ERROR_CHECK_FIRST(first, x) \
105         { if (INV_SUCCESS == first) first = x; }
106
107 #define INV_SUCCESS                       (0)
108 /* Generic Error code.  Proprietary Error Codes only */
109 #define INV_ERROR_BASE                    (0x20)
110 #define INV_ERROR                         (INV_ERROR_BASE)
111
112 /* Compatibility and other generic error codes */
113 #define INV_ERROR_INVALID_PARAMETER             (EINVAL)
114 #define INV_ERROR_FEATURE_NOT_ENABLED           (EPERM)
115 #define INV_ERROR_FEATURE_NOT_IMPLEMENTED       (INV_ERROR_BASE + 4)
116 #define INV_ERROR_DMP_NOT_STARTED               (INV_ERROR_BASE + 6)
117 #define INV_ERROR_DMP_STARTED                   (INV_ERROR_BASE + 7)
118 #define INV_ERROR_NOT_OPENED                    (INV_ERROR_BASE + 8)
119 #define INV_ERROR_OPENED                        (INV_ERROR_BASE + 9)
120 #define INV_ERROR_INVALID_MODULE                (ENODEV)
121 #define INV_ERROR_MEMORY_EXAUSTED               (ENOMEM)
122 #define INV_ERROR_DIVIDE_BY_ZERO                (INV_ERROR_BASE + 12)
123 #define INV_ERROR_ASSERTION_FAILURE             (INV_ERROR_BASE + 13)
124 #define INV_ERROR_FILE_OPEN                     (INV_ERROR_BASE + 14)
125 #define INV_ERROR_FILE_READ                     (INV_ERROR_BASE + 15)
126 #define INV_ERROR_FILE_WRITE                    (INV_ERROR_BASE + 16)
127 #define INV_ERROR_INVALID_CONFIGURATION         (INV_ERROR_BASE + 17)
128
129 /* Serial Communication */
130 #define INV_ERROR_SERIAL_CLOSED                 (INV_ERROR_BASE + 20)
131 #define INV_ERROR_SERIAL_OPEN_ERROR             (INV_ERROR_BASE + 21)
132 #define INV_ERROR_SERIAL_READ                   (INV_ERROR_BASE + 22)
133 #define INV_ERROR_SERIAL_WRITE                  (INV_ERROR_BASE + 23)
134 #define INV_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED  (INV_ERROR_BASE + 24)
135
136 /* SM = State Machine */
137 #define INV_ERROR_SM_TRANSITION                 (INV_ERROR_BASE + 25)
138 #define INV_ERROR_SM_IMPROPER_STATE             (INV_ERROR_BASE + 26)
139
140 /* Fifo */
141 #define INV_ERROR_FIFO_OVERFLOW                 (INV_ERROR_BASE + 30)
142 #define INV_ERROR_FIFO_FOOTER                   (INV_ERROR_BASE + 31)
143 #define INV_ERROR_FIFO_READ_COUNT               (INV_ERROR_BASE + 32)
144 #define INV_ERROR_FIFO_READ_DATA                (INV_ERROR_BASE + 33)
145
146 /* Memory & Registers, Set & Get */
147 #define INV_ERROR_MEMORY_SET                    (INV_ERROR_BASE + 40)
148
149 #define INV_ERROR_LOG_MEMORY_ERROR              (INV_ERROR_BASE + 50)
150 #define INV_ERROR_LOG_OUTPUT_ERROR              (INV_ERROR_BASE + 51)
151
152 /* OS interface errors */
153 #define INV_ERROR_OS_BAD_PTR                    (INV_ERROR_BASE + 60)
154 #define INV_ERROR_OS_BAD_HANDLE                 (INV_ERROR_BASE + 61)
155 #define INV_ERROR_OS_CREATE_FAILED              (INV_ERROR_BASE + 62)
156 #define INV_ERROR_OS_LOCK_FAILED                (INV_ERROR_BASE + 63)
157
158 /* Compass errors */
159 #define INV_ERROR_COMPASS_DATA_OVERFLOW         (INV_ERROR_BASE + 70)
160 #define INV_ERROR_COMPASS_DATA_UNDERFLOW        (INV_ERROR_BASE + 71)
161 #define INV_ERROR_COMPASS_DATA_NOT_READY        (INV_ERROR_BASE + 72)
162 #define INV_ERROR_COMPASS_DATA_ERROR            (INV_ERROR_BASE + 73)
163
164 /* Load/Store calibration */
165 #define INV_ERROR_CALIBRATION_LOAD              (INV_ERROR_BASE + 75)
166 #define INV_ERROR_CALIBRATION_STORE             (INV_ERROR_BASE + 76)
167 #define INV_ERROR_CALIBRATION_LEN               (INV_ERROR_BASE + 77)
168 #define INV_ERROR_CALIBRATION_CHECKSUM          (INV_ERROR_BASE + 78)
169
170 /* Accel errors */
171 #define INV_ERROR_ACCEL_DATA_OVERFLOW           (INV_ERROR_BASE + 79)
172 #define INV_ERROR_ACCEL_DATA_UNDERFLOW          (INV_ERROR_BASE + 80)
173 #define INV_ERROR_ACCEL_DATA_NOT_READY          (INV_ERROR_BASE + 81)
174 #define INV_ERROR_ACCEL_DATA_ERROR              (INV_ERROR_BASE + 82)
175
176 /* No Motion Warning States */
177 #define INV_WARNING_MOTION_RACE                 (INV_ERROR_BASE + 83)
178 #define INV_WARNING_QUAT_TRASHED                (INV_ERROR_BASE + 84)
179 #define INV_WARNING_GYRO_MAG                    (INV_ERROR_BASE + 85)
180
181 #ifdef INV_USE_LEGACY_NAMES
182 #define ML_SUCCESS                        INV_SUCCESS
183 #define ML_ERROR                          INV_ERROR
184 #define ML_ERROR_INVALID_PARAMETER        INV_ERROR_INVALID_PARAMETER
185 #define ML_ERROR_FEATURE_NOT_ENABLED      INV_ERROR_FEATURE_NOT_ENABLED
186 #define ML_ERROR_FEATURE_NOT_IMPLEMENTED  INV_ERROR_FEATURE_NOT_IMPLEMENTED
187 #define ML_ERROR_DMP_NOT_STARTED          INV_ERROR_DMP_NOT_STARTED
188 #define ML_ERROR_DMP_STARTED              INV_ERROR_DMP_STARTED
189 #define ML_ERROR_NOT_OPENED               INV_ERROR_NOT_OPENED
190 #define ML_ERROR_OPENED                   INV_ERROR_OPENED
191 #define ML_ERROR_INVALID_MODULE           INV_ERROR_INVALID_MODULE
192 #define ML_ERROR_MEMORY_EXAUSTED          INV_ERROR_MEMORY_EXAUSTED
193 #define ML_ERROR_DIVIDE_BY_ZERO           INV_ERROR_DIVIDE_BY_ZERO
194 #define ML_ERROR_ASSERTION_FAILURE        INV_ERROR_ASSERTION_FAILURE
195 #define ML_ERROR_FILE_OPEN                INV_ERROR_FILE_OPEN
196 #define ML_ERROR_FILE_READ                INV_ERROR_FILE_READ
197 #define ML_ERROR_FILE_WRITE               INV_ERROR_FILE_WRITE
198 #define ML_ERROR_INVALID_CONFIGURATION    INV_ERROR_INVALID_CONFIGURATION
199 #define ML_ERROR_SERIAL_CLOSED            INV_ERROR_SERIAL_CLOSED
200 #define ML_ERROR_SERIAL_OPEN_ERROR        INV_ERROR_SERIAL_OPEN_ERROR
201 #define ML_ERROR_SERIAL_READ              INV_ERROR_SERIAL_READ
202 #define ML_ERROR_SERIAL_WRITE             INV_ERROR_SERIAL_WRITE
203 #define ML_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED  \
204         INV_ERROR_SERIAL_DEVICE_NOT_RECOGNIZED
205 #define ML_ERROR_SM_TRANSITION            INV_ERROR_SM_TRANSITION
206 #define ML_ERROR_SM_IMPROPER_STATE        INV_ERROR_SM_IMPROPER_STATE
207 #define ML_ERROR_FIFO_OVERFLOW            INV_ERROR_FIFO_OVERFLOW
208 #define ML_ERROR_FIFO_FOOTER              INV_ERROR_FIFO_FOOTER
209 #define ML_ERROR_FIFO_READ_COUNT          INV_ERROR_FIFO_READ_COUNT
210 #define ML_ERROR_FIFO_READ_DATA           INV_ERROR_FIFO_READ_DATA
211 #define ML_ERROR_MEMORY_SET               INV_ERROR_MEMORY_SET
212 #define ML_ERROR_LOG_MEMORY_ERROR         INV_ERROR_LOG_MEMORY_ERROR
213 #define ML_ERROR_LOG_OUTPUT_ERROR         INV_ERROR_LOG_OUTPUT_ERROR
214 #define ML_ERROR_OS_BAD_PTR               INV_ERROR_OS_BAD_PTR
215 #define ML_ERROR_OS_BAD_HANDLE            INV_ERROR_OS_BAD_HANDLE
216 #define ML_ERROR_OS_CREATE_FAILED         INV_ERROR_OS_CREATE_FAILED
217 #define ML_ERROR_OS_LOCK_FAILED           INV_ERROR_OS_LOCK_FAILED
218 #define ML_ERROR_COMPASS_DATA_OVERFLOW    INV_ERROR_COMPASS_DATA_OVERFLOW
219 #define ML_ERROR_COMPASS_DATA_UNDERFLOW   INV_ERROR_COMPASS_DATA_UNDERFLOW
220 #define ML_ERROR_COMPASS_DATA_NOT_READY   INV_ERROR_COMPASS_DATA_NOT_READY
221 #define ML_ERROR_COMPASS_DATA_ERROR       INV_ERROR_COMPASS_DATA_ERROR
222 #define ML_ERROR_CALIBRATION_LOAD         INV_ERROR_CALIBRATION_LOAD
223 #define ML_ERROR_CALIBRATION_STORE        INV_ERROR_CALIBRATION_STORE
224 #define ML_ERROR_CALIBRATION_LEN          INV_ERROR_CALIBRATION_LEN
225 #define ML_ERROR_CALIBRATION_CHECKSUM     INV_ERROR_CALIBRATION_CHECKSUM
226 #define ML_ERROR_ACCEL_DATA_OVERFLOW      INV_ERROR_ACCEL_DATA_OVERFLOW
227 #define ML_ERROR_ACCEL_DATA_UNDERFLOW     INV_ERROR_ACCEL_DATA_UNDERFLOW
228 #define ML_ERROR_ACCEL_DATA_NOT_READY     INV_ERROR_ACCEL_DATA_NOT_READY
229 #define ML_ERROR_ACCEL_DATA_ERROR         INV_ERROR_ACCEL_DATA_ERROR
230 #endif
231
232 /* For Linux coding compliance */
233
234 #endif                          /* MLTYPES_H */