#if (BTM_WBS_INCLUDED == TRUE )
/* Allow any platform specific pre-SCO set up to take place */
- bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, BTA_AG_CO_AUD_STATE_SETUP,\
- esco_codec);
+ bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, SCO_STATE_SETUP,
+ esco_codec);
/* This setting may not be necessary */
/* To be verified with stable 2049 boards */
p_scb->inuse_codec = esco_codec;
#else
/* Allow any platform specific pre-SCO set up to take place */
- bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, BTA_AG_CO_AUD_STATE_SETUP);
+ bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, SCO_STATE_SETUP);
#endif
#if (BTM_SCO_HCI_INCLUDED == TRUE )
bta_sys_sco_open(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);
#if (BTM_WBS_INCLUDED == TRUE)
- bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, BTA_AG_CO_AUD_STATE_ON,
+ bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, SCO_STATE_ON,
p_scb->inuse_codec);
#else
- bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, BTA_AG_CO_AUD_STATE_ON);
+ bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, SCO_STATE_ON);
#endif
#if (BTM_SCO_HCI_INCLUDED == TRUE )
#endif
else
{
+ sco_state_t sco_state = bta_ag_cb.sco.p_xfer_scb ? SCO_STATE_OFF_TRANSFER : SCO_STATE_OFF;
#if (BTM_WBS_INCLUDED == TRUE)
/* Indicate if the closing of audio is because of transfer */
- bta_ag_co_audio_state(handle, p_scb->app_id,(bta_ag_cb.sco.p_xfer_scb)?\
- BTA_AG_CO_AUD_STATE_OFF_XFER:BTA_AG_CO_AUD_STATE_OFF,p_scb->inuse_codec);
+ bta_ag_co_audio_state(handle, p_scb->app_id, sco_state, p_scb->inuse_codec);
#else
/* Indicate if the closing of audio is because of transfer */
- bta_ag_co_audio_state(handle, p_scb->app_id,(bta_ag_cb.sco.p_xfer_scb)?\
- BTA_AG_CO_AUD_STATE_OFF_XFER:BTA_AG_CO_AUD_STATE_OFF);
+ bta_ag_co_audio_state(handle, p_scb->app_id, sco_state);
#endif
bta_ag_sco_event(p_scb, BTA_AG_SCO_CONN_CLOSE_E);
#if (BTM_WBS_INCLUDED == FALSE )
/* Allow any platform specific pre-SCO set up to take place */
- bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, BTA_AG_CO_AUD_STATE_SETUP);
+ bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, SCO_STATE_SETUP);
#else
/* When HS initiated SCO, it cannot be WBS. */
/* Allow any platform specific pre-SCO set up to take place */
- bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, BTA_AG_CO_AUD_STATE_SETUP,
+ bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, SCO_STATE_SETUP,
BTA_AG_CODEC_CVSD);
#endif
typedef UINT16 tBTA_AG_PEER_FEAT;
/* HFP peer supported codec masks */
+// TODO(google) This should use common definitions
+// in hci/include/hci_audio.h
#define BTA_AG_CODEC_NONE BTM_SCO_CODEC_NONE
#define BTA_AG_CODEC_CVSD BTM_SCO_CODEC_CVSD /* CVSD */
#define BTA_AG_CODEC_MSBC BTM_SCO_CODEC_MSBC /* mSBC */
#define BTA_AG_CO_H
#include "bta_ag_api.h"
-
-/* Definitions for audio state callout function "state" parameter */
-#define BTA_AG_CO_AUD_STATE_OFF 0
-#define BTA_AG_CO_AUD_STATE_OFF_XFER 1 /* Closed pending transfer of audio */
-#define BTA_AG_CO_AUD_STATE_ON 2
-#define BTA_AG_CO_AUD_STATE_SETUP 3
+#include "hci/include/hci_audio.h"
/*******************************************************************************
**
**
** Parameters handle - handle of the AG instance
** state - Audio state
-** BTA_AG_CO_AUD_STATE_OFF - Audio has been turned off
-** BTA_AG_CO_AUD_STATE_OFF_XFER - Audio is closed pending transfer
-** BTA_AG_CO_AUD_STATE_ON - Audio has been turned on
-** BTA_AG_CO_AUD_STATE_SETUP - Audio is about to be turned on
** codec - if WBS support is compiled in, codec to going to be used is provided
-** and when in BTA_AG_CO_AUD_STATE_SETUP, BTM_I2SPCMConfig() must be called with
+** and when in SCO_STATE_SETUP, BTM_I2SPCMConfig() must be called with
** the correct platform parameters.
** in the other states codec type should not be ignored
**
#define LOG_TAG "bt_btif_bta_ag"
-#include "gki.h"
-#include "bta_api.h"
-#include "bta_sys.h"
-#include "bta_ag_api.h"
-#include "bta_ag_co.h"
-#include "bt_utils.h"
-
-#ifndef LINUX_NATIVE
#include <cutils/properties.h>
-#else
-#include <stdio.h>
-#define LOGI(format, ...) fprintf (stdout, LOG_TAG format"\n", ## __VA_ARGS__)
-#define LOGD(format, ...) fprintf (stdout, LOG_TAG format"\n", ## __VA_ARGS__)
-#define LOGV(format, ...) fprintf (stdout, LOG_TAG format"\n", ## __VA_ARGS__)
-#define LOGE(format, ...) fprintf (stderr, LOG_TAG format"\n", ## __VA_ARGS__)
-#endif
-
-/************************************************************************************
-** Externs
-************************************************************************************/
-extern int set_audio_state(UINT16 handle, UINT16 codec, UINT8 state, void *param);
+#include "hci/include/hci_audio.h"
+#include "osi/include/osi.h"
/*******************************************************************************
**
**
** Parameters handle - handle of the AG instance
** state - Audio state
-** BTA_AG_CO_AUD_STATE_OFF - Audio has been turned off
-** BTA_AG_CO_AUD_STATE_OFF_XFER - Audio has been turned off (xfer)
-** BTA_AG_CO_AUD_STATE_ON - Audio has been turned on
-** BTA_AG_CO_AUD_STATE_SETUP - Audio is about to be turned on
** codec - if WBS support is compiled in, codec to going to be used is provided
-** and when in BTA_AG_CO_AUD_STATE_SETUP, BTM_I2SPCMConfig() must be called with
+** and when in SCO_STATE_SETUP, BTM_I2SPCMConfig() must be called with
** the correct platform parameters.
** in the other states codec type should not be ignored
**
BTIF_TRACE_DEBUG("bta_ag_co_audio_state: handle %d, state %d", handle, state);
switch (state)
{
- case BTA_AG_CO_AUD_STATE_OFF:
+ case SCO_STATE_OFF:
#if (BTM_WBS_INCLUDED == TRUE )
BTIF_TRACE_DEBUG("bta_ag_co_audio_state(handle %d)::Closed (OFF), codec: 0x%x",
handle, codec);
- set_audio_state(handle, codec, state, NULL);
+ set_audio_state(handle, codec, state);
#else
BTIF_TRACE_DEBUG("bta_ag_co_audio_state(handle %d)::Closed (OFF)",
handle);
#endif
break;
- case BTA_AG_CO_AUD_STATE_OFF_XFER:
+ case SCO_STATE_OFF_TRANSFER:
BTIF_TRACE_DEBUG("bta_ag_co_audio_state(handle %d)::Closed (XFERRING)", handle);
break;
- case BTA_AG_CO_AUD_STATE_SETUP:
+ case SCO_STATE_SETUP:
#if (BTM_WBS_INCLUDED == TRUE )
- set_audio_state(handle, codec, state, NULL);
+ set_audio_state(handle, codec, state);
#else
- set_audio_state(handle, BTA_AG_CODEC_CVSD, state, NULL);
+ set_audio_state(handle, BTA_AG_CODEC_CVSD, state);
#endif
break;
default:
** Returns void
**
*******************************************************************************/
-void bta_ag_co_tx_write(UINT16 handle, UINT8 * p_data, UINT16 len)
+void bta_ag_co_tx_write(UINT16 handle, UNUSED_ATTR UINT8 * p_data, UINT16 len)
{
- UNUSED(p_data);
BTIF_TRACE_DEBUG( "bta_ag_co_tx_write: handle: %d, len: %d", handle, len );
}
-
src/btsnoop.c \
src/btsnoop_net.c \
src/buffer_allocator.c \
+ src/hci_audio.c \
src/hci_hal.c \
src/hci_hal_h4.c \
src/hci_hal_mct.c \
HC_EVENT_LPM_IDLE_TIMEOUT,
} bthc_event_t;
-#define MSG_CTRL_TO_HC_CMD 0x0100 /* evt mask used by HC_EVENT_TX_CMD */
-
/* Message event mask across Host/Controller lib and stack */
#define MSG_EVT_MASK 0xFF00 /* eq. BT_EVT_MASK */
#define MSG_SUB_EVT_MASK 0x00FF /* eq. BT_SUB_EVT_MASK */
/* Local Bluetooth Controller ID for BR/EDR */
#define LOCAL_BR_EDR_CONTROLLER_ID 0
-/* Definitions of audio codec type
- * inherited from AG callout function "codec" parameter
- */
-#define SCO_CODEC_NONE 0x0000 /* BTA_AG_CODEC_NONE/BTM_SCO_CODEC_NONE */
-#define SCO_CODEC_CVSD 0x0001 /* BTA_AG_CODEC_CVSD/BTM_SCO_CODEC_CVSD */
-#define SCO_CODEC_MSBC 0x0002 /* BTA_AG_CODEC_MSBC/BTM_SCO_CODEC_MSBC */
-
/******************************************************************************
** Type definitions and return values
******************************************************************************/
BT_HC_LOGGING_ON,
} bt_hc_logging_state_t;
-/* commands to be used in LSB with MSG_CTRL_TO_HC_CMD */
-typedef enum {
- BT_HC_AUDIO_STATE = 0,
- BT_HC_CMD_MAX
-} bt_hc_tx_cmd_t;
/** Result of write request */
typedef enum {
BT_HC_TX_SUCCESS, /* a buffer is fully processed and can be released */
--- /dev/null
+/******************************************************************************
+ *
+ * Copyright (C) 2015 Google, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#pragma once
+
+#include "bta/include/bta_ag_api.h"
+
+// Audio state definitions.
+typedef enum {
+ SCO_STATE_OFF = 0, // Audio is off.
+ SCO_STATE_OFF_TRANSFER, // Closed pending final transfer of audio.
+ SCO_STATE_ON, // Audio is on.
+ SCO_STATE_SETUP, // Open pending completion of audio setup.
+} sco_state_t;
+
+// Codec type definitions.
+typedef enum {
+ SCO_CODEC_NONE = 0x0000,
+ SCO_CODEC_CVSD = 0x0001,
+ SCO_CODEC_MSBC = 0x0002,
+} sco_codec_t;
+
+// Set the audio state on the controller for SCO (PCM, WBS, ...) using the
+// vendor library.
+void set_audio_state(uint16_t handle, sco_codec_t codec, sco_state_t state);
VENDOR_OPEN_USERIAL = BT_VND_OP_USERIAL_OPEN,
VENDOR_CLOSE_USERIAL = BT_VND_OP_USERIAL_CLOSE,
VENDOR_GET_LPM_IDLE_TIMEOUT = BT_VND_OP_GET_LPM_IDLE_TIMEOUT,
- VENDOR_SET_LPM_WAKE_STATE = BT_VND_OP_LPM_WAKE_SET_STATE
+ VENDOR_SET_LPM_WAKE_STATE = BT_VND_OP_LPM_WAKE_SET_STATE,
+ VENDOR_SET_AUDIO_STATE = BT_VND_OP_SET_AUDIO_STATE
} vendor_opcode_t;
typedef enum {
--- /dev/null
+/******************************************************************************
+ *
+ * Copyright (C) 2015 Google, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#define LOG_TAG "hci_audio"
+
+#include <stdint.h>
+
+#include "hci/include/bt_vendor_lib.h"
+#include "hci/include/hci_audio.h"
+#include "hci/include/vendor.h"
+#include "osi/include/log.h"
+
+void set_audio_state(uint16_t handle, sco_codec_t codec, sco_state_t state)
+{
+ LOG_INFO("%s handle:%d codec:0x%x state:%d", __func__, handle, codec, state);
+
+ bt_vendor_op_audio_state_t audio_state;
+
+ audio_state.handle = handle;
+ audio_state.peer_codec = codec;
+ audio_state.state = state;
+
+ vendor_get_interface()->send_command(VENDOR_SET_AUDIO_STATE, &audio_state);
+}
}
#endif // HCILP_INCLUDED
-
-/* NOTICE:
- * Definitions for audio state structure, this type needs to match to
- * the bt_vendor_op_audio_state_t type defined in bt_vendor_lib.h
- */
-typedef struct {
- UINT16 handle;
- UINT16 peer_codec;
- UINT16 state;
-} bt_hc_audio_state_t;
-
-struct bt_audio_state_tag {
- BT_HDR hdr;
- bt_hc_audio_state_t audio;
-};
-
-/******************************************************************************
-**
-** Function set_audio_state
-**
-** Description Sets audio state on controller state for SCO (PCM, WBS, FM)
-**
-** Parameters handle: codec related handle for SCO: sco cb idx, unused for
-** codec: BTA_AG_CODEC_MSBC, BTA_AG_CODEC_CSVD or FM codec
-** state: codec state, eg. BTA_AG_CO_AUD_STATE_SETUP
-** param: future extensions, e.g. call-in structure/event.
-**
-** Returns None
-**
-******************************************************************************/
-int set_audio_state(UINT16 handle, UINT16 codec, UINT8 state, void *param)
-{
- struct bt_audio_state_tag *p_msg;
- int result = -1;
-
- APPL_TRACE_API("set_audio_state(handle: %d, codec: 0x%x, state: %d)", handle,
- codec, state);
- if (NULL != param)
- APPL_TRACE_WARNING("set_audio_state() non-null param not supported");
- p_msg = (struct bt_audio_state_tag *)GKI_getbuf(sizeof(*p_msg));
- if (!p_msg)
- return result;
- p_msg->audio.handle = handle;
- p_msg->audio.peer_codec = codec;
- p_msg->audio.state = state;
-
- p_msg->hdr.event = MSG_CTRL_TO_HC_CMD | (MSG_SUB_EVT_MASK & BT_HC_AUDIO_STATE);
- p_msg->hdr.len = sizeof(p_msg->audio);
- p_msg->hdr.offset = 0;
- /* layer_specific shall contain return path event! for BTA events!
- * 0 means no return message is expected. */
- p_msg->hdr.layer_specific = 0;
- hci->transmit_downward(MSG_STACK_TO_HC_HCI_CMD, p_msg);
- return result;
-}
-
-
/******************************************************************************
**
** Function bte_main_hci_send
/*******************
** SCO Codec Types
********************/
+// TODO(google) This should use common definitions
+// in hci/include/hci_audio.h
#define BTM_SCO_CODEC_NONE 0x0000
#define BTM_SCO_CODEC_CVSD 0x0001
#define BTM_SCO_CODEC_MSBC 0x0002