1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
/*
* Copyright (C) 2012, Samsung Electronics Co. Ltd. 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.
*
*/
#ifndef __SSP_PRJ_H__
#define __SSP_PRJ_H__
#include <stdint.h>
#include <linux/types.h>
#include <linux/ioctl.h>
#define SSP_SW_RESET_TIME 3000
#define DEFUALT_POLLING_DELAY (200 * NSEC_PER_MSEC)
#define PROX_AVG_READ_NUM 80
#define DEFAULT_RETRIES 3
/* Sensor Sampling Time Define */
enum {
SENSOR_NS_DELAY_FASTEST = 10000000, /* 10msec */
SENSOR_NS_DELAY_GAME = 20000000, /* 20msec */
SENSOR_NS_DELAY_UI = 66700000, /* 66.7msec */
SENSOR_NS_DELAY_NORMAL = 200000000, /* 200msec */
};
enum {
SENSOR_MS_DELAY_FASTEST = 10, /* 10msec */
SENSOR_MS_DELAY_GAME = 20, /* 20msec */
SENSOR_MS_DELAY_UI = 66, /* 66.7msec */
SENSOR_MS_DELAY_NORMAL = 200, /* 200msec */
};
enum {
SENSOR_CMD_DELAY_FASTEST = 0, /* 10msec */
SENSOR_CMD_DELAY_GAME, /* 20msec */
SENSOR_CMD_DELAY_UI, /* 66.7msec */
SENSOR_CMD_DELAY_NORMAL, /* 200msec */
};
/*
* SENSOR_DELAY_SET_STATE
* Check delay set to avoid sending ADD instruction twice
*/
enum {
INITIALIZATION_STATE = 0,
NO_SENSOR_STATE,
ADD_SENSOR_STATE,
RUNNING_SENSOR_STATE,
};
/* Gyroscope DPS */
#define GYROSCOPE_DPS250 250
#define GYROSCOPE_DPS500 500
#define GYROSCOPE_DPS2000 2000
/* kernel -> ssp manager cmd*/
#define SSP_LIBRARY_SLEEP_CMD (1 << 5)
#define SSP_LIBRARY_LARGE_DATA_CMD (1 << 6)
#define SSP_LIBRARY_WAKEUP_CMD (1 << 7)
/* ioctl command */
#define AKMIO 0xA1
#define ECS_IOCTL_GET_FUSEROMDATA _IOR(AKMIO, 0x01, unsigned char[3])
#define ECS_IOCTL_GET_MAGDATA _IOR(AKMIO, 0x02, unsigned char[8])
#define ECS_IOCTL_GET_ACCDATA _IOR(AKMIO, 0x03, int[3])
/* AP -> SSP Instruction */
#define MSG2SSP_INST_BYPASS_SENSOR_ADD 0xA1
#define MSG2SSP_INST_BYPASS_SENSOR_REMOVE 0xA2
#define MSG2SSP_INST_REMOVE_ALL 0xA3
#define MSG2SSP_INST_CHANGE_DELAY 0xA4
#define MSG2SSP_INST_SENSOR_SELFTEST 0xA8
#define MSG2SSP_INST_LIBRARY_ADD 0xB1
#define MSG2SSP_INST_LIBRARY_REMOVE 0xB2
#define MSG2SSP_AP_STT 0xC8
#define MSG2SSP_AP_STATUS_WAKEUP 0xD1
#define MSG2SSP_AP_STATUS_SLEEP 0xD2
#define MSG2SSP_AP_STATUS_RESET 0xD3
#define MSG2SSP_AP_WHOAMI 0x0F
#define MSG2SSP_AP_FIRMWARE_REV 0xF0
#define MSG2SSP_AP_SENSOR_FORMATION 0xF1
#define MSG2SSP_AP_SENSOR_PROXTHRESHOLD 0xF2
#define MSG2SSP_AP_SENSOR_BARCODE_EMUL 0xF3
#define MSG2SSP_AP_SENSOR_SCANNING 0xF4
#define MSG2SSP_AP_FUSEROM 0X01
/* AP -> SSP Data Protocol Frame Field */
#define MSG2SSP_SSP_SLEEP 0xC1
#define MSG2SSP_STS 0xC2 /* Start to Send */
#define MSG2SSP_RTS 0xC4 /* Ready to Send */
#define MSG2SSP_STT 0xC8
#define MSG2SSP_SRM 0xCA /* Start to Read MSG */
#define MSG2SSP_SSM 0xCB /* Start to Send MSG */
#define MSG2SSP_SSD 0xCE /* Start to Send Data Type & Length */
/* SSP -> AP ACK about write CMD */
#define MSG_ACK 0x80 /* ACK from SSP to AP */
#define MSG_NAK 0x70 /* NAK from SSP to AP */
/* SSP_INSTRUCTION_CMD */
enum {
REMOVE_SENSOR = 0,
ADD_SENSOR,
CHANGE_DELAY,
GO_SLEEP,
FACTORY_MODE,
REMOVE_LIBRARY,
ADD_LIBRARY,
};
/* SENSOR_TYPE */
enum {
ACCELEROMETER_SENSOR = 0,
GYROSCOPE_SENSOR,
GEOMAGNETIC_SENSOR,
PRESSURE_SENSOR,
GESTURE_SENSOR,
PROXIMITY_SENSOR,
LIGHT_SENSOR,
PROXIMITY_RAW,
SENSOR_MAX,
};
/* SENSOR_FACTORY_MODE_TYPE */
enum {
ACCELEROMETER_FACTORY = 0,
GYROSCOPE_FACTORY,
GEOMAGNETIC_FACTORY,
PRESSURE_FACTORY,
MCU_FACTORY,
GYROSCOPE_TEMP_FACTORY,
GYROSCOPE_DPS_FACTORY,
MCU_SLEEP_FACTORY,
SENSOR_FACTORY_MAX,
};
struct sensor_value {
union {
struct {
__s16 x;
__s16 y;
__s16 z;
};
struct {
__u16 r;
__u16 g;
__u16 b;
__u16 w;
};
__u8 prox[4];
__s16 data[4];
__s32 pressure[3];
};
};
struct calibraion_data {
int x;
int y;
int z;
};
#endif
|