From c23b66b1dec56c17b3515a98c6db8d9ee5cb6ac9 Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Tue, 7 Mar 2017 14:21:26 +0800 Subject: [PATCH] component/bt: transport bta_av_co.c --- .../profile/std/a2dp}/bta_av_co.c | 28 +-- .../btc/profile/std/a2dp/btc_media_task.c | 2 +- .../profile/std/a2dp/include/btc_av_co.h} | 42 ++--- .../bt/bluedroid/btif/include/btif_api.h | 88 --------- .../bt/bluedroid/btif/include/stack_manager.h | 29 --- components/bt/bluedroid/btif/stack_manager.c | 177 ------------------ components/bt/component.mk | 1 + 7 files changed, 35 insertions(+), 332 deletions(-) rename components/bt/bluedroid/{btif => btc/profile/std/a2dp}/bta_av_co.c (98%) rename components/bt/bluedroid/{btif/include/btif_av_co.h => btc/profile/std/a2dp/include/btc_av_co.h} (85%) delete mode 100644 components/bt/bluedroid/btif/include/btif_api.h delete mode 100644 components/bt/bluedroid/btif/include/stack_manager.h delete mode 100644 components/bt/bluedroid/btif/stack_manager.c diff --git a/components/bt/bluedroid/btif/bta_av_co.c b/components/bt/bluedroid/btc/profile/std/a2dp/bta_av_co.c similarity index 98% rename from components/bt/bluedroid/btif/bta_av_co.c rename to components/bt/bluedroid/btc/profile/std/a2dp/bta_av_co.c index 3cbf422bdb..c68ca478af 100644 --- a/components/bt/bluedroid/btif/bta_av_co.c +++ b/components/bt/bluedroid/btc/profile/std/a2dp/bta_av_co.c @@ -19,7 +19,7 @@ /****************************************************************************** * * This is the advanced audio/video call-out function implementation for - * BTIF. + * BTC. * ******************************************************************************/ @@ -32,7 +32,7 @@ #include "bta_av_ci.h" #include "bta_av_sbc.h" #include "btc_media.h" -#include "btif_av_co.h" +#include "btc_av_co.h" #include "btif_util.h" /***************************************************************************** @@ -86,13 +86,13 @@ const tA2D_SBC_CIE bta_av_co_sbc_sink_caps = { A2D_SBC_IE_MIN_BITPOOL /* min_bitpool */ }; -#if !defined(BTIF_AV_SBC_DEFAULT_SAMP_FREQ) -#define BTIF_AV_SBC_DEFAULT_SAMP_FREQ A2D_SBC_IE_SAMP_FREQ_44 +#if !defined(BTC_AV_SBC_DEFAULT_SAMP_FREQ) +#define BTC_AV_SBC_DEFAULT_SAMP_FREQ A2D_SBC_IE_SAMP_FREQ_44 #endif /* Default SBC codec configuration */ -const tA2D_SBC_CIE btif_av_sbc_default_config = { - BTIF_AV_SBC_DEFAULT_SAMP_FREQ, /* samp_freq */ +const tA2D_SBC_CIE btc_av_sbc_default_config = { + BTC_AV_SBC_DEFAULT_SAMP_FREQ, /* samp_freq */ A2D_SBC_IE_CH_MD_JOINT, /* ch_mode */ A2D_SBC_IE_BLOCKS_16, /* block_len */ A2D_SBC_IE_SUBBAND_8, /* num_subbands */ @@ -116,8 +116,8 @@ typedef struct { typedef struct { BD_ADDR addr; /* address of audio/video peer */ - tBTA_AV_CO_SINK snks[BTIF_SV_AV_AA_SEP_INDEX]; /* array of supported sinks */ - tBTA_AV_CO_SINK srcs[BTIF_SV_AV_AA_SEP_INDEX]; /* array of supported srcs */ + tBTA_AV_CO_SINK snks[BTC_SV_AV_AA_SEP_INDEX]; /* array of supported sinks */ + tBTA_AV_CO_SINK srcs[BTC_SV_AV_AA_SEP_INDEX]; /* array of supported srcs */ UINT8 num_snks; /* total number of sinks at peer */ UINT8 num_srcs; /* total number of srcs at peer */ UINT8 num_seps; /* total number of seids at peer */ @@ -277,7 +277,7 @@ BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_ bta_av_co_cb.codec_cfg_setconfig.id = BTC_AV_CODEC_NONE; switch (index) { - case BTIF_SV_AV_AA_SBC_INDEX: + case BTC_SV_AV_AA_SBC_INDEX: #if defined(BTA_AV_CO_CP_SCMS_T) && (BTA_AV_CO_CP_SCMS_T == TRUE) { UINT8 *p = p_protect_info; @@ -298,7 +298,7 @@ BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_ /* Codec is valid */ return TRUE; #if (BTA_AV_SINK_INCLUDED == TRUE) - case BTIF_SV_AV_AA_SBC_SINK_INDEX: + case BTC_SV_AV_AA_SBC_SINK_INDEX: *p_codec_type = BTA_AV_CODEC_SBC; /* This should not fail because we are using constants for parameters */ @@ -379,7 +379,7 @@ void bta_av_build_src_cfg (UINT8 *p_pref_cfg, UINT8 *p_src_cap) UINT8 status = 0; /* initialize it to default SBC configuration */ - A2D_BldSbcInfo(AVDT_MEDIA_AUDIO, (tA2D_SBC_CIE *) &btif_av_sbc_default_config, p_pref_cfg); + A2D_BldSbcInfo(AVDT_MEDIA_AUDIO, (tA2D_SBC_CIE *) &btc_av_sbc_default_config, p_pref_cfg); /* now try to build a preferred one */ /* parse configuration */ if ((status = A2D_ParsSbcInfo(&src_cap, p_src_cap, TRUE)) != 0) { @@ -1467,7 +1467,7 @@ void bta_av_co_audio_codec_reset(void) /* Reset the current configuration to SBC */ bta_av_co_cb.codec_cfg.id = BTC_AV_CODEC_SBC; - if (A2D_BldSbcInfo(A2D_MEDIA_TYPE_AUDIO, (tA2D_SBC_CIE *)&btif_av_sbc_default_config, bta_av_co_cb.codec_cfg.info) != A2D_SUCCESS) { + if (A2D_BldSbcInfo(A2D_MEDIA_TYPE_AUDIO, (tA2D_SBC_CIE *)&btc_av_sbc_default_config, bta_av_co_cb.codec_cfg.info) != A2D_SUCCESS) { APPL_TRACE_ERROR("bta_av_co_audio_codec_reset A2D_BldSbcInfo failed"); } @@ -1502,7 +1502,7 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTC_AV_MEDIA_FEEDINGS *p_feeding, tBTC_ case BTC_AV_CODEC_PCM: new_cfg.id = BTC_AV_CODEC_SBC; - sbc_config = btif_av_sbc_default_config; + sbc_config = btc_av_sbc_default_config; if ((p_feeding->cfg.pcm.num_channel != 1) && (p_feeding->cfg.pcm.num_channel != 2)) { APPL_TRACE_ERROR("bta_av_co_audio_set_codec PCM channel number unsupported"); @@ -1610,7 +1610,7 @@ BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_min if (!result) { /* Not SBC, still return the default values */ - *p_sbc_config = btif_av_sbc_default_config; + *p_sbc_config = btc_av_sbc_default_config; } GKI_enable(); diff --git a/components/bt/bluedroid/btc/profile/std/a2dp/btc_media_task.c b/components/bt/bluedroid/btc/profile/std/a2dp/btc_media_task.c index ec12b32f3c..f7e00fd66c 100644 --- a/components/bt/bluedroid/btc/profile/std/a2dp/btc_media_task.c +++ b/components/bt/bluedroid/btc/profile/std/a2dp/btc_media_task.c @@ -43,7 +43,7 @@ #include "bta_av_ci.h" #include "l2c_api.h" -#include "btif_av_co.h" +#include "btc_av_co.h" #include "btc_media.h" #include "alarm.h" diff --git a/components/bt/bluedroid/btif/include/btif_av_co.h b/components/bt/bluedroid/btc/profile/std/a2dp/include/btc_av_co.h similarity index 85% rename from components/bt/bluedroid/btif/include/btif_av_co.h rename to components/bt/bluedroid/btc/profile/std/a2dp/include/btc_av_co.h index bc72387a14..43a83002e4 100644 --- a/components/bt/bluedroid/btif/include/btif_av_co.h +++ b/components/bt/bluedroid/btc/profile/std/a2dp/include/btc_av_co.h @@ -1,23 +1,19 @@ -/****************************************************************************** - * - * Copyright (C) 2009-2012 Broadcom Corporation - * - * 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. - * - ******************************************************************************/ - -#ifndef BTIF_AV_CO_H -#define BTIF_AV_CO_H +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// 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. + +#ifndef __BTC_AV_CO_H__ +#define __BTC_AV_CO_H__ #include "btc_media.h" @@ -26,9 +22,9 @@ ********************************************************************************/ enum { - BTIF_SV_AV_AA_SBC_INDEX = 0, - BTIF_SV_AV_AA_SBC_SINK_INDEX, - BTIF_SV_AV_AA_SEP_INDEX /* Last index */ + BTC_SV_AV_AA_SBC_INDEX = 0, + BTC_SV_AV_AA_SBC_SINK_INDEX, + BTC_SV_AV_AA_SEP_INDEX /* Last index */ }; diff --git a/components/bt/bluedroid/btif/include/btif_api.h b/components/bt/bluedroid/btif/include/btif_api.h deleted file mode 100644 index 753fec100d..0000000000 --- a/components/bt/bluedroid/btif/include/btif_api.h +++ /dev/null @@ -1,88 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2009-2012 Broadcom Corporation - * - * 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. - * - ******************************************************************************/ - -/******************************************************************************* - * - * Filename: btif_api.h - * - * Description: Main API header file for all BTIF functions accessed - * from main bluetooth HAL. All HAL extensions will not - * require headerfiles as they would be accessed through - * callout/callins. - * - *******************************************************************************/ - -#ifndef BTIF_API_H -#define BTIF_API_H - -#include "btif_common.h" -#include "btif_dm.h" - -/******************************************************************************* -** BTIF CORE API -********************************************************************************/ - -/******************************************************************************* -** -** Function btif_init_bluetooth -** -** Description Creates BTIF task and prepares BT scheduler for startup -** -** Returns bt_status_t -** -*******************************************************************************/ -bt_status_t btif_init_bluetooth(void); - -/******************************************************************************* -** -** Function btif_enable_bluetooth -** -** Description Performs chip power on and kickstarts OS scheduler -** -** Returns bt_status_t -** -*******************************************************************************/ -bt_status_t btif_enable_bluetooth(void); - -/******************************************************************************* -** -** Function btif_disable_bluetooth -** -** Description Inititates shutdown of Bluetooth system. -** Any active links will be dropped and device entering -** non connectable/discoverable mode -** -** Returns void -** -*******************************************************************************/ -bt_status_t btif_disable_bluetooth(void); - -/******************************************************************************* -** -** Function btif_shutdown_bluetooth -** -** Description Finalizes BT scheduler shutdown and terminates BTIF -** task. -** -** -** Returns void -** -*******************************************************************************/ -bt_status_t btif_shutdown_bluetooth(void); - -#endif /* BTIF_API_H */ diff --git a/components/bt/bluedroid/btif/include/stack_manager.h b/components/bt/bluedroid/btif/include/stack_manager.h deleted file mode 100644 index 466cdca122..0000000000 --- a/components/bt/bluedroid/btif/include/stack_manager.h +++ /dev/null @@ -1,29 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2014 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. - * - ******************************************************************************/ - -#ifndef __STACK_MANAGER_H__ -#define __STACK_MANAGER_H__ - -#include -#include "future.h" - -bool stack_manager_is_stack_running(void); - -future_t *stack_manager_get_hack_future(void); - -#endif /* __STACK_MANAGER_H__*/ diff --git a/components/bt/bluedroid/btif/stack_manager.c b/components/bt/bluedroid/btif/stack_manager.c deleted file mode 100644 index ecf526b4bb..0000000000 --- a/components/bt/bluedroid/btif/stack_manager.c +++ /dev/null @@ -1,177 +0,0 @@ -#include -#include -#include "esp_bt_stack_manager.h" -#include "stack_manager.h" -#include "bt_defs.h" -#include "bt_trace.h" -#include "future.h" -#include "btif_common.h" -#include "btif_api.h" -#include "btif_dm.h" -#include "btif_config.h" - -/************************************************************************************ -** Constants & Macros -************************************************************************************/ -/************************************************************************************ -** Local type definitions -************************************************************************************/ -/************************************************************************************ -** Static variables -************************************************************************************/ -static bool stack_is_initialized = false; -static bool stack_is_running = false; -static future_t *hack_future = NULL; - -static bt_status_t event_init_stack(void); -static bt_status_t event_start_up_stack(void); -static bt_status_t event_shut_down_stack(void); -static bt_status_t event_clean_up_stack(void); - -static bt_status_t event_init_stack(void) -{ - bt_status_t ret; - if (!stack_is_initialized) { - hack_future = future_new(); - btif_config_init(); - ret = btif_init_bluetooth(); - if (future_await(hack_future) != FUTURE_SUCCESS) { - return BT_STATUS_FAIL; - } - if (ret == BT_STATUS_SUCCESS) { - stack_is_initialized = true; - } - return ret; - } else { - return BT_STATUS_DONE; - } -} - -static bt_status_t event_start_up_stack(void) -{ - if (!stack_is_initialized) { - LOG_DEBUG("%s stack not initialized yet.\n", __func__); - return BT_STATUS_NOT_READY; - } - - if (stack_is_running) { - LOG_DEBUG("%s stack already brought up.\n", __func__); - return BT_STATUS_DONE; - } - - LOG_DEBUG("%s is bringing up the stack.\n", __func__); - hack_future = future_new(); - - btif_enable_bluetooth(); - - if (future_await(hack_future) != FUTURE_SUCCESS) { - stack_is_running = true; // So stack shutdown actually happens - event_shut_down_stack(); - return BT_STATUS_FAIL; - } - - stack_is_running = true; - LOG_DEBUG("%s finished\n", __func__); - return BT_STATUS_SUCCESS; -} - -static bt_status_t event_shut_down_stack(void) -{ - if (!stack_is_initialized) { - LOG_DEBUG("%s stack not initialized yet.\n", __func__); - return BT_STATUS_NOT_READY; - } - - if (!stack_is_running) { - LOG_DEBUG("%s stack is already brought down.\n", __func__); - return BT_STATUS_DONE; - } - - LOG_DEBUG("%s is bringing down the stack.\n", __func__); - hack_future = future_new(); - stack_is_running = false; - - btif_disable_bluetooth(); - btif_config_shut_down(); - future_await(hack_future); - - LOG_DEBUG("%s finished.\n", __func__); - return BT_STATUS_SUCCESS; -} - -static bt_status_t event_clean_up_stack(void) -{ - if (!stack_is_initialized) { - LOG_DEBUG("%s found the stack already in a clean state.\n", __func__); - return BT_STATUS_DONE; - } - - if (stack_is_running) { - event_shut_down_stack(); - } - - LOG_DEBUG("%s is cleaning up the stack.\n", __func__); - - stack_is_initialized = false; - btif_config_clean_up(); - btif_shutdown_bluetooth(); - - return BT_STATUS_SUCCESS; -} - -esp_err_t esp_bt_init_stack(void) -{ - bt_status_t status; - status = event_init_stack(); - switch (status) { - case BT_STATUS_SUCCESS: return ESP_OK; - case BT_STATUS_DONE: return ESP_ERR_INVALID_STATE; - default: return ESP_FAIL; - } -} - -esp_err_t esp_bt_deinit_stack(void) -{ - bt_status_t status; - status = event_clean_up_stack(); - switch (status) { - case BT_STATUS_SUCCESS: return ESP_OK; - default: return ESP_ERR_INVALID_STATE; - } -} - -esp_err_t esp_bt_enable_stack(void) -{ - bt_status_t status; - status = event_start_up_stack(); - switch (status) { - case BT_STATUS_SUCCESS: return ESP_OK; - case BT_STATUS_NOT_READY: - case BT_STATUS_DONE: - return ESP_ERR_INVALID_STATE; - default: return ESP_FAIL; - } -} - -esp_err_t esp_bt_disable_stack(void) -{ - bt_status_t status; - status = event_shut_down_stack(); - switch (status) { - case BT_STATUS_SUCCESS: return ESP_OK; - case BT_STATUS_NOT_READY: - case BT_STATUS_DONE: - return ESP_ERR_INVALID_STATE; - default: return ESP_FAIL; - } -} - -bool stack_manager_is_stack_running(void) -{ - return stack_is_running; -} - -future_t *stack_manager_get_hack_future(void) -{ - return hack_future; -} diff --git a/components/bt/component.mk b/components/bt/component.mk index 67fc96f393..3f86ac34d4 100644 --- a/components/bt/component.mk +++ b/components/bt/component.mk @@ -17,6 +17,7 @@ COMPONENT_ADD_INCLUDEDIRS := bluedroid/bta/include \ bluedroid/btc/profile/esp/include \ bluedroid/btc/profile/std/gatt/include \ bluedroid/btc/profile/std/gap/include \ + bluedroid/btc/profile/std/a2dp/include \ bluedroid/btc/profile/std/sdp/include \ bluedroid/btc/profile/std/include \ bluedroid/btc/include \ -- 2.40.0