The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 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 Nanavati | 4480276 | 2014-12-23 23:08:58 -0800 | [diff] [blame] | 18 | |
Chris Manton | f802700 | 2015-03-12 09:22:48 -0700 | [diff] [blame] | 19 | #define LOG_TAG "bt_btif_bta_ag" |
Sharvil Nanavati | 4480276 | 2014-12-23 23:08:58 -0800 | [diff] [blame] | 20 | |
Andre Eisenbach | 37d2de2 | 2015-03-26 14:14:40 -0700 | [diff] [blame] | 21 | #include "bta/include/bta_ag_api.h" |
Jakub Pawlowski | 713993d | 2016-04-21 13:16:45 -0700 | [diff] [blame^] | 22 | #include "bta/include/bta_ag_co.h" |
Mudumba Ananth | 6afb248 | 2015-03-25 05:20:02 -0700 | [diff] [blame] | 23 | #include "hci/include/hci_audio.h" |
| 24 | #include "osi/include/osi.h" |
Matthew Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 25 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 26 | /******************************************************************************* |
| 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 | *******************************************************************************/ |
| 39 | void 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 Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 54 | ** codec - if WBS support is compiled in, codec to going to be used is provided |
Mudumba Ananth | 6afb248 | 2015-03-25 05:20:02 -0700 | [diff] [blame] | 55 | ** and when in SCO_STATE_SETUP, BTM_I2SPCMConfig() must be called with |
Matthew Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 56 | ** the correct platform parameters. |
| 57 | ** in the other states codec type should not be ignored |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 58 | ** |
| 59 | ** Returns void |
| 60 | ** |
| 61 | *******************************************************************************/ |
Matthew Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 62 | #if (BTM_WBS_INCLUDED == TRUE ) |
| 63 | void bta_ag_co_audio_state(UINT16 handle, UINT8 app_id, UINT8 state, tBTA_AG_PEER_CODEC codec) |
| 64 | #else |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 65 | void bta_ag_co_audio_state(UINT16 handle, UINT8 app_id, UINT8 state) |
Matthew Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 66 | #endif |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 67 | { |
Sharvil Nanavati | e8c3d75 | 2014-05-04 10:12:26 -0700 | [diff] [blame] | 68 | BTIF_TRACE_DEBUG("bta_ag_co_audio_state: handle %d, state %d", handle, state); |
Matthew Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 69 | switch (state) |
| 70 | { |
Mudumba Ananth | 6afb248 | 2015-03-25 05:20:02 -0700 | [diff] [blame] | 71 | case SCO_STATE_OFF: |
Matthew Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 72 | #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 Pawlowski | 713993d | 2016-04-21 13:16:45 -0700 | [diff] [blame^] | 75 | set_audio_state(handle, (sco_codec_t) codec, (sco_state_t) state); |
Matthew Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 76 | #else |
| 77 | BTIF_TRACE_DEBUG("bta_ag_co_audio_state(handle %d)::Closed (OFF)", |
| 78 | handle); |
| 79 | #endif |
| 80 | break; |
Mudumba Ananth | 6afb248 | 2015-03-25 05:20:02 -0700 | [diff] [blame] | 81 | case SCO_STATE_OFF_TRANSFER: |
Matthew Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 82 | BTIF_TRACE_DEBUG("bta_ag_co_audio_state(handle %d)::Closed (XFERRING)", handle); |
| 83 | break; |
Mudumba Ananth | 6afb248 | 2015-03-25 05:20:02 -0700 | [diff] [blame] | 84 | case SCO_STATE_SETUP: |
Matthew Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 85 | #if (BTM_WBS_INCLUDED == TRUE ) |
Jakub Pawlowski | 713993d | 2016-04-21 13:16:45 -0700 | [diff] [blame^] | 86 | set_audio_state(handle, (sco_codec_t) codec, (sco_state_t) state); |
Matthew Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 87 | #else |
Jakub Pawlowski | 713993d | 2016-04-21 13:16:45 -0700 | [diff] [blame^] | 88 | set_audio_state(handle, (sco_codec_t) BTA_AG_CODEC_CVSD, (sco_state_t) state); |
Matthew Xie | 66432dc | 2014-04-27 05:45:32 -0700 | [diff] [blame] | 89 | #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 Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 101 | } |
| 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 | *******************************************************************************/ |
| 117 | void bta_ag_co_data_open(UINT16 handle, tBTA_SERVICE_ID service) |
| 118 | { |
Sharvil Nanavati | e8c3d75 | 2014-05-04 10:12:26 -0700 | [diff] [blame] | 119 | BTIF_TRACE_DEBUG("bta_ag_co_data_open handle:%d service:%d", handle, service); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 120 | } |
| 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 | *******************************************************************************/ |
| 133 | void bta_ag_co_data_close(UINT16 handle) |
| 134 | { |
Sharvil Nanavati | e8c3d75 | 2014-05-04 10:12:26 -0700 | [diff] [blame] | 135 | BTIF_TRACE_DEBUG("bta_ag_co_data_close handle:%d", handle); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 136 | } |
| 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 Ananth | 6afb248 | 2015-03-25 05:20:02 -0700 | [diff] [blame] | 151 | void bta_ag_co_tx_write(UINT16 handle, UNUSED_ATTR UINT8 * p_data, UINT16 len) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 152 | { |
Sharvil Nanavati | e8c3d75 | 2014-05-04 10:12:26 -0700 | [diff] [blame] | 153 | BTIF_TRACE_DEBUG( "bta_ag_co_tx_write: handle: %d, len: %d", handle, len ); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 154 | } |