summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/msg2233/mstar_drv_hotknot.h
blob: 1c6da72f093d54569ada73bf80c5214624d820f9 (plain)
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2006-2012 MStar Semiconductor, Inc.
// All rights reserved.
//
// Unless otherwise stipulated in writing, any and all information contained
// herein regardless in any format shall remain the sole proprietary of
// MStar Semiconductor Inc. and be kept in strict confidence
// (??MStar Confidential Information??) by the recipient.
// Any unauthorized act including without limitation unauthorized disclosure,
// copying, use, reproduction, sale, distribution, modification, disassembling,
// reverse engineering and compiling of the contents of MStar Confidential
// Information is unlawful and strictly prohibited. MStar hereby reserves the
// rights to any and all damages, losses, costs and expenses resulting therefrom.
//
////////////////////////////////////////////////////////////////////////////////

/**
 *
 * @file    mstar_drv_hotknot.h
 *
 * @brief   This file defines the hotknot functions
 *
 *
 */

#ifndef __MSTAR_DRV_HOTKNOT_H__
#define __MSTAR_DRV_HOTKNOT_H__


////////////////////////////////////////////////////////////
/// Included Files
////////////////////////////////////////////////////////////
#include "mstar_drv_common.h"
#include "mstar_drv_hotknot_queue.h"


#ifdef CONFIG_ENABLE_HOTKNOT
////////////////////////////////////////////////////////////
/// Data Types
////////////////////////////////////////////////////////////
//typedef int bool;

//#define false   0
//#define true    !false


////////////////////////////////////////////////////////////
/// Function Prototype
////////////////////////////////////////////////////////////
extern void CreateHotKnotMem(void);
extern void DeleteHotKnotMem(void);


////////////////////////////////////////////////////////////
/// Data Types
////////////////////////////////////////////////////////////
typedef struct
{
    u8          nCmdId;
    u8         *pSndData;      //send data to fw  
    u16         nSndLen;
    u8         *pRcvData;      //receive data from fw
    u16         nRcvLen;
    u16        *pFwMode;
    s32         nTimeOut;
} DrvCmd_t;


//hotknot cmd
typedef struct
{
    u8         nHeader;
    u8         nInstruction;
    u8         szReserved[2];     
} HotKnotCmd_t;

typedef struct
{
    u8         nHeader;
    u8         nInstruction;
	u8         nResult;
    u8         szReserved[38];     
	u8         nIdentify;    	
	u8         nCheckSum;
} DemoHotKnotCmdRet_t;

typedef struct
{
    u8         nHeader;
	u8         nPacketLen_H;  
	u8         nPacketLen_L;
	u8         nType;    
    u8         nInstruction;
	u8         nResult;
  //u8         szReserved[40];    //unknown size   	
  //u8         nCheckSum;
} DebugHotKnotCmdRet_t;


//hotknot auth
typedef struct
{
    u8         nHeader;
    u8         nInstruction;
    u8         szReserved[2];     
} HotKnotAuth_t;


//hotknot writecipher
typedef struct
{
    u8         nHeader;
    u8         nInstruction;      
	u16        nSMBusAdr;
    u8         szData[16];     
	u8         nCheckSum;
} HotKnotWriteCipher_t;
//return 0 if success, return 1 if fail


//hotknot send
typedef struct
{
    u8         nHeader;
    u8         nInstruction;      
	u16        nSMBusAdr;
    u8         szData[129];     
	u8         nDataLen_H;  
	u8         nDataLen_L;  	
	u8         nCheckSum;
} HotKnotSnd_t;

typedef struct
{
    u8         nHeader;
	u8         nPacketLen_H;  
	u8         nPacketLen_L;  		
    u8         nType;      	
    u8         nInstruction;      
	u8         nResult;
    u8         szReserved[143];     
	u8         nCheckSum;
} DemoHotKnotSndRet_t;

typedef struct
{
    u8         nHeader;
	u8         nPacketLen_H;  
	u8         nPacketLen_L;  		
    u8         nType;      	
    u8         nInstruction;      
	u8         nResult;
    u8         szReserved[143];
    u8         szDebug[100];    
	u8         nCheckSum;
} DebugHotKnotSndRet_t;


//hotknot receive
typedef struct
{
    u8         nHeader;
    u8         nInstruction;
	u8         nRequireDataLen_H;  
	u8         nRequireDataLen_L;  	
} HotKnotRcv_t;

typedef struct
{
    u8         nHeader;      	     
	u8         nActualHotKnotLen_H;  
	u8         nActualHotKnotLen_L;   
    u8         szData[146];    
	u8         nCheckSum;
} DemoHotKnotLibRcvRet_t;

typedef struct
{
    u8         nHeader;
	u8         nPacketLen_H;  
	u8         nPacketLen_L;  		
    u8         nType;      	
    u8         szData[143];     
	u8         nActualDataLen_H;  
	u8         nActualDataLen_L;  		
	u8         nCheckSum;
} DemoHotKnotRcvRet_t;

typedef struct
{
    u8         nHeader;
	u8         nPacketLen_H;  
	u8         nPacketLen_L;  		
    u8         nType;      	
    u8         szData[143];     
	u8         nActualDataLen_H;  
	u8         nActualDataLen_L;
    u8         szDebug[100];    
	u8         nCheckSum;
} DebugHotKnotRcvRet_t;


//hotknot get queue data
typedef struct
{
    u8         nHeader;
    u8         nInstruction;
	u8         nRequireDataLen_H;  
	u8         nRequireDataLen_L;  	
} HotKnotGetQ_t;

typedef struct
{
    u8         nHeader;
	u16        nFront;  
	u16        nRear;  		     	
    u8         szData[HOTKNOT_QUEUE_SIZE];     
	u8         nCheckSum;
} DemoHotKnotGetQRet_t;


////////////////////////////////////////////////////////////
/// Variables
////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////
/// Macro
////////////////////////////////////////////////////////////
#define HOTKNOT_IOCTL_BASE               99
#define HOTKNOT_IOCTL_RUN_CMD            _IOWR(HOTKNOT_IOCTL_BASE, 0, long)
#define HOTKNOT_IOCTL_QUERY_VENDOR       _IOR('G', 28, char[30])


#define HOTKNOT_CMD                      0x60
#define HOTKNOT_AUTH                     0x61
#define HOTKNOT_SEND                     0x62
#define HOTKNOT_RECEIVE                  0x63


//HotKnot CMD
#define ENABLE_HOTKNOT                   0xA0 
#define DISABLE_HOTKNOT                  0xA1
#define ENTER_MASTER_MODE                0xA2 
#define EXIT_MASTER_MODE                 0xA3 
#define ENTER_SLAVE_MODE                 0xA4 
#define EXIT_SLAVE_MODE                  0xA5 
#define READ_PAIR_STATE                  0xA6 
#define EXIT_READ_PAIR_STATE             0xA7 
#define ENTER_TRANSFER_MODE              0xA8 
#define EXIT_TRANSFER_MODE               0xA9 
#define READ_DEPART_STATE                0xAA 

//HotKnot AUTH
#define AUTH_INIT                        0xB0 
#define AUTH_GETKEYINDEX                 0xB1 
#define AUTH_READSCRAMBLECIPHER          0xB2 

//Hotknot QueryVersion
#define QUERY_VERSION                    0xB3

//HotKnot Send
#define AUTH_WRITECIPHER                 0xC0 
#define SEND_DATA                        0xC1 
#define ADAPTIVEMOD_BEGIN                0xC3    //notice fw to begin adaptive modulation

//HotKnot Receive
#define RECEIVE_DATA                     0xD0 

//HotKnot Send Test
#define SEND_DATA_TEST                   0xC2 

//HotKnot Get Queue
#define GET_QUEUE                        0xD1    //decide the size to get queue data

//
#define DEMO_PD_PACKET_ID                0x5A    //only for PD state in demo mode
#define DEMO_PD_PACKET_IDENTIFY          0xC0    //only for PD state in demo mode
#define HOTKNOT_PACKET_ID                0xA7
#define HOTKNOT_PACKET_TYPE              0x41    //for command and send packet
#define HOTKNOT_RECEIVE_PACKET_TYPE      0x40

//send length
#define HOTKNOT_CMD_LEN                  4
#define HOTKNOT_AUTH_LEN                 4
#define HOTKNOT_WRITECIPHER_LEN          21
#define HOTKNOT_SEND_LEN                 136
#define HOTKNOT_RECEIVE_LEN              4      //TBD
#define HOTKNOT_MAX_DATA_LEN             128 
#define HOTKNOT_GETQUEUE_LEN             4 

//receive length
#define KEYINDEX_LEN                     4
#define QUERYVERSION_LEN                 4 
#define CIPHER_LEN                       16
#define DEMO_PD_PACKET_RET_LEN           43
#define MAX_PD_PACKET_RET_LEN            100    //TBD  
#define DEMO_HOTKNOT_SEND_RET_LEN        150
#define DEMO_HOTKNOT_RECEIVE_RET_LEN     150
#define DEBUG_HOTKNOT_SEND_RET_LEN       250
#define DEBUG_HOTKNOT_RECEIVE_RET_LEN    250

//result
#define RESULT_OK                        0
#define RESULT_FAIL                      1
#define RESULT_TIMEOUT                   2

//hotknot mode
#define HOTKNOT_BEFORE_TRANS_STATE       0x91    //read_pair_state success, fw send 43 bytes to driver
#define HOTKNOT_TRANS_STATE              0x92    //enter_transfer_mode success, fw send 150 bytes to driver
#define HOTKNOT_AFTER_TRANS_STATE        0x93    //exit_transfer_mode, fw send 43 bytes to driver
#define HOTKNOT_NOT_TRANS_STATE          0x94    //enter_slave_mode success, fw send 43 bytes to driver



////////////////////////////////////////////////////////////
/// COMPILE OPTION DEFINITION                                        
////////////////////////////////////////////////////////////
//#define CONFIG_ENABLE_HOTKNOT_RCV_BLOCKING



////////////////////////////////////////////////////////////
/// Function Prototypes
////////////////////////////////////////////////////////////
extern void ReportHotKnotCmd(u8 *pPacket, u16 nLength);
extern long HotKnotIoctl( struct file *pFile, unsigned int nCmd, unsigned long nArg );


#endif //CONFIG_ENABLE_HOTKNOT
#endif // __MSTAR_DRV_HOTKNOT_H__