summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbtif/co/bta_hl_co.c892
-rwxr-xr-x[-rw-r--r--]btif/include/btif_av.h11
-rwxr-xr-x[-rw-r--r--]btif/include/btif_common.h1
-rw-r--r--[-rwxr-xr-x]btif/src/bluetooth.c0
-rw-r--r--btif/src/btif_av.c59
-rw-r--r--[-rwxr-xr-x]btif/src/btif_core.c26
-rw-r--r--[-rwxr-xr-x]btif/src/btif_dm.c0
-rw-r--r--[-rwxr-xr-x]btif/src/btif_hh.c0
-rw-r--r--[-rwxr-xr-x]btif/src/btif_hl.c0
-rwxr-xr-x[-rw-r--r--]btif/src/btif_media_task.c19
10 files changed, 543 insertions, 465 deletions
diff --git a/btif/co/bta_hl_co.c b/btif/co/bta_hl_co.c
index 9ef5834..c851807 100755
--- a/btif/co/bta_hl_co.c
+++ b/btif/co/bta_hl_co.c
@@ -1,446 +1,446 @@
-/*****************************************************************************
-**
-** Name: bta_hl_co.c
-**
-** Description: This is the implementation file for the HeaLth device profile
-** (HL) subsystem call-out functions.
-**
-** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
-** Broadcom Bluetooth Core. Proprietary and confidential.
-**
-*****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <time.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <cutils/sockets.h>
-#include <cutils/log.h>
-#include "bta_api.h"
-#include "btm_api.h"
-#include "bta_sys.h"
-#include "bta_hl_api.h"
-#include "bta_hl_co.h"
-#include "bta_hl_ci.h"
-#include "btif_hl.h"
-
-
-
-/*****************************************************************************
-** Constants and Data Types
-*****************************************************************************/
-/**************************
-** Common Definitions
-***************************/
-
-
-
-
-/*******************************************************************************
-**
-** Function bta_hl_co_get_num_of_mdep
-**
-** Description This function is called to get the number of MDEPs for this
-** application ID
-**
-** Parameters app_id - application ID
-** p_num_of_mdep (output) - number of MDEP configurations supported
-** by the application
-**
-** Returns Bloolean - TRUE success
-**
-*******************************************************************************/
-BOOLEAN bta_hl_co_get_num_of_mdep(UINT8 app_id, UINT8 *p_num_of_mdep)
-{
- UINT8 app_idx;
- BOOLEAN success = FALSE;
-
- if (btif_hl_find_app_idx(app_id, &app_idx))
- {
- *p_num_of_mdep = p_btif_hl_cb->acb[app_idx].sup_feature.num_of_mdeps;
- success = TRUE;
- }
-
-
- BTIF_TRACE_DEBUG3("%s success=%d num_mdeps=%d",
- __FUNCTION__, success, *p_num_of_mdep );
- return success;
-}
-
-/*******************************************************************************
-**
-** Function bta_hl_co_advrtise_source_sdp
-**
-** Description This function is called to find out whether the SOURCE MDEP
-** configuration information should be advertize in the SDP or nopt
-**
-** Parameters app_id - application ID
-**
-** Returns Bloolean - TRUE advertise the SOURCE MDEP configuration
-** information
-**
-*******************************************************************************/
-BOOLEAN bta_hl_co_advrtise_source_sdp(UINT8 app_id)
-{
- BOOLEAN advertize_source_sdp=FALSE;
- UINT8 app_idx;
-
- if (btif_hl_find_app_idx(app_id, &app_idx))
- {
- advertize_source_sdp = p_btif_hl_cb->acb[app_idx].sup_feature.advertize_source_sdp;
- }
-
-
- BTIF_TRACE_DEBUG2("%s advertize_flag=%d", __FUNCTION__, advertize_source_sdp );
-
- return advertize_source_sdp;
-}
-/*******************************************************************************
-**
-** Function bta_hl_co_get_mdep_config
-**
-** Description This function is called to get the supported feature
-** configuration for the specified mdep index and it also assigns
-** the MDEP ID for the specified mdep index
-**
-** Parameters app_id - HDP application ID
-** mdep_idx - the mdep index
-** mdep_id - the assigned MDEP ID for the specified medp_idx
-** p_mdl_cfg (output) - pointer to the MDEP configuration
-**
-**
-** Returns Bloolean - TRUE success
-*******************************************************************************/
-BOOLEAN bta_hl_co_get_mdep_config(UINT8 app_id,
- UINT8 mdep_idx,
- tBTA_HL_MDEP_ID mdep_id,
- tBTA_HL_MDEP_CFG *p_mdep_cfg)
-{
- UINT8 idx ;
- UINT8 app_idx;
- BOOLEAN success = FALSE;
-
- BTIF_TRACE_DEBUG4("%s app_id=%d mdep_idx=%d mdep_id=%d",
- __FUNCTION__, app_id,mdep_idx,mdep_id );
-
- if (btif_hl_find_app_idx(app_id, &app_idx))
- {
- idx = mdep_idx -1;
- p_btif_hl_cb->acb[app_idx].sup_feature.mdep[idx].mdep_id = mdep_id;
- memcpy(p_mdep_cfg,
- &p_btif_hl_cb->acb[app_idx].sup_feature.mdep[idx].mdep_cfg,
- sizeof(tBTA_HL_MDEP_CFG));
-
- success = TRUE;
- }
-
- BTIF_TRACE_DEBUG4("%s success=%d mdep_idx=%d mdep_id=%d",
- __FUNCTION__, success, mdep_idx, mdep_id );
-
- return success;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_hl_co_get_echo_config
-**
-** Description This function is called to get the echo test
-** maximum APDU size configurations
-**
-** Parameters app_id - HDP application ID
-** p_echo_cfg (output) - pointer to the Echo test maximum APDU size
-** configuration
-**
-** Returns Bloolean - TRUE success
-*******************************************************************************/
-BOOLEAN bta_hl_co_get_echo_config(UINT8 app_id,
- tBTA_HL_ECHO_CFG *p_echo_cfg)
-{
- UINT8 app_idx;
- BOOLEAN success = FALSE;
- btif_hl_app_cb_t *p_acb;
- tBTA_HL_SUP_FEATURE *p_sup;
-
- BTIF_TRACE_DEBUG2("%s app_id=%d",__FUNCTION__, app_id );
-
- if (btif_hl_find_app_idx(app_id, &app_idx))
- {
- p_acb = BTIF_HL_GET_APP_CB_PTR(app_idx);
- p_sup = &p_acb->sup_feature;
- p_echo_cfg->max_rx_apdu_size = p_sup->echo_cfg.max_rx_apdu_size;
- p_echo_cfg->max_tx_apdu_size = p_sup->echo_cfg.max_tx_apdu_size;
- success = TRUE;
- }
-
- BTIF_TRACE_DEBUG4("%s success=%d max tx_size=%d rx_size=%d",
- __FUNCTION__, success, p_echo_cfg->max_tx_apdu_size,
- p_echo_cfg->max_rx_apdu_size );
-
- return success;
-}
-
-
-/*******************************************************************************
-**
-** Function bta_hl_co_save_mdl
-**
-** Description This function is called to save a MDL configuration item in persistent
-** storage
-**
-** Parameters app_id - HDP application ID
-** item_idx - the MDL configuration storage index
-** p_mdl_cfg - pointer to the MDL configuration data
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hl_co_save_mdl(UINT8 app_id, UINT8 item_idx, tBTA_HL_MDL_CFG *p_mdl_cfg )
-{
-
- BTIF_TRACE_DEBUG6("%s app_id=%d, item_idx=%d active=%d mdl_id=%d time=%d",
- __FUNCTION__, app_id, item_idx,
- p_mdl_cfg->active,
- p_mdl_cfg->mdl_id,
- p_mdl_cfg->time);
-
-
- btif_hl_save_mdl_cfg(app_id, item_idx, p_mdl_cfg);
-
-}
-
-/*******************************************************************************
-**
-** Function bta_hl_co_delete_mdl
-**
-** Description This function is called to delete a MDL configuration item in persistent
-** storage
-**
-** Parameters app_id - HDP application ID
-** item_idx - the MDL configuration storage index
-**
-** Returns void
-**
-*******************************************************************************/
-void bta_hl_co_delete_mdl(UINT8 app_id, UINT8 item_idx)
-{
-
-
- BTIF_TRACE_DEBUG3("%s app_id=%d, item_idx=%d", __FUNCTION__, app_id, item_idx);
-
- btif_hl_delete_mdl_cfg(app_id, item_idx);
-
-
-}
-
-/*******************************************************************************
-**
-** Function bta_hl_co_get_mdl_config
-**
-** Description This function is called to get the MDL configuration
-** from the persistent memory. This function shall only be called
-*8 once after the device is powered up
-**
-** Parameters app_id - HDP application ID
-** buffer_size - the unit of the buffer size is sizeof(tBTA_HL_MDL_CFG)
-** p_mdl_buf - Point to the starting location of the buffer
-**
-** Returns BOOLEAN
-**
-**
-*******************************************************************************/
-BOOLEAN bta_hl_co_load_mdl_config (UINT8 app_id, UINT8 buffer_size,
- tBTA_HL_MDL_CFG *p_mdl_buf )
-{
- tBTA_HL_MDL_CFG *p;
- BOOLEAN success = TRUE;
- UINT8 i;
-
-
- BTIF_TRACE_DEBUG3("%s app_id=%d, buffer_size=%d",
- __FUNCTION__, app_id, buffer_size);
-
-
- if (buffer_size > BTA_HL_NUM_MDL_CFGS)
- {
- success= FALSE;
- return success;
- }
-
- p = p_mdl_buf;
-
- for (i=0; i < buffer_size; i++, p++)
- {
- memset(p, 0, sizeof(tBTA_HL_MDL_CFG));
- /* todo load from NV */
- }
-
-
- BTIF_TRACE_DEBUG3("%s success=%d num_items=%d",
- __FUNCTION__, success, buffer_size);
-
-
- return success;
-}
-
-/*******************************************************************************
-**
-** Function bta_hl_co_get_tx_data
-**
-** Description Get the data to be sent
-**
-** Parameters app_id - HDP application ID
-** mdl_handle - MDL handle
-** buf_size - the size of the buffer
-** p_buf - the buffer pointer
-** evt - the evt to be passed back to the HL in the
-** bta_hl_ci_get_tx_data call-in function
-**
-** Returns Void
-**
-*******************************************************************************/
-void bta_hl_co_get_tx_data (UINT8 app_id, tBTA_HL_MDL_HANDLE mdl_handle,
- UINT16 buf_size, UINT8 *p_buf, UINT16 evt)
-{
- UINT8 app_idx, mcl_idx, mdl_idx;
- btif_hl_mdl_cb_t *p_dcb;
- tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL;
-
- BTIF_TRACE_DEBUG4("%s app_id=%d mdl_handle=0x%x buf_size=%d",
- __FUNCTION__, app_id, mdl_handle, buf_size);
-
- if (btif_hl_find_mdl_idx_using_handle(mdl_handle, &app_idx, &mcl_idx, &mdl_idx))
- {
- p_dcb = BTIF_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
-
- if (p_dcb->tx_size <= buf_size )
- {
- memcpy(p_buf, p_dcb->p_tx_pkt, p_dcb->tx_size);
- btif_hl_free_buf((void **) &p_dcb->p_tx_pkt);
- p_dcb->tx_size = 0;
- status = BTA_HL_STATUS_OK;
- }
- }
-
-
- bta_hl_ci_get_tx_data(mdl_handle, status, evt);
-
-}
-
-
-/*******************************************************************************
-**
-** Function bta_hl_co_put_rx_data
-**
-** Description Put the received data
-**
-** Parameters app_id - HDP application ID
-** mdl_handle - MDL handle
-** data_size - the size of the data
-** p_data - the data pointer
-** evt - the evt to be passed back to the HL in the
-** bta_hl_ci_put_rx_data call-in function
-**
-** Returns Void
-**
-*******************************************************************************/
-void bta_hl_co_put_rx_data (UINT8 app_id, tBTA_HL_MDL_HANDLE mdl_handle,
- UINT16 data_size, UINT8 *p_data, UINT16 evt)
-{
- UINT8 app_idx, mcl_idx, mdl_idx;
- btif_hl_mdl_cb_t *p_dcb;
- tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL;
- int r;
- BTIF_TRACE_DEBUG4("%s app_id=%d mdl_handle=0x%x data_size=%d",
- __FUNCTION__,app_id, mdl_handle, data_size);
-
- if (btif_hl_find_mdl_idx_using_handle(mdl_handle, &app_idx, &mcl_idx, &mdl_idx))
- {
- p_dcb = BTIF_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
-
- if ((p_dcb->p_rx_pkt = (UINT8 *)btif_hl_get_buf(data_size)) != NULL)
- {
- memcpy(p_dcb->p_rx_pkt, p_data, data_size);
- if (p_dcb->p_scb)
- {
- BTIF_TRACE_DEBUG4("app_idx=%d mcl_idx=0x%x mdl_idx=0x%x data_size=%d",
- app_idx, mcl_idx, mdl_idx, data_size);
- r = send(p_dcb->p_scb->socket_id[1], p_dcb->p_rx_pkt, data_size, 0);
-
- if (r == data_size)
- {
- BTIF_TRACE_DEBUG1("socket send success data_size=%d", data_size);
- status = BTA_HL_STATUS_OK;
- }
- else
- {
- BTIF_TRACE_ERROR2("socket send failed r=%d data_size=%d",r, data_size);
- }
-
-
- }
- btif_hl_free_buf((void **) &p_dcb->p_rx_pkt);
- }
- }
-
- bta_hl_ci_put_rx_data(mdl_handle, status, evt);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_hl_co_get_tx_data
-**
-** Description Get the Echo data to be sent
-**
-** Parameters app_id - HDP application ID
-** mcl_handle - MCL handle
-** buf_size - the size of the buffer
-** p_buf - the buffer pointer
-** evt - the evt to be passed back to the HL in the
-** bta_hl_ci_get_tx_data call-in function
-**
-** Returns Void
-**
-*******************************************************************************/
-void bta_hl_co_get_echo_data (UINT8 app_id, tBTA_HL_MCL_HANDLE mcl_handle,
- UINT16 buf_size, UINT8 *p_buf, UINT16 evt)
-{
- tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL;
-
- BTIF_TRACE_ERROR1("%s not supported",__FUNCTION__);
- bta_hl_ci_get_echo_data(mcl_handle, status, evt);
-}
-
-
-/*******************************************************************************
-**
-** Function bta_hl_co_put_echo_data
-**
-** Description Put the received loopback echo data
-**
-** Parameters app_id - HDP application ID
-** mcl_handle - MCL handle
-** data_size - the size of the data
-** p_data - the data pointer
-** evt - the evt to be passed back to the HL in the
-** bta_hl_ci_put_echo_data call-in function
-**
-** Returns Void
-**
-*******************************************************************************/
-void bta_hl_co_put_echo_data (UINT8 app_id, tBTA_HL_MCL_HANDLE mcl_handle,
- UINT16 data_size, UINT8 *p_data, UINT16 evt)
-{
- tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL;
-
- BTIF_TRACE_ERROR1("%s not supported",__FUNCTION__);
- bta_hl_ci_put_echo_data(mcl_handle, status, evt);
-}
-
+/*****************************************************************************
+**
+** Name: bta_hl_co.c
+**
+** Description: This is the implementation file for the HeaLth device profile
+** (HL) subsystem call-out functions.
+**
+** Copyright (c) 2009, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+*****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <time.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <cutils/sockets.h>
+#include <cutils/log.h>
+#include "bta_api.h"
+#include "btm_api.h"
+#include "bta_sys.h"
+#include "bta_hl_api.h"
+#include "bta_hl_co.h"
+#include "bta_hl_ci.h"
+#include "btif_hl.h"
+
+
+
+/*****************************************************************************
+** Constants and Data Types
+*****************************************************************************/
+/**************************
+** Common Definitions
+***************************/
+
+
+
+
+/*******************************************************************************
+**
+** Function bta_hl_co_get_num_of_mdep
+**
+** Description This function is called to get the number of MDEPs for this
+** application ID
+**
+** Parameters app_id - application ID
+** p_num_of_mdep (output) - number of MDEP configurations supported
+** by the application
+**
+** Returns Bloolean - TRUE success
+**
+*******************************************************************************/
+BOOLEAN bta_hl_co_get_num_of_mdep(UINT8 app_id, UINT8 *p_num_of_mdep)
+{
+ UINT8 app_idx;
+ BOOLEAN success = FALSE;
+
+ if (btif_hl_find_app_idx(app_id, &app_idx))
+ {
+ *p_num_of_mdep = p_btif_hl_cb->acb[app_idx].sup_feature.num_of_mdeps;
+ success = TRUE;
+ }
+
+
+ BTIF_TRACE_DEBUG3("%s success=%d num_mdeps=%d",
+ __FUNCTION__, success, *p_num_of_mdep );
+ return success;
+}
+
+/*******************************************************************************
+**
+** Function bta_hl_co_advrtise_source_sdp
+**
+** Description This function is called to find out whether the SOURCE MDEP
+** configuration information should be advertize in the SDP or nopt
+**
+** Parameters app_id - application ID
+**
+** Returns Bloolean - TRUE advertise the SOURCE MDEP configuration
+** information
+**
+*******************************************************************************/
+BOOLEAN bta_hl_co_advrtise_source_sdp(UINT8 app_id)
+{
+ BOOLEAN advertize_source_sdp=FALSE;
+ UINT8 app_idx;
+
+ if (btif_hl_find_app_idx(app_id, &app_idx))
+ {
+ advertize_source_sdp = p_btif_hl_cb->acb[app_idx].sup_feature.advertize_source_sdp;
+ }
+
+
+ BTIF_TRACE_DEBUG2("%s advertize_flag=%d", __FUNCTION__, advertize_source_sdp );
+
+ return advertize_source_sdp;
+}
+/*******************************************************************************
+**
+** Function bta_hl_co_get_mdep_config
+**
+** Description This function is called to get the supported feature
+** configuration for the specified mdep index and it also assigns
+** the MDEP ID for the specified mdep index
+**
+** Parameters app_id - HDP application ID
+** mdep_idx - the mdep index
+** mdep_id - the assigned MDEP ID for the specified medp_idx
+** p_mdl_cfg (output) - pointer to the MDEP configuration
+**
+**
+** Returns Bloolean - TRUE success
+*******************************************************************************/
+BOOLEAN bta_hl_co_get_mdep_config(UINT8 app_id,
+ UINT8 mdep_idx,
+ tBTA_HL_MDEP_ID mdep_id,
+ tBTA_HL_MDEP_CFG *p_mdep_cfg)
+{
+ UINT8 idx ;
+ UINT8 app_idx;
+ BOOLEAN success = FALSE;
+
+ BTIF_TRACE_DEBUG4("%s app_id=%d mdep_idx=%d mdep_id=%d",
+ __FUNCTION__, app_id,mdep_idx,mdep_id );
+
+ if (btif_hl_find_app_idx(app_id, &app_idx))
+ {
+ idx = mdep_idx -1;
+ p_btif_hl_cb->acb[app_idx].sup_feature.mdep[idx].mdep_id = mdep_id;
+ memcpy(p_mdep_cfg,
+ &p_btif_hl_cb->acb[app_idx].sup_feature.mdep[idx].mdep_cfg,
+ sizeof(tBTA_HL_MDEP_CFG));
+
+ success = TRUE;
+ }
+
+ BTIF_TRACE_DEBUG4("%s success=%d mdep_idx=%d mdep_id=%d",
+ __FUNCTION__, success, mdep_idx, mdep_id );
+
+ return success;
+}
+
+
+/*******************************************************************************
+**
+** Function bta_hl_co_get_echo_config
+**
+** Description This function is called to get the echo test
+** maximum APDU size configurations
+**
+** Parameters app_id - HDP application ID
+** p_echo_cfg (output) - pointer to the Echo test maximum APDU size
+** configuration
+**
+** Returns Bloolean - TRUE success
+*******************************************************************************/
+BOOLEAN bta_hl_co_get_echo_config(UINT8 app_id,
+ tBTA_HL_ECHO_CFG *p_echo_cfg)
+{
+ UINT8 app_idx;
+ BOOLEAN success = FALSE;
+ btif_hl_app_cb_t *p_acb;
+ tBTA_HL_SUP_FEATURE *p_sup;
+
+ BTIF_TRACE_DEBUG2("%s app_id=%d",__FUNCTION__, app_id );
+
+ if (btif_hl_find_app_idx(app_id, &app_idx))
+ {
+ p_acb = BTIF_HL_GET_APP_CB_PTR(app_idx);
+ p_sup = &p_acb->sup_feature;
+ p_echo_cfg->max_rx_apdu_size = p_sup->echo_cfg.max_rx_apdu_size;
+ p_echo_cfg->max_tx_apdu_size = p_sup->echo_cfg.max_tx_apdu_size;
+ success = TRUE;
+ }
+
+ BTIF_TRACE_DEBUG4("%s success=%d max tx_size=%d rx_size=%d",
+ __FUNCTION__, success, p_echo_cfg->max_tx_apdu_size,
+ p_echo_cfg->max_rx_apdu_size );
+
+ return success;
+}
+
+
+/*******************************************************************************
+**
+** Function bta_hl_co_save_mdl
+**
+** Description This function is called to save a MDL configuration item in persistent
+** storage
+**
+** Parameters app_id - HDP application ID
+** item_idx - the MDL configuration storage index
+** p_mdl_cfg - pointer to the MDL configuration data
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hl_co_save_mdl(UINT8 app_id, UINT8 item_idx, tBTA_HL_MDL_CFG *p_mdl_cfg )
+{
+
+ BTIF_TRACE_DEBUG6("%s app_id=%d, item_idx=%d active=%d mdl_id=%d time=%d",
+ __FUNCTION__, app_id, item_idx,
+ p_mdl_cfg->active,
+ p_mdl_cfg->mdl_id,
+ p_mdl_cfg->time);
+
+
+ btif_hl_save_mdl_cfg(app_id, item_idx, p_mdl_cfg);
+
+}
+
+/*******************************************************************************
+**
+** Function bta_hl_co_delete_mdl
+**
+** Description This function is called to delete a MDL configuration item in persistent
+** storage
+**
+** Parameters app_id - HDP application ID
+** item_idx - the MDL configuration storage index
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_hl_co_delete_mdl(UINT8 app_id, UINT8 item_idx)
+{
+
+
+ BTIF_TRACE_DEBUG3("%s app_id=%d, item_idx=%d", __FUNCTION__, app_id, item_idx);
+
+ btif_hl_delete_mdl_cfg(app_id, item_idx);
+
+
+}
+
+/*******************************************************************************
+**
+** Function bta_hl_co_get_mdl_config
+**
+** Description This function is called to get the MDL configuration
+** from the persistent memory. This function shall only be called
+*8 once after the device is powered up
+**
+** Parameters app_id - HDP application ID
+** buffer_size - the unit of the buffer size is sizeof(tBTA_HL_MDL_CFG)
+** p_mdl_buf - Point to the starting location of the buffer
+**
+** Returns BOOLEAN
+**
+**
+*******************************************************************************/
+BOOLEAN bta_hl_co_load_mdl_config (UINT8 app_id, UINT8 buffer_size,
+ tBTA_HL_MDL_CFG *p_mdl_buf )
+{
+ tBTA_HL_MDL_CFG *p;
+ BOOLEAN success = TRUE;
+ UINT8 i;
+
+
+ BTIF_TRACE_DEBUG3("%s app_id=%d, buffer_size=%d",
+ __FUNCTION__, app_id, buffer_size);
+
+
+ if (buffer_size > BTA_HL_NUM_MDL_CFGS)
+ {
+ success= FALSE;
+ return success;
+ }
+
+ p = p_mdl_buf;
+
+ for (i=0; i < buffer_size; i++, p++)
+ {
+ memset(p, 0, sizeof(tBTA_HL_MDL_CFG));
+ /* todo load from NV */
+ }
+
+
+ BTIF_TRACE_DEBUG3("%s success=%d num_items=%d",
+ __FUNCTION__, success, buffer_size);
+
+
+ return success;
+}
+
+/*******************************************************************************
+**
+** Function bta_hl_co_get_tx_data
+**
+** Description Get the data to be sent
+**
+** Parameters app_id - HDP application ID
+** mdl_handle - MDL handle
+** buf_size - the size of the buffer
+** p_buf - the buffer pointer
+** evt - the evt to be passed back to the HL in the
+** bta_hl_ci_get_tx_data call-in function
+**
+** Returns Void
+**
+*******************************************************************************/
+void bta_hl_co_get_tx_data (UINT8 app_id, tBTA_HL_MDL_HANDLE mdl_handle,
+ UINT16 buf_size, UINT8 *p_buf, UINT16 evt)
+{
+ UINT8 app_idx, mcl_idx, mdl_idx;
+ btif_hl_mdl_cb_t *p_dcb;
+ tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL;
+
+ BTIF_TRACE_DEBUG4("%s app_id=%d mdl_handle=0x%x buf_size=%d",
+ __FUNCTION__, app_id, mdl_handle, buf_size);
+
+ if (btif_hl_find_mdl_idx_using_handle(mdl_handle, &app_idx, &mcl_idx, &mdl_idx))
+ {
+ p_dcb = BTIF_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
+
+ if (p_dcb->tx_size <= buf_size )
+ {
+ memcpy(p_buf, p_dcb->p_tx_pkt, p_dcb->tx_size);
+ btif_hl_free_buf((void **) &p_dcb->p_tx_pkt);
+ p_dcb->tx_size = 0;
+ status = BTA_HL_STATUS_OK;
+ }
+ }
+
+
+ bta_hl_ci_get_tx_data(mdl_handle, status, evt);
+
+}
+
+
+/*******************************************************************************
+**
+** Function bta_hl_co_put_rx_data
+**
+** Description Put the received data
+**
+** Parameters app_id - HDP application ID
+** mdl_handle - MDL handle
+** data_size - the size of the data
+** p_data - the data pointer
+** evt - the evt to be passed back to the HL in the
+** bta_hl_ci_put_rx_data call-in function
+**
+** Returns Void
+**
+*******************************************************************************/
+void bta_hl_co_put_rx_data (UINT8 app_id, tBTA_HL_MDL_HANDLE mdl_handle,
+ UINT16 data_size, UINT8 *p_data, UINT16 evt)
+{
+ UINT8 app_idx, mcl_idx, mdl_idx;
+ btif_hl_mdl_cb_t *p_dcb;
+ tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL;
+ int r;
+ BTIF_TRACE_DEBUG4("%s app_id=%d mdl_handle=0x%x data_size=%d",
+ __FUNCTION__,app_id, mdl_handle, data_size);
+
+ if (btif_hl_find_mdl_idx_using_handle(mdl_handle, &app_idx, &mcl_idx, &mdl_idx))
+ {
+ p_dcb = BTIF_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
+
+ if ((p_dcb->p_rx_pkt = (UINT8 *)btif_hl_get_buf(data_size)) != NULL)
+ {
+ memcpy(p_dcb->p_rx_pkt, p_data, data_size);
+ if (p_dcb->p_scb)
+ {
+ BTIF_TRACE_DEBUG4("app_idx=%d mcl_idx=0x%x mdl_idx=0x%x data_size=%d",
+ app_idx, mcl_idx, mdl_idx, data_size);
+ r = send(p_dcb->p_scb->socket_id[1], p_dcb->p_rx_pkt, data_size, 0);
+
+ if (r == data_size)
+ {
+ BTIF_TRACE_DEBUG1("socket send success data_size=%d", data_size);
+ status = BTA_HL_STATUS_OK;
+ }
+ else
+ {
+ BTIF_TRACE_ERROR2("socket send failed r=%d data_size=%d",r, data_size);
+ }
+
+
+ }
+ btif_hl_free_buf((void **) &p_dcb->p_rx_pkt);
+ }
+ }
+
+ bta_hl_ci_put_rx_data(mdl_handle, status, evt);
+}
+
+
+/*******************************************************************************
+**
+** Function bta_hl_co_get_tx_data
+**
+** Description Get the Echo data to be sent
+**
+** Parameters app_id - HDP application ID
+** mcl_handle - MCL handle
+** buf_size - the size of the buffer
+** p_buf - the buffer pointer
+** evt - the evt to be passed back to the HL in the
+** bta_hl_ci_get_tx_data call-in function
+**
+** Returns Void
+**
+*******************************************************************************/
+void bta_hl_co_get_echo_data (UINT8 app_id, tBTA_HL_MCL_HANDLE mcl_handle,
+ UINT16 buf_size, UINT8 *p_buf, UINT16 evt)
+{
+ tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL;
+
+ BTIF_TRACE_ERROR1("%s not supported",__FUNCTION__);
+ bta_hl_ci_get_echo_data(mcl_handle, status, evt);
+}
+
+
+/*******************************************************************************
+**
+** Function bta_hl_co_put_echo_data
+**
+** Description Put the received loopback echo data
+**
+** Parameters app_id - HDP application ID
+** mcl_handle - MCL handle
+** data_size - the size of the data
+** p_data - the data pointer
+** evt - the evt to be passed back to the HL in the
+** bta_hl_ci_put_echo_data call-in function
+**
+** Returns Void
+**
+*******************************************************************************/
+void bta_hl_co_put_echo_data (UINT8 app_id, tBTA_HL_MCL_HANDLE mcl_handle,
+ UINT16 data_size, UINT8 *p_data, UINT16 evt)
+{
+ tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL;
+
+ BTIF_TRACE_ERROR1("%s not supported",__FUNCTION__);
+ bta_hl_ci_put_echo_data(mcl_handle, status, evt);
+}
+
diff --git a/btif/include/btif_av.h b/btif/include/btif_av.h
index 8d67f66..e481459 100644..100755
--- a/btif/include/btif_av.h
+++ b/btif/include/btif_av.h
@@ -151,6 +151,17 @@ BOOLEAN btif_av_stream_started(void);
/* used to pass events to AV statemachine from other tasks */
void btif_dispatch_sm_event(btif_av_sm_event_t event, void *p_data, int len);
+/*******************************************************************************
+**
+** Function btif_av_init
+**
+** Description Initializes btif AV if not already done
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+
+bt_status_t btif_av_init(void);
#endif /* BTIF_AV_H */
diff --git a/btif/include/btif_common.h b/btif/include/btif_common.h
index ec3f4f3..635caeb 100644..100755
--- a/btif/include/btif_common.h
+++ b/btif/include/btif_common.h
@@ -170,6 +170,7 @@ bt_status_t btif_transfer_context (tBTIF_CBACK *p_cback, UINT16 event, char* p_p
tBTA_SERVICE_MASK btif_get_enabled_services_mask(void);
bt_status_t btif_enable_service(tBTA_SERVICE_ID service_id);
bt_status_t btif_disable_service(tBTA_SERVICE_ID service_id);
+int btif_is_enabled(void);
/*
* BTIF_Events
diff --git a/btif/src/bluetooth.c b/btif/src/bluetooth.c
index 5864eac..5864eac 100755..100644
--- a/btif/src/bluetooth.c
+++ b/btif/src/bluetooth.c
diff --git a/btif/src/btif_av.c b/btif/src/btif_av.c
index 3c5afb4..a3987ad 100644
--- a/btif/src/btif_av.c
+++ b/btif/src/btif_av.c
@@ -100,7 +100,8 @@ static btif_av_cb_t btif_av_cb;
static TIMER_LIST_ENT tle_av_open_on_rc;
-#define CHECK_BTAV_INIT() if (bt_av_callbacks == NULL)\
+/* both interface and media task needs to be ready to alloc incoming request */
+#define CHECK_BTAV_INIT() if ((bt_av_callbacks == NULL) || (btif_av_cb.sm_handle == NULL))\
{\
BTIF_TRACE_WARNING1("%s: BTAV not initialized", __FUNCTION__);\
return BT_STATUS_NOT_READY;\
@@ -663,27 +664,21 @@ static void bte_av_callback(tBTA_AV_EVT event, tBTA_AV *p_data)
/*******************************************************************************
**
-** Function init
+** Function btif_av_init
**
-** Description Initializes the AV interface
+** Description Initializes btif AV if not already done
**
** Returns bt_status_t
**
*******************************************************************************/
-static bt_status_t init(btav_callbacks_t* callbacks )
+bt_status_t btif_av_init(void)
{
- int status;
-
- BTIF_TRACE_EVENT1("%s", __FUNCTION__);
-
- status = btif_a2dp_start_media_task();
-
- if (status != GKI_SUCCESS)
+ if (btif_av_cb.sm_handle == NULL)
+{
+ if (btif_a2dp_start_media_task() != GKI_SUCCESS)
return BT_STATUS_FAIL;
- bt_av_callbacks = callbacks;
-
btif_enable_service(BTA_A2DP_SERVICE_ID);
/* Initialize the AVRC CB */
@@ -697,6 +692,43 @@ static bt_status_t init(btav_callbacks_t* callbacks )
return BT_STATUS_SUCCESS;
}
+ return BT_STATUS_DONE;
+}
+
+/*******************************************************************************
+**
+** Function init
+**
+** Description Initializes the AV interface
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+
+static bt_status_t init(btav_callbacks_t* callbacks )
+{
+ int status;
+
+ BTIF_TRACE_EVENT1("%s", __FUNCTION__);
+
+ if (bt_av_callbacks)
+ return BT_STATUS_DONE;
+
+ bt_av_callbacks = callbacks;
+ btif_av_cb.sm_handle = NULL;
+
+ /* check if stack/gki is started/enabled yet, if not defer until bluetooth
+ is enabled */
+
+ if (btif_is_enabled() == 0)
+ {
+ BTIF_TRACE_EVENT0("deferred av init until gki is enabled");
+ return BT_STATUS_SUCCESS;
+ }
+
+ return btif_av_init();
+}
+
/*******************************************************************************
**
** Function connect
@@ -863,6 +895,7 @@ bt_status_t btif_av_execute_service(BOOLEAN b_enable)
/* TODO: Removed BTA_SEC_AUTHORIZE since the Java/App does not
* handle this request in order to allow incoming connections to succeed.
* We need to put this back once support for this is added */
+
/* Added BTA_AV_FEAT_NO_SCO_SSPD - this ensures that the BTA does not
* auto-suspend av streaming on AG events(SCO or Call). The suspend shall
* be initiated by the app/audioflinger layers */
diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c
index b77cddb..f6f54f0 100755..100644
--- a/btif/src/btif_core.c
+++ b/btif/src/btif_core.c
@@ -55,6 +55,7 @@
***********************************************************************************/
#include <hardware/bluetooth.h>
+
#include <string.h>
#define LOG_TAG "BTIF_CORE"
@@ -65,9 +66,11 @@
#include "btu.h"
#include "bte.h"
#include "bd.h"
+#include "btif_av.h"
#include "btif_storage.h"
#include "btif_util.h"
#include "btif_sock.h"
+
/************************************************************************************
** Constants & Macros
************************************************************************************/
@@ -431,16 +434,25 @@ void btif_enable_bluetooth_evt(tBTA_STATUS status, BD_ADDR local_bd)
{
/* store state */
btif_enabled = 1;
- //init rfcomm & l2cap api
+
+ /* check if we have a deferred av init */
+ btif_av_init();
+
+ /* init rfcomm & l2cap api */
btif_sock_init();
+
+ /* load did configuration */
bte_load_did_conf(BTE_DID_CONF_FILE);
+
HAL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_ON);
}
else
{
- //cleanup rfcomm & l2cap api
+ /* cleanup rfcomm & l2cap api */
btif_sock_cleanup();
+
btif_enabled = 0;
+
HAL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_OFF);
}
}
@@ -456,6 +468,7 @@ void btif_enable_bluetooth_evt(tBTA_STATUS status, BD_ADDR local_bd)
** Returns void
**
*******************************************************************************/
+
bt_status_t btif_disable_bluetooth(void)
{
tBTA_STATUS status;
@@ -467,8 +480,10 @@ bt_status_t btif_disable_bluetooth(void)
}
BTIF_TRACE_DEBUG1("%s", __FUNCTION__);
- //cleanup rfcomm & l2cap api
+
+ /* cleanup rfcomm & l2cap api */
btif_sock_cleanup();
+
status = BTA_DisableBluetooth();
if (status != BTA_SUCCESS)
@@ -1077,6 +1092,11 @@ tBTA_SERVICE_MASK btif_get_enabled_services_mask(void)
return btif_enabled_services;
}
+int btif_is_enabled(void)
+{
+ return btif_enabled;
+}
+
/*******************************************************************************
**
** Function btif_enable_service
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index ee30090..ee30090 100755..100644
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
diff --git a/btif/src/btif_hh.c b/btif/src/btif_hh.c
index 0b945a0..0b945a0 100755..100644
--- a/btif/src/btif_hh.c
+++ b/btif/src/btif_hh.c
diff --git a/btif/src/btif_hl.c b/btif/src/btif_hl.c
index 1e4ffaf..1e4ffaf 100755..100644
--- a/btif/src/btif_hl.c
+++ b/btif/src/btif_hl.c
diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c
index 70c48cc..a122408 100644..100755
--- a/btif/src/btif_media_task.c
+++ b/btif/src/btif_media_task.c
@@ -671,6 +671,8 @@ static void btif_a2dp_encoder_update(void)
int btif_a2dp_start_media_task(void)
{
+ int retval;
+
if (media_task_running)
{
APPL_TRACE_ERROR0("warning : media task already running");
@@ -679,13 +681,22 @@ int btif_a2dp_start_media_task(void)
APPL_TRACE_EVENT0("## A2DP START MEDIA TASK ##");
- media_task_running = 1;
-
/* start a2dp media task */
- return GKI_create_task((TASKPTR)btif_media_task, A2DP_MEDIA_TASK,
+ retval = GKI_create_task((TASKPTR)btif_media_task, A2DP_MEDIA_TASK,
A2DP_MEDIA_TASK_TASK_STR,
(UINT16 *) ((UINT8 *)a2dp_media_task_stack + A2DP_MEDIA_TASK_STACK_SIZE),
sizeof(a2dp_media_task_stack));
+
+ if (retval != GKI_SUCCESS)
+ return retval;
+
+ /* wait for task to come up to sure we are able to send messages to it */
+ while (media_task_running == 0)
+ usleep(10);
+
+ APPL_TRACE_EVENT0("## A2DP MEDIA TASK STARTED ##");
+
+ return retval;
}
/*****************************************************************************
@@ -1123,6 +1134,8 @@ int btif_media_task(void *p)
btif_media_task_init();
+ media_task_running = 1;
+
while (1)
{
event = GKI_wait(0xffff, 0);