FreeCalypso > hg > fc-magnetite
comparison src/aci2/mfw/mfw_mme.c @ 3:93999a60b835
src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Sep 2016 00:29:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:c41a534f33c6 | 3:93999a60b835 |
---|---|
1 /* | |
2 +--------------------------------------------------------------------+ | |
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_mme.c $| | |
4 | $Author:: Kk $ CONDAT GmbH $Revision:: 5 $| | |
5 | CREATED: 11.02.99 $Modtime:: 3.03.00 17:40 $| | |
6 | STATE : code | | |
7 +--------------------------------------------------------------------+ | |
8 | |
9 MODULE : MFW_MME | |
10 | |
11 PURPOSE : Miscelleaneous Mobile Equipment functions | |
12 | |
13 EXPORT : | |
14 | |
15 TO DO : | |
16 | |
17 $History:: mfw_mme.c $ | |
18 ************************************************************************ | |
19 * nekkareb - OMAPS00057367: 8 Dec 2005 | |
20 * Description: Fix build problems for fix of OMAPS00057367 | |
21 * Solution: Included OMAPS00057367 changes under a flag ISAMPLE | |
22 * | |
23 * nekkareb - OMAPS00057367: 3 Dec 2005 | |
24 * Description: Locosto: TTY MT call does not work | |
25 * Solution: Extra TTY command added so as to initiate the AUDIO entity to send the | |
26 * TTY_START request to L1 only after the Vocoder enable is sent. | |
27 * Current audio device is read from audio service entity functions. | |
28 * | |
29 * xpradipg - LOCOSTO-ENH-31895 : 23 June 2005 | |
30 * Description: Support for various audio profiles | |
31 * Solution: The support for audio device's carkit/headset/loudspeaker/handheld. | |
32 * The audio device is enabled as per the user actions. | |
33 * | |
34 * ***************** Version 5 ******************************************** | |
35 * User: Kk Date: 3.03.00 Time: 17:52 | |
36 * Updated in $/GSM/Condat/MS/SRC/MFW | |
37 * | |
38 * ***************** Version 4 ***************** | |
39 * User: Es Date: 2.03.00 Time: 16:48 | |
40 * Updated in $/GSM/Condat/MS/SRC/MFW | |
41 * generate battery/signal primitives with more info from driver | |
42 * callbacks. Catch the primitives on reception and call MMI event | |
43 * handler. Don't use ACI any longer for this purpose. | |
44 * | |
45 * ***************** Version 3 ***************** | |
46 * User: Es Date: 14.04.99 Time: 17:34 | |
47 * Updated in $/GSM/DEV/MS/SRC/MFW | |
48 * moved to CST | |
49 | | |
50 | ***************** Version 2 ***************** | |
51 | User: Le Date: 14.04.99 Time: 9:51 | |
52 | Updated in $/GSM/DEV/MS/SRC/MFW | |
53 * | |
54 * ***************** Version 1 ***************** | |
55 * User: Es Date: 20.02.99 Time: 11:54 | |
56 * Created in $/GSM/DEV/MS/SRC/MFW | |
57 * mobile equipment | |
58 */ | |
59 | |
60 #define ENTITY_MFW | |
61 | |
62 #include <stdio.h> | |
63 | |
64 #if defined (NEW_FRAME) | |
65 | |
66 #include "typedefs.h" | |
67 #include "vsi.h" | |
68 #include "custom.h" | |
69 #include "gsm.h" | |
70 | |
71 #else | |
72 | |
73 #include "STDDEFS.H" | |
74 #include "custom.h" | |
75 #include "gsm.h" | |
76 #include "vsi.h" | |
77 | |
78 #endif | |
79 | |
80 #include "mfw_mfw.h" | |
81 #include "mfw_sys.h" | |
82 #include "prim.h" | |
83 #include "message.h" | |
84 #include "prim.h" | |
85 #include "aci_cmh.h" | |
86 #include "gdi.h" | |
87 #include "audio.h" | |
88 #include "pwr.h" | |
89 #include "rx.h" | |
90 #include "light.h" | |
91 #include "mfw_acie.h" | |
92 #include "mfw_mme.h" | |
93 #include "mfw_win.h" | |
94 | |
95 /* OMAPS00057367, 8 Dec 2005, nekkare, build fix */ | |
96 #if (BOARD == 71) | |
97 #define ISAMPLE | |
98 #endif | |
99 | |
100 #define hCommPL _ENTITY_PREFIXED(hCommPL) | |
101 #define hCommACI _ENTITY_PREFIXED(hCommACI) | |
102 | |
103 #if defined (NEW_FRAME) | |
104 EXTERN T_HANDLE hCommPL; | |
105 EXTERN T_HANDLE hCommACI; | |
106 #else | |
107 EXTERN T_VSI_CHANDLE hCommPL; | |
108 EXTERN T_VSI_CHANDLE hCommACI; | |
109 #endif | |
110 | |
111 EXTERN MfwHdr * current_mfw_elem; | |
112 | |
113 /* FLAG DRIVER CALLBACKS */ | |
114 #define MmeFlagRtcAlarm 1 /* rtc alarm */ | |
115 #define MmeFlagHdsDetect 2 /* headset detection */ | |
116 #define MmeFlagIrdaMsg 4 /* IRDA event */ | |
117 U16 mfwMmeDrvFlag = 0; /* hold driver CB flags */ | |
118 | |
119 static U8 battLevel = 0; /* battery level */ | |
120 static U8 battState = 0; /* state of power supply */ | |
121 static U16 hdsPresence = 0; /* headset presence */ | |
122 static U16 irdaMsg = 0; /* IRDA message */ | |
123 | |
124 static int mmeCommand (U32 cmd, void *h); | |
125 | |
126 /* driver callbacks */ | |
127 static void pwrCb (drv_SignalID_Type *signal_params); | |
128 static void rxCb (drv_SignalID_Type *signal_params); | |
129 static void rtcCb (drv_SignalID_Type *signal_params); | |
130 | |
131 static BOOL mmePrimHandler (USHORT opc, void *data); | |
132 static int pSlot; /* primitive handler slot */ | |
133 | |
134 static void hdsCb (drv_SignalID_Type *signal_params); | |
135 // xpradipg - LOCOSTO-ENH-31895 : 23 June 2005 | |
136 #ifdef FF_MMI_AUDIO_PROFILE | |
137 #define HANDHELD "handheld" //0 | |
138 #define LOUDSPEAKER "handfree" // 1 | |
139 #define HEADSET "headset" // 2 | |
140 #define CARKIT "carkit" // 3 | |
141 static UBYTE currAudioDevice = MFW_AUD_HANDHELD; | |
142 static UBYTE prevAudioDevice = MFW_AUD_HANDHELD; | |
143 UBYTE headsetInserted = FALSE; //indicates if the headset is inserted or not | |
144 UBYTE carkitInserted = FALSE; //indicates if the carkit is inserted or not | |
145 UBYTE mfwAudPlay = FALSE; //indicates if any other audio media is being played or not | |
146 extern audio_set_device(char* mode); | |
147 void mfw_audio_headSet_indication ( T_AUDIO_ACCESSORY_NOTIFICATION notify, | |
148 ACCESSORY_CALLBACK_PARAM callbackparam ); | |
149 void mfw_audio_carKit_indication ( T_AUDIO_ACCESSORY_NOTIFICATION notify, | |
150 ACCESSORY_CALLBACK_PARAM callbackparam ); | |
151 #endif | |
152 | |
153 void mfw_audio_set_device(int type); | |
154 /* | |
155 +--------------------------------------------------------------------+ | |
156 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
157 | STATE : code ROUTINE : mmeInit | | |
158 +--------------------------------------------------------------------+ | |
159 | |
160 PURPOSE : initialize equipment handler | |
161 | |
162 */ | |
163 | |
164 MfwRes mmeInit (void) | |
165 { | |
166 // int i; // RAVI | |
167 // xpradipg - LOCOSTO-ENH-31895 : 23 June 2005 | |
168 // the callback registeration variables are populated here and passed as | |
169 // argument to audio_init | |
170 #ifdef FF_MMI_AUDIO_PROFILE | |
171 T_ACCESSORY_CALLBACK audio_device_config[MAX_EXT_AUD_DEVICE]; | |
172 | |
173 audio_device_config[CALLBACK_HEADSET].callbackFunc = mfw_audio_headSet_indication; | |
174 audio_device_config[CALLBACK_HEADSET].callbackVal = NULL; | |
175 audio_device_config[CALLBACK_CARKIT].callbackFunc = mfw_audio_carKit_indication; | |
176 audio_device_config[CALLBACK_CARKIT].callbackVal = NULL; | |
177 #endif | |
178 | |
179 mfwCommand[MfwTypMme] = (MfwCb) mmeCommand; | |
180 | |
181 mfwMmeDrvFlag = 0; | |
182 | |
183 battLevel = 0; | |
184 battState = 0; | |
185 hdsPresence = 0; | |
186 irdaMsg = 0; | |
187 | |
188 pwr_Init(pwrCb); //power driver | |
189 rx_Init(rxCb); //fieldstrength driver | |
190 light_Init(); //light emitting driver | |
191 // xpradipg - LOCOSTO-ENH-31895 : 23 June 2005 | |
192 #ifdef FF_MMI_AUDIO_PROFILE | |
193 audio_Init(audio_device_config); | |
194 #else | |
195 audio_Init(hdsCb); //audio driver | |
196 #endif | |
197 | |
198 mmeBattInfo ( 10, 0); | |
199 | |
200 mmeRxInfo(5,0); | |
201 | |
202 /* install prim handler */ | |
203 pSlot = aci_create((T_PRIM_HANDLER)mmePrimHandler,NULL); | |
204 | |
205 return MfwResOk; | |
206 } | |
207 | |
208 | |
209 /* | |
210 +--------------------------------------------------------------------+ | |
211 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
212 | STATE : code ROUTINE : mmeExit | | |
213 +--------------------------------------------------------------------+ | |
214 | |
215 PURPOSE : finalize equipment handler | |
216 | |
217 */ | |
218 | |
219 MfwRes mmeExit (void) | |
220 { | |
221 aci_delete(pSlot); /* remove prim handler */ | |
222 mfwCommand[MfwTypMme] = 0; | |
223 | |
224 return MfwResOk; | |
225 } | |
226 | |
227 | |
228 /* | |
229 +--------------------------------------------------------------------+ | |
230 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
231 | STATE : code ROUTINE : mmeCreate | | |
232 +--------------------------------------------------------------------+ | |
233 | |
234 PURPOSE : create equipment control | |
235 | |
236 */ | |
237 | |
238 MfwHnd mmeCreate (MfwHnd w, MfwEvt e, MfwCb f) | |
239 { | |
240 MfwHdr *hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr)); | |
241 MfwMme *mme = (MfwMme *) mfwAlloc(sizeof(MfwMme)); | |
242 MfwHdr *insert_status =0; | |
243 | |
244 if (!hdr || !mme) | |
245 { | |
246 TRACE_ERROR("ERROR: mmeCreate() Mem Alloc Failed."); | |
247 | |
248 if(hdr) | |
249 mfwFree((U8*)hdr,sizeof(MfwHdr)); | |
250 if(mme) | |
251 mfwFree((U8*)mme,sizeof(MfwMme)); | |
252 | |
253 return 0; | |
254 } | |
255 | |
256 mme->map = e; | |
257 mme->handler = f; | |
258 mme->value = 0; | |
259 | |
260 hdr->data = mme; | |
261 hdr->type = MfwTypMme; | |
262 | |
263 insert_status = mfwInsert(w,hdr); | |
264 | |
265 if(!insert_status) | |
266 { | |
267 TRACE_ERROR("ERROR: mmeCreate() Failed to Install Handler. "); | |
268 mfwFree((U8*)hdr,sizeof(MfwHdr)); | |
269 mfwFree((U8*)mme ,sizeof(MfwMme)); | |
270 return 0; | |
271 } | |
272 return insert_status; | |
273 } | |
274 | |
275 | |
276 /* | |
277 +--------------------------------------------------------------------+ | |
278 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
279 | STATE : code ROUTINE : mmeDelete | | |
280 +--------------------------------------------------------------------+ | |
281 | |
282 PURPOSE : delete equipment control | |
283 | |
284 */ | |
285 | |
286 MfwRes mmeDelete (MfwHnd h) | |
287 { | |
288 MfwRes res; | |
289 | |
290 if (!h) | |
291 return MfwResIllHnd; | |
292 | |
293 res = (mfwRemove(h)) ? MfwResOk : MfwResIllHnd; | |
294 | |
295 mfwFree(((MfwHdr *) h)->data,sizeof(MfwMme)); | |
296 mfwFree(h,sizeof(MfwHdr)); | |
297 | |
298 return res; | |
299 } | |
300 | |
301 | |
302 /* | |
303 +--------------------------------------------------------------------+ | |
304 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
305 | STATE : code ROUTINE : mmeHdsInit | | |
306 +--------------------------------------------------------------------+ | |
307 | |
308 PURPOSE : init the Headset detection and setup callback handler | |
309 | |
310 */ | |
311 | |
312 MfwRes mmeHdsInit (void (*hds_init) ()) | |
313 { | |
314 mfwMmeDrvFlag &= ~MmeFlagHdsDetect; | |
315 | |
316 return 1; | |
317 } | |
318 | |
319 | |
320 /* | |
321 +--------------------------------------------------------------------+ | |
322 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
323 | STATE : code ROUTINE : mmeRtcInit | | |
324 +--------------------------------------------------------------------+ | |
325 | |
326 PURPOSE : init the RTC and setup the alarm callback handler | |
327 | |
328 extern UBYTE clk_Init (USHORT, drv_SignalCB_Type, UBYTE*); | |
329 */ | |
330 | |
331 MfwRes mmeRtcInit (USHORT drvHandle, UBYTE *info) | |
332 { | |
333 mfwMmeDrvFlag &= ~MmeFlagRtcAlarm; | |
334 | |
335 return 0; // RAVI | |
336 } | |
337 | |
338 | |
339 static int mme_backlightStatus[BL_LAST_OPTION]; | |
340 /* | |
341 +--------------------------------------------------------------------+ | |
342 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
343 | STATE : code ROUTINE : mme_setBacklightIdle | | |
344 +--------------------------------------------------------------------+ | |
345 | |
346 PURPOSE : called when an event may change the backlight level/status | |
347 | |
348 */ | |
349 void mme_backlightEvent(int event) | |
350 { | |
351 int light; | |
352 if ((event >=BL_INIT) && (event <BL_LAST_OPTION)) | |
353 { | |
354 light = mme_backlightStatus[event]; | |
355 if (light == BL_SET_IDLE) | |
356 { | |
357 light_setBacklightIdle(); | |
358 } | |
359 else if (light == BL_NO_CHANGE) | |
360 { | |
361 //No change | |
362 } | |
363 else if ((light >=BL_NO_LIGHT) && (light <=BL_MAX_LIGHT)) | |
364 { | |
365 mmeBackLight ((U8)light); | |
366 } | |
367 | |
368 } | |
369 } | |
370 | |
371 /* | |
372 +--------------------------------------------------------------------+ | |
373 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
374 | STATE : code ROUTINE : mme_setBacklightIdle | | |
375 +--------------------------------------------------------------------+ | |
376 | |
377 PURPOSE : called to initialise backlight events | |
378 | |
379 */ | |
380 void mme_setBacklightEvent(int event, int lightLevel) | |
381 { | |
382 if ((event >=BL_INIT) && (event <BL_LAST_OPTION)) | |
383 { | |
384 mme_backlightStatus[event] = lightLevel; | |
385 } | |
386 } | |
387 | |
388 | |
389 /* | |
390 +--------------------------------------------------------------------+ | |
391 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
392 | STATE : code ROUTINE : mmeBackLight | | |
393 +--------------------------------------------------------------------+ | |
394 | |
395 PURPOSE : set display backlight | |
396 | |
397 */ | |
398 void mmeBackLight (U8 level) | |
399 { | |
400 light_SetStatus(LIGHT_DEVICE_BACKLIGHT,level); | |
401 } | |
402 | |
403 | |
404 /* | |
405 +--------------------------------------------------------------------+ | |
406 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
407 | STATE : code ROUTINE : mmeAudioTone | | |
408 +--------------------------------------------------------------------+ | |
409 | |
410 PURPOSE : configure the buzzer | |
411 | |
412 */ | |
413 | |
414 void mmeAudioTone (U8 callTone, U8 volume, U8 toneStat) | |
415 { | |
416 if (toneStat EQ TONE_SWT_OFF) | |
417 #ifdef FF_MMI_RINGTONE /* Stop MSL Play */ | |
418 audio_StopSoundbyID(AUDIO_SPEAKER, CALLTONE_SELECT); | |
419 #else | |
420 audio_StopSoundbyID(AUDIO_SPEAKER,callTone); | |
421 #endif | |
422 else | |
423 #ifdef FF_MMI_RINGTONE /* Play MSL Ring tone */ | |
424 audio_PlaySoundID(AUDIO_SPEAKER,CALLTONE_SELECT,volume,toneStat); | |
425 #else | |
426 audio_PlaySoundID(AUDIO_SPEAKER,callTone,volume,toneStat); | |
427 #endif | |
428 } | |
429 | |
430 | |
431 /* | |
432 +--------------------------------------------------------------------+ | |
433 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
434 | STATE : code ROUTINE : mmeSetVolume | | |
435 +--------------------------------------------------------------------+ | |
436 | |
437 PURPOSE : configure mic and speaker volume | |
438 | |
439 */ | |
440 | |
441 MfwRes mmeSetVolume (U16 audioIn, U16 audioOut) | |
442 { | |
443 if (audioIn > 255) audioIn = 255; | |
444 if (audioOut > 255) audioOut = 255; | |
445 | |
446 audio_SetAmplf(AUDIO_MICROPHONE,(U8) audioIn); | |
447 audio_SetAmplf(AUDIO_SPEAKER,(U8) audioOut); | |
448 | |
449 return MfwResOk; | |
450 } | |
451 | |
452 | |
453 /* | |
454 +--------------------------------------------------------------------+ | |
455 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
456 | STATE : code ROUTINE : mmeRxInfo | | |
457 +--------------------------------------------------------------------+ | |
458 | |
459 PURPOSE : configure signal quality information: | |
460 request from the PS an indication on change of the | |
461 rx level with n intervalls. | |
462 Parameters mode and level are not used in the moment. | |
463 | |
464 */ | |
465 | |
466 void mmeRxInfo (U8 intervalls, U16 level) | |
467 { | |
468 rx_DCB_Type rx_DCB; | |
469 | |
470 rx_DCB.Steps = intervalls; | |
471 rx_SetConfig(&rx_DCB); | |
472 } | |
473 | |
474 | |
475 /* | |
476 +--------------------------------------------------------------------+ | |
477 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
478 | STATE : code ROUTINE : mmeBattInfo | | |
479 +--------------------------------------------------------------------+ | |
480 | |
481 PURPOSE : configure battery level information | |
482 | |
483 | |
484 */ | |
485 | |
486 void mmeBattInfo ( U8 intervalls, U16 level) | |
487 { | |
488 pwr_DCB_Type pwr_DCB; | |
489 | |
490 if (level > 255) level = 255; | |
491 | |
492 pwr_DCB.RangeMin = (U8) level; /* low level threshold */ | |
493 pwr_DCB.RangeMax = 100; /* 100 Percent */ | |
494 pwr_DCB.Steps = intervalls; /* n Steps */ | |
495 pwr_SetConfig(&pwr_DCB); | |
496 } | |
497 | |
498 | |
499 /* | |
500 +--------------------------------------------------------------------+ | |
501 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
502 | STATE : code ROUTINE : sigExec | | |
503 +--------------------------------------------------------------------+ | |
504 | |
505 PURPOSE : execute equipment signal | |
506 | |
507 */ | |
508 | |
509 static int sigExec (MfwHdr *curElem, U32 evt, U32 val) | |
510 { | |
511 MfwMme *ec; | |
512 | |
513 while (curElem) | |
514 { | |
515 if (curElem->type == MfwTypMme) | |
516 { | |
517 ec = curElem->data; | |
518 if (ec->map & evt) | |
519 { /* events match */ | |
520 ec->value = val; | |
521 if (ec->handler) /* handler valid */ | |
522 { | |
523 // PATCH LE 06.06.00 | |
524 // store current mfw elem | |
525 current_mfw_elem = curElem; | |
526 // END PATCH LE 06.06.00 | |
527 if ((*(ec->handler))(evt,ec)) | |
528 return 1; /* event consumed */ | |
529 } | |
530 } | |
531 } | |
532 curElem = curElem->next; | |
533 } | |
534 | |
535 return 0; | |
536 } | |
537 | |
538 | |
539 /* | |
540 +--------------------------------------------------------------------+ | |
541 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
542 | STATE : code ROUTINE : mmeSignal | | |
543 +--------------------------------------------------------------------+ | |
544 | |
545 PURPOSE : equipment event (called by driver/PEI) | |
546 | |
547 */ | |
548 | |
549 void mmeSignal (U32 evt, U32 value) | |
550 { | |
551 UBYTE temp; | |
552 | |
553 temp = dspl_Enable(0); | |
554 if (mfwSignallingMethod EQ 0) | |
555 { | |
556 if (mfwFocus) | |
557 if (sigExec(mfwFocus,evt,value)) | |
558 { | |
559 dspl_Enable(temp); | |
560 return; | |
561 } | |
562 if (mfwRoot) | |
563 sigExec(mfwRoot,evt,value); | |
564 } | |
565 else | |
566 { | |
567 MfwHdr * h = 0; | |
568 | |
569 /* | |
570 * Focus set, then start here | |
571 */ | |
572 if (mfwFocus) | |
573 h = mfwFocus; | |
574 /* | |
575 * Focus not set, then start root | |
576 */ | |
577 if (!h) | |
578 h = mfwRoot; | |
579 | |
580 /* | |
581 * No elements available, return | |
582 */ | |
583 | |
584 while (h) | |
585 | |
586 | |
587 { | |
588 /* | |
589 * Signal consumed, then return | |
590 */ | |
591 if (sigExec (h, evt, value)) | |
592 { | |
593 dspl_Enable(temp); | |
594 return; | |
595 } | |
596 | |
597 /* | |
598 * All windows tried inclusive root | |
599 */ | |
600 if (h == mfwRoot) | |
601 { | |
602 dspl_Enable(temp); | |
603 return; | |
604 } | |
605 | |
606 /* | |
607 * get parent window | |
608 */ | |
609 h = mfwParent(mfwParent(h)); | |
610 if(h) | |
611 h = ((MfwWin * )(h->data))->elems; | |
612 } | |
613 sigExec (mfwRoot, evt, value); | |
614 sigExec (mfwRoot, evt, value); | |
615 | |
616 } | |
617 dspl_Enable(temp); | |
618 return; | |
619 } | |
620 | |
621 | |
622 /* | |
623 +--------------------------------------------------------------------+ | |
624 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
625 | STATE : code ROUTINE : mmeCommand | | |
626 +--------------------------------------------------------------------+ | |
627 | |
628 PURPOSE : handle mfw windows command | |
629 | |
630 */ | |
631 | |
632 static int mmeCommand (U32 cmd, void *h) | |
633 { | |
634 switch (cmd) | |
635 { | |
636 case MfwCmdDelete: /* delete me */ | |
637 if (!h) | |
638 return 0; | |
639 mmeDelete(h); | |
640 return 1; | |
641 default: | |
642 break; | |
643 } | |
644 | |
645 return 0; | |
646 } | |
647 | |
648 | |
649 /* | |
650 +--------------------------------------------------------------------+ | |
651 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
652 | STATE : code ROUTINE : rAT_PercentSQ | | |
653 +--------------------------------------------------------------------+ | |
654 | |
655 PURPOSE : called by ACI on change of signal quality | |
656 | |
657 */ | |
658 | |
659 void rAT_PercentSQ (BYTE val) | |
660 { | |
661 TRACE_FUNCTION("rAT_PercentSQ()"); | |
662 | |
663 //ES!! no longer needed mmeSignal(MfwMmeSignal,val); | |
664 } | |
665 | |
666 | |
667 /* | |
668 +--------------------------------------------------------------------+ | |
669 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
670 | STATE : code ROUTINE : rAT_PercentBC | | |
671 +--------------------------------------------------------------------+ | |
672 | |
673 PURPOSE : called by ACI on change of battery status | |
674 | |
675 */ | |
676 | |
677 void rAT_PercentBC (BYTE val) | |
678 { | |
679 TRACE_FUNCTION("rAT_PercentBC()"); | |
680 | |
681 //ES!! no longer needed mmeSignal(MfwMmeBattery,val); | |
682 } | |
683 | |
684 | |
685 /* | |
686 +--------------------------------------------------------------------+ | |
687 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
688 | STATE : code ROUTINE : mmePrimHandler | | |
689 +--------------------------------------------------------------------+ | |
690 | |
691 PURPOSE : MME primitive handler | |
692 | |
693 */ | |
694 | |
695 static BOOL mmePrimHandler (USHORT opc, void *data) | |
696 { | |
697 U8 level; | |
698 U8 state; | |
699 // xpradipg - LOCOSTO-ENH-31895 : 23 June 2005 | |
700 #ifdef FF_MMI_AUDIO_PROFILE | |
701 U8 hdsData; | |
702 U8 cktData; | |
703 #endif | |
704 | |
705 | |
706 // TRACE_FUNCTION ("mmePrimHandler()"); | |
707 | |
708 switch (opc) | |
709 { | |
710 case MMI_RXLEV_IND: | |
711 level = ((T_MMI_RXLEV_IND *) data)->rxlev; | |
712 mmeSignal(MfwMmeSignal,level); | |
713 return TRUE; /* processed by MME, delete */ | |
714 case MMI_BATTERY_IND: | |
715 level = ((T_MMI_BATTERY_IND *) data)->volt; | |
716 state = ((T_MMI_BATTERY_IND *) data)->temp; | |
717 if (battLevel != level) | |
718 { | |
719 battLevel = level; | |
720 mmeSignal(MfwMmeBattery,level); | |
721 } | |
722 if (battState != state) | |
723 { | |
724 battState = state; | |
725 mmeSignal(MfwMmeBaState,state); | |
726 } | |
727 return TRUE; /* processed by MME, delete */ | |
728 // xpradipg - LOCOSTO-ENH-31895 : 23 June 2005 | |
729 // the corresponding callback function is called in MMI context | |
730 // this comment will be removed once the sap for this is available | |
731 #ifdef FF_MMI_AUDIO_PROFILE | |
732 case MMI_HEADSET_IND: | |
733 TRACE_EVENT("MMI_HEADSET_IND"); | |
734 hdsData = ((T_MMI_HEADSET_IND *) data)->headset_status; | |
735 mmeSignal(MfwMmeHeadset,hdsData); | |
736 return TRUE; | |
737 case MMI_CARKIT_IND: | |
738 TRACE_EVENT("MMI_CARKIT_IND"); | |
739 cktData = ((T_MMI_CARKIT_IND *) data)->carkit_status; | |
740 mmeSignal(MfwMmeCarkit, cktData); | |
741 return TRUE; | |
742 #endif | |
743 } | |
744 | |
745 return FALSE; /* not processed, forward */ | |
746 } | |
747 | |
748 | |
749 /* | |
750 +--------------------------------------------------------------------+ | |
751 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
752 | STATE : code ROUTINE : mmeFlagHandler | | |
753 +--------------------------------------------------------------------+ | |
754 | |
755 PURPOSE : MME driver flag handler | |
756 | |
757 */ | |
758 | |
759 void mmeFlagHandler (void) | |
760 { | |
761 TRACE_FUNCTION ("mmeFlagHandler()"); | |
762 | |
763 while (mfwMmeDrvFlag) | |
764 { | |
765 if (mfwMmeDrvFlag & MmeFlagRtcAlarm) | |
766 { | |
767 mfwMmeDrvFlag &= ~MmeFlagRtcAlarm; | |
768 mmeSignal(MfwMmeRtcAlarm,0); | |
769 } | |
770 else if (mfwMmeDrvFlag & MmeFlagHdsDetect) | |
771 { | |
772 mfwMmeDrvFlag &= ~MmeFlagHdsDetect; | |
773 mmeSignal(MfwMmeHdsDetect,hdsPresence); | |
774 } | |
775 else if (mfwMmeDrvFlag & MmeFlagIrdaMsg) | |
776 { | |
777 } | |
778 else | |
779 { | |
780 mfwMmeDrvFlag = 0; | |
781 } | |
782 } | |
783 } | |
784 | |
785 | |
786 /* | |
787 +--------------------------------------------------------------------+ | |
788 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
789 | STATE : code ROUTINE : pwr_callback | | |
790 +--------------------------------------------------------------------+ | |
791 | |
792 PURPOSE : Called by battery driver | |
793 | |
794 */ | |
795 | |
796 static void pwrCb (drv_SignalID_Type *signal_params) | |
797 { | |
798 pwr_Status_Type *para; | |
799 PALLOC(battery_ind, MMI_BATTERY_IND); | |
800 | |
801 para = (pwr_Status_Type *) signal_params->UserData; | |
802 battery_ind->volt = para->BatteryLevel; | |
803 battery_ind->temp = para->Status; | |
804 | |
805 PSENDX(ACI,battery_ind); | |
806 } | |
807 | |
808 | |
809 /* | |
810 +--------------------------------------------------------------------+ | |
811 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
812 | STATE : code ROUTINE : rx_callback | | |
813 +--------------------------------------------------------------------+ | |
814 | |
815 PURPOSE : Called by fieldstrength driver | |
816 | |
817 */ | |
818 | |
819 static void rxCb (drv_SignalID_Type *signal_params) | |
820 { | |
821 rx_Status_Type *para; | |
822 PALLOC(rxlevel_ind,MMI_RXLEV_IND); | |
823 | |
824 para = (rx_Status_Type *) signal_params->UserData; | |
825 rxlevel_ind->rxlev = para->actLevel; | |
826 | |
827 PSENDX(ACI,rxlevel_ind); | |
828 } | |
829 | |
830 | |
831 /* | |
832 +--------------------------------------------------------------------+ | |
833 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
834 | STATE : code ROUTINE : rtcCb | | |
835 +--------------------------------------------------------------------+ | |
836 | |
837 PURPOSE : alarm callback from RTC | |
838 | |
839 */ | |
840 | |
841 static void rtcCb (drv_SignalID_Type *signal_params) | |
842 { | |
843 mfwMmeDrvFlag |= MmeFlagRtcAlarm; | |
844 vsi_c_awake(VSI_CALLER_SINGLE); | |
845 } | |
846 | |
847 | |
848 | |
849 /* | |
850 +--------------------------------------------------------------------+ | |
851 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
852 | STATE : code ROUTINE : hdsCb | | |
853 +--------------------------------------------------------------------+ | |
854 | |
855 PURPOSE : callback from headset detection | |
856 | |
857 */ | |
858 | |
859 static void hdsCb (drv_SignalID_Type *signal_params) | |
860 { | |
861 if (signal_params->SignalType == 1) | |
862 { | |
863 hdsPresence = (U16)signal_params->UserData; | |
864 mfwMmeDrvFlag |= MmeFlagHdsDetect; | |
865 vsi_c_awake(VSI_CALLER_SINGLE); | |
866 } | |
867 } | |
868 #ifdef FF_MMI_AUDIO_PROFILE | |
869 /* | |
870 +--------------------------------------------------------------------+ | |
871 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
872 | STATE : code ROUTINE : mfw_set_stereo_path | | |
873 +--------------------------------------------------------------------+ | |
874 | |
875 PURPOSE : This sets the stereo path for the current audio profile | |
876 | |
877 */ | |
878 | |
879 void mfw_set_stereo_path(int device) | |
880 { | |
881 TRACE_FUNCTION("mfw_set_stereo_path()"); | |
882 | |
883 TRACE_EVENT_P1("Device === %d", device); | |
884 switch(device) | |
885 { | |
886 case MFW_AUD_HEADSET: | |
887 audio_set_path(AUDIO_STEREO_SPEAKER_HEADPHONE, TRUE); | |
888 break; | |
889 case MFW_AUD_HANDHELD: | |
890 audio_set_path(AUDIO_STEREO_SPEAKER_HANDHELD, TRUE); | |
891 break; | |
892 case MFW_AUD_CARKIT: | |
893 audio_set_path(AUDIO_STEREO_SPEAKER_CARKIT, TRUE); | |
894 break; | |
895 case MFW_AUD_LOUDSPEAKER: | |
896 audio_set_path(AUDIO_STEREO_SPEAKER_HANDFREE, TRUE); | |
897 break; | |
898 } | |
899 } | |
900 /* | |
901 +--------------------------------------------------------------------+ | |
902 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
903 | STATE : code ROUTINE : mfw_unset_stereo_path | | |
904 +--------------------------------------------------------------------+ | |
905 | |
906 PURPOSE : This resets the voice path for the current audio profile | |
907 | |
908 */ | |
909 void mfw_unset_stereo_path(int device) | |
910 { | |
911 TRACE_FUNCTION("mfw_unset_stereo_path()"); | |
912 | |
913 TRACE_EVENT_P1("Device === %d", device); | |
914 switch(device) | |
915 { | |
916 case MFW_AUD_HEADSET: | |
917 audio_set_path(AUDIO_SPEAKER_HEADSET, FALSE); | |
918 break; | |
919 case MFW_AUD_HANDHELD: | |
920 audio_set_path(AUDIO_SPEAKER_HANDHELD, FALSE); | |
921 break; | |
922 case MFW_AUD_CARKIT: | |
923 audio_set_path(AUDIO_SPEAKER_CARKIT, FALSE); | |
924 break; | |
925 case MFW_AUD_LOUDSPEAKER: | |
926 audio_set_path(AUDIO_SPEAKER_HANDFREE, FALSE); | |
927 break; | |
928 } | |
929 } | |
930 | |
931 /* | |
932 +--------------------------------------------------------------------+ | |
933 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
934 | STATE : code ROUTINE : mfw_audio_headSet_indication | | |
935 +--------------------------------------------------------------------+ | |
936 | |
937 PURPOSE :Callback function for the events related to headset and create and post a primitive | |
938 | |
939 */ | |
940 void mfw_audio_headSet_indication ( T_AUDIO_ACCESSORY_NOTIFICATION notify, | |
941 ACCESSORY_CALLBACK_PARAM callbackparam ) | |
942 { | |
943 | |
944 PALLOC(hdsData,MMI_HEADSET_IND); | |
945 hdsData->headset_status = (U8)notify; | |
946 PSENDX(ACI,hdsData); | |
947 | |
948 } | |
949 /* | |
950 +--------------------------------------------------------------------+ | |
951 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
952 | STATE : code ROUTINE : mfw_audio_headSet_indication | | |
953 +--------------------------------------------------------------------+ | |
954 | |
955 PURPOSE :Callback function for the events related to carkit and create and post a primitive | |
956 | |
957 */ | |
958 void mfw_audio_carKit_indication ( T_AUDIO_ACCESSORY_NOTIFICATION notify, | |
959 ACCESSORY_CALLBACK_PARAM callback_param ) | |
960 { | |
961 PALLOC(cktData,MMI_CARKIT_IND); | |
962 cktData->carkit_status = (U8)notify; | |
963 PSENDX(ACI,cktData); | |
964 } | |
965 /* | |
966 +--------------------------------------------------------------------+ | |
967 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
968 | STATE : code ROUTINE : mfw_audio_headSet_indication | | |
969 +--------------------------------------------------------------------+ | |
970 | |
971 PURPOSE :handles the request to switch to the respective device from the | |
972 Bmi when the indications of insert and removal are received | |
973 | |
974 */ | |
975 void mfw_audio_device_indication( U8 notify) | |
976 { | |
977 TRACE_FUNCTION("mfw_audio_device_indication()"); | |
978 | |
979 TRACE_EVENT_P1(" Indication Type == %d",notify); | |
980 switch(notify) | |
981 { | |
982 case AUDIO_HEADSET_PLUGGED: | |
983 if(currAudioDevice != MFW_AUD_HEADSET) | |
984 { | |
985 mfw_audio_set_device(MFW_AUD_HEADSET); | |
986 headsetInserted = TRUE; | |
987 } | |
988 break; | |
989 case AUDIO_HEADSET_UNPLUGGED: | |
990 if( currAudioDevice == MFW_AUD_HEADSET) | |
991 { | |
992 mfw_audio_set_device(MFW_AUD_HANDHELD ); | |
993 | |
994 } | |
995 headsetInserted = FALSE; | |
996 break; | |
997 case AUDIO_HEADSET_HOOK_DETECT: | |
998 break; | |
999 case AUDIO_CARKIT_PLUGGED: | |
1000 if(currAudioDevice != MFW_AUD_CARKIT) | |
1001 { | |
1002 mfw_audio_set_device(MFW_AUD_CARKIT); | |
1003 carkitInserted = TRUE; | |
1004 } | |
1005 break; | |
1006 case AUDIO_CARKIT_UNPLUGGED: | |
1007 if( currAudioDevice == MFW_AUD_CARKIT) | |
1008 { | |
1009 if(headsetInserted == TRUE) | |
1010 { | |
1011 mfw_audio_set_device (MFW_AUD_HEADSET); | |
1012 } | |
1013 else | |
1014 { | |
1015 mfw_audio_set_device (MFW_AUD_HANDHELD); | |
1016 } | |
1017 } | |
1018 carkitInserted = FALSE; | |
1019 break; | |
1020 default: | |
1021 break; | |
1022 } | |
1023 } | |
1024 /* | |
1025 +--------------------------------------------------------------------+ | |
1026 | PROJECT : MMI-Framework (8417) MODULE : MFW_MME | | |
1027 | STATE : code ROUTINE : mfw_audio_headSet_indication | | |
1028 +--------------------------------------------------------------------+ | |
1029 | |
1030 PURPOSE :This function handles the switch between the handheld and loudspeaker. | |
1031 The type of device to be loaded will be posted from the menu selection | |
1032 When the profile changes if there is any other media played then the | |
1033 speaker should be set to stereo speaker | |
1034 | |
1035 */ | |
1036 void mfw_audio_set_device(int type) | |
1037 { | |
1038 /*Description: this array holds the file names on the ffs in which the audio profiles are stored. | |
1039 The file names are yet to be confirmed from the audio services group*/ | |
1040 //char aud_cg_file[4][15] = {"handheld","loudspeaker","headset","carkit"}; | |
1041 TRACE_FUNCTION("mfw_audio_set_device()"); | |
1042 | |
1043 TRACE_EVENT_P1("type of device = %d",type); | |
1044 switch(type) | |
1045 { | |
1046 case MFW_AUD_HANDHELD: | |
1047 audio_set_device((char*)HANDHELD);// (aud_cg_file[HANDHELD] ); | |
1048 currAudioDevice = MFW_AUD_HANDHELD; | |
1049 break; | |
1050 case MFW_AUD_LOUDSPEAKER: | |
1051 audio_set_device((char*) LOUDSPEAKER);//(aud_cg_file[LOUDSPEAKER]); | |
1052 currAudioDevice = MFW_AUD_LOUDSPEAKER; | |
1053 break; | |
1054 case MFW_AUD_HEADSET: | |
1055 audio_set_device((char*)HEADSET);//(aud_cg_file[HEADSET]); | |
1056 currAudioDevice = MFW_AUD_HEADSET; | |
1057 break; | |
1058 case MFW_AUD_CARKIT: | |
1059 audio_set_device((char*)CARKIT);//(aud_cg_file[CARKIT]); | |
1060 currAudioDevice = MFW_AUD_CARKIT; | |
1061 default: | |
1062 break; | |
1063 } | |
1064 if(TRUE == mfwAudPlay) | |
1065 mfw_set_stereo_path(currAudioDevice); | |
1066 | |
1067 } | |
1068 | |
1069 #ifdef ISAMPLE | |
1070 /* OMAPS00057367, 3 Dec 2005, nekkareb : start */ | |
1071 /* Function mfw_get_current_audioDevice modified to read the | |
1072 current audio device using the audio service entity function | |
1073 audio_full_access_read. This solves some synchronisation | |
1074 problems b/n Audio & MMI for the DR OMAPS00057367 */ | |
1075 /*returns the current active audio device*/ | |
1076 int mfw_get_current_audioDevice() | |
1077 { | |
1078 T_AUDIO_FULL_ACCESS_READ read; | |
1079 INT8 speaker; | |
1080 | |
1081 read.variable_indentifier = AUDIO_SPEAKER_MODE; | |
1082 read.data = &speaker; | |
1083 | |
1084 TRACE_FUNCTION("mfw_get_current_audioDevice()"); | |
1085 audio_full_access_read(&read ); | |
1086 | |
1087 switch(speaker) | |
1088 { | |
1089 case AUDIO_SPEAKER_NONE: | |
1090 TRACE_EVENT("mfw_get_current_audioDevice() - SPEAKER PATH NOT CONFIGURED"); | |
1091 currAudioDevice = MFW_AUD_HANDHELD; //Need to check the mapping | |
1092 break; | |
1093 case AUDIO_SPEAKER_HANDHELD: | |
1094 currAudioDevice = MFW_AUD_HANDHELD; | |
1095 break; | |
1096 case AUDIO_SPEAKER_HEADSET: | |
1097 currAudioDevice = MFW_AUD_HEADSET; | |
1098 break; | |
1099 case AUDIO_SPEAKER_AUX: | |
1100 currAudioDevice = MFW_AUD_LOUDSPEAKER; //Need to check the mapping | |
1101 break; | |
1102 case AUDIO_SPEAKER_CARKIT: | |
1103 currAudioDevice = MFW_AUD_CARKIT; | |
1104 break; | |
1105 case AUDIO_SPEAKER_HANDFREE: | |
1106 case AUDIO_SPEAKER_HANDFREE_CLASS_D: | |
1107 currAudioDevice = MFW_AUD_LOUDSPEAKER; | |
1108 break; | |
1109 case AUDIO_SPEAKER_INVERTED_VOICE: | |
1110 currAudioDevice = MFW_AUD_HEADSET; //Need to check the mapping | |
1111 break; | |
1112 } | |
1113 | |
1114 return currAudioDevice; | |
1115 } | |
1116 /* OMAPS00057367, 3 Dec 2005, nekkareb : end */ | |
1117 #else | |
1118 /*returns the current active audio device*/ | |
1119 int mfw_get_current_audioDevice() | |
1120 { | |
1121 TRACE_FUNCTION("mfw_get_current_audioDevice()"); | |
1122 return currAudioDevice; | |
1123 } | |
1124 #endif //ISAMPLE | |
1125 #endif | |
1126 | |
1127 |