2 * drivers/input/touchscreen/gsl_point_id.c
4 * Copyright (c) 2012 Shanghai Basewin
5 * Guan Yuwei<guanyuwei@basewin.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 //#include "linux/module.h"
17 IN PDRIVER_OBJECT DriverObject,
18 IN PUNICODE_STRING RegistryPath
22 #pragma alloc_text(INIT, DriverEntry)
26 DllInitialize( IN PUNICODE_STRING pus )
28 DbgPrint("GSL_POINT_ID: DllInitialize(%S)\n", pus->Buffer );
29 return STATUS_SUCCESS;
35 DbgPrint("GSL_POINT_ID: DllUnload\n");
36 return STATUS_SUCCESS;
39 //#define GESTURE_ABLE 1
40 #define GESTURE_LICH 1
42 #define GSL_VERSION 0x20140421
44 #define NULL ((void*)0)
47 #define UINT unsigned int
54 #define POINT_DEEP (PP_DEEP + PS_DEEP + PR_DEEP)
55 #define PRESSURE_DEEP 8
56 #define CONFIG_LENGTH 512
59 #define FLAG_ABLE (0x4<<12)
60 #define FLAG_FILL (0x2<<12)
61 #define FLAG_KEY (0x1<<12)
62 #define FLAG_COOR (0x0fff0fff)
63 #define FLAG_COOR_EX (0xffff0fff)
64 #define FLAG_ID (0xf0000000)
78 unsigned int min;//distance min
79 unsigned int d[POINT_MAX][POINT_MAX];//distance;
125 unsigned interpolation:4;
155 unsigned over_report_mask:1;
156 unsigned opposite_x:1;
157 unsigned opposite_y:1;
158 unsigned opposite_xy:1;
161 unsigned line_half:1;
162 unsigned middle_drv:1;
164 unsigned key_only_one:1;
168 unsigned base_median:1;
170 unsigned refe_reset:1;
171 unsigned sub_cross:1;
174 unsigned sub_line_coe:1;
175 unsigned sub_row_coe:1;
179 unsigned init_repeat:1;
180 unsigned near_reset_able:1;
183 unsigned emb_point_mask:1;
184 unsigned interpolation:1;
185 unsigned sum2_able:1;
186 unsigned reduce_pin:1;
187 unsigned drv_order_ex:1;
194 static gsl_POINT_TYPE point_array[POINT_DEEP][POINT_MAX];
195 static gsl_POINT_TYPE *point_pointer[PP_DEEP];
196 static gsl_POINT_TYPE *point_stretch[PS_DEEP];
197 static gsl_POINT_TYPE *point_report[PR_DEEP];
198 static gsl_POINT_TYPE point_now[POINT_MAX];
199 static gsl_DELAY_TYPE point_delay[POINT_MAX];
200 static int filter_deep[POINT_MAX];
201 static gsl_EDGE_TYPE point_edge;
202 static gsl_DECIMAL_TYPE point_decimal[POINT_MAX];
204 static unsigned int pressure_now[POINT_MAX];
205 static unsigned int pressure_array[PRESSURE_DEEP][POINT_MAX];
206 static unsigned int pressure_report[POINT_MAX];
207 static unsigned int *pressure_pointer[PRESSURE_DEEP];
209 #define pp point_pointer
210 #define ps point_stretch
211 #define pr point_report
212 #define point_predict pp[0]
213 #define pa pressure_pointer
215 static gsl_STATE_TYPE global_state;
216 static int inte_count;
217 static unsigned int csensor_count;
218 static unsigned int click_count[4];
219 static gsl_POINT_TYPE point_click[4];
220 static unsigned int double_click;
222 static int point_num;
224 static int point_near;
225 static unsigned int point_shake;
226 static unsigned int reset_mask_send;
227 static unsigned int reset_mask_max;
228 static unsigned int reset_mask_count;
229 static gsl_FLAG_TYPE global_flag;
230 static unsigned int id_first_coe;
231 static unsigned int id_speed_coe;
232 static unsigned int id_static_coe;
233 static unsigned int average;
234 static unsigned int soft_average;
235 static unsigned int report_delay;
236 static unsigned int report_ahead;
237 static unsigned char median_dis[4];
238 static unsigned int shake_min;
239 static int match_y[2];
240 static int match_x[2];
241 static int ignore_y[2];
242 static int ignore_x[2];
243 static int screen_y_max;
244 static int screen_x_max;
245 static int point_num_max;
246 static unsigned int drv_num;
247 static unsigned int sen_num;
248 static unsigned int drv_num_nokey;
249 static unsigned int sen_num_nokey;
250 static unsigned int coordinate_correct_able;
251 static unsigned int coordinate_correct_coe_x[64];
252 static unsigned int coordinate_correct_coe_y[64];
253 static unsigned int edge_cut[4];
254 static unsigned int stretch_array[4*4*2];
255 static unsigned int shake_all_array[2*8];
256 static unsigned int reset_mask_dis;
257 static unsigned int reset_mask_type;
258 static unsigned int key_map_able;
259 static unsigned int key_range_array[8*3];
260 static int filter_able;
261 static unsigned int filter_coe[4];
262 static unsigned int multi_x_array[4],multi_y_array[4];
263 static unsigned int multi_group[4][64];
264 static int ps_coe[4][8],pr_coe[4][8];
265 static int point_repeat[2];
266 static int near_set[2];
268 // unsigned int key_dead_time ;
269 // unsigned int point_dead_time ;
270 // unsigned int point_dead_time2 ;
271 // unsigned int point_dead_distance ;
272 // unsigned int point_dead_distance2 ;
273 // unsigned int pressure_able;
274 // unsigned int pressure_save[POINT_MAX];
275 static unsigned int edge_first;
276 static unsigned int edge_first_coe;
278 static unsigned int point_corner;
279 //-------------------------------------------------
280 static unsigned int config_static[CONFIG_LENGTH];
281 //-------------------------------------------------
285 #define GesturePtNum 15
295 unsigned int data_int;
301 POINT_TYPE_DEFINE point_buff[MAXSTACK];
310 static TouchFinger point_stack;
311 static int qushi_x[10];
312 static int qushi_y[10];
313 static int vector_change_x[MAXSTACK];
314 static int vector_change_y[MAXSTACK];
315 static int rate_weight[MAXSTACK];
316 static POINT_TYPE_DEFINE top,bottom,left,right;
317 static int Letter_width;
318 static int Letter_height;
319 static unsigned int max_x,min_x,max_y,min_y;
320 static char gesture_letter;
322 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++
324 #define GESTURE_BUF_SIZE 256
325 #define GESTURE_SIZE_REFE 255
326 #define GESTURE_SIZE_NUM 32
327 #define GESTURE_XY 0x1
328 #define GESTURE_DEAL 0x2
329 #define GESTURE_LRUD 0x4
330 #define GESTURE_ALL 0x7fffffff
345 unsigned int coor[GESTURE_SIZE_NUM/2];
347 //GESTURE_POINT_TYPE gesture_buf[GESTURE_BUF_SIZE];//gesture_buf
348 #define gesture_buf ((GESTURE_POINT_TYPE*)config_static)
349 #define gesture_standard ((GESTURE_POINT_TYPE*)(&config_static[GESTURE_BUF_SIZE]))
350 static int gesture_num,gesture_num_last;//gesture_num
351 static int gesture_dis_min;
352 static int gesture_deal;
353 static int gesture_last;
354 static int gesture_threshold[2];
357 static int double_down,double_up;
358 static const GESTURE_MODEL_TYPE * model_extern = NULL;
359 static int model_extern_len = 0;
360 static int GestureSqrt(int d);
361 static int GestureDistance(GESTURE_POINT_TYPE* d1,GESTURE_POINT_TYPE* d2,int sqrt_able);
362 static int GesturePush(GESTURE_POINT_TYPE* data);
363 static int GestureStretch(void);
364 static int GestureLength(void);
365 static int GestureDeal(void);
366 static int GestureModel(const GESTURE_MODEL_TYPE * model,int len,int threshold,int *out);
367 static int GestureMain(unsigned int data[],unsigned int pn);
368 static void GestureStandard(void);
369 static void GestureInit(void);
370 static void ChangeXY(void);
371 static int GestureLRUD(void);
372 static void GestureSet(unsigned int conf[]);
373 static const GESTURE_MODEL_TYPE model_default[]
376 0x37170105,0x78580000,0xba990a03,0xedd92e14,0xb9d85347,0x7798655b,0x3657716b,0x1f156d74,
377 0x60406969,0xa2816f69,0xe3c28075,0xf9fbb899,0xc3e3e0d2,0x83a4f6ee,0x4262fffc,0x0021f7fd,}},
379 0xa2be0400,0x70881f10,0x4258402e,0x1d2e6c54,0x040ea084,0x0a01d6bc,0x381df9ec,0x7054fffd,
380 0xa88cfafe,0xdac2ddef,0xfff0b2cb,0xe2f78497,0xaac7747a,0x728e7472,0x3b56817b,0x0420968b,}},
382 0x12000001,0x37240000,0x5b490000,0x806e0000,0xa5930000,0xcab70000,0xefdc0300,0xf9fd1f0e,
383 0xe2ee3d30,0xc5d4564a,0xa7b76c61,0x8c9a8579,0x717e9f93,0x5863bbad,0x434cdbc9,0x3c3dffec,}},
385 0xdaff030c,0x8eb40000,0x41670c06,0x001c3116,0x431e5448,0x8f69635d,0xd1b58a6f,0xcedfd0af,
386 0x88acf5e6,0x3c62fffd,0x0718cdf1,0x341493aa,0x7a556d7d,0xc19e4f60,0xf9e51c3c,0xb5dc0005,}},
388 0x627d231e,0x2f49382c,0x03175a48,0x21098172,0x563c958c,0x856eb0a2,0x8f99dac4,0x5b76eee5,
389 0x243ffdf5,0x090ddbf4,0x2918acc2,0x4d3a8497,0x78636172,0xa38e4050,0xd0ba1f2e,0xffe7000f,}},
391 0xe8ff0715,0xb4ce0001,0x819a0500,0x4f68150c,0x1e362a1e,0x000c543c,0x270d7169,0x5b417273,
392 0x9076666d,0xbda74a5a,0xddcf1e36,0xc8d7321b,0xb4be634b,0xa4ac967d,0x959ccab0,0x898fffe4,}},
394 0xaeca000b,0x74900e02,0x41582d1b,0x182a5942,0x02099375,0x0600cfb1,0x2c15fcea,0x664af1fe,
395 0x957ec8dd,0xb5a894b0,0xc9bf5876,0xd7d31c3a,0xd4d75134,0xd3d38d6f,0xdbd4c9ab,0xffe9fce6,}},
397 0x8eab0102,0x56711307,0x2c3f3a25,0x0e1b6b51,0x0004a689,0x0e02ddc2,0x3e22fbf2,0x725be8fa,
398 0x9284b6d0,0xa69d7f9b,0xb3ae4562,0xb7b80b28,0xa7a6290c,0xb1aa6346,0xd0be947d,0xffe7bba7,}},
400 0x56591a00,0x474e4e35,0x343f8168,0x242cb59c,0x0f1be7ce,0x170ddbf4,0x3c25b4c4,0x6e549ca6,
401 0xa3889799,0xd8bd9d96,0xfcf1bea8,0xd3e9e4d4,0xa0baf6f0,0x6b85fcfa,0x3650fffd,0x001bfbff,}},
403 0xfaff2337,0xdaec0913,0xb0c50003,0x879c0500,0x5f720f09,0x3b4c271a,0x1d2b4534,0x08116a56,
404 0x0003937f,0x0a03bca8,0x2515ddce,0x4b38f2e8,0x7560fff9,0x9e89f7fd,0xc6b2e8f0,0xeed9d7df,}},
406 0xacbf0100,0x86990a04,0x64751b12,0x45533225,0x2b375141,0x17217160,0x080f9582,0x0103bba8,
407 0x0200e2cf,0x200ff9f1,0x4633fefc,0x6c59ffff,0x9380fcfd,0xb9a6f4f9,0xdccbe4ed,0xffeeceda,}},
409 0x57670a00,0x3a492116,0x222d3d2e,0x0f175e4d,0x0408816f,0x0001a693,0x0300cab8,0x0e07eddc,
410 0x2f1dfefb,0x5241f5fc,0x7362e2ec,0x8e80c9d6,0xa89bafbc,0xc3b594a1,0xe1d27e89,0xfff06673,}},
412 0x99b5858f,0x5f7c8883,0x28429c8f,0x010fc6ab,0x240cf4e1,0x5d41fefb,0x957af1fc,0xc1adcbe0,
413 0xd2cc92af,0xd3d25875,0xd7d71f3b,0xd7d71b02,0xd4d75538,0xd4d48f72,0xe1d9c9ac,0xffe6f4e6,}},
415 0x391c948f,0x73569595,0xad908a92,0xddc8677e,0xf1ee304d,0xc3dd0d1b,0x89a70002,0x536d1304,
416 0x233b3a25,0x08137053,0x0301aa8d,0x220edcc6,0x573af7ee,0x9174fffc,0xcaaef6ff,0xffe5dbeb,}},
418 0xaaca0000,0x698a0000,0x2a491106,0x000f4226,0x23067061,0x64437674,0xa3836874,0xdac04759,
419 0xfaec0b2a,0xfefb401f,0xffff8160,0xf5fdc0a1,0xc9e9eedf,0x89a9fff9,0x4869faff,0x0928e3f3,}},
421 0xeaff1421,0xb9d20308,0x88a00000,0x57700f05,0x2b3f2618,0x09174d37,0x00037f66,0x0d05af97,
422 0x2a1adac7,0x5940ede5,0x8b72f2f3,0xbca4e9ee,0xe4d2cbde,0xfbf09cb3,0xf5f8ceb5,0xe9f1ffe6,}},
424 0x03021300,0x06053a26,0x0b0a604d,0x0b0b8774,0x0a0bae9a,0x0506d4c1,0x0002fbe8,0x1104e0f0,
425 0x2e1ec3d1,0x503dadb5,0x7764a5a7,0x9e8aa1a2,0xc4b1a3a0,0xead8ada8,0xfff8d1bd,0xfffff8e4,}},
427 0x1d1a2000,0x171a6040,0x1114a080,0x060edfc0,0x1100e2ff,0x3420a8c5,0x6f4f8b95,0xaf8f8285,
428 0xefcf8683,0xe1fcb3a0,0xa0c1c2bb,0x6080c6c5,0x2c40c9c7,0x6c4cd8d1,0xac8ceadf,0xedccfef3,}},
430 0x22341900,0x15185436,0x0e119072,0x0c0cccae,0x0709f6ea,0x0a07b9d8,0x2918859e,0x5b406170,
431 0x90796658,0x627c8b7c,0x2a47a79a,0x110db8b1,0x4d2fbfbc,0x896bcac4,0xc3a6d9d1,0xffe1ede2,}},
433 0x3f4a0c00,0x35372c1c,0x2c314d3d,0x26296e5d,0x1b218e7e,0x1316af9f,0x0910cfc0,0x0004f1e0,
434 0x1605ffff,0x3727ffff,0x5848ffff,0x7a69fdff,0x9b8afcfd,0xbcabfcfc,0xddcdfafb,0xffeef9f9,}},
436 0x0900e0ff,0x2017a0c0,0x3a296381,0x4e442443,0x5a583010,0x6b5f6f4f,0x7471ae8f,0x7977eece,
437 0x8c80c5e5,0xa19886a5,0xbaad4766,0xd3c70a29,0xddda3516,0xe7e17555,0xf4f0b494,0xfffaf4d4,}},
439 0x0400e7ff,0x130bb8cf,0x281e89a1,0x38305a71,0x51452c43,0x675d1d13,0x68684e36,0x6b697f66,
440 0x726fb097,0x7875e0c8,0x907ee8f8,0xa79ebbd2,0xbfb38fa4,0xd1c95f77,0xe6da3148,0xfff20019,}},
442 0x2e3f311f,0x101e5c46,0x03088f76,0x0001c2a8,0x1e08e7da,0x4f35fdf4,0x8168fcff,0xb39beef5,
443 0xdac7cedf,0xf3e9a0b8,0xfef96d87,0xf9ff3c54,0xdaec1326,0xaac30108,0x77900100,0x465e1407,}},
445 0xd0e30213,0x9cb60000,0x68820c05,0x384f2416,0x17254c36,0x040c8066,0x0001b49a,0x1305e4ce,
446 0x442bfaf0,0x785efffe,0xab92f1f9,0xd3c1cfe3,0xf1e3a1b9,0xfffa6e88,0xf8ff3b54,0xd5e81024,}},
448 0x000f768a,0x0900455d,0x2b171e30,0x5a420611,0x8d740100,0xbca5170b,0xe3d23824,0xfcf2644c,
449 0xfaff977e,0xe3f0c4af,0xbdd2e6d7,0x8ea7faf2,0x5b74fefe,0x2e44e9f6,0x0a1bc2d6,0x02028fa9,}},
451 0x829c0900,0x4e682315,0x24384a34,0x08157c61,0x0002b598,0x0d03edd1,0x4326fffd,0x7a5feef8,
452 0xab93cfe0,0xd5c1a7bd,0xf4e67690,0xfbff3d5a,0xcfec1b26,0x96b31818,0x5e7a251d,0x28433b2f,}},
454 0x381e5e68,0x6e535156,0xa388504f,0xd8be5e56,0xf9ed876d,0xf9fcbaa1,0xd8ece5d2,0xa5c0f9f2,
455 0x708bfffd,0x3b55fbfe,0x1423d7ed,0x0006a4bf,0x09027089,0x26154157,0x50391e2e,0x7e670010,}},
457 0x8670020b,0xb8a01307,0xe3ce3423,0xf8f0664c,0xfffc9b81,0xf1faceb5,0xcee4f4e5,0x9ab4fffb,
458 0x657fffff,0x364ceaf8,0x1623c0d7,0x00098ea7,0x06015973,0x24122e41,0x4d380c1c,0x82670104,}},
460 0xb7cf0001,0x869e0301,0x556d0905,0x273e1f12,0x0311442c,0x2009665a,0x5138726b,0x826a7876,
461 0xb39b807b,0xdfcb998b,0xfff5bea7,0xdcf2ded0,0xadc6f1e8,0x7c94fbf7,0x4b63fffd,0x1932ffff,}},
463 0xcbde0200,0xa8ba1209,0x8597241a,0x6a753f2f,0x806c5751,0xa6935e5b,0xccb96662,0xf2e0746b,
464 0xfcff9482,0xe0f0b2a6,0xbdcfc2bb,0x97abd1c9,0x7385ddd7,0x4c60e8e3,0x273af4ee,0x0014fff9,}},
466 0x050d2209,0x0001573c,0x03008c71,0x1106bfa6,0x2f1bebda,0x604ae1f0,0x8873bccd,0xa59990a8,
467 0xbcb05f78,0xcdc72c46,0xd0d00911,0xc9cb3e24,0xc6c87359,0xc9c6a88d,0xd8d2ddc2,0xffe4fff6,}},
469 0x09000f00,0x1911301f,0x27205240,0x342d7563,0x413a9785,0x4f47b9a8,0x6057d9c9,0x7569f9ea,
470 0x9486f4ff,0xa99fd5e5,0xb8b0b4c5,0xc9c093a3,0xdbd17484,0xe9e35263,0xf5ef2f41,0xfff90b1d,}},
472 0x08001908,0x160f3b2b,0x251d5d4c,0x312b806f,0x3e37a392,0x4843c6b5,0x524de9d8,0x5b58f2fb,
473 0x6560cfe0,0x776dafbf,0x8a8090a0,0x9d947080,0xb4a85361,0xccc03745,0xe6d91d2a,0xfff2000e,}},
475 0x06001f00,0x110c5f3f,0x1c189f7f,0x2822debe,0x4131e3fd,0x554ba4c3,0x655c6484,0x786f2444,
476 0x847f2f0f,0x8a866f4f,0x928eae8f,0x9e99eece,0xbaacd0ee,0xd5c893b3,0xebe05373,0xfff61333,}},
478 0xf7ff2000,0xe4ed6040,0xd5dba181,0xbdcbe0c0,0xa0aad3f3,0x909892b3,0x848a5272,0x80811131,
479 0x777d3d1d,0x636d7e5e,0x535bbf9e,0x3c48fdde,0x272fc1e2,0x121a82a2,0x030a4161,0x00020021,}},
481 0x16000b13,0x442d0303,0x4b48341b,0x61505e4b,0x91795c62,0xbca74551,0xe1d02637,0xfcf40c14,
482 0xe8f13922,0xdbe16951,0xd6d99a82,0xced3cbb2,0xb0c4f0e1,0x7f98fbf7,0x4e67fefd,0x1d36fdff,}},
484 0x30160200,0x644a0403,0x997f0303,0xcdb30202,0xe7e80d00,0xc4d63622,0x9bb05c4a,0x73857f6c,
485 0x5061a893,0x293eccbb,0x0013f2dd,0x2d13fcfd,0x6248f6f8,0x967cf1f3,0xcbb1edef,0xffe5f1ec,}},
486 //--------------------------------------------------------------------------------------------
488 0x0003ecff,0x0502c6d9,0x0b099fb2,0x1410788c,0x221b5265,0x362b2f40,0x5341121d,0x7966020a,
489 0xa08d0100,0xc3b3170b,0xd9ce3a28,0xede25f4d,0xf4f28672,0xfaf6ac99,0xfffdd3c0,0xfffffae6,}},
491 0x1900847d,0x4c328785,0x7f658b88,0xb198898b,0xe3cb7f88,0xf8f24f68,0xecf81d35,0xbfd9010b,
492 0x90a61504,0x8186462d,0x7c7d7960,0x7f7bac93,0x8883dfc6,0xaf97fff4,0xdcc7eafa,0xffeec1d7,}},
494 0x7543141a,0xd7a82e17,0xf8f78f5c,0xc6e6e9bf,0x6497f8fa,0x1338b3db,0x03024f82,0x4a1c0620,
495 0xaf7c1001,0xf8da582b,0xeafebc8b,0x9acbfbe6,0x3868eeff,0x0a1892c4,0x2712305f,0x85520e11,}},
497 0x04003204,0x120b8e60,0x1714ebbd,0x2f27b8e6,0x43385b89,0x5b4c032d,0x6a666032,0x7770bc8e,
498 0x8c82b8e6,0x9b945c8a,0xaea2012d,0xbbb75d2f,0xc9c1ba8c,0xe3d5bce7,0xf1ea5f8d,0xfff50231,}},
500 0x1900020a,0x4d330400,0x7c65180a,0xa18f3f2b,0xb3ac7258,0xbcb8a58b,0xb0b9d7bf,0x8aa0fcec,
501 0x5971f2fd,0x414bc2db,0x433f8ea8,0x534a5d76,0x71613246,0x9d85101e,0xd0b60609,0xffea1409,}},
503 0xdeff0714,0x9abc0002,0x57790a02,0x1d373018,0x01076d4b,0x2f0f988a,0x72519c9c,0xb2948b9c,
504 0xa3bc576b,0x60815653,0x26417963,0x020eb191,0x2005e7d3,0x6442fbf4,0xa785fbff,0xebc9e7f3,}},
506 0xf6ff0600,0xe4ed140c,0xd5dd261d,0xc5cd362e,0xb3bc463e,0xa2aa574e,0x939a6860,0x83897970,
507 0x747c8a82,0x646c9c93,0x525baca4,0x434abdb4,0x333bcfc6,0x222addd5,0x121beee6,0x0009fff6,}},
509 0x09000900,0x19111b13,0x28202d24,0x39303d35,0x49424e45,0x5a515d56,0x6b626d65,0x7d747b74,
510 0x8e868b82,0x9d969c93,0xaca4aea5,0xbcb4bfb6,0xcac4d1c7,0xdbd2e1d9,0xece3f1e9,0xfff5fff8,}},
512 0x0a00faff,0x1d14edf4,0x2e25dce5,0x3e36cbd4,0x4e44bac2,0x5f57aab2,0x6f679aa2,0x7f778890,
513 0x8c85757e,0x9c94636b,0xaba3515a,0xbbb2414a,0xcbc33039,0xddd31f28,0xeee51119,0xfff7000a,}},
515 0xf4fffaff,0xe1eaeff6,0xd1d9dde6,0xc1cacdd5,0xb4bbbac3,0xa2aca8b0,0x929a99a1,0x83888791,
516 0x767d747d,0x666e636b,0x535c545e,0x444d424b,0x333d323a,0x242b212a,0x141c0f18,0x000a0008,}},
518 0x30000208,0x90600200,0xf1c11e0c,0xb5e64d3f,0x55855653,0x32245556,0x93625756,0xf1c3745e,
519 0xbaeaa997,0x598ab2b0,0x0f29aab1,0x7040a8a7,0xd1a0b8ae,0xd0f8ecd0,0x6f9ffcf5,0x0e3ffcff,}},
521 0x2600140c,0x66494226,0x827c8d66,0x6d80d8b4,0x284ffaf4,0x0a0ab9e0,0x411f8097,0x8e689182,
522 0xd6b47f94,0xf9f23960,0xd5f80012,0x91af270a,0x7e83734c,0x7e7dc19a,0xb490fae5,0xffdbe9fe,}},
524 0x768e0c00,0x465e2619,0x192f4635,0x0107745a,0x32178a85,0x674d858a,0x9b81747d,0xccb45c69,
525 0xf7e33b4d,0xebfd0d21,0xb6d00004,0x939e270d,0x888d5d42,0x83859378,0x7c80c9ae,0x6c75ffe4,}},
527 0xb3bd1000,0x9ea82d1e,0x87924a3b,0x6f7b6658,0x56628375,0x3e4a9e91,0x2934bcad,0x1720ddcd,
528 0x010bfced,0x2513ffff,0x4937fdff,0x6d5bf9fa,0x9280f4f7,0xb6a4f0f1,0xdac8eeef,0xffececed,}},
531 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++
532 static void SortBubble(int t[],int size)
538 for(n=m+1;n<size;n++)
554 static int Sqrt(int d)
560 if((ret + (0x1<<i))*(ret + (0x1<<i)) <= d)
566 static void PointCoor(void)
570 for(i=0;i<point_num;i++)
572 if(global_state.other.ex)
573 point_now[i].all &= (FLAG_COOR_EX | FLAG_KEY | FLAG_ABLE);
575 point_now[i].all &= (FLAG_COOR | FLAG_KEY | FLAG_ABLE);
578 static void PointRepeat(void)
582 int x_min,x_max,y_min,y_max;
586 if(prev_num > point_num)
588 if(point_repeat[0]==0 || point_repeat[1]==0)
598 pn = point_repeat[1];
600 pn = point_repeat[0];
602 for(i=0;i<POINT_MAX;i++)
604 if(point_now[i].all == 0)
606 if (point_now[i].other.key)
608 x_min = point_now[i].other.x - pn;
609 x_max = point_now[i].other.x + pn;
610 y_min = point_now[i].other.y - pn;
611 y_max = point_now[i].other.y + pn;
612 for(j=i+1;j<POINT_MAX;j++)
614 if(point_now[j].all == 0)
616 if (point_now[j].other.key)
618 x = point_now[j].other.x;
619 y = point_now[j].other.y;
620 if(x>x_min && x<x_max && y>y_min && y<y_max)
622 point_now[i].other.x =
623 (point_now[i].other.x +
624 point_now[j].other.x + 1) / 2;
625 point_now[i].other.y =
626 (point_now[i].other.y +
627 point_now[j].other.y + 1) / 2;
628 point_now[j].all = 0;
637 static void PointPointer(void)
641 if(point_n >= PP_DEEP * PS_DEEP * PR_DEEP * PRESSURE_DEEP)
643 pn = point_n % PP_DEEP;
644 for(i=0;i<PP_DEEP;i++)
646 pp[i] = point_array[pn];
652 pn = point_n % PS_DEEP;
653 for(i=0;i<PS_DEEP;i++)
655 ps[i] = point_array[pn+PP_DEEP];
661 pn = point_n % PR_DEEP;
662 for(i=0;i<PR_DEEP;i++)
664 pr[i] = point_array[pn+PP_DEEP+PS_DEEP];
670 pn = point_n % PRESSURE_DEEP;
671 for(i=0;i<PRESSURE_DEEP;i++)
673 pa[i] = pressure_array[pn];
675 pn = PRESSURE_DEEP - 1;
679 //------------------------------------------------------
681 for(i=0;i<POINT_MAX;i++)
684 point_now[pn++].all = point_now[i].all;
690 for(i=pn;i<POINT_MAX;i++)
691 point_now[i].all = 0;
694 static unsigned int CCO(unsigned int x,unsigned int coe[],int k)
699 return (x & ~31)+(31 - (coe[31-(x&31)] & 31));
701 return (x & ~31)+(coe[x&31] & 31);
706 return (x & ~63)+(63 - (coe[63-(x&63)] & 63));
708 return (x & ~63)+(coe[x&63] & 63);
712 return (x & ~63)+(coe[x&63] & 63);
717 static void CoordinateCorrect(void)
724 #ifdef LINE_MULTI_SIZE
725 #define LINE_SIZE LINE_MULTI_SIZE
730 unsigned int *px[LINE_SIZE+1],*py[LINE_SIZE+1];
731 MULTI_TYPE multi_x[LINE_SIZE],multi_y[LINE_SIZE];
732 unsigned int edge_size = 64;
734 if((coordinate_correct_able&0xf) == 0)
736 kx = (coordinate_correct_able>>4)&0xf;
737 ky = (coordinate_correct_able>>8)&0xf;
738 px[0] = coordinate_correct_coe_x;
739 py[0] = coordinate_correct_coe_y;
740 for(i=0;i<LINE_SIZE;i++)
745 if(kx == 3 || ky == 3)
748 if(((coordinate_correct_able>>4)&0xf) == 3)
749 px[1] = multi_group[i++];
750 if(((coordinate_correct_able>>8)&0xf) == 3)
751 py[1] = multi_group[i++];
755 for(i=0;i<LINE_SIZE;i++)
757 multi_x[i].range = multi_x_array[i] & 0xffff;
758 multi_x[i].group = multi_x_array[i] >> 16;
759 multi_y[i].range = multi_y_array[i] & 0xffff;
760 multi_y[i].group = multi_y_array[i] >> 16;
763 for(i=0;i<LINE_SIZE;i++)
764 if(multi_x[i].range && multi_x[i].group<LINE_SIZE)
765 px[j++] = multi_group[multi_x[i].group];
767 for(i=0;i<LINE_SIZE;i++)
768 if(multi_y[i].range && multi_y[i].group<LINE_SIZE)
769 py[j++] = multi_group[multi_y[i].group];
771 for(i=0;i<(int)point_num && i<POINT_MAX;i++)
773 if(point_now[i].all==0)
775 if (point_now[i].other.key != 0)
777 if (point_now[i].other.x >= edge_size &&
778 point_now[i].other.x <= drv_num_nokey * 64 - edge_size)
782 if (point_now[i].other.x & 64)
783 point_now[i].other.x = CCO(point_now[i].other.x, px[0], 2);
785 point_now[i].other.x = CCO(point_now[i].other.x, px[1], 2);
789 for(j=0;j<LINE_SIZE+1;j++)
791 if (!(j >= LINE_SIZE ||
793 multi_x[j].range == 0 ||
794 point_now[i].other.x < multi_x[j].range))
796 point_now[i].other.x = CCO(point_now[i].other.x, px[j], kx);
801 if (point_now[i].other.y >= edge_size &&
802 point_now[i].other.y <= sen_num_nokey * 64 - edge_size)
806 if (point_now[i].other.y & 64)
807 point_now[i].other.y = CCO(point_now[i].other.y, py[0], 2);
809 point_now[i].other.y = CCO(point_now[i].other.y, py[1], 2);
813 for(j=0;j<LINE_SIZE+1;j++)
815 if (!(j >= LINE_SIZE ||
817 multi_y[j].range == 0 ||
818 point_now[i].other.y < multi_y[j].range))
820 point_now[i].other.y = CCO(point_now[i].other.y, py[j], ky);
829 static void PointPredictOne(unsigned int n)
831 pp[0][n].all = pp[1][n].all & FLAG_COOR;
832 pp[0][n].other.predict = 0;
835 static void PointPredictTwo(unsigned int n)
839 t = pp[1][n].other.x * 2;
840 if (t > pp[2][n].other.x)
841 t -= pp[2][n].other.x;
845 pp[0][n].other.x = 0xffff;
847 pp[0][n].other.x = t;
848 t = pp[1][n].other.y * 2;
849 if (t > pp[2][n].other.y)
850 t -= pp[2][n].other.y;
854 pp[0][n].other.y = 0xfff;
856 pp[0][n].other.y = t;
857 pp[0][n].other.predict = 1;
860 static void PointPredictThree(unsigned int n)
864 t = pp[1][n].other.x * 5 + pp[3][n].other.x;
865 t2 = pp[2][n].other.x * 4;
872 pp[0][n].other.x = 0xffff;
874 pp[0][n].other.x = t;
875 t = pp[1][n].other.y * 5 + pp[3][n].other.y;
876 t2 = pp[2][n].other.y * 4;
883 pp[0][n].other.y = 0xfff;
885 pp[0][n].other.y = t;
886 pp[0][n].other.predict = 1;
889 static void PointPredict(void)
892 for(i=0;i<POINT_MAX;i++)
894 if(pp[1][i].all != 0)
896 if (global_state.other.interpolation
898 || pp[2][i].other.fill != 0
899 || pp[3][i].other.fill != 0
900 || pp[1][i].other.key != 0
901 || global_state.other.only)
905 else if(pp[2][i].all != 0)
907 if(pp[3][i].all != 0)
908 PointPredictThree(i);
912 pp[0][i].all |= FLAG_FILL;
916 pp[0][i].all = 0x0fff0fff;
917 if (pp[1][i].other.key)
918 pp[0][i].all |= FLAG_KEY;
922 static unsigned int PointDistance(gsl_POINT_TYPE *p1,gsl_POINT_TYPE *p2)
934 static void DistanceInit(gsl_DISTANCE_TYPE *p)
937 unsigned int *p_int = &(p->d[0][0]);
938 for(i=0;i<POINT_MAX*POINT_MAX;i++)
939 *p_int++ = 0x7fffffff;
942 static int DistanceMin(gsl_DISTANCE_TYPE *p)
946 for(j=0;j<POINT_MAX;j++)
948 for(i=0;i<POINT_MAX;i++)
950 if(p->d[j][i] < p->min)
958 if(p->min == 0x7fffffff)
963 static void DistanceIgnore(gsl_DISTANCE_TYPE *p)
966 for(i=0;i<POINT_MAX;i++)
967 p->d[p->j][i] = 0x7fffffff;
968 for(j=0;j<POINT_MAX;j++)
969 p->d[j][p->i] = 0x7fffffff;
972 static int SpeedGet(int d)
983 static void PointId(void)
986 gsl_DISTANCE_TYPE distance;
987 unsigned int id_speed[POINT_MAX];
988 DistanceInit(&distance);
989 for(i=0;i<POINT_MAX;i++)
991 if (pp[0][i].other.predict == 0 || pp[1][i].other.fill != 0)
992 id_speed[i] = id_first_coe;
994 id_speed[i] = SpeedGet( PointDistance(&pp[1][i],&pp[0][i]) );
996 for(i=0;i<POINT_MAX;i++)
998 if(pp[0][i].all == FLAG_COOR)
1000 for(j=0;j<point_num && j<POINT_MAX;j++)
1002 distance.d[j][i] = PointDistance(&point_now[j],&pp[0][i]);
1007 if (global_state.other.only)
1011 if(DistanceMin(&distance))
1013 if (pp[1][0].all != 0 &&
1014 pp[1][0].other.key !=
1015 point_now[distance.j].other.key)
1017 DistanceIgnore(&distance);
1021 pp[0][0].all = point_now[distance.j].all;
1024 pp[0][0].all = point_now[0].all;
1025 for(i=0;i<POINT_MAX;i++)
1026 point_now[i].all = 0;
1033 for(j=0;j<point_num && j<POINT_MAX;j++)
1035 if(DistanceMin(&distance) == 0)
1037 if(distance.min >= (id_static_coe +
1038 id_speed[distance.i] * id_speed_coe) /**average/(soft_average+1)*/)
1040 //point_now[distance.j].id = 0xf;//new id
1043 pp[0][distance.i].all = point_now[distance.j].all;
1044 pa[0][distance.i] = pressure_now[distance.j];
1045 point_now[distance.j].all = 0;
1046 DistanceIgnore(&distance);
1051 static int ClearLenPP(int i)
1054 for(n=0;n<PP_DEEP;n++)
1061 static void PointNewId(void)
1064 for(j=0;j<POINT_MAX;j++)
1065 if((pp[0][j].all & FLAG_COOR) == FLAG_COOR)
1067 for(j=0;j<POINT_MAX;j++)
1069 if(point_now[j].all != 0)
1071 if (point_now[j].other.able)
1073 for(id=1;id<=POINT_MAX;id++)
1075 if(ClearLenPP(id-1) > (int)(1+1))
1077 pp[0][id-1].all = point_now[j].all;
1078 pa[0][id-1] = pressure_now[j];
1079 point_now[j].all = 0;
1087 static void PointOrder(void)
1090 for(i=0;i<POINT_MAX;i++)
1092 if (pp[0][i].other.fill == 0)
1094 if (pp[1][i].all == 0 || pp[1][i].other.fill != 0 || filter_able == 0 || filter_able == 1)
1097 pressure_now[i] = 0;
1102 static void PointCross(void)
1106 for(j=0;j<POINT_MAX;j++)
1108 for(i=j+1;i<POINT_MAX;i++)
1110 if(pp[0][i].all == 0 || pp[0][j].all == 0
1111 || pp[1][i].all == 0 || pp[1][j].all == 0)
1113 if (((pp[0][j].other.x < pp[0][i].other.x && pp[1][j].other.x > pp[1][i].other.x)
1114 || (pp[0][j].other.x > pp[0][i].other.x && pp[1][j].other.x < pp[1][i].other.x))
1115 && ((pp[0][j].other.y < pp[0][i].other.y && pp[1][j].other.y > pp[1][i].other.y)
1116 || (pp[0][j].other.y > pp[0][i].other.y && pp[1][j].other.y < pp[1][i].other.y)))
1118 t = pp[0][i].other.x;
1119 pp[0][i].other.x = pp[0][j].other.x;
1120 pp[0][j].other.x = t;
1121 t = pp[0][i].other.y;
1122 pp[0][i].other.y = pp[0][j].other.y;
1123 pp[0][j].other.y = t;
1129 static void GetPointNum(gsl_POINT_TYPE *pt)
1133 for(i=0;i<POINT_MAX;i++)
1138 static void PointDelay(void)
1141 for(i=0;i<POINT_MAX;i++)
1143 if(report_delay == 0)
1145 point_delay[i].all = 0;
1147 point_delay[i].other.able = 1;
1150 if (pp[0][i].all != 0 &&
1151 point_delay[i].other.init == 0 &&
1152 point_delay[i].other.able == 0)
1156 point_delay[i].other.delay = (report_delay >> 3 *
1157 ((point_num>10 ? 10 : point_num) - 1)) & 0x7;
1158 point_delay[i].other.report = (report_ahead >> 3 *
1159 ((point_num>10 ? 10 : point_num) - 1)) & 0x7;
1160 if (point_delay[i].other.report > point_delay[i].other.delay)
1161 point_delay[i].other.report = point_delay[i].other.delay;
1162 point_delay[i].other.init = 1;
1164 if(pp[0][i].all == 0)
1166 point_delay[i].other.init = 0;
1168 if (point_delay[i].other.able == 0 && point_delay[i].other.init != 0)
1170 for (j = 0; j <= (int)point_delay[i].other.delay; j++)
1171 if (pp[j][i].all == 0 ||
1172 pp[j][i].other.fill != 0 ||
1173 pp[j][i].other.able != 0)
1175 if (j <= (int)point_delay[i].other.delay)
1177 point_delay[i].other.able = 1;
1179 if (pp[point_delay[i].other.report][i].all == 0)
1181 point_delay[i].other.able = 0;
1184 if (point_delay[i].other.able == 0)
1186 if (point_delay[i].other.report)
1188 if (PointDistance(&pp[point_delay[i].other.report][i],
1189 &pp[point_delay[i].other.report - 1][i]) < 3 * 3)
1190 point_delay[i].other.report--;
1195 static void FilterOne(int i,int *ps_c,int *pr_c,int denominator)
1199 pr[0][i].all = ps[0][i].all;
1200 if(pr[0][i].all == 0)
1202 if(denominator <= 0)
1206 x += (int)pr[j][i].other.x * (int)pr_c[j] +
1207 (int)ps[j][i].other.x * (int)ps_c[j];
1208 y += (int)pr[j][i].other.y * (int)pr_c[j] +
1209 (int)ps[j][i].other.y * (int)ps_c[j];
1211 x = (x + denominator/2) / denominator;
1212 y = (y + denominator/2) / denominator;
1221 pr[0][i].other.x = x;
1222 pr[0][i].other.y = y;
1225 static unsigned int FilterSpeed(int i)
1227 return (Sqrt(PointDistance(&ps[0][i],&ps[1][i])) +
1228 Sqrt(PointDistance(&ps[1][i],&ps[2][i])))/2;
1231 static int MedianSpeedOver(int id,int deep)
1237 if(deep < 0 || deep > 3)
1239 dis = median_dis[deep] * median_dis[deep];
1240 for(i=0;i<=deep && i<POINT_DEEP;i++)
1242 if(PointDistance(&ps[i][id],&ps[i+1][id]) > dis)
1250 static void PointMedian(void)
1254 int buf_x[PS_DEEP],buf_y[PS_DEEP];
1255 for(i=0;i<POINT_MAX;i++)
1257 if(filter_deep[i] < 3)
1260 deep = filter_deep[i] + 2;
1264 for(;deep>=3;deep-=2)
1266 if(MedianSpeedOver(i,deep))
1270 buf_x[j] = ps[j][i].other.x;
1271 buf_y[j] = ps[j][i].other.y;
1273 SortBubble(buf_x,deep);
1274 SortBubble(buf_y,deep);
1275 pr[0][i].other.x = buf_x[deep / 2];
1276 pr[0][i].other.y = buf_y[deep / 2];
1278 filter_deep[i] = deep;
1281 static void PointFilter(void)
1285 int filter_speed[6];
1288 for(i=0;i<POINT_MAX;i++)
1290 pr[0][i].all = ps[0][i].all;
1292 for(i=0;i<POINT_MAX;i++)
1294 if(pr[0][i].all!=0 && pr[1][i].all == 0)
1296 for(j=1;j<PR_DEEP;j++)
1297 pr[j][i].all = ps[0][i].all;
1298 for(j=1;j<PS_DEEP;j++)
1299 ps[j][i].all = ps[0][i].all;
1302 if(filter_able >=0 && filter_able <= 1)
1308 ps_c[i] = (filter_coe[i/4] >> ((i%4)*8)) & 0xff;
1309 pr_c[i] = (filter_coe[i/4+2] >> ((i%4)*8)) & 0xff;
1311 ps_c[i] |= 0xffffff00;
1313 pr_c[i] |= 0xffffff00;
1315 for(i=0;i<POINT_MAX;i++)
1317 FilterOne(i,ps_c,pr_c,filter_able);
1320 else if(filter_able == -1)
1324 else if(filter_able < 0)
1327 filter_speed[i+1] = median_dis[i];
1328 filter_speed[0] = median_dis[0] * 2 - median_dis[1];
1329 filter_speed[5] = median_dis[3] /2;
1330 for(i=0;i<POINT_MAX;i++)
1332 if(pr[0][i].all == 0)
1337 speed_now = FilterSpeed(i);
1338 if(filter_deep[i] > 0 &&
1339 speed_now > filter_speed[filter_deep[i]+1 - 2])
1341 else if(filter_deep[i] < 3 &&
1342 speed_now < filter_speed[filter_deep[i]+1 + 2])
1345 FilterOne(i,ps_coe[filter_deep[i]],
1346 pr_coe[filter_deep[i]],0-filter_able);
1350 static unsigned int KeyMap(int *drv,int *sen)
1354 unsigned int up_down,left_right;
1357 KEY_TYPE_RANGE *key_range = (KEY_TYPE_RANGE * )key_range_array;
1361 if((unsigned int)*drv >= (key_range[i].up_down >> 16)
1362 && (unsigned int)*drv <= (key_range[i].up_down & 0xffff)
1363 && (unsigned int)*sen >= (key_range[i].left_right >> 16)
1364 && (unsigned int)*sen <= (key_range[i].left_right & 0xffff))
1366 *sen = key_range[i].coor >> 16;
1367 *drv = key_range[i].coor & 0xffff;
1368 return key_range[i].coor;
1374 static unsigned int ScreenResolution(gsl_POINT_TYPE *p)
1379 if (p->other.key == FALSE)
1381 y = ((y - match_y[1]) * match_y[0] + 2048)/4096;
1382 x = ((x - match_x[1]) * match_x[0] + 2048)/4096 ;
1384 y = y * (int)screen_y_max / ((int)sen_num_nokey * 64);
1385 x = x * (int)screen_x_max / ((int)drv_num_nokey * 64);
1386 if (p->other.key == FALSE)
1388 if((ignore_y[0]!=0 || ignore_y[1]!=0))
1392 if(ignore_y[1] <= screen_y_max/2 && y > screen_y_max - ignore_y[1])
1394 if(ignore_y[1] >= screen_y_max/2 && y > ignore_y[1])
1397 if(ignore_x[0]!=0 || ignore_x[1]!=0)
1401 if(ignore_x[1] <= screen_y_max/2 && x > screen_x_max - ignore_x[1])
1403 if(ignore_x[1] >= screen_y_max/2 && x > ignore_x[1])
1406 if(y <= (int)edge_cut[2])
1407 y = (int)edge_cut[2] + 1;
1408 if(y >= screen_y_max - (int)edge_cut[3])
1409 y = screen_y_max - (int)edge_cut[3] - 1;
1410 if(x <= (int)edge_cut[0])
1411 x = (int)edge_cut[0] + 1;
1412 if(x >= screen_x_max - (int)edge_cut[1])
1413 x = screen_x_max - (int)edge_cut[1] - 1;
1414 if (global_flag.other.opposite_x)
1415 y = screen_y_max - y;
1416 if (global_flag.other.opposite_y)
1417 x = screen_x_max - x;
1418 if (global_flag.other.opposite_xy)
1431 if((key_map_able & 0x1) != FALSE && KeyMap(&x,&y) == 0)
1434 return ((y<<16) & 0x0fff0000) + (x & 0x0000ffff);
1437 static void PointReport(struct gsl_touch_info *cinfo)
1440 unsigned int data[POINT_MAX];
1442 if (point_num > point_num_max && global_flag.other.over_report_mask != 0)
1445 cinfo->finger_num = 0;
1448 for(i=0;i<POINT_MAX;i++)
1451 if (global_flag.other.id_over)
1453 for(i=0;i<POINT_MAX && num<point_num_max;i++)
1455 if (point_delay[i].other.able == 0)
1457 if (point_delay[i].other.report >= PR_DEEP - 1)
1459 if (pr[point_delay[i].other.report + 1][i].other.able == 0)
1461 if (pr[point_delay[i].other.report][i].all)
1463 pr[point_delay[i].other.report][i].other.able = 1;
1464 data[i] = ScreenResolution(&pr[point_delay[i].other.report][i]);
1467 data[i] |= (i+1)<<28;
1472 for(i=0;i<POINT_MAX && num<point_num_max;i++)
1474 if (point_delay[i].other.able == 0)
1476 if (point_delay[i].other.report >= PR_DEEP)
1478 if (pr[point_delay[i].other.report][i].all == 0)
1480 if (pr[point_delay[i].other.report][i].other.able == 0)
1482 pr[point_delay[i].other.report][i].other.able = 1;
1483 data[i] = ScreenResolution(&pr[point_delay[i].other.report][i]);
1486 data[i] |= (i+1)<<28;
1495 for(i=0;i<point_num_max;i++)
1497 if (point_delay[i].other.able == 0)
1499 if (point_delay[i].other.report >= PR_DEEP)
1501 data[num] = ScreenResolution(&pr[point_delay[i].other.report][i]);
1503 data[num++] |= (i+1)<<28;
1507 for(i=0;i<POINT_MAX;i++)
1511 point_now[num].all = data[i];
1512 cinfo->x[num] = (data[i] >> 16) & 0xfff;
1513 cinfo->y[num] = data[i] & 0xfff;
1514 cinfo->id[num] = data[i] >> 28;
1515 pressure_now[num] = pressure_report[i];
1519 cinfo->finger_num = num;
1524 static void PointEdge(void)
1534 STRETCH_TYPE down[4];
1535 STRETCH_TYPE left[4];
1536 STRETCH_TYPE right[4];
1538 STRETCH_TYPE_ALL *stretch;
1543 if(screen_x_max == 0 || screen_y_max == 0)
1546 for(i=0;i<4*4*2;i++)
1548 sac[i] = stretch_array[i];
1554 stretch = (STRETCH_TYPE_ALL *)sac;
1557 if(stretch->right[i].range > screen_y_max * 64 / 128
1558 || stretch->down [i].range > screen_x_max * 64 / 128)
1562 if(stretch->up[i].range)
1563 stretch->up[i].range =
1564 stretch->up[i].range *
1565 drv_num_nokey * 64 / screen_x_max;
1566 if(stretch->down[i].range)
1567 stretch->down[i].range =
1569 stretch->down[i].range) *
1570 drv_num_nokey * 64 / screen_x_max;
1571 if(stretch->left[i].range)
1572 stretch->left[i].range =
1573 stretch->left[i].range *
1574 sen_num_nokey * 64 / screen_y_max;
1575 if(stretch->right[i].range)
1576 stretch->right[i].range =
1578 stretch->right[i].range) *
1579 sen_num_nokey * 64 / screen_y_max;
1584 for(id=0;id<POINT_MAX;id++)
1586 if (point_now[id].all == 0 || point_now[id].other.key != 0)
1588 x = point_now[id].other.x;
1589 y = point_now[id].other.y;
1595 if(stretch->left[i].range == 0)
1597 if(data[1] < stretch->left[i].range)
1599 data[0] += (stretch->left[i].range - data[1]) *
1600 stretch->left[i].coe/128;
1601 data[1] = stretch->left[i].range;
1604 y = data[1] - data[0];
1607 if(y >= (int)sen_num_nokey*64)
1608 y = sen_num_nokey*64 - 1;
1611 data[1] = sen_num_nokey * 64 - y;
1614 if(stretch->right[i].range == 0)
1616 if(data[1] < stretch->right[i].range)
1618 data[0] += (stretch->right[i].range - data[1]) *
1619 stretch->right[i].coe/128;
1620 data[1] = stretch->right[i].range;
1623 y = sen_num_nokey * 64 - (data[1] - data[0]);
1626 if(y >= (int)sen_num_nokey*64)
1627 y = sen_num_nokey*64 - 1;
1633 if(stretch->up[i].range == 0)
1635 if(data[1] < stretch->up[i].range)
1637 data[0] += (stretch->up[i].range - data[1]) *
1638 stretch->up[i].coe/128;
1639 data[1] = stretch->up[i].range;
1642 x = data[1] - data[0];
1645 if(x >= (int)drv_num_nokey*64)
1646 x = drv_num_nokey*64 - 1;
1649 data[1] = drv_num_nokey * 64 - x;
1652 if(stretch->down[i].range == 0)
1654 if(data[1] < stretch->down[i].range)
1656 data[0] += (stretch->down[i].range - data[1]) *
1657 stretch->down[i].coe/128;
1658 data[1] = stretch->down[i].range;
1661 x = drv_num_nokey * 64 - (data[1] - data[0]);
1664 if(x >= (int)drv_num_nokey*64)
1665 x = drv_num_nokey*64 - 1;
1667 point_now[id].other.x = x;
1668 point_now[id].other.y = y;
1672 static void PointStretch(void)
1674 static int save_dr[POINT_MAX],save_dn[POINT_MAX];
1680 SHAKE_TYPE * shake_all = (SHAKE_TYPE *) shake_all_array;
1687 for(i=0;i<POINT_MAX;i++)
1689 ps[0][i].all = pp[0][i].all;
1691 for(i=0;i<POINT_MAX;i++)
1693 if (pp[0][i].all == 0 || pp[0][i].other.key)
1695 point_shake &= ~(0x1<<i);
1697 point_edge.rate = 0;
1702 if(edge_first!=0 && ps[1][i].all == 0)
1704 point_edge.coor.all = ps[0][i].all;
1705 if (point_edge.coor.other.x < (unsigned int)((edge_first >> 24) & 0xff))
1706 point_edge.coor.other.x = ((edge_first >> 24) & 0xff);
1707 if (point_edge.coor.other.x > drv_num_nokey * 64 - ((edge_first >> 16) & 0xff))
1708 point_edge.coor.other.x = drv_num_nokey * 64 - ((edge_first >> 16) & 0xff);
1709 if (point_edge.coor.other.y < (unsigned int)((edge_first >> 8) & 0xff))
1710 point_edge.coor.other.y = ((edge_first >> 8) & 0xff);
1711 if (point_edge.coor.other.y > sen_num_nokey * 64 - ((edge_first >> 0) & 0xff))
1712 point_edge.coor.other.y = sen_num_nokey * 64 - ((edge_first >> 0) & 0xff);
1713 if(point_edge.coor.all != ps[0][i].all)
1715 point_edge.dis = PointDistance(&ps[0][i],&point_edge.coor);
1717 point_edge.rate = 0x1000;
1720 if(point_edge.rate!=0 && point_edge.dis!=0)
1722 temp = PointDistance(&ps[0][i],&point_edge.coor);
1723 if(temp >= point_edge.dis * edge_first_coe / 0x80)
1725 point_edge.rate = 0;
1727 else if(temp > point_edge.dis)
1729 temp = (point_edge.dis * edge_first_coe / 0x80 - temp) *
1730 0x1000 / point_edge.dis;
1731 if(temp < point_edge.rate)
1732 point_edge.rate = temp;
1734 ps[0][i].other.x = point_edge.coor.other.x +
1735 (ps[0][i].other.x - point_edge.coor.other.x) *
1736 (0x1000 - point_edge.rate) / 0x1000;
1737 ps[0][i].other.y = point_edge.coor.other.y +
1738 (ps[0][i].other.y - point_edge.coor.other.y) *
1739 (0x1000 - point_edge.rate) / 0x1000;
1742 if(ps[1][i].all == 0)
1746 else if((point_shake & (0x1<<i)) == 0)
1748 if(PointDistance(&ps[0][i],&ps[1][i]) < (unsigned int)shake_min)
1750 ps[0][i].all = ps[1][i].all;
1754 point_shake |= (0x1<<i);
1759 if(shake_all[i].dis == 0)
1767 ds[0] = shake_all[0].dis;
1768 dc[0] = (shake_all[0].coe*100+64)/128;
1769 for(i=0;i<POINT_MAX;i++)
1771 if(ps[1][i].all == 0)
1773 for(j=1;j<PS_DEEP;j++)
1774 ps[j][i].all = ps[0][i].all;
1777 if((point_shake & (0x1<<i)) == 0)
1779 dn = PointDistance(&pp[0][i],&ps[1][i]);
1781 dr = dn>ds[0] ? dn-ds[0] : 0;
1782 temp = ps[0][i].all;
1783 if(dn == 0 || dr == 0)
1785 ps[0][i].other.x = ps[1][i].other.x;
1786 ps[0][i].other.y = ps[1][i].other.y;
1790 ps[0][i].other.x = (int)ps[1][i].other.x +
1791 ((int)pp[0][i].other.x -
1792 (int)ps[1][i].other.x) * dr / dn;
1793 ps[0][i].other.y = (int)ps[1][i].other.y +
1794 ((int)pp[0][i].other.y -
1795 (int)ps[1][i].other.y) * dr / dn;
1799 if(ps[0][i].all == ps[1][i].all && temp != ps[0][i].all)
1801 ps[0][i].all = temp;
1802 point_decimal[i].other.x +=
1803 (short)ps[0][i].other.x -
1804 (short)ps[1][i].other.x;
1805 point_decimal[i].other.y +=
1806 (short)ps[0][i].other.y -
1807 (short)ps[1][i].other.y;
1808 ps[0][i].other.x = ps[1][i].other.x;
1809 ps[0][i].other.y = ps[1][i].other.y;
1810 if (point_decimal[i].other.x > dc[0] && ps[1][i].other.x < 0xffff)
1812 ps[0][i].other.x += 1;
1813 point_decimal[i].other.x = 0;
1815 if (point_decimal[i].other.x < -dc[0] && ps[1][i].other.x > 0)
1817 ps[0][i].other.x -= 1;
1818 point_decimal[i].other.x = 0;
1820 if (point_decimal[i].other.y > dc[0] && ps[1][i].other.y < 0xffff)
1822 ps[0][i].other.y += 1;
1823 point_decimal[i].other.y = 0;
1825 if (point_decimal[i].other.y < -dc[0] && ps[1][i].other.y > 0)
1827 ps[0][i].other.y -= 1;
1828 point_decimal[i].other.y = 0;
1833 point_decimal[i].other.x = 0;
1834 point_decimal[i].other.y = 0;
1842 for(i=0;i<8 && i<len;i++)
1844 ds[i+1] = shake_all[i].dis;
1845 dc[i+1] = shake_all[i].coe;//;ds[i+1] * shake_all[i].coe;
1847 if(shake_all[0].coe >= 128 || shake_all[0].coe <= shake_all[1].coe)
1854 ds[0] = ds[1] + (128 - shake_all[0].coe) *
1855 (ds[1]-ds[2])/(shake_all[0].coe - shake_all[1].coe);
1858 for(i=0;i<POINT_MAX;i++)
1860 if(ps[1][i].all == 0)
1862 for(j=1;j<PS_DEEP;j++)
1863 ps[j][i].all = ps[0][i].all;
1868 if((point_shake & (0x1<<i)) == 0)
1870 dn = PointDistance(&pp[0][i],&ps[1][i]);
1880 ps[0][i].other.x = (int)ps[1][i].other.x +
1881 (((int)pp[0][i].other.x -
1882 (int)ps[1][i].other.x) * dr) / 128;
1883 ps[0][i].other.y = (int)ps[1][i].other.y +
1884 (((int)pp[0][i].other.y -
1885 (int)ps[1][i].other.y) * dr) / 128;
1890 if(j == len || dn == 0)
1892 ps[0][i].other.x = ps[1][i].other.x;
1893 ps[0][i].other.y = ps[1][i].other.y;
1896 else if(ds[j] > dn && dn >=ds[j+1])
1898 dr = dc[j+1] + ((dn - ds[j+1]) * (dc[j] - dc[j+1])) / (ds[j] - ds[j+1]);
1901 // ps[0][i].x = (int)ps[1][i].x + ((int)pp[0][i].x - (int)ps[1][i].x) * dr / dn / 128;
1902 // ps[0][i].y = (int)ps[1][i].y + ((int)pp[0][i].y - (int)ps[1][i].y) * dr / dn / 128;
1903 ps[0][i].other.x = (int)ps[1][i].other.x +
1904 (((int)pp[0][i].other.x -
1905 (int)ps[1][i].other.x) * dr + 64) / 128;
1906 ps[0][i].other.y = (int)ps[1][i].other.y +
1907 (((int)pp[0][i].other.y -
1908 (int)ps[1][i].other.y) * dr + 64) / 128;
1920 static void ResetMask(void)
1924 reset_mask_send = 0;
1926 if (global_state.other.mask)
1928 if(reset_mask_dis ==0 || reset_mask_type == 0)
1930 if(reset_mask_max == 0xfffffff1)
1933 reset_mask_max = 0xf0000000 + 1;
1936 if(reset_mask_max > 0xf0000000)
1939 if(reset_mask_max == 0xf0000000)
1941 reset_mask_send = reset_mask_type;
1942 global_state.other.mask = 1;
1946 if(point_num > 1 || pp[0][0].all == 0)
1948 reset_mask_count = 0;
1950 reset_mask_count = 0;
1953 reset_mask_count ++;
1954 if(reset_mask_max == 0)
1955 reset_mask_max = pp[0][0].all;
1957 if(PointDistance((gsl_POINT_TYPE*)(&reset_mask_max),pp[0]) >
1958 (((unsigned int)reset_mask_dis) & 0xffffff) &&
1959 reset_mask_count > (((unsigned int)reset_mask_dis) >> 24))
1960 reset_mask_max = 0xfffffff1;
1963 static int ConfigCoorMulti(int data[])
1971 if((data[247+i]&63)==0 && (data[247+i]>>16)<4)
1978 if((data[251+i]&63)==0 && (data[251+i]>>16)<4)
1990 if(data[256+j*64+i] >= 64)
1994 if(data[256+j*64+i] < data[256+j*64+i-1])
2002 static int ConfigFilter(unsigned int data[])
2005 unsigned int ps_c[8];
2006 unsigned int pr_c[8];
2007 unsigned int sum = 0;
2008 //if(data[242]>1 && (data[255]>=0 && data[255]<=256))
2009 if (data[242]>1 && (data[255] <= 256))
2013 ps_c[i] = (data[243+i/4] >> ((i%4)*8)) & 0xff;
2014 pr_c[i] = (data[243+i/4+2] >> ((i%4)*8)) & 0xff;
2016 ps_c[i] |= 0xffffff00;
2018 pr_c[i] |= 0xffffff00;
2022 if(sum == data[242] || sum + data[242] == 0)
2028 static int ConfigKeyMap(int data[])
2035 if(data[218+2] == 0)
2037 if((data[218+i*3+0]>>16) > (data[218+i*3+0]&0xffff))
2039 if((data[218+i*3+1]>>16) > (data[218+i*3+1]&0xffff))
2045 static int DiagonalDistance(gsl_POINT_TYPE *p,int type)
2048 divisor = ((int)sen_num_nokey * (int)sen_num_nokey +
2049 (int)drv_num_nokey * (int)drv_num_nokey)/16;
2053 square = ((int)sen_num_nokey*(int)(p->other.x) -
2054 (int)drv_num_nokey*(int)(p->other.y)) / 4;
2056 square = ((int)sen_num_nokey*(int)(p->other.x) +
2057 (int)drv_num_nokey*(int)(p->other.y) -
2058 (int)sen_num_nokey*(int)drv_num_nokey * 64) / 4;
2059 return square * square / divisor;
2062 static void DiagonalCompress(gsl_POINT_TYPE *p,int type,int dis,int dis_max)
2070 cp_ceof = (dis - dis_max)*128/(3*dis_max) + 128;
2078 y = (int)sen_num_nokey*64 - y;
2079 x *= (int)sen_num_nokey;
2080 y *= (int)drv_num_nokey;
2083 x = ((tx+ty)+(tx-ty)*cp_ceof/256)/2;
2084 y = ((tx+ty)+(ty-tx)*cp_ceof/256)/2;
2085 x /= (int)sen_num_nokey;
2086 y /= (int)drv_num_nokey;
2088 y = sen_num_nokey*64 - y;
2093 if(x >= (int)drv_num_nokey*64)
2094 x = drv_num_nokey*64 - 1;
2095 if(y >= (int)sen_num_nokey*64)
2096 y = (int)sen_num_nokey*64 - 1;
2101 static void PointDiagonal(void)
2106 unsigned int diagonal_start;
2109 diagonal_size = diagonal * diagonal;
2110 diagonal_start = diagonal * 3/2;
2111 for(i=0;i<POINT_MAX;i++)
2113 if (ps[0][i].all == 0 || ps[0][i].other.key != 0)
2115 point_corner &= ~(0x3<<i*2);
2118 else if((point_corner & (0x3<<i*2)) == 0)
2120 if ((ps[0][i].other.x <= diagonal_start &&
2121 ps[0][i].other.y <= diagonal_start) ||
2122 (ps[0][i].other.x >= drv_num_nokey * 64 - diagonal_start &&
2123 ps[0][i].other.y >= sen_num_nokey * 64 - diagonal_start))
2124 point_corner |= 0x2<<i*2;
2125 else if ((ps[0][i].other.x <= diagonal_start &&
2126 ps[0][i].other.y >= sen_num_nokey * 64 - diagonal_start) ||
2127 (ps[0][i].other.x >= drv_num_nokey * 64 - diagonal_start &&
2128 ps[0][i].other.y <= diagonal_start))
2129 point_corner |= 0x3<<i*2;
2131 point_corner |= 0x1<<i*2;
2133 if(point_corner & (0x2<<i*2))
2135 dis = DiagonalDistance(&(ps[0][i]),point_corner & (0x1<<i*2));
2136 if(dis <= diagonal_size*4)
2138 DiagonalCompress(&(ps[0][i]),point_corner & (0x1<<i*2),dis,diagonal_size);
2140 else if(dis > diagonal_size*4)
2142 point_corner &= ~(0x3<<i*2);
2143 point_corner |= 0x1<<i*2;
2149 static void PressureSave(void)
2152 if((point_num & 0x1000)==0)
2156 for(i=0;i<POINT_MAX;i++)
2158 pressure_now[i] = point_now[i].all >> 28;
2159 point_now[i].all &= ~(0xf<<28);
2163 static void PointPressure(void)
2166 for(i=0;i<POINT_MAX;i++)
2168 if(pa[0][i]!=0 && pa[1][i]==0)
2170 pressure_report[i] = pa[0][i]*5;
2171 for(j=1;j<PRESSURE_DEEP;j++)
2172 pa[j][i] = pa[0][i];
2175 j = (pressure_report[i]+1)/2 + pa[0][i] +
2176 pa[1][i] + (pa[2][i]+1)/2 - pressure_report[i];
2183 pressure_report[i] = pressure_report[i]+j;
2187 void gsl_ReportPressure(unsigned int *p)
2190 for(i=0;i<POINT_MAX;i++)
2194 if(pressure_now[i] == 0)
2196 else if(pressure_now[i] <= 7)
2198 else if(pressure_now[i] > 63+7)
2201 p[i] = pressure_now[i] - 7;
2207 //EXPORT_SYMBOL(gsl_ReportPressure);
2209 int gsl_TouchNear(void)
2213 //EXPORT_SYMBOL(gsl_TouchNear);
2215 static void DoubleClick(void)
2218 unsigned int width[3];
2220 // printk("sileadinc DoubleClick c = %08x , %08x\n",csensor_count,pp[0][0].all);
2221 if (point_num >= 2 || (point_num == 1 && pp[0][0].all == 0) || pp[0][0].other.key)
2223 // printk("sileadinc DoubleClick return\n");
2224 for(i=0;i<sizeof(click_count)/sizeof(click_count[0]);i++)
2228 if(point_num!=0 && prev_num==0)
2230 for(i=sizeof(click_count)/sizeof(click_count[0])-1;i>0;i--)
2231 click_count[i] = click_count[i-1];
2232 click_count[0] = csensor_count;
2233 for(i=sizeof(point_click)/sizeof(point_click[0])-1;i>1;i--)
2234 point_click[i].all = point_click[i-2].all;
2235 point_click[0].all = pp[0][0].all;
2236 point_click[1].all = pp[0][0].all;
2238 if(point_num!=0 && prev_num!=0)
2240 if(PointDistance(&point_click[1],&pp[0][0]) > PointDistance(&point_click[1],&point_click[0]))
2241 point_click[0].all = pp[0][0].all;
2243 if(point_num==0 && prev_num!=0)
2245 // printk("sileadinc DoubleClick point_click %08x %08x %08x %08x\n",point_click[0],point_click[1],point_click[2],point_click[3]);
2246 for(i=sizeof(click_count)/sizeof(click_count[0])-1;i>0;i--)
2247 click_count[i] = click_count[i-1];
2248 click_count[0] = csensor_count;
2249 for(i=0;i<sizeof(click_count)/sizeof(click_count[0])-1;i++)
2250 width[i] = (click_count[i] - click_count[i+1]) & 0xffff;
2251 if(!(width[0]>=double_down*average && width[2]>=double_down*average && width[1]<=double_up*average))
2253 // printk("sileadinc DoubleClick width %08x %08x %08x\n",width[0],width[1],width[2]);
2256 if(PointDistance(&point_click[0],&point_click[1]) > 64*64
2257 || PointDistance(&point_click[2],&point_click[3]) > 64*64
2258 || PointDistance(&point_click[1],&point_click[3]) > 128*128)
2260 // printk("sileadinc DoubleClick distance %08x %08x %08x\n",
2261 // PointDistance(&point_click[0],&point_click[1]),
2262 // PointDistance(&point_click[2],&point_click[3]),
2263 // PointDistance(&point_click[1],&point_click[3]));
2266 for(i=0;i<sizeof(click_count)/sizeof(click_count[0]);i++)
2267 click_count[i] = 0;//?point_click
2269 // printk("sileadinc DoubleClick succeed double_click=%c\n",double_click);
2273 static void gsl_id_reg_init(int flag)
2276 for(j=0;j<POINT_DEEP;j++)
2277 for(i=0;i<POINT_MAX;i++)
2278 point_array[j][i].all = 0;
2279 for(j=0;j<PRESSURE_DEEP;j++)
2280 for(i=0;i<POINT_MAX;i++)
2281 pressure_array[j][i] = 0;
2282 for(i=0;i<POINT_MAX;i++)
2284 point_delay[i].all = 0;
2286 point_decimal[i].all = 0;
2288 point_edge.rate = 0;
2294 reset_mask_send = 0;
2296 reset_mask_count = 0;
2299 global_state.all = 0;
2308 static int DataCheck(void)
2310 if(drv_num==0 || drv_num_nokey==0 || sen_num==0 || sen_num_nokey==0)
2312 if(screen_x_max==0 || screen_y_max==0)
2317 void gsl_DataInit(unsigned int * conf_in)
2323 conf = config_static;
2324 coordinate_correct_able = 0;
2327 coordinate_correct_coe_x[i] = i;
2328 coordinate_correct_coe_y[i] = i;
2331 id_speed_coe = 128*128;
2332 id_static_coe = 64*64;
2336 report_ahead = 0x9249249;
2359 stretch_array[i] = 0;
2361 shake_all_array[i] = 0;
2367 key_range_array[i] = 0;
2369 filter_coe[0] = ( 0<<6*4)+( 0<<6*3)+( 0<<6*2)+(40<<6*1)+(24<<6*0);
2370 filter_coe[1] = ( 0<<6*4)+( 0<<6*3)+(16<<6*2)+(24<<6*1)+(24<<6*0);
2371 filter_coe[2] = ( 0<<6*4)+(16<<6*3)+(24<<6*2)+(16<<6*1)+( 8<<6*0);
2372 filter_coe[3] = ( 6<<6*4)+(16<<6*3)+(24<<6*2)+(12<<6*1)+( 6<<6*0);
2378 point_repeat[0] = 32;
2379 point_repeat[1] = 96;
2381 edge_first_coe = 0x80;
2382 //----------------------------------------------
2387 if(conf_in[0] <= 0xfff)
2389 if(ConfigCoorMulti((int*)conf_in))
2391 else if(ConfigFilter(conf_in))
2393 else if (ConfigKeyMap((int*)conf_in))
2398 else if(conf_in[1] <= CONFIG_LENGTH)
2401 len = CONFIG_LENGTH;
2403 conf[i] = conf_in[i];
2404 for(;i<CONFIG_LENGTH;i++)
2406 if(conf_in[0] <= 0xfff)
2408 coordinate_correct_able = conf[0];
2411 drv_num_nokey = conf[3];
2412 sen_num_nokey = conf[4];
2413 id_first_coe = conf[5];
2414 id_speed_coe = conf[6];
2415 id_static_coe = conf[7];
2417 soft_average = conf[9];
2419 report_delay = conf[13];
2420 shake_min = conf[14];
2421 screen_y_max = conf[15];
2422 screen_x_max = conf[16];
2423 point_num_max = conf[17];
2424 global_flag.all = conf[18];
2426 median_dis[i] = (unsigned char)conf[19+i];
2429 match_y[i] = conf[23+i];
2430 match_x[i] = conf[25+i];
2431 ignore_y[i] = conf[27+i];
2432 ignore_x[i] = conf[29+i];
2436 coordinate_correct_coe_x[i] = conf[31+i];
2437 coordinate_correct_coe_y[i] = conf[95+i];
2440 edge_cut[i] = conf[159+i];
2442 stretch_array[i] = conf[163+i];
2444 shake_all_array[i] = conf[195+i];
2445 reset_mask_dis = conf[213];
2446 reset_mask_type = conf[214];
2447 key_map_able = conf[217];
2449 key_range_array[i] = conf[218+i];
2450 filter_able = conf[242];
2452 filter_coe[i] = conf[243+i];
2454 multi_x_array[i] = conf[247+i];
2456 multi_y_array[i] = conf[251+i];
2457 diagonal = conf[255];
2460 multi_group[i][j] = conf[256+64*i+j];
2465 ps_coe[i][j] = conf[256 + 64*3 + 8*i+j];
2466 pr_coe[i][j] = conf[256 + 64*3 + 8*i+j + 32];
2469 //-----------------------
2475 global_flag.all = conf[0x10];
2476 point_num_max = conf[0x11];
2477 drv_num = conf[0x12]&0xffff;
2478 sen_num = conf[0x12]>>16;
2479 drv_num_nokey = conf[0x13]&0xffff;
2480 sen_num_nokey = conf[0x13]>>16;
2481 screen_x_max = conf[0x14]&0xffff;
2482 screen_y_max = conf[0x14]>>16;
2483 average = conf[0x15];
2484 reset_mask_dis = conf[0x16];
2485 reset_mask_type = conf[0x17];
2486 point_repeat[0] = conf[0x18]>>16;
2487 point_repeat[1] = conf[0x18]&0xffff;
2489 near_set[0] = conf[0x19]>>16;
2490 near_set[1] = conf[0x19]&0xffff;
2491 diagonal = conf[0x1a];
2492 //-------------------------
2494 id_first_coe = conf[0x20];
2495 id_speed_coe = conf[0x21];
2496 id_static_coe = conf[0x22];
2497 match_y[0] = conf[0x23]>>16;
2498 match_y[1] = conf[0x23]&0xffff;
2499 match_x[0] = conf[0x24]>>16;
2500 match_x[1] = conf[0x24]&0xffff;
2501 ignore_y[0] = conf[0x25]>>16;
2502 ignore_y[1] = conf[0x25]&0xffff;
2503 ignore_x[0] = conf[0x26]>>16;
2504 ignore_x[1] = conf[0x26]&0xffff;
2505 edge_cut[0] = (conf[0x27]>>24) & 0xff;
2506 edge_cut[1] = (conf[0x27]>>16) & 0xff;
2507 edge_cut[2] = (conf[0x27]>> 8) & 0xff;
2508 edge_cut[3] = (conf[0x27]>> 0) & 0xff;
2509 report_delay = conf[0x28];
2510 shake_min = conf[0x29];
2513 stretch_array[i*2+0] = conf[0x2a+i] & 0xffff;
2514 stretch_array[i*2+1] = conf[0x2a+i] >> 16;
2518 shake_all_array[i*2+0] = conf[0x3a+i] & 0xffff;
2519 shake_all_array[i*2+1] = conf[0x3a+i] >> 16;
2521 report_ahead = conf[0x42];
2522 // key_dead_time = conf[0x43];
2523 // point_dead_time = conf[0x44];
2524 // point_dead_time2 = conf[0x45];
2525 // point_dead_distance = conf[0x46];
2526 // point_dead_distance2 = conf[0x47];
2527 edge_first = conf[0x48];
2528 edge_first_coe = conf[0x49];
2531 key_map_able = conf[0x60];
2533 key_range_array[i] = conf[0x61+i];
2535 coordinate_correct_able = conf[0x100];
2538 multi_x_array[i] = conf[0x101+i];
2539 multi_y_array[i] = conf[0x105+i];
2543 coordinate_correct_coe_x[i] = (conf[0x109+i/4]>>(i%4*8)) & 0xff;
2544 coordinate_correct_coe_y[i] = (conf[0x109+64/4+i/4]>>(i%4*8)) & 0xff;
2549 multi_group[i][j] = (conf[0x109+64/4*2+(64*i+j)/4]>>((64*i+j)%4*8)) & 0xff;
2552 filter_able = conf[0x180];
2554 filter_coe[i] = conf[0x181+i];
2556 median_dis[i] = (unsigned char)conf[0x185+i];
2561 ps_coe[i][j] = conf[0x189 + 8*i+j];
2562 pr_coe[i][j] = conf[0x189 + 8*i+j + 32];
2566 GestureSet(&conf[0x189 + 64]);
2569 //---------------------------------------------
2574 if(shake_all_array[i*2] & 0x8000)
2575 shake_all_array[i*2] = shake_all_array[i*2] & ~0x8000;
2577 shake_all_array[i*2] = Sqrt(shake_all_array[i*2]);
2581 if(match_x[i] & 0x8000)
2582 match_x[i] |= 0xffff0000;
2583 if(match_y[i] & 0x8000)
2584 match_y[i] |= 0xffff0000;
2585 if(ignore_x[i] & 0x8000)
2586 ignore_x[i] |= 0xffff0000;
2587 if(ignore_y[i] & 0x8000)
2588 ignore_y[i] |= 0xffff0000;
2590 for(i=0;i<CONFIG_LENGTH;i++)
2591 config_static[i] = 0;
2593 //EXPORT_SYMBOL(gsl_DataInit);
2595 unsigned int gsl_version_id(void)
2599 //EXPORT_SYMBOL(gsl_version_id);
2601 unsigned int gsl_mask_tiaoping(void)
2603 return reset_mask_send;
2605 //EXPORT_SYMBOL(gsl_mask_tiaoping);
2608 static void GetFlag(void)
2612 if(((point_num & 0x100)!=0) ||
2613 ((point_num & 0x200) != 0 &&
2614 global_state.other.reset == 1))
2618 if((point_num & 0x300) == 0)
2620 global_state.other.reset = 1;
2622 if(point_num & 0x400)
2623 global_state.other.only = 1;
2625 global_state.other.only = 0;
2626 if(point_num & 0x2000)
2627 global_state.other.interpolation = 0xf;
2628 else if (global_state.other.interpolation)
2629 global_state.other.interpolation--;
2630 if(point_num & 0x4000)
2631 global_state.other.ex = 1;
2633 global_state.other.ex = 0;
2635 csensor_count = ((unsigned int)point_num)>>16;
2636 num_save = point_num & 0xff;
2637 if(num_save > POINT_MAX)
2638 num_save = POINT_MAX;
2639 for(i=0;i<POINT_MAX;i++)
2642 point_now[i].all = 0;
2644 point_num = (point_num & (~0xff)) + num_save;
2647 void gsl_alg_id_main(struct gsl_touch_info *cinfo)
2650 point_num = cinfo->finger_num;
2651 for(i=0;i<POINT_MAX;i++)
2653 point_now[i].all = (cinfo->id[i]<<28) |
2654 (cinfo->x[i]<<16) | cinfo->y[i];
2658 if(DataCheck() == 0)
2661 cinfo->finger_num = 0;
2666 CoordinateCorrect();
2669 GetPointNum(point_now);
2678 prev_num = point_num;
2685 GestureMain(&(pr[0][0].all),point_num);
2691 //EXPORT_SYMBOL(gsl_alg_id_main);
2694 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2697 int gsl_obtain_gesture(void)
2699 return GestureDeal();
2701 //EXPORT_SYMBOL(gsl_obtain_gesture);
2703 static int GestureMain(unsigned int data_coor[],unsigned int num)
2705 gesture_deal = FALSE;
2706 if(gesture_dis_min == 0)
2710 if(gesture_num == 0)
2712 if(gesture_num <= 8)
2717 gesture_deal = GESTURE_ALL;
2720 else if(gesture_num < 0)
2724 else if(num == 1 && data_coor[0] != 0)
2726 GesturePush((GESTURE_POINT_TYPE*) data_coor);
2737 static int GestureSqrt(int d)
2743 if((ret + (0x1<<i))*(ret + (0x1<<i)) <= d)
2749 static int GestureDistance(GESTURE_POINT_TYPE* d1,GESTURE_POINT_TYPE* d2,int sqrt_able)
2752 return GestureSqrt((d1->other.x - d2->other.x) *
2753 (d1->other.x - d2->other.x) +
2754 (d1->other.y - d2->other.y) *
2755 (d1->other.y - d2->other.y));
2757 return (d1->other.x - d2->other.x) *
2758 (d1->other.x - d2->other.x) +
2759 (d1->other.y - d2->other.y) *
2760 (d1->other.y - d2->other.y);
2763 static int GesturePush(GESTURE_POINT_TYPE* data)
2765 if(gesture_num >= GESTURE_BUF_SIZE)
2767 if(gesture_num == 0)
2769 gesture_buf[gesture_num ++].all = data->all & 0xffff0fff;
2772 if(GestureDistance(data,&gesture_buf[gesture_num-1],TRUE) <= gesture_dis_min)
2774 gesture_buf[gesture_num ++].all = data->all & 0xffff0fff;
2778 static void GestureInit(void)
2780 gesture_num_last = gesture_num;
2782 gesture_deal = FALSE;
2783 if(gesture_dis_min < 0 || gesture_dis_min > 64)
2784 gesture_dis_min = 2;
2787 static int GestureStretch(void)
2789 unsigned int x_max=0,x_min=0xffff,y_max=0,y_min=0xffff;
2791 // if(gesture_num <= GESTURE_SIZE_NUM/2)
2793 if(gesture_num >= GESTURE_BUF_SIZE)
2795 for(i=0;i<gesture_num;i++)
2797 if(gesture_buf[i].other.x > x_max)
2798 x_max = gesture_buf[i].other.x;
2799 if (gesture_buf[i].other.x < x_min)
2800 x_min = gesture_buf[i].other.x;
2801 if (gesture_buf[i].other.y > y_max)
2802 y_max = gesture_buf[i].other.y;
2803 if (gesture_buf[i].other.y < y_min)
2804 y_min = gesture_buf[i].other.y;
2806 if(x_max < x_min+64*2 || y_max < y_min+64*3)
2808 for(i=0;i<gesture_num;i++)
2810 gesture_buf[i].other.x = (gesture_buf[i].other.x - x_min) *
2811 GESTURE_SIZE_REFE / (x_max - x_min);
2812 gesture_buf[i].other.y = (gesture_buf[i].other.y - y_min) *
2813 GESTURE_SIZE_REFE / (y_max - y_min);
2818 static int GestureLength(void)
2822 for(i=1;i<gesture_num;i++)
2824 len += GestureDistance(&gesture_buf[i],&gesture_buf[i-1],TRUE);
2829 static void GestureStandard(void)
2834 int len_total = GestureLength();
2835 gesture_standard[0].all = gesture_buf[0].all&0x0fffffff;
2836 gesture_standard[GESTURE_SIZE_NUM - 1].all =
2837 gesture_buf[gesture_num -1].all&0x0fffffff;
2838 for(i=1,n=0;i<GESTURE_SIZE_NUM-1;i++)
2840 while(++n<gesture_num)
2842 len_now = GestureDistance(&gesture_buf[n],&gesture_buf[n-1],TRUE);
2844 if(len_his*(GESTURE_SIZE_NUM-1) >= len_total*i)
2847 if(n >= gesture_num || len_now == 0)
2849 gesture_standard[i].all = 0;
2850 t = (int)gesture_buf[n - 1].other.x
2851 + ((int)gesture_buf[n].other.x - (int)gesture_buf[n - 1].other.x)
2852 * ((int)len_total*i/(GESTURE_SIZE_NUM-1) - (int)len_his + (int)len_now)
2857 gesture_standard[i].other.x = t;
2858 t = (int)gesture_buf[n - 1].other.y
2859 + ((int)gesture_buf[n].other.y - (int)gesture_buf[n - 1].other.y)
2860 * ((int)len_total*i/(GESTURE_SIZE_NUM-1) - (int)len_his + (int)len_now)
2865 gesture_standard[i].other.y = t;
2871 static int GestureModel(const GESTURE_MODEL_TYPE * model,int len,int threshold,int *out)
2873 int offset[] = {-2,-1,0,1,2};
2877 GESTURE_POINT_TYPE model_coor;
2878 if(model == NULL || threshold <= 0)
2887 for(k=0;k<sizeof(offset)/sizeof(offset[0]);k++)
2891 for(i=0;i<GESTURE_SIZE_NUM;i++)
2893 if(i+offset[k] < 0 || i+offset[k] >= GESTURE_SIZE_NUM)
2896 model_coor.all = model[j].coor[i/2] & 0x00ff00ff;
2898 model_coor.all = (model[j].coor[i/2]>>8) & 0x00ff00ff;
2899 ret_offset += GestureDistance(&gesture_standard[i+offset[k]],&model_coor,FALSE);
2904 ret_offset = ret_offset / n * model[j].coe / 0x10;//coe <0x3fff
2905 if(ret_offset < min)
2913 *out = model[min_n].out;
2919 static void ChangeXY(void)
2922 for(i=0;i<gesture_num && i<GESTURE_BUF_SIZE;i++)
2923 gesture_buf[i].all = ((gesture_buf[i].all & 0xfff) << 16) +
2924 ((gesture_buf[i].all>>16) & 0xffff);
2927 static void GestureSet(unsigned int conf[])
2931 //if(conf[0] >= 0 && conf[0] <= 64)
2933 gesture_dis_min = conf[0];
2935 gesture_dis_min = 0;
2937 gesture_threshold[0] = conf[1];
2939 gesture_threshold[0] = 0xfff;
2940 gesture_threshold[1] = conf[2];
2941 x_scale = (conf[3]==0) ? 4 : conf[3];
2942 y_scale = (conf[4]==0) ? 4 : conf[4];
2950 double_down = conf[5] & 0xffff;
2951 double_up = conf[5] >> 16;
2955 static int GestureDeal(void)
2964 gesture_last = double_click;
2967 if(gesture_deal & GESTURE_XY)
2969 gesture_deal &= ~GESTURE_XY;
2972 if((gesture_deal & GESTURE_DEAL) == 0)
2974 gesture_deal &= ~GESTURE_DEAL;
2975 gesture_last = GestureLRUD();
2978 if(GestureStretch() == FALSE)
2981 gesture_val[0] = GestureModel(model_default,
2982 sizeof(model_default)/sizeof(model_default[0]),
2983 gesture_threshold[0],&gesture_out[0]);
2984 gesture_val[1] = GestureModel(model_extern,
2985 model_extern_len,gesture_threshold[1],&gesture_out[1]);
2986 gesture_last = 0x7fffffff;
2989 if(gesture_val[i] <= gesture_last)
2991 // gesture_value = gesture_val[i];
2992 gesture_last = gesture_out[i];
2998 return gesture_last;
3001 void gsl_GestureExtern(const GESTURE_MODEL_TYPE *model,int len)
3003 model_extern = model;
3004 model_extern_len = len;
3006 //EXPORT_SYMBOL(gsl_GestureExtern);
3008 static int GestureLRUD(void)
3010 int x1=0,y1=0,x2=0,y2=0,i=0;
3015 // printk("flag3,gesture_deal=%x\n",gesture_deal);
3016 if(gesture_deal & GESTURE_XY)
3018 gesture_deal &= ~GESTURE_XY;
3020 // printk("flag3,ChangeXY_GestureLRUD,gesture_deal=%x\n",gesture_deal);
3022 if((gesture_deal & GESTURE_LRUD) == 0)
3024 gesture_deal &= ~GESTURE_LRUD;
3025 // int screen_x_max=0,screen_y_max=0;
3026 x1 = gesture_buf[0].other.x;//480
3027 y1 = gesture_buf[0].other.y;//800
3028 x2 = gesture_buf[gesture_num - 1].other.x;
3029 y2 = gesture_buf[gesture_num - 1].other.y;
3030 // if(!x1&&!y1&&!x2&&!y2)
3032 middle_x =( x1 + x2)/2;
3033 middle_y = (y1 + y2)/2;
3034 for(i=1;i<gesture_num;i++)
3036 if (abs(gesture_buf[i].other.x - middle_x)<(int)sen_num_nokey * 64 / x_scale)//screen_y_max/8)//30
3040 if (abs(gesture_buf[i].other.y - middle_y)<(int)drv_num_nokey * 64 / y_scale)//screen_x_max/8)//25
3044 if ((int)gesture_buf[i].other.x - (int)gesture_buf[i - 1].other.x>min_scale)
3046 else if ((int)gesture_buf[i].other.x - (int)gesture_buf[i - 1].other.x<-min_scale)
3048 if ((int)gesture_buf[i].other.y - (int)gesture_buf[i - 1].other.y>min_scale)
3050 else if ((int)gesture_buf[i].other.y - (int)gesture_buf[i - 1].other.y<-min_scale)
3053 // printk("flag3_____flag3=%x,x_scale=%d,y_scale=%d\n",flag3,x_scale,y_scale);
3054 // if(flag3&&!point_num)
3056 // printk("flag3,x1=%d,y1=%d,x2=%d,y2=%d,screen_x_max=%d,screen_y_max=%d\n",x1,y1,x2,y2,screen_x_max,screen_y_max);
3057 // printk("flag3====== %x,x1-x2=%d,x2-x1=%d,y1-y2=%d,y2-y1=%d\n",flag3,x1-x2,x2-x1,y1-y2,y2-y1);
3062 if((flag3==0x2031||flag3==0x2131||flag3==0x2231||flag3==0x2331))//&&(y2-y1>screen_x_max/3))
3063 return 0xa1fc;//up(a1,fc)
3064 else if((flag3==0x1031||flag3==0x1131||flag3==0x1231||flag3==0x1331))//&&(y1-y2>screen_x_max/3))
3065 return 0xa1fd;//down
3066 else if((flag3==0x213||flag3==0x1213||flag3==0x2213||flag3==0x2213))//&&(x2-x1>screen_y_max/3))
3067 return 0xa1fb;//left
3068 else if((flag3==0x113||flag3==0x1113||flag3==0x2113||flag3==0x3113))//&&(x1-x2>screen_y_max/3))
3069 return 0xa1fa;//right
3070 // if(abs(x2-x1)<64*4&&abs(y2-y1)<64*6)
3076 unsigned int gsl_GestureBuffer(unsigned int **buf)
3079 if(gesture_num_last >= GESTURE_BUF_SIZE)
3080 gesture_num_last = GESTURE_BUF_SIZE - 1;
3081 for(i=0;i<gesture_num_last;i++)
3083 gesture_buf[i].all = ScreenResolution((gsl_POINT_TYPE*)(&gesture_buf[i].all));
3085 *buf = &(gesture_buf[0].all);
3086 return gesture_num_last;
3088 //EXPORT_SYMBOL(gsl_GestureBuffer);
3091 // The DLL must have an entry point, but it is never called.
3095 IN PDRIVER_OBJECT DriverObject,
3096 IN PUNICODE_STRING RegistryPath
3099 return STATUS_SUCCESS;