blob: cb4bdf7669650f4c473ba9af9bb0282520864206 [file] [log] [blame]
The Android Open Source Project5738f832012-12-12 16:00:35 -08001/******************************************************************************
2 *
3 * Copyright (C) 2009-2012 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
Sharvil Nanavati44802762014-12-23 23:08:58 -080018
Chris Mantonf8027002015-03-12 09:22:48 -070019#define LOG_TAG "bt_btif_bta_ag"
Sharvil Nanavati44802762014-12-23 23:08:58 -080020
Andre Eisenbach37d2de22015-03-26 14:14:40 -070021#include "bta/include/bta_ag_api.h"
Jakub Pawlowski713993d2016-04-21 13:16:45 -070022#include "bta/include/bta_ag_co.h"
Mudumba Ananth6afb2482015-03-25 05:20:02 -070023#include "hci/include/hci_audio.h"
24#include "osi/include/osi.h"
Matthew Xie66432dc2014-04-27 05:45:32 -070025
The Android Open Source Project5738f832012-12-12 16:00:35 -080026/*******************************************************************************
27**
28** Function bta_ag_co_init
29**
30** Description This callout function is executed by AG when it is
31** started by calling BTA_AgEnable(). This function can be
32** used by the phone to initialize audio paths or for other
33** initialization purposes.
34**
35**
36** Returns Void.
37**
38*******************************************************************************/
39void bta_ag_co_init(void)
40{
41 BTM_WriteVoiceSettings(AG_VOICE_SETTINGS);
42}
43
44
45/*******************************************************************************
46**
47** Function bta_ag_co_audio_state
48**
49** Description This function is called by the AG before the audio connection
50** is brought up, after it comes up, and after it goes down.
51**
52** Parameters handle - handle of the AG instance
53** state - Audio state
Matthew Xie66432dc2014-04-27 05:45:32 -070054** codec - if WBS support is compiled in, codec to going to be used is provided
Mudumba Ananth6afb2482015-03-25 05:20:02 -070055** and when in SCO_STATE_SETUP, BTM_I2SPCMConfig() must be called with
Matthew Xie66432dc2014-04-27 05:45:32 -070056** the correct platform parameters.
57** in the other states codec type should not be ignored
The Android Open Source Project5738f832012-12-12 16:00:35 -080058**
59** Returns void
60**
61*******************************************************************************/
Matthew Xie66432dc2014-04-27 05:45:32 -070062#if (BTM_WBS_INCLUDED == TRUE )
63void bta_ag_co_audio_state(UINT16 handle, UINT8 app_id, UINT8 state, tBTA_AG_PEER_CODEC codec)
64#else
The Android Open Source Project5738f832012-12-12 16:00:35 -080065void bta_ag_co_audio_state(UINT16 handle, UINT8 app_id, UINT8 state)
Matthew Xie66432dc2014-04-27 05:45:32 -070066#endif
The Android Open Source Project5738f832012-12-12 16:00:35 -080067{
Sharvil Nanavatie8c3d752014-05-04 10:12:26 -070068 BTIF_TRACE_DEBUG("bta_ag_co_audio_state: handle %d, state %d", handle, state);
Matthew Xie66432dc2014-04-27 05:45:32 -070069 switch (state)
70 {
Mudumba Ananth6afb2482015-03-25 05:20:02 -070071 case SCO_STATE_OFF:
Matthew Xie66432dc2014-04-27 05:45:32 -070072#if (BTM_WBS_INCLUDED == TRUE )
73 BTIF_TRACE_DEBUG("bta_ag_co_audio_state(handle %d)::Closed (OFF), codec: 0x%x",
74 handle, codec);
Jakub Pawlowski713993d2016-04-21 13:16:45 -070075 set_audio_state(handle, (sco_codec_t) codec, (sco_state_t) state);
Matthew Xie66432dc2014-04-27 05:45:32 -070076#else
77 BTIF_TRACE_DEBUG("bta_ag_co_audio_state(handle %d)::Closed (OFF)",
78 handle);
79#endif
80 break;
Mudumba Ananth6afb2482015-03-25 05:20:02 -070081 case SCO_STATE_OFF_TRANSFER:
Matthew Xie66432dc2014-04-27 05:45:32 -070082 BTIF_TRACE_DEBUG("bta_ag_co_audio_state(handle %d)::Closed (XFERRING)", handle);
83 break;
Mudumba Ananth6afb2482015-03-25 05:20:02 -070084 case SCO_STATE_SETUP:
Matthew Xie66432dc2014-04-27 05:45:32 -070085#if (BTM_WBS_INCLUDED == TRUE )
Jakub Pawlowski713993d2016-04-21 13:16:45 -070086 set_audio_state(handle, (sco_codec_t) codec, (sco_state_t) state);
Matthew Xie66432dc2014-04-27 05:45:32 -070087#else
Jakub Pawlowski713993d2016-04-21 13:16:45 -070088 set_audio_state(handle, (sco_codec_t) BTA_AG_CODEC_CVSD, (sco_state_t) state);
Matthew Xie66432dc2014-04-27 05:45:32 -070089#endif
90 break;
91 default:
92 break;
93 }
94#if (BTM_WBS_INCLUDED == TRUE )
95 APPL_TRACE_DEBUG("bta_ag_co_audio_state(handle %d, app_id: %d, state %d, codec: 0x%x)",
96 handle, app_id, state, codec);
97#else
98 APPL_TRACE_DEBUG("bta_ag_co_audio_state(handle %d, app_id: %d, state %d)", \
99 handle, app_id, state);
100#endif
The Android Open Source Project5738f832012-12-12 16:00:35 -0800101}
102
103
104/*******************************************************************************
105**
106** Function bta_ag_co_data_open
107**
108** Description This function is executed by AG when a service level connection
109** is opened. The phone can use this function to set
110** up data paths or perform any required initialization or
111** set up particular to the connected service.
112**
113**
114** Returns void
115**
116*******************************************************************************/
117void bta_ag_co_data_open(UINT16 handle, tBTA_SERVICE_ID service)
118{
Sharvil Nanavatie8c3d752014-05-04 10:12:26 -0700119 BTIF_TRACE_DEBUG("bta_ag_co_data_open handle:%d service:%d", handle, service);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800120}
121
122/*******************************************************************************
123**
124** Function bta_ag_co_data_close
125**
126** Description This function is called by AG when a service level
127** connection is closed
128**
129**
130** Returns void
131**
132*******************************************************************************/
133void bta_ag_co_data_close(UINT16 handle)
134{
Sharvil Nanavatie8c3d752014-05-04 10:12:26 -0700135 BTIF_TRACE_DEBUG("bta_ag_co_data_close handle:%d", handle);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800136}
137
138
139/*******************************************************************************
140 **
141 ** Function bta_ag_co_tx_write
142 **
143 ** Description This function is called by the AG to send data to the
144 ** phone when the AG is configured for AT command pass-through.
145 ** The implementation of this function must copy the data to
146 ** the phones memory.
147 **
148 ** Returns void
149 **
150 *******************************************************************************/
Mudumba Ananth6afb2482015-03-25 05:20:02 -0700151void bta_ag_co_tx_write(UINT16 handle, UNUSED_ATTR UINT8 * p_data, UINT16 len)
The Android Open Source Project5738f832012-12-12 16:00:35 -0800152{
Sharvil Nanavatie8c3d752014-05-04 10:12:26 -0700153 BTIF_TRACE_DEBUG( "bta_ag_co_tx_write: handle: %d, len: %d", handle, len );
The Android Open Source Project5738f832012-12-12 16:00:35 -0800154}