hardware/broadcom/libbt
リビジョン | f219785e8a4e011abe5488d22f3d72b6698ce45a (tree) |
---|---|
日時 | 2013-05-10 04:20:28 |
作者 | YK Jeffrey Chao <jechao@broa...> |
コミッター | Matthew Xie |
New call-in/-back functions for Controller to do vendor-specific shutdown (2/2)
A pair of asynchronous call-in and call-back API are added into the Host
Controller Vendor Lib interface (bt_vendor_lib.h). The caller calls this new
call-in function to inform the vendor module to perform vendor-specific
shutdown process (e.g. send HCI_RESET to BT Controller) before the caller calls
for interface cleanup() function. The vendor module is responsible for calling
call-back function to notify the caller completion of vendor-specific shutdown
process.
Sample codes of sending a HCI_RESET command in the vendor-specific shutdown
process.
bug 7390787
Change-Id: I817c0a7dd57e750d38884746edeb3436cfc9cfd8
@@ -349,6 +349,16 @@ | ||
349 | 349 | #define PCM_DATA_FMT_JUSTIFY_MODE 0 |
350 | 350 | #endif |
351 | 351 | |
352 | +/* HW_END_WITH_HCI_RESET | |
353 | + | |
354 | + Sample code implementation of sending a HCI_RESET command during the epilog | |
355 | + process. It calls back to the callers after command complete of HCI_RESET | |
356 | + is received. | |
357 | +*/ | |
358 | +#ifndef HW_END_WITH_HCI_RESET | |
359 | +#define HW_END_WITH_HCI_RESET TRUE | |
360 | +#endif | |
361 | + | |
352 | 362 | /****************************************************************************** |
353 | 363 | ** Extern variables and functions |
354 | 364 | ******************************************************************************/ |
@@ -53,6 +53,9 @@ void hw_lpm_set_wake_state(uint8_t wake_assert); | ||
53 | 53 | void hw_sco_config(void); |
54 | 54 | #endif |
55 | 55 | void vnd_load_conf(const char *p_path); |
56 | +#if (HW_END_WITH_HCI_RESET == TRUE) | |
57 | +void hw_epilog_process(void); | |
58 | +#endif | |
56 | 59 | |
57 | 60 | /****************************************************************************** |
58 | 61 | ** Variables |
@@ -203,6 +206,19 @@ static int op(bt_vendor_opcode_t opcode, void *param) | ||
203 | 206 | hw_lpm_set_wake_state(wake_assert); |
204 | 207 | } |
205 | 208 | break; |
209 | + | |
210 | + case BT_VND_OP_EPILOG: | |
211 | + { | |
212 | +#if (HW_END_WITH_HCI_RESET == FALSE) | |
213 | + if (bt_vendor_cbacks) | |
214 | + { | |
215 | + bt_vendor_cbacks->epilog_cb(BT_VND_OP_RESULT_SUCCESS); | |
216 | + } | |
217 | +#else | |
218 | + hw_epilog_process(); | |
219 | +#endif | |
220 | + } | |
221 | + break; | |
206 | 222 | } |
207 | 223 | |
208 | 224 | return retval; |
@@ -1231,3 +1231,89 @@ int hw_set_patch_settlement_delay(char *p_conf_name, char *p_conf_value, int par | ||
1231 | 1231 | } |
1232 | 1232 | #endif //VENDOR_LIB_RUNTIME_TUNING_ENABLED |
1233 | 1233 | |
1234 | +/***************************************************************************** | |
1235 | +** Sample Codes Section | |
1236 | +*****************************************************************************/ | |
1237 | + | |
1238 | +#if (HW_END_WITH_HCI_RESET == TRUE) | |
1239 | +/******************************************************************************* | |
1240 | +** | |
1241 | +** Function hw_epilog_cback | |
1242 | +** | |
1243 | +** Description Callback function for Command Complete Events from HCI | |
1244 | +** commands sent in epilog process. | |
1245 | +** | |
1246 | +** Returns None | |
1247 | +** | |
1248 | +*******************************************************************************/ | |
1249 | +void hw_epilog_cback(void *p_mem) | |
1250 | +{ | |
1251 | + HC_BT_HDR *p_evt_buf = (HC_BT_HDR *) p_mem; | |
1252 | + uint8_t *p, status; | |
1253 | + uint16_t opcode; | |
1254 | + | |
1255 | + status = *((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE); | |
1256 | + p = (uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_OPCODE; | |
1257 | + STREAM_TO_UINT16(opcode,p); | |
1258 | + | |
1259 | + BTHWDBG("%s Opcode:0x%04X Status: %d", __FUNCTION__, opcode, status); | |
1260 | + | |
1261 | + if (bt_vendor_cbacks) | |
1262 | + { | |
1263 | + /* Must free the RX event buffer */ | |
1264 | + bt_vendor_cbacks->dealloc(p_evt_buf); | |
1265 | + | |
1266 | + /* Once epilog process is done, must call epilog_cb callback | |
1267 | + to notify caller */ | |
1268 | + bt_vendor_cbacks->epilog_cb(BT_VND_OP_RESULT_SUCCESS); | |
1269 | + } | |
1270 | +} | |
1271 | + | |
1272 | +/******************************************************************************* | |
1273 | +** | |
1274 | +** Function hw_epilog_process | |
1275 | +** | |
1276 | +** Description Sample implementation of epilog process | |
1277 | +** | |
1278 | +** Returns None | |
1279 | +** | |
1280 | +*******************************************************************************/ | |
1281 | +void hw_epilog_process(void) | |
1282 | +{ | |
1283 | + HC_BT_HDR *p_buf = NULL; | |
1284 | + uint8_t *p; | |
1285 | + | |
1286 | + BTHWDBG("hw_epilog_process"); | |
1287 | + | |
1288 | + /* Sending a HCI_RESET */ | |
1289 | + if (bt_vendor_cbacks) | |
1290 | + { | |
1291 | + /* Must allocate command buffer via HC's alloc API */ | |
1292 | + p_buf = (HC_BT_HDR *) bt_vendor_cbacks->alloc(BT_HC_HDR_SIZE + \ | |
1293 | + HCI_CMD_PREAMBLE_SIZE); | |
1294 | + } | |
1295 | + | |
1296 | + if (p_buf) | |
1297 | + { | |
1298 | + p_buf->event = MSG_STACK_TO_HC_HCI_CMD; | |
1299 | + p_buf->offset = 0; | |
1300 | + p_buf->layer_specific = 0; | |
1301 | + p_buf->len = HCI_CMD_PREAMBLE_SIZE; | |
1302 | + | |
1303 | + p = (uint8_t *) (p_buf + 1); | |
1304 | + UINT16_TO_STREAM(p, HCI_RESET); | |
1305 | + *p = 0; /* parameter length */ | |
1306 | + | |
1307 | + /* Send command via HC's xmit_cb API */ | |
1308 | + bt_vendor_cbacks->xmit_cb(HCI_RESET, p_buf, hw_epilog_cback); | |
1309 | + } | |
1310 | + else | |
1311 | + { | |
1312 | + if (bt_vendor_cbacks) | |
1313 | + { | |
1314 | + ALOGE("vendor lib epilog process aborted [no buffer]"); | |
1315 | + bt_vendor_cbacks->epilog_cb(BT_VND_OP_RESULT_FAIL); | |
1316 | + } | |
1317 | + } | |
1318 | +} | |
1319 | +#endif // (HW_END_WITH_HCI_RESET == TRUE) |