FreeCalypso > hg > fc-tourmaline
comparison src/ui/mfw/ti1_key.c @ 213:0947a816580c
first stage of FreeCalypso handset switch-on logic rework
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 22 Apr 2021 21:23:16 +0000 |
parents | c632896652ba |
children |
comparison
equal
deleted
inserted
replaced
212:782c6ae77467 | 213:0947a816580c |
---|---|
42 #include "kbd.h" | 42 #include "kbd.h" |
43 | 43 |
44 #include "drv_key.h" | 44 #include "drv_key.h" |
45 #include "ti1_key.h" | 45 #include "ti1_key.h" |
46 | 46 |
47 #ifndef NEPTUNE_BOARD | |
48 #include "kpd/kpd_api.h" | 47 #include "kpd/kpd_api.h" |
49 #else | |
50 #define PLATFORM_ARCH_ARM | |
51 #define PLATFORM_ENDIAN_LITTLE | |
52 #define PLATFORM tcs3100Evm | |
53 #include "bspSystem.h" | |
54 #include "bspKeypad_Gsp.h" | |
55 #endif | |
56 | |
57 /* BUG FIX - OMAPS00084167 */ | |
58 #ifdef FF_MMI_MULTIMEDIA | |
59 #include "typedefs.h" | |
60 #include "main_system.h" | |
61 /*#include "dev_Mbox.h" */ /* 04-07-2006 */ | |
62 #endif | |
63 /* END - OMAPS00084167 */ | |
64 | |
65 BOOL powered_on=FALSE; | |
66 | 48 |
67 #define POWER_KEY 25 | 49 #define POWER_KEY 25 |
68 | 50 |
69 extern void mmiInit(void); | 51 extern void mmiInit(void); |
70 | |
71 //TISH modified for MSIM | |
72 #ifdef WIN32 | |
73 #define _SIMULATION_ | |
74 #endif | |
75 | 52 |
76 /* | 53 /* |
77 * Marcus: Issue 811: 05:09/2002: | 54 * Marcus: Issue 811: 05:09/2002: |
78 * Moved kbd_map, simkbd_map and config_map to \g23m\Condat\COM\SRC\DRIVER\keypad.c | 55 * Moved kbd_map, simkbd_map and config_map to \g23m\Condat\COM\SRC\DRIVER\keypad.c |
79 */ | 56 */ |
89 static void (*sig) (char,char) = 0; /* kbd signaling function */ | 66 static void (*sig) (char,char) = 0; /* kbd signaling function */ |
90 static char *keyMap = (char *) kbd_map; /* current keyboard mapping */ | 67 static char *keyMap = (char *) kbd_map; /* current keyboard mapping */ |
91 | 68 |
92 T_KPD_SUBSCRIBER subscriber_p; /* keep the subscription indentification value */ | 69 T_KPD_SUBSCRIBER subscriber_p; /* keep the subscription indentification value */ |
93 | 70 |
94 // Sep 18, 2006 REF: OMAPS00094426 - x0039928 | |
95 #if (BOARD == 71) | |
96 extern UBYTE kpd_key; | |
97 #endif | |
98 | |
99 typedef struct | 71 typedef struct |
100 { | 72 { |
101 U32 msg_id; | 73 U32 msg_id; |
102 void (*callback_func)(void *); | 74 void (*callback_func)(void *); |
103 U16 src_addr_id; | 75 U16 src_addr_id; |
104 U16 dest_addr_id; | 76 U16 dest_addr_id; |
105 } T_RV_CHECK; | 77 } T_RV_CHECK; |
106 | 78 |
79 /* | |
80 * New FreeCalypso way of launching "full on" operation: Switch_ON() | |
81 * will call fchs_pwon_button_boot() when the switch-on cause is the | |
82 * PWON button (as opposed to charging or test reset), the latter | |
83 * function will post a different version of the MMI_KEYPAD_IND | |
84 * primitive to MMI task, drvKeyUpDown() will get called as a result | |
85 * of this special MMI_KEYPAD_IND, and the latter function calls | |
86 * mmiInit(). Here we define the special "key code" used in the | |
87 * MMI_KEYPAD_IND primitive to pass this event to the MMI task. | |
88 */ | |
89 | |
90 #define SPECIAL_KEYCODE_PWON 0x81 | |
107 | 91 |
108 | 92 |
109 /* JVJ #1874 - new function to initialize the power key*/ | 93 /* JVJ #1874 - new function to initialize the power key*/ |
110 | |
111 | 94 |
112 /* | 95 /* |
113 +--------------------------------------------------------------------+ | 96 +--------------------------------------------------------------------+ |
114 | PROJECT : MMI-Framework (8417) MODULE : key_power_init | | 97 | PROJECT : MMI-Framework (8417) MODULE : key_power_init | |
115 | STATE : code ROUTINE : key_power_init | | 98 | STATE : code ROUTINE : key_power_init | |
117 | 100 |
118 PURPOSE : initialize the power key handler in the TI driver | 101 PURPOSE : initialize the power key handler in the TI driver |
119 | 102 |
120 */ | 103 */ |
121 | 104 |
122 | |
123 | |
124 void key_power_init() | 105 void key_power_init() |
125 { | 106 { |
126 kbd_Init(kbdCb); | 107 kbd_Init(kbdCb); |
127 } | 108 } |
128 | |
129 | 109 |
130 | 110 |
131 /* | 111 /* |
132 +--------------------------------------------------------------------+ | 112 +--------------------------------------------------------------------+ |
133 | PROJECT : MMI-Framework (8417) MODULE : ti1_key | | 113 | PROJECT : MMI-Framework (8417) MODULE : ti1_key | |
147 * | 127 * |
148 * EEPROM reading not now !!! | 128 * EEPROM reading not now !!! |
149 */ | 129 */ |
150 keyMap = (char *) kbd_map; | 130 keyMap = (char *) kbd_map; |
151 | 131 |
152 | |
153 //new keypad driver | |
154 #ifdef NEPTUNE_BOARD | |
155 // Commented by Nitin for Neptune Platfrom. 05/04/2005 | |
156 //keypad_initialize (); | |
157 #else | |
158 keypad_initialize (); | 132 keypad_initialize (); |
159 #endif | |
160 | |
161 | |
162 } | 133 } |
163 | 134 |
164 | 135 |
165 /* | 136 /* |
166 +--------------------------------------------------------------------+ | 137 +--------------------------------------------------------------------+ |
174 | 145 |
175 void keyExit (void) | 146 void keyExit (void) |
176 { | 147 { |
177 sig = 0; | 148 sig = 0; |
178 | 149 |
179 // by Nitin 05/04/2004 | 150 //unsubscribe the client from the keypad driver |
180 #ifndef NEPTUNE_BOARD | |
181 //unsubscribe the client from the keypad driver | |
182 #ifndef _SIMULATION_ | |
183 kpd_unsubscribe (&subscriber_p); | 151 kpd_unsubscribe (&subscriber_p); |
184 #endif | |
185 // Added by Nitin 05/04/2004 | |
186 #else /* NOT defined NEPTUNE_BOARD */ | |
187 kpdMgr_unsubscribe(); // Sumit; commented for time being | |
188 #endif | |
189 | |
190 } | 152 } |
191 | 153 |
192 /* | 154 /* |
193 +--------------------------------------------------------------------+ | 155 +--------------------------------------------------------------------+ |
194 | PROJECT : MMI-Framework (8417) MODULE : ti1_key | | 156 | PROJECT : MMI-Framework (8417) MODULE : ti1_key | |
200 */ | 162 */ |
201 char drvGetKeyIndex( char key) | 163 char drvGetKeyIndex( char key) |
202 { | 164 { |
203 int i; | 165 int i; |
204 | 166 |
205 #ifndef _SIMULATION_ | |
206 for (i = 0; i < 32; i++) | 167 for (i = 0; i < 32; i++) |
207 { | 168 { |
208 if (keyMap[i] == key) | 169 if (keyMap[i] == key) |
209 { | 170 { |
210 return (i); | 171 return (i); |
211 } | 172 } |
212 } | 173 } |
213 | 174 |
214 #else | |
215 /* TEST only ES!! */ | |
216 for (i = 0; i < NUM_KPD_KEYS; i++) | |
217 { | |
218 if (simkbd_map[i] == key) | |
219 { | |
220 return (i); | |
221 } | |
222 } | |
223 #endif | |
224 | |
225 return (char)(0xFE); //No match./*a0393213 warnings removal - -1 changed to 0xFE*/ | 175 return (char)(0xFE); //No match./*a0393213 warnings removal - -1 changed to 0xFE*/ |
226 | |
227 | |
228 } | 176 } |
229 | 177 |
230 | 178 |
231 /* | 179 /* |
232 +--------------------------------------------------------------------+ | 180 +--------------------------------------------------------------------+ |
239 */ | 187 */ |
240 | 188 |
241 void drvKeyUpDown (char upDown, char key) | 189 void drvKeyUpDown (char upDown, char key) |
242 { | 190 { |
243 TRACE_EVENT_P2("drvKeyUpDown : key = %d : state = %x", key, upDown); | 191 TRACE_EVENT_P2("drvKeyUpDown : key = %d : state = %x", key, upDown); |
244 /* JVJ #1705 The first KEY event can only be the Power Key*/ | |
245 /* This will start MMI */ | |
246 if ((!powered_on)) | |
247 { | |
248 powered_on =TRUE; | |
249 | |
250 /* ADDED BY RAVI - 22-11-2005 - OMAPS00056702 FIX */ | |
251 #if (BOARD!=61) | |
252 /* JVJ #1705 MMI will be started here */ | |
253 mmiInit(); | |
254 return; | |
255 #endif | |
256 /* END RAVI - 22-11-2005 */ | |
257 } | |
258 | 192 |
259 if (key != (char)0) | 193 if (key != (char)0) |
260 { | 194 { |
261 if ((key >= 48) && (key <=57)) | 195 if ((key >= 48) && (key <= 57)) |
262 { | 196 { |
263 key -= 47; | 197 key -= 47; |
264 } | 198 } |
265 else | 199 else |
266 { | 200 { |
300 | 234 |
301 case 98: | 235 case 98: |
302 key = (char)12; | 236 key = (char)12; |
303 break; | 237 break; |
304 | 238 |
239 /* FreeCalypso new way */ | |
240 case SPECIAL_KEYCODE_PWON: | |
241 mmiInit(); | |
242 return; | |
243 | |
305 default: | 244 default: |
306 key = (char)0; | 245 key = (char)0; |
307 break; | 246 break; |
308 } | 247 } |
309 } | 248 } |
314 if (!sig) return; /* no event handler */ | 253 if (!sig) return; /* no event handler */ |
315 | 254 |
316 sig((char)(!upDown),0); | 255 sig((char)(!upDown),0); |
317 | 256 |
318 return; | 257 return; |
319 | |
320 } | 258 } |
321 | 259 |
322 | 260 |
323 /* | 261 /* |
324 +--------------------------------------------------------------------+ | 262 +--------------------------------------------------------------------+ |
427 | 365 |
428 #define hCommACI _ENTITY_PREFIXED(hCommACI) | 366 #define hCommACI _ENTITY_PREFIXED(hCommACI) |
429 | 367 |
430 static void kbdCb (drv_SignalID_Type *signal_params) | 368 static void kbdCb (drv_SignalID_Type *signal_params) |
431 { | 369 { |
432 #if defined (NEW_FRAME) | 370 ULONG signal_raw; |
433 ULONG signal_raw; | |
434 | |
435 #endif | |
436 | |
437 U16 signal_high; | 371 U16 signal_high; |
438 U16 signal_low; | 372 U16 signal_low; |
439 U8 key_code; | 373 U8 key_code; |
440 U8 key_state; | 374 U8 key_state; |
441 | 375 |
442 int nPresses; //Number of key presses still in the queue | 376 int nPresses; //Number of key presses still in the queue |
443 | 377 |
444 | |
445 #if defined (NEW_FRAME) | |
446 signal_raw = (ULONG)signal_params->UserData; | 378 signal_raw = (ULONG)signal_params->UserData; |
447 signal_high = (U16) (signal_raw >> 16); | 379 signal_high = (U16) (signal_raw >> 16); |
448 signal_low = (U16) (signal_raw & 0xFFFF); | 380 signal_low = (U16) (signal_raw & 0xFFFF); |
449 #else | |
450 signal_high = (U16) (signal_params->UserData >> 16); | |
451 signal_low = (U16) (signal_params->UserData & 0xFFFF); | |
452 #endif | |
453 | 381 |
454 key_code = (U8) (signal_low & 0xFF); | 382 key_code = (U8) (signal_low & 0xFF); |
455 if (signal_high == 1) | 383 if (signal_high == 1) |
456 key_state = KEY_STAT_PRS; | 384 key_state = KEY_STAT_PRS; |
457 else | 385 else |
458 key_state = KEY_STAT_REL; | 386 key_state = KEY_STAT_REL; |
459 | 387 |
460 /*JVJ #1705 When the first POWER KEY event arrives, an event is sent to MMI */ | |
461 /*to start it */ | |
462 if ((!powered_on)&&(key_code==POWER_KEY)) | |
463 { | |
464 sendKeyInd(key_code, key_state, 0); | |
465 return; | |
466 } | |
467 | |
468 | |
469 //Add keypress to queue of key presses | 388 //Add keypress to queue of key presses |
470 nPresses = kbd_getNumElements(); | 389 nPresses = kbd_getNumElements(); |
471 | |
472 | 390 |
473 kbd_putMakeAndKey( (char)key_state, (char)key_code); | 391 kbd_putMakeAndKey( (char)key_state, (char)key_code); |
474 | 392 |
475 if ((!kbd_stillProcessingKeys()) && (nPresses == 0)) | 393 if ((!kbd_stillProcessingKeys()) && (nPresses == 0)) |
476 { //Only this element present - create and send message. | 394 { //Only this element present - create and send message. |
477 sendKeyInd(key_code, key_state, 0); | 395 sendKeyInd(key_code, key_state, 0); |
478 | 396 |
479 } | 397 } |
480 | 398 } |
481 } | 399 |
482 | 400 /* |
483 /* | 401 +--------------------------------------------------------------------+ |
484 +--------------------------------------------------------------------+ | 402 | PROJECT : MMI-Framework (8417) MODULE : ti1_key | |
485 | PROJECT : MMI-Framework (8417) MODULE : ti1_key | | 403 | STATE : code ROUTINE : keypad_cb | |
486 | STATE : code ROUTINE : keypad_cb | | |
487 +--------------------------------------------------------------------+ | 404 +--------------------------------------------------------------------+ |
488 | 405 |
489 PURPOSE : This CB function is called by the driver when a key is pressed/released | 406 PURPOSE : This CB function is called by the driver when a key is pressed/released |
490 or a status of an asynch. process is requested. | 407 or a status of an asynch. process is requested. |
491 | 408 |
492 */ | 409 */ |
493 | 410 |
494 void keypad_cb (void* parameter) | 411 void keypad_cb (void* parameter) |
495 { | 412 { |
496 // NITIN | |
497 #ifndef NEPTUNE_BOARD | |
498 T_KPD_KEY_EVENT_MSG* event; | 413 T_KPD_KEY_EVENT_MSG* event; |
499 T_KPD_STATUS_MSG* status; | 414 T_KPD_STATUS_MSG* status; |
500 T_RV_CHECK* check; | 415 T_RV_CHECK* check; |
501 | 416 |
502 | |
503 check = (T_RV_CHECK*)parameter; | 417 check = (T_RV_CHECK*)parameter; |
504 | 418 |
505 if (check->msg_id EQ KPD_STATUS_MSG) | 419 if (check->msg_id EQ KPD_STATUS_MSG) |
506 { | 420 { |
507 //status message is used | 421 //status message is used |
520 else | 434 else |
521 { | 435 { |
522 int nPresses; //Number of key presses still in the queue | 436 int nPresses; //Number of key presses still in the queue |
523 //event message is used | 437 //event message is used |
524 event = (T_KPD_KEY_EVENT_MSG*) parameter; | 438 event = (T_KPD_KEY_EVENT_MSG*) parameter; |
525 | |
526 | 439 |
527 //Add keypress to queue of key presses | 440 //Add keypress to queue of key presses |
528 nPresses = kbd_getNumElements(); | 441 nPresses = kbd_getNumElements(); |
529 | 442 |
530 if (event->key_info.press_state EQ KPD_INSIGNIFICANT_VALUE) | 443 if (event->key_info.press_state EQ KPD_INSIGNIFICANT_VALUE) |
540 // 0000 00xx = KPD_FIRST_PRESS | 453 // 0000 00xx = KPD_FIRST_PRESS |
541 // 0001 00xx = KPD_LONG_PRESS | 454 // 0001 00xx = KPD_LONG_PRESS |
542 // 0010 00xx = KPD_REPEAT_PRESS | 455 // 0010 00xx = KPD_REPEAT_PRESS |
543 // | 456 // |
544 // x = anystate | 457 // x = anystate |
545 // Sep 18, 2006 REF: OMAPS00094426 - x0039928 | |
546 // Fix : Store the virtual key info in the global variable kpd_key for later use | |
547 #if (BOARD == 71) | |
548 kpd_key = (char)event->key_info.virtual_key_id; | |
549 #endif | |
550 kbd_putMakeAndKey( (char)(event->key_info.state | (event->key_info.press_state << 4)), | 458 kbd_putMakeAndKey( (char)(event->key_info.state | (event->key_info.press_state << 4)), |
551 (char)event->key_info.virtual_key_id ); | 459 (char)event->key_info.virtual_key_id ); |
552 } | 460 } |
553 | 461 |
554 if ((!kbd_stillProcessingKeys()) && (nPresses == 0)) | 462 if ((!kbd_stillProcessingKeys()) && (nPresses == 0)) |
558 sendKeyInd(event->key_info.virtual_key_id, event->key_info.state, event->key_info.press_state); | 466 sendKeyInd(event->key_info.virtual_key_id, event->key_info.state, event->key_info.press_state); |
559 | 467 |
560 } | 468 } |
561 | 469 |
562 } | 470 } |
563 #endif // NEPTUNE_BOARD | |
564 return; | 471 return; |
565 | 472 } |
566 } | 473 |
567 | 474 |
568 | 475 /* |
569 /* | 476 +--------------------------------------------------------------------+ |
570 +--------------------------------------------------------------------+ | 477 | PROJECT : MMI-Framework (8417) MODULE : ti1_key | |
571 | PROJECT : MMI-Framework (8417) MODULE : ti1_key | | 478 | STATE : code ROUTINE : keypad_initialize | |
572 | STATE : code ROUTINE : keypad_initialize | | |
573 +--------------------------------------------------------------------+ | 479 +--------------------------------------------------------------------+ |
574 | 480 |
575 PURPOSE : initialize keyboard driver | 481 PURPOSE : initialize keyboard driver |
576 | 482 |
577 */ | 483 */ |
578 // Commented by Nitin for Neptune Platfrom. 05/04/2005 | 484 |
579 | |
580 #ifndef NEPTUNE_BOARD | |
581 UBYTE keypad_initialize (void) | 485 UBYTE keypad_initialize (void) |
582 { | 486 { |
583 T_KPD_MODE mode; | 487 T_KPD_MODE mode; |
584 T_KPD_VIRTUAL_KEY_TABLE notified_keys; | 488 T_KPD_VIRTUAL_KEY_TABLE notified_keys; |
585 T_RV_RETURN return_path; | 489 T_RV_RETURN return_path; |
622 notified_keys.notified_keys [21] = KPD_KEY_VOL_UP; | 526 notified_keys.notified_keys [21] = KPD_KEY_VOL_UP; |
623 notified_keys.notified_keys [22] = KPD_KEY_VOL_DOWN; | 527 notified_keys.notified_keys [22] = KPD_KEY_VOL_DOWN; |
624 notified_keys.notified_keys [23] = KPD_KEY_RECORD; | 528 notified_keys.notified_keys [23] = KPD_KEY_RECORD; |
625 #endif | 529 #endif |
626 | 530 |
627 #ifndef _SIMULATION_ | |
628 return_value = kpd_subscribe (&subscriber_p, mode, ¬ified_keys, return_path); | 531 return_value = kpd_subscribe (&subscriber_p, mode, ¬ified_keys, return_path); |
629 #else | |
630 return_value = RV_OK; /* do some faking here, to get it compileable */ | |
631 #endif | |
632 | 532 |
633 if (return_value EQ RV_INTERNAL_ERR || | 533 if (return_value EQ RV_INTERNAL_ERR || |
634 return_value EQ RV_INVALID_PARAMETER || | 534 return_value EQ RV_INVALID_PARAMETER || |
635 return_value EQ RV_MEMORY_ERR) | 535 return_value EQ RV_MEMORY_ERR) |
636 { | 536 { |
648 | 548 |
649 //Subscribe to key press and key release (at the moment) | 549 //Subscribe to key press and key release (at the moment) |
650 //subscribe to KPD_LONG_KEY_PRESS_NOTIF once implemented. | 550 //subscribe to KPD_LONG_KEY_PRESS_NOTIF once implemented. |
651 notif_level = KPD_FIRST_PRESS_NOTIF | KPD_RELEASE_NOTIF; | 551 notif_level = KPD_FIRST_PRESS_NOTIF | KPD_RELEASE_NOTIF; |
652 | 552 |
653 #ifndef _SIMULATION_ | |
654 return_value = kpd_define_key_notification( subscriber_p, ¬ified_keys, notif_level, | 553 return_value = kpd_define_key_notification( subscriber_p, ¬ified_keys, notif_level, |
655 long_press_time, repeat_time ); | 554 long_press_time, repeat_time ); |
656 #else | |
657 return_value = RV_OK; | |
658 #endif | |
659 | 555 |
660 if (return_value EQ RV_INVALID_PARAMETER || | 556 if (return_value EQ RV_INVALID_PARAMETER || |
661 return_value EQ RV_MEMORY_ERR) | 557 return_value EQ RV_MEMORY_ERR) |
662 { //failed | 558 { //failed |
663 return 1; | 559 return 1; |
664 } | 560 } |
665 return 0; | 561 return 0; |
666 } | 562 } |
667 // Commented by Nitin for Neptune Platfrom. 05/04/2005 | |
668 #endif /* NEPTUNE_BOARD*/ | |
669 | 563 |
670 | 564 |
671 /* | 565 /* |
672 +--------------------------------------------------------------------+ | 566 +--------------------------------------------------------------------+ |
673 | PROJECT : MMI-Framework (8417) MODULE : ti1_key | | 567 | PROJECT : MMI-Framework (8417) MODULE : ti1_key | |
678 */ | 572 */ |
679 void sendKeyInd( T_KPD_VIRTUAL_KEY_ID virtual_key_id, | 573 void sendKeyInd( T_KPD_VIRTUAL_KEY_ID virtual_key_id, |
680 T_KPD_KEY_STATE key_state, | 574 T_KPD_KEY_STATE key_state, |
681 T_KPD_PRESS_STATE press_state) | 575 T_KPD_PRESS_STATE press_state) |
682 { | 576 { |
683 #if defined (NEW_FRAME) | |
684 EXTERN T_HANDLE hCommACI; | 577 EXTERN T_HANDLE hCommACI; |
685 | 578 |
686 // ULONG signal_raw; // RAVI | |
687 #else | |
688 EXTERN T_VSI_CHANDLE hCommACI; | |
689 #endif | |
690 | |
691 PALLOC(key_ind,MMI_KEYPAD_IND); | 579 PALLOC(key_ind,MMI_KEYPAD_IND); |
692 | 580 |
693 key_ind->key_code = (U8)0; | 581 key_ind->key_code = (U8)0; |
694 | 582 |
695 key_ind->key_stat = 0; | 583 key_ind->key_stat = 0; |
696 | 584 |
697 #if defined (NEW_FRAME) | |
698 PSENDX(ACI,key_ind); | 585 PSENDX(ACI,key_ind); |
699 #else | |
700 #if defined (_TMS470) | |
701 vsi_c_send("",hCommACI,D2P(key_ind), | |
702 sizeof(T_PRIM_HEADER)+sizeof(T_MMI_KEYPAD_IND)); | |
703 #else | |
704 PSEND(ACI,key_ind); | |
705 #endif | |
706 #endif | |
707 | 586 |
708 return; | 587 return; |
709 | 588 } |
710 } | 589 |
590 /* new FreeCalypso functions for switch-on causes */ | |
591 | |
592 void fchs_pwon_button_boot(void) | |
593 { | |
594 EXTERN T_HANDLE hCommACI; | |
595 | |
596 PALLOC(key_ind,MMI_KEYPAD_IND); | |
597 | |
598 key_ind->key_code = SPECIAL_KEYCODE_PWON; | |
599 | |
600 key_ind->key_stat = 0; | |
601 | |
602 PSENDX(ACI,key_ind); | |
603 } |