15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Copyright (C) 2009-2012 Broadcom Corporation 45738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 55738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 65738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * you may not use this file except in compliance with the License. 75738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * You may obtain a copy of the License at: 85738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 95738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * See the License for the specific language governing permissions and 155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * limitations under the License. 165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <stdio.h> 195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <stdlib.h> 205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_api.h" 225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_sys.h" 235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_dm_co.h" 245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_dm_ci.h" 255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTM_OOB_INCLUDED == TRUE) 265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "btif_dm.h" 275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 28ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE) 29ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta#include "bte_appl.h" 30ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 31ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi BattatBTE_APPL_CFG bte_appl_cfg = { 0x5, 0x4, 0x7, 0x7, 0x10 }; 32fc4b2f1953dbe60464d0f5ef7daaa10001fbc62fMatthew Xie#endif 33ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_co_get_compress_memory 375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This callout function is executed by DM to get memory for compression 395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters id - BTA SYS ID 415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** memory_p - memory return by callout 425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** memory_size - memory size 435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns TRUE for success, FALSE for fail. 455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectBOOLEAN bta_dm_co_get_compress_memory(tBTA_SYS_ID id, UINT8 **memory_p, UINT32 *memory_size) 485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return TRUE; 505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_co_io_req 555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This callout function is executed by DM to get IO capabilities 575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** of the local device for the Simple Pairing process 585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters bd_addr - The peer device 605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_io_cap - The local Input/Output capabilities 615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_oob_data - TRUE, if OOB data is available for the peer device. 625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_auth_req - TRUE, if MITM protection is required. 635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_co_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap, tBTA_OOB_DATA *p_oob_data, 685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AUTH_REQ *p_auth_req, BOOLEAN is_orig) 695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTM_OOB_INCLUDED == TRUE) 715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_set_oob_for_io_req(p_oob_data); 725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("bta_dm_co_io_req *p_oob_data = %d", *p_oob_data); 745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("bta_dm_co_io_req *p_io_cap = %d", *p_io_cap); 755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("bta_dm_co_io_req *p_auth_req = %d", *p_auth_req); 765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("bta_dm_co_io_req is_orig = %d", is_orig); 775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_co_io_rsp 825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This callout function is executed by DM to report IO capabilities 845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** of the peer device for the Simple Pairing process 855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters bd_addr - The peer device 875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** io_cap - The remote Input/Output capabilities 885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** oob_data - TRUE, if OOB data is available for the peer device. 895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** auth_req - TRUE, if MITM protection is required. 905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_co_io_rsp(BD_ADDR bd_addr, tBTA_IO_CAP io_cap, 955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req) 965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_co_lk_upgrade 1025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This callout function is executed by DM to check if the 1045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** platform wants allow link key upgrade 1055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters bd_addr - The peer device 1075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_upgrade - TRUE, if link key upgrade is desired. 1085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 1105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_co_lk_upgrade(BD_ADDR bd_addr, BOOLEAN *p_upgrade ) 1135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTM_OOB_INCLUDED == TRUE) 1175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_co_loc_oob 1205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This callout function is executed by DM to report the OOB 1225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** data of the local device for the Simple Pairing process 1235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters valid - TRUE, if the local OOB data is retrieved from LM 1255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** c - Simple Pairing Hash C 1265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** r - Simple Pairing Randomnizer R 1275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 1295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_co_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r) 1325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("bta_dm_co_loc_oob, valid = %d", valid); 1345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#ifdef BTIF_DM_OOB_TEST 1355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btif_dm_proc_loc_oob(valid, c, r); 1365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 1375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_co_rmt_oob 1425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This callout function is executed by DM to request the OOB 1445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** data for the remote device for the Simple Pairing process 1455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Need to call bta_dm_ci_rmt_oob() in response 1465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters bd_addr - The peer device 1485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 1505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_co_rmt_oob(BD_ADDR bd_addr) 1535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_OCTET16 p_c; 1555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_OCTET16 p_r; 1565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN result = FALSE; 1575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#ifdef BTIF_DM_OOB_TEST 1595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = btif_dm_proc_rmt_oob(bd_addr, p_c, p_r); 1605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 1615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG1("bta_dm_co_rmt_oob: result=%d",result); 1635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_dm_ci_rmt_oob(result, bd_addr, p_c, p_r); 1645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif /* BTM_OOB_INCLUDED */ 1675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project// REMOVE FOR BLUEDROID ? 1705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTM_SCO_HCI_INCLUDED == TRUE ) && (BTM_SCO_INCLUDED == TRUE) 1725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function btui_sco_codec_callback 1765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Callback for btui codec. 1785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 1815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void btui_sco_codec_callback(UINT16 event, UINT16 sco_handle) 1845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_dm_sco_ci_data_ready(event, sco_handle); 1865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_sco_co_init 1905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function can be used by the phone to initialize audio 1925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** codec or for other initialization purposes before SCO connection 1935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** is opened. 1945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns tBTA_DM_SCO_ROUTE_TYPE: SCO routing configuration type. 1975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjecttBTA_DM_SCO_ROUTE_TYPE bta_dm_sco_co_init(UINT32 rx_bw, UINT32 tx_bw, 2005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_CODEC_INFO * p_codec_type, UINT8 app_id) 2015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTM_SCO_ROUTE_TYPE route = BTA_DM_SCO_ROUTE_PCM; 2035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG0("bta_dm_sco_co_init"); 2055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up SCO routing configuration if SCO over HCI app ID is used and run time 2075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project configuration is set to SCO over HCI */ 2085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* HS invoke this call-out */ 2095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( 2105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BTA_HS_INCLUDED == TRUE ) && (BTA_HS_INCLUDED == TRUE) 2115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (app_id == BTUI_DM_SCO_4_HS_APP_ID && btui_cfg.hs_sco_over_hci) || 2125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 2135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* AG invoke this call-out */ 2145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (app_id != BTUI_DM_SCO_4_HS_APP_ID && btui_cfg.ag_sco_over_hci )) 2155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project route = btui_cb.sco_hci = BTA_DM_SCO_ROUTE_HCI; 2175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* no codec is is used for the SCO data */ 2195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_codec_type->codec_type == BTA_SCO_CODEC_PCM && route == BTA_DM_SCO_ROUTE_HCI) 2205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* initialize SCO codec */ 2225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!btui_sco_codec_init(rx_bw, tx_bw)) 2235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_ERROR0("codec initialization exception!"); 2255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return route; 2295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_sco_co_open 2365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is executed when a SCO connection is open. 2385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 2415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_sco_co_open(UINT16 handle, UINT8 pkt_size, UINT16 event) 2445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTUI_SCO_CODEC_CFG cfg; 2465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (btui_cb.sco_hci) 2485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG2("bta_dm_sco_co_open handle:%d pkt_size:%d", handle, pkt_size); 2505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* use dedicated SCO buffer pool for SCO TX data */ 2515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cfg.pool_id = HCI_SCO_POOL_ID; 2525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cfg.p_cback = btui_sco_codec_callback; 2535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cfg.pkt_size = pkt_size; 2545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cfg.cb_event = event; 2555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* open and start the codec */ 2565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btui_sco_codec_open(&cfg); 2575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btui_sco_codec_start(handle); 2585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_sco_co_close 2645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called when a SCO connection is closed 2665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 2695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_sco_co_close(void) 2725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (btui_cb.sco_hci) 2745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_DEBUG0("bta_dm_sco_co_close close codec"); 2765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* close sco codec */ 2775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btui_sco_codec_close(); 2785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btui_cb.sco_hci = FALSE; 2805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_sco_co_in_data 2865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to send incoming SCO data to application. 2885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 2905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_sco_co_in_data(BT_HDR *p_buf) 2935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (btui_cfg.sco_use_mic) 2955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btui_sco_codec_inqdata (p_buf); 2965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 2975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_buf); 2985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_sco_co_out_data 3035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to send SCO data over HCI. 3055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 3075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_sco_co_out_data(BT_HDR **p_buf) 3105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project btui_sco_codec_readbuf(p_buf); 3125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) && (BTM_SCO_INCLUDED == TRUE)*/ 3155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE) 3185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_co_le_io_key_req 3215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This callout function is executed by DM to get BLE key information 3235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** before SMP pairing gets going. 3245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters bd_addr - The peer device 3265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_max_key_size - max key size local device supported. 3275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_init_key - initiator keys. 3285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_resp_key - responder keys. 3295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 3315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_co_le_io_key_req(BD_ADDR bd_addr, UINT8 *p_max_key_size, 3345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_LE_KEY_TYPE *p_init_key, 3355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_LE_KEY_TYPE *p_resp_key ) 3365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_ERROR0("##################################"); 3385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_ERROR0("bta_dm_co_le_io_key_req: only setting max size to 16"); 3395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTIF_TRACE_ERROR0("##################################"); 3405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_max_key_size = 16; 3415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_init_key = *p_resp_key = 3425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (BTA_LE_KEY_PENC|BTA_LE_KEY_PID|BTA_LE_KEY_PCSRK|BTA_LE_KEY_LENC|BTA_LE_KEY_LID|BTA_LE_KEY_LCSRK); 3435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_co_ble_local_key_reload 3495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This callout function is to load the local BLE keys if available 3515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** on the device. 3525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters none 3545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 3565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_co_ble_load_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er, 3595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_BLE_LOCAL_ID_KEYS *p_id_keys) 3605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 361ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("##################################"); 362ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("bta_dm_co_ble_load_local_keys: Load local keys if any are persisted"); 363ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BTIF_TRACE_DEBUG0("##################################"); 364ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta btif_dm_get_ble_local_keys( p_key_mask, er, p_id_keys); 3655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_dm_co_ble_io_req 3705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This callout function is executed by DM to get BLE IO capabilities 3725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** before SMP pairing gets going. 3735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Parameters bd_addr - The peer device 3755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_io_cap - The local Input/Output capabilities 3765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_oob_data - TRUE, if OOB data is available for the peer device. 3775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_auth_req - Auth request setting (Bonding and MITM required or not) 3785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_max_key_size - max key size local device supported. 3795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_init_key - initiator keys. 3805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** *p_resp_key - responder keys. 3815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void. 3835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap, 3865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_OOB_DATA *p_oob_data, 3875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_LE_AUTH_REQ *p_auth_req, 3885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_max_key_size, 3895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_LE_KEY_TYPE *p_init_key, 3905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_LE_KEY_TYPE *p_resp_key ) 3915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if OOB is not supported, this call-out function does not need to do anything 3935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * otherwise, look for the OOB data associated with the address and set *p_oob_data accordingly 3945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * If the answer can not be obtained right away, 3955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * set *p_oob_data to BTA_OOB_UNKNOWN and call bta_dm_ci_io_req() when the answer is available */ 3965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 397ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta *p_oob_data = FALSE; 398ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 3995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* *p_auth_req by default is FALSE for devices with NoInputNoOutput; TRUE for other devices. */ 4005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bte_appl_cfg.ble_auth_req) 4025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_auth_req = bte_appl_cfg.ble_auth_req | (bte_appl_cfg.ble_auth_req & 0x04) | ((*p_auth_req) & 0x04); 4035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bte_appl_cfg.ble_io_cap <=4) 4055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_io_cap = bte_appl_cfg.ble_io_cap; 4065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bte_appl_cfg.ble_init_key<=7) 4085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_init_key = bte_appl_cfg.ble_init_key; 4095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bte_appl_cfg.ble_resp_key<=7) 4115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_resp_key = bte_appl_cfg.ble_resp_key; 4125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 413ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (bte_appl_cfg.ble_max_key_size > 7 && bte_appl_cfg.ble_max_key_size <= 16) 4145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_max_key_size = bte_appl_cfg.ble_max_key_size; 4155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 4195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 420