FreeCalypso > hg > fc-magnetite
comparison src/ui3/mfw/mfw_bt_api.c @ 420:e8ddbb0837ed
src/ui3: initial import of TCS3/LoCosto BMI & MFW code
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sun, 21 Jan 2018 03:09:00 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 419:59143cd42ec7 | 420:e8ddbb0837ed |
|---|---|
| 1 /*******************************************************************************\ | |
| 2 * * | |
| 3 * TEXAS INSTRUMENTS ISRAEL PROPRIETARY AND CONFIDENTIAL INFORMATION * | |
| 4 * * | |
| 5 * LEGAL NOTE: THE TRANSFER OF THE TECHNICAL INFORMATION IS BEING MADE * | |
| 6 * UNDER AN EXPORT LICENSE ISSUED BY THE ISRAELI GOVERNMENT AND THAT THE * | |
| 7 * APPLICABLE EXPORT LICENSE DOES NOT ALLOW THE TECHNICAL INFORMATION TO * | |
| 8 * BE USED FOR THE MODIFICATION OF THE BT ENCRYPTION OR THE DEVELOPMENT * | |
| 9 * OF ANY NEW ENCRYPTION. THE INFORMATION CAN BE USED FOR THE INTERNAL * | |
| 10 * DESIGN AND MANUFACTURE OF TI PRODUCTS THAT WILL CONTAIN THE BT IC. * | |
| 11 * * | |
| 12 \*******************************************************************************/ | |
| 13 /*******************************************************************************\ | |
| 14 * | |
| 15 * FILE NAME: mfw_bt_api.c | |
| 16 * | |
| 17 * DESCRIPTION: This file implements the API between BMI (MMI) and BT applications | |
| 18 * | |
| 19 * AUTHOR: Anandhi Ramesh | |
| 20 * | |
| 21 * Rev 0.1 | |
| 22 * | |
| 23 \*******************************************************************************/ | |
| 24 /* ========================================================== */ | |
| 25 /*=========================================================== | |
| 26 *! | |
| 27 *! Revision History | |
| 28 *! =================================== | |
| 29 | |
| 30 Nov 12, 2007 DRT :OMAPS00151698 x0056422 | |
| 31 Description: MM: Commands that are not recognized by MMI are | |
| 32 handled improperly in BMI_NotifyBtEvent function. *! | |
| 33 *! | |
| 34 *! 17-Jan-2006 mf: Revisions appear in reverse chronological order; | |
| 35 *! that is, newest first. The date format is dd-Mon-yyyy. | |
| 36 * =========================================================== */ | |
| 37 | |
| 38 /****************************************************************************** | |
| 39 Include Files | |
| 40 *******************************************************************************/ | |
| 41 #ifdef FF_MMI_A2DP_AVRCP | |
| 42 #if defined (NEW_FRAME) | |
| 43 | |
| 44 #include "typedefs.h" | |
| 45 #include "vsi.h" | |
| 46 #include "pei.h" | |
| 47 #include "custom.h" | |
| 48 #include "gsm.h" | |
| 49 | |
| 50 #else | |
| 51 | |
| 52 #include "STDDEFS.H" | |
| 53 #include "custom.h" | |
| 54 #include "gsm.h" | |
| 55 #include "vsi.h" | |
| 56 | |
| 57 #endif | |
| 58 | |
| 59 | |
| 60 #include "mfw_mfw.h" | |
| 61 #include "mfw_phb.h" | |
| 62 #include "mfw_phbi.h" | |
| 63 #include "mfw_cm.h" | |
| 64 #include "mfw_cmi.h" | |
| 65 #include "mfw_kbd.h" | |
| 66 | |
| 67 #include "mfw_nm.h" | |
| 68 #include "mfw_sim.h" | |
| 69 #include "mfw_sima.h" | |
| 70 #include "mfw_nmi.h" | |
| 71 #include "mfw_simi.h" | |
| 72 #include "mfw_sms.h" | |
| 73 #include "mfw_smsi.h" | |
| 74 #include "mfw_win.h" | |
| 75 | |
| 76 #include "ksd.h" | |
| 77 #include "psa.h" | |
| 78 | |
| 79 #include "mfw_bt_api.h" | |
| 80 #include "mfw_bt_private.h" | |
| 81 | |
| 82 /*Declaration of Global BT structure for BMI*/ | |
| 83 BMI_BT_STRUCTTYPE tGlobalBmiBtStruct; | |
| 84 | |
| 85 extern BOOL mmi_progress_bar; | |
| 86 /* temp comment */ | |
| 87 extern T_AS_RET as_bt_cfg(BOOL , const T_RV_RETURN_PATH* ); | |
| 88 /* ========================================================================== */ | |
| 89 /** | |
| 90 * @fn BMI_SwitchAudioToBtHeadset : Sets BT connection status. | |
| 91 * Connect or disconnect the audio output to BT headset. | |
| 92 * BT will call this function to let BMI know an A2DP link to a wireless headset | |
| 93 * has been connected (and is in Open state), or disconnected. | |
| 94 * | |
| 95 * When link is connected, BMI will decide whether it wants to | |
| 96 * direct the audio output to the wireless headset. | |
| 97 * | |
| 98 * @param [in] connected | |
| 99 * connected [in] - whether the link has just been connected or disconnected: | |
| 100 * TRUE - connected | |
| 101 * FALSE - disconnected | |
| 102 * | |
| 103 * @return BOOL | |
| 104 * when connect parameter is TRUE: | |
| 105 * - return TRUE when BMI approves and will use A2DP headset as the audio output | |
| 106 * - return FALSE when BMI rejects using A2DP headset as the audio output | |
| 107 * | |
| 108 * when connect parameter is FALSE - returned value is ignored | |
| 109 * | |
| 110 * @see mfw_bt_api.h | |
| 111 */ | |
| 112 /* ========================================================================== */ | |
| 113 | |
| 114 BOOL BMI_SwitchAudioToBtHeadset(BOOL connected) | |
| 115 { | |
| 116 static U8 first_time = 1; | |
| 117 TRACE_FUNCTION("BMI_SwitchAudioToBtHeadset"); | |
| 118 if(first_time == 1) | |
| 119 { | |
| 120 tGlobalBmiBtStruct.tCmdSrc = BMI_BT_COMMAND_NONE; | |
| 121 first_time = 0; | |
| 122 } | |
| 123 if(connected == 0) | |
| 124 { | |
| 125 TRACE_FUNCTION("BMI_BT_Trace BMI_SwitchAudioToBtHeadset OFF"); | |
| 126 tGlobalBmiBtStruct.bConnected = BMI_BT_NOTCONNECTED; | |
| 127 } | |
| 128 else | |
| 129 { | |
| 130 TRACE_FUNCTION("BMI_BT_Trace BMI_SwitchAudioToBtHeadset ON"); | |
| 131 tGlobalBmiBtStruct.bConnected = BMI_BT_CONNECTED; | |
| 132 } | |
| 133 | |
| 134 //send the status to AS layer. | |
| 135 as_bt_cfg(connected, NULL); | |
| 136 return connected; | |
| 137 } | |
| 138 /* ========================================================================== */ | |
| 139 /** | |
| 140 * @fn BMI_NotifyBtEvent : Informs BMI of any events triggered by the BT headset. | |
| 141 * @Description : This function is called by BT to notify MMI of any events in the headset. | |
| 142 * MMI translates these events to corresponding keypad events and posts the event to itself. | |
| 143 * | |
| 144 * @param [in] BtAppEvent event | |
| 145 * The events that are recognised by MMI are | |
| 146 * BT_EVENT_USER_PLAY - user has pressed play on handset, or resume. | |
| 147 * BT_EVENT_USER_STOP - user has pressed stop on handset. | |
| 148 * BT_EVENT_USER_PAUSE - user has pressed pause on handset. | |
| 149 * | |
| 150 * @return none | |
| 151 * | |
| 152 * @see mfw_bt_api.h | |
| 153 */ | |
| 154 /* ========================================================================== */ | |
| 155 | |
| 156 void BMI_NotifyBtEvent(BtAppEvent event) | |
| 157 { | |
| 158 U8 key_state, key_code; | |
| 159 int nPresses; | |
| 160 TRACE_FUNCTION("BMI_BT_Trace BMI_NotifyBtEvent Enter"); | |
| 161 if(tGlobalBmiBtStruct.bConnected != BMI_BT_NOTCONNECTED) | |
| 162 { | |
| 163 key_state = KEY_STAT_PRS; | |
| 164 | |
| 165 TRACE_FUNCTION("BMI_BT_Trace BMI_NotifyBtEvent - BT connected"); | |
| 166 switch(event) | |
| 167 { | |
| 168 case BT_EVENT_USER_PLAY: | |
| 169 TRACE_FUNCTION("Play"); | |
| 170 if(tGlobalBmiBtStruct.tAudioState == FM_AUD_PAUSE | |
| 171 && mmi_progress_bar==1) | |
| 172 key_code = 0x0D; | |
| 173 else if (tGlobalBmiBtStruct.tAudioState == FM_AUD_STOP || | |
| 174 tGlobalBmiBtStruct.tAudioState == FM_AUD_NONE) | |
| 175 key_code = 0x17; | |
| 176 else | |
| 177 goto EXIT; | |
| 178 break; | |
| 179 case BT_EVENT_USER_STOP: | |
| 180 TRACE_FUNCTION("Stop"); | |
| 181 if(tGlobalBmiBtStruct.tAudioState == FM_AUD_PLAY | |
| 182 && mmi_progress_bar==0) | |
| 183 key_code = 0x17; | |
| 184 else if(tGlobalBmiBtStruct.tAudioState != FM_AUD_NONE | |
| 185 && mmi_progress_bar==1) | |
| 186 key_code = 0x0E; | |
| 187 else | |
| 188 goto EXIT; | |
| 189 break; | |
| 190 case BT_EVENT_USER_PAUSE: | |
| 191 TRACE_FUNCTION("Pause"); | |
| 192 if(tGlobalBmiBtStruct.tAudioState == FM_AUD_PLAY | |
| 193 && mmi_progress_bar == 1 ) | |
| 194 key_code = 0x0D; | |
| 195 else | |
| 196 goto EXIT; | |
| 197 break; | |
| 198 | |
| 199 /* OMAPS00151698 x0056422 */ | |
| 200 default : | |
| 201 goto EXIT; | |
| 202 break; | |
| 203 } | |
| 204 | |
| 205 //set the indication that this command came from BT and not handset | |
| 206 tGlobalBmiBtStruct.tCmdSrc = BMI_BT_HEADSET_COMMAND; | |
| 207 | |
| 208 //<post a keypad indication message to the MMI> | |
| 209 //Add keypress to queue of key presses | |
| 210 nPresses = kbd_getNumElements(); | |
| 211 kbd_putMakeAndKey( (char)key_state, (char)key_code); | |
| 212 /*also send a key release indicaiton for the same key. | |
| 213 If this is not done, the key press becomes a long press and is | |
| 214 handled differently */ | |
| 215 key_state = KEY_STAT_REL; | |
| 216 kbd_putMakeAndKey( (char)key_state, (char)key_code); | |
| 217 if ((!kbd_stillProcessingKeys()) && (nPresses == 0)) | |
| 218 { //Only this element present - create and send message. | |
| 219 | |
| 220 sendKeyInd(key_code, KEY_STAT_PRS, 0); | |
| 221 } | |
| 222 if ((!kbd_stillProcessingKeys()) && (nPresses == 0)) | |
| 223 { //Only this element present - create and send message. | |
| 224 | |
| 225 sendKeyInd(key_code, KEY_STAT_REL, 0); | |
| 226 } | |
| 227 } | |
| 228 EXIT: | |
| 229 return; | |
| 230 } | |
| 231 | |
| 232 /* ========================================================================== */ | |
| 233 /** | |
| 234 * @fn BMI_RegisterEventCallback : BT calls this function to register a callback with MMI | |
| 235 * Whenever there is a | |
| 236 * | |
| 237 * @param [in] BtAppEvent event | |
| 238 * The events that are recognised by MMI are | |
| 239 * BT_EVENT_USER_PLAY - user has pressed play on handset, or resume. | |
| 240 * BT_EVENT_USER_STOP - user has pressed stop on handset. | |
| 241 * BT_EVENT_USER_PAUSE - user has pressed pause on handset. | |
| 242 * | |
| 243 * @return none | |
| 244 * | |
| 245 * @see mfw_bt_api.h | |
| 246 */ | |
| 247 /* ========================================================================== */ | |
| 248 void BMI_RegisterEventCallback(BmiEventCallback eventCallback) | |
| 249 { | |
| 250 TRACE_FUNCTION("BMI_RegisterEventCallback"); | |
| 251 tGlobalBmiBtStruct.BmiEventCallback = eventCallback; | |
| 252 return; | |
| 253 } | |
| 254 #endif //FF_MMI_A2DP_AVRCP | |
| 255 |
