diff options
author | Kausik Sinnaswamy <kausik@broadcom.com> | 2012-03-07 19:30:20 -0800 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:12 -0700 |
commit | 95fa11b3b2f19a382c7e3a744a6afb452fad86df (patch) | |
tree | 1019e123db4596f2b8bd1259da04b51f3c44d7b2 /btif/include | |
parent | e2197423bcf1a93c620be13d458a9da6693fa94d (diff) | |
download | external_bluetooth_bluedroid-95fa11b3b2f19a382c7e3a744a6afb452fad86df.zip external_bluetooth_bluedroid-95fa11b3b2f19a382c7e3a744a6afb452fad86df.tar.gz external_bluetooth_bluedroid-95fa11b3b2f19a382c7e3a744a6afb452fad86df.tar.bz2 |
AV control and data path added
Change-Id: I88ec6084c140fa257154a98e23e075900e84cc8c
Diffstat (limited to 'btif/include')
-rw-r--r-- | btif/include/btif_av.h | 190 | ||||
-rw-r--r-- | btif/include/btif_av_api.h | 238 | ||||
-rw-r--r-- | btif/include/btif_media.h | 265 | ||||
-rw-r--r-- | btif/include/btif_sm.h | 158 | ||||
-rw-r--r-- | btif/include/btif_util.h | 2 |
5 files changed, 853 insertions, 0 deletions
diff --git a/btif/include/btif_av.h b/btif/include/btif_av.h new file mode 100644 index 0000000..720fa87 --- /dev/null +++ b/btif/include/btif_av.h @@ -0,0 +1,190 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * This program is the proprietary software of Broadcom Corporation and/or its + * licensors, and may only be used, duplicated, modified or distributed + * pursuant to the terms and conditions of a separate, written license + * agreement executed between you and Broadcom (an "Authorized License"). + * Except as set forth in an Authorized License, Broadcom grants no license + * (express or implied), right to use, or waiver of any kind with respect to + * the Software, and Broadcom expressly reserves all rights in and to the + * Software and all intellectual property rights therein. + * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS + * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE + * ALL USE OF THE SOFTWARE. + * + * Except as expressly set forth in the Authorized License, + * + * 1. This program, including its structure, sequence and organization, + * constitutes the valuable trade secrets of Broadcom, and you shall + * use all reasonable efforts to protect the confidentiality thereof, + * and to use this information only in connection with your use of + * Broadcom integrated circuit products. + * + * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED + * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, + * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, + * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY + * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, + * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, + * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR + * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING + * OUT OF USE OR PERFORMANCE OF THE SOFTWARE. + * + * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM + * OR ITS LICENSORS BE LIABLE FOR + * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY + * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO + * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR + * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE + * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE + * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF + * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. + * + *****************************************************************************/ + +/***************************************************************************** +** +** Name: btif_av.h +** +** Description: +** +******************************************************************************/ + + +#ifndef BTIF_AV_H +#define BTIF_AV_H + +#include "btif_media.h" + +enum +{ + BTIF_SV_AV_AA_SBC_INDEX = 0, + BTIF_SV_AV_AA_SEP_INDEX /* Last index */ +}; + + +/******************************************************************************* + ** + ** Function bta_av_co_cp_is_active + ** + ** Description Get the current configuration of content protection + ** + ** Returns TRUE if the current streaming has CP, FALSE otherwise + ** + *******************************************************************************/ +BOOLEAN bta_av_co_cp_is_active(void); + +/******************************************************************************* + ** + ** Function bta_av_co_cp_get_flag + ** + ** Description Get content protection flag + ** BTA_AV_CP_SCMS_COPY_NEVER + ** BTA_AV_CP_SCMS_COPY_ONCE + ** BTA_AV_CP_SCMS_COPY_FREE + ** + ** Returns The current flag value + ** + *******************************************************************************/ +UINT8 bta_av_co_cp_get_flag(void); + +/******************************************************************************* + ** + ** Function bta_av_co_cp_set_flag + ** + ** Description Set content protection flag + ** BTA_AV_CP_SCMS_COPY_NEVER + ** BTA_AV_CP_SCMS_COPY_ONCE + ** BTA_AV_CP_SCMS_COPY_FREE + ** + ** Returns TRUE if setting the SCMS flag is supported else FALSE + ** + *******************************************************************************/ +BOOLEAN bta_av_co_cp_set_flag(UINT8 cp_flag); + +/******************************************************************************* + ** + ** Function bta_av_co_audio_codec_reset + ** + ** Description Reset the current codec configuration + ** + ** Returns void + ** + *******************************************************************************/ +void bta_av_co_audio_codec_reset(void); + +/******************************************************************************* + ** + ** Function bta_av_co_audio_codec_supported + ** + ** Description Check if all opened connections are compatible with a codec + ** configuration + ** + ** Returns TRUE if all opened devices support this codec, FALSE otherwise + ** + *******************************************************************************/ +BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status); + +/******************************************************************************* + ** + ** Function bta_av_co_audio_set_codec + ** + ** Description Set the current codec configuration from the feeding type. + ** This function is starting to modify the configuration, it + ** should be protected. + ** + ** Returns TRUE if successful, FALSE otherwise + ** + *******************************************************************************/ +BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTIF_STATUS *p_status); + +/******************************************************************************* + ** + ** Function bta_av_co_audio_get_sbc_config + ** + ** Description Retrieves the SBC codec configuration. If the codec in use + ** is not SBC, return the default SBC codec configuration. + ** + ** Returns TRUE if codec is SBC, FALSE otherwise + ** + *******************************************************************************/ +BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_minmtu); + +/******************************************************************************* + ** + ** Function bta_av_co_audio_discard_config + ** + ** Description Discard the codec configuration of a connection + ** + ** Returns Nothing + ** + *******************************************************************************/ +void bta_av_co_audio_discard_config(tBTA_AV_HNDL hndl); + +/******************************************************************************* + ** + ** Function bta_av_co_init + ** + ** Description Initialization + ** + ** Returns Nothing + ** + *******************************************************************************/ +void bta_av_co_init(void); + + +/******************************************************************************* + ** + ** Function bta_av_co_peer_cp_supported + ** + ** Description Checks if the peer supports CP + ** + ** Returns TRUE if the peer supports CP + ** + *******************************************************************************/ +BOOLEAN bta_av_co_peer_cp_supported(tBTA_AV_HNDL hndl); + +#endif diff --git a/btif/include/btif_av_api.h b/btif/include/btif_av_api.h new file mode 100644 index 0000000..f7a0304 --- /dev/null +++ b/btif/include/btif_av_api.h @@ -0,0 +1,238 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * This program is the proprietary software of Broadcom Corporation and/or its + * licensors, and may only be used, duplicated, modified or distributed + * pursuant to the terms and conditions of a separate, written license + * agreement executed between you and Broadcom (an "Authorized License"). + * Except as set forth in an Authorized License, Broadcom grants no license + * (express or implied), right to use, or waiver of any kind with respect to + * the Software, and Broadcom expressly reserves all rights in and to the + * Software and all intellectual property rights therein. + * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS + * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE + * ALL USE OF THE SOFTWARE. + * + * Except as expressly set forth in the Authorized License, + * + * 1. This program, including its structure, sequence and organization, + * constitutes the valuable trade secrets of Broadcom, and you shall + * use all reasonable efforts to protect the confidentiality thereof, + * and to use this information only in connection with your use of + * Broadcom integrated circuit products. + * + * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED + * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, + * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, + * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY + * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, + * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, + * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR + * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING + * OUT OF USE OR PERFORMANCE OF THE SOFTWARE. + * + * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM + * OR ITS LICENSORS BE LIABLE FOR + * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY + * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO + * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR + * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE + * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE + * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF + * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. + * + *****************************************************************************/ + +/***************************************************************************** + ** + ** Name: btif_av_api.h + ** + ** Description: This is the public interface file for the advanced + ** audio/video streaming (AV) subsystem of BTIF, Widcomm's + ** Bluetooth application layer for mobile phones. + ** + *****************************************************************************/ +#ifndef BTIF_AV_API_H +#define BTIF_AV_API_H + +#include "bt_target.h" +#include "bta_av_api.h" +#include "uipc.h" + +#include "btif_media.h" +#include "a2d_api.h" +#include "a2d_sbc.h" +#include "a2d_m12.h" +#include "a2d_m24.h" + +/***************************************************************************** + ** Constants and data types + *****************************************************************************/ + +/* codec type */ +#define BTIF_AV_CODEC_SBC A2D_MEDIA_CT_SBC /* SBC media codec type */ + +#define BTIF_AV_CODEC_PCM 0x5 /* Raw PCM */ + +typedef UINT8 tBTIF_AV_CODEC_ID; + +/* AV features masks */ +#define BTIF_AV_FEAT_RCTG BTA_AV_FEAT_RCTG /* remote control target */ +#define BTIF_AV_FEAT_RCCT BTA_AV_FEAT_RCCT /* remote control controller */ +#define BTIF_AV_FEAT_METADATA BTA_AV_FEAT_METADATA /* remote control Metadata Transfer command/response */ + +typedef UINT16 tBTIF_AV_FEAT; + +/* AV channel values */ +#define BTIF_AV_CHNL_MSK BTA_AV_CHNL_MSK +#define BTIF_AV_CHNL_AUDIO BTA_AV_CHNL_AUDIO /* audio channel */ +#define BTIF_AV_CHNL_VIDEO BTA_AV_CHNL_VIDEO /* video channel */ +typedef UINT8 tBTIF_AV_CHNL; + +typedef UINT8 tBTIF_AV_HNDL; + +/* operation id list for BTIF_AvRemoteCmd */ +#define BTIF_AV_ID_SELECT 0x00 /* select */ +#define BTIF_AV_ID_UP 0x01 /* up */ +#define BTIF_AV_ID_DOWN 0x02 /* down */ +#define BTIF_AV_ID_LEFT 0x03 /* left */ +#define BTIF_AV_ID_RIGHT 0x04 /* right */ +#define BTIF_AV_ID_RIGHT_UP 0x05 /* right-up */ +#define BTIF_AV_ID_RIGHT_DOWN 0x06 /* right-down */ +#define BTIF_AV_ID_LEFT_UP 0x07 /* left-up */ +#define BTIF_AV_ID_LEFT_DOWN 0x08 /* left-down */ +#define BTIF_AV_ID_ROOT_MENU 0x09 /* root menu */ +#define BTIF_AV_ID_SETUP_MENU 0x0A /* setup menu */ +#define BTIF_AV_ID_CONT_MENU 0x0B /* contents menu */ +#define BTIF_AV_ID_FAV_MENU 0x0C /* favorite menu */ +#define BTIF_AV_ID_EXIT 0x0D /* exit */ +#define BTIF_AV_ID_0 0x20 /* 0 */ +#define BTIF_AV_ID_1 0x21 /* 1 */ +#define BTIF_AV_ID_2 0x22 /* 2 */ +#define BTIF_AV_ID_3 0x23 /* 3 */ +#define BTIF_AV_ID_4 0x24 /* 4 */ +#define BTIF_AV_ID_5 0x25 /* 5 */ +#define BTIF_AV_ID_6 0x26 /* 6 */ +#define BTIF_AV_ID_7 0x27 /* 7 */ +#define BTIF_AV_ID_8 0x28 /* 8 */ +#define BTIF_AV_ID_9 0x29 /* 9 */ +#define BTIF_AV_ID_DOT 0x2A /* dot */ +#define BTIF_AV_ID_ENTER 0x2B /* enter */ +#define BTIF_AV_ID_CLEAR 0x2C /* clear */ +#define BTIF_AV_ID_CHAN_UP 0x30 /* channel up */ +#define BTIF_AV_ID_CHAN_DOWN 0x31 /* channel down */ +#define BTIF_AV_ID_PREV_CHAN 0x32 /* previous channel */ +#define BTIF_AV_ID_SOUND_SEL 0x33 /* sound select */ +#define BTIF_AV_ID_INPUT_SEL 0x34 /* input select */ +#define BTIF_AV_ID_DISP_INFO 0x35 /* display information */ +#define BTIF_AV_ID_HELP 0x36 /* help */ +#define BTIF_AV_ID_PAGE_UP 0x37 /* page up */ +#define BTIF_AV_ID_PAGE_DOWN 0x38 /* page down */ +#define BTIF_AV_ID_POWER 0x40 /* power */ +#define BTIF_AV_ID_VOL_UP 0x41 /* volume up */ +#define BTIF_AV_ID_VOL_DOWN 0x42 /* volume down */ +#define BTIF_AV_ID_MUTE 0x43 /* mute */ +#define BTIF_AV_ID_PLAY 0x44 /* play */ +#define BTIF_AV_ID_STOP 0x45 /* stop */ +#define BTIF_AV_ID_PAUSE 0x46 /* pause */ +#define BTIF_AV_ID_RECORD 0x47 /* record */ +#define BTIF_AV_ID_REWIND 0x48 /* rewind */ +#define BTIF_AV_ID_FAST_FOR 0x49 /* fast forward */ +#define BTIF_AV_ID_EJECT 0x4A /* eject */ +#define BTIF_AV_ID_FORWARD 0x4B /* forward */ +#define BTIF_AV_ID_BACKWARD 0x4C /* backward */ +#define BTIF_AV_ID_ANGLE 0x50 /* angle */ +#define BTIF_AV_ID_SUBPICT 0x51 /* subpicture */ +#define BTIF_AV_ID_F1 0x71 /* F1 */ +#define BTIF_AV_ID_F2 0x72 /* F2 */ +#define BTIF_AV_ID_F3 0x73 /* F3 */ +#define BTIF_AV_ID_F4 0x74 /* F4 */ +#define BTIF_AV_ID_F5 0x75 /* F5 */ +#define BTIF_AV_ID_VENDOR 0x7E /* vendor unique */ +#define BTIF_AV_KEYPRESSED_RELEASE 0x80 + +typedef UINT8 tBTIF_AV_RC; + +/* state flag for pass through command */ +#define BTIF_AV_STATE_PRESS 0 /* key pressed */ +#define BTIF_AV_STATE_RELEASE 1 /* key released */ + +typedef UINT8 tBTIF_AV_STATE; + +typedef UINT8 tBTIF_AV_RC_HNDL; + +/* command codes for BTIF_AvVendorCmd */ +#define BTIF_AV_CMD_CTRL 0 +#define BTIF_AV_CMD_STATUS 1 +#define BTIF_AV_CMD_SPEC_INQ 2 +#define BTIF_AV_CMD_NOTIF 3 +#define BTIF_AV_CMD_GEN_INQ 4 + +typedef UINT8 tBTIF_AV_CMD; + +/* AV callback events */ +#define BTIF_AV_OPEN_EVT 0 /* connection opened */ +#define BTIF_AV_CLOSE_EVT 1 /* connection closed */ +#define BTIF_AV_START_EVT 2 /* stream data transfer started */ +#define BTIF_AV_STOP_EVT 3 /* stream data transfer stopped */ +#define BTIF_AV_RC_OPEN_EVT 4 /* remote control channel open */ +#define BTIF_AV_RC_CLOSE_EVT 5 /* remote control channel closed */ +#define BTIF_AV_REMOTE_CMD_EVT 6 /* remote control command */ +#define BTIF_AV_REMOTE_RSP_EVT 7 /* remote control response */ +#define BTIF_AV_META_MSG_EVT 8 /* metadata messages */ + +typedef UINT8 tBTIF_AV_EVT; + +#define BTIF_AV_FEEDING_ASYNCHRONOUS 0 /* asynchronous feeding, use tx av timer */ +#define BTIF_AV_FEEDING_SYNCHRONOUS 1 /* synchronous feeding, no av tx timer */ + +#define BTIF_AV_MAX_SYNCHRONOUS_LATENCY 80 /* max latency in ms for BTIF_AV_FEEDING_SYNCHRONOUS */ +#define BTIF_AV_MIN_SYNCHRONOUS_LATENCY 4 /* min latency in ms for BTIF_AV_FEEDING_SYNCHRONOUS */ + +typedef UINT8 tBTIF_AV_FEEDING_MODE; + +#define BTIF_AV_CHANNEL_MODE_MONO A2D_SBC_IE_CH_MD_MONO +#define BTIF_AV_CHANNEL_MODE_STEREO A2D_SBC_IE_CH_MD_STEREO +#define BTIF_AV_CHANNEL_MODE_JOINT A2D_SBC_IE_CH_MD_JOINT +#define BTIF_AV_CHANNEL_MODE_DUAL A2D_SBC_IE_CH_MD_DUAL + +typedef UINT8 tBTIF_AV_CHANNEL_MODE; +/* + * Structure used to configure the AV codec capabilities/config + */ +typedef struct +{ + tBTIF_AV_CODEC_ID id; /* Codec ID (in terms of BTIF) */ + UINT8 info[AVDT_CODEC_SIZE]; /* Codec info (can be config or capabilities) */ +} tBTIF_AV_CODEC_INFO; + +/* + * Structure used to configure the AV media feeding + */ +typedef struct +{ + UINT16 sampling_freq; /* 44100, 48000 etc */ + UINT16 num_channel; /* 1 for mono or 2 stereo */ + UINT8 bit_per_sample; /* Number of bits per sample (8, 16) */ +} tBTIF_AV_MEDIA_FEED_CFG_PCM; + + +typedef union +{ + tBTIF_AV_MEDIA_FEED_CFG_PCM pcm; /* raw PCM feeding format */ +}tBTIF_AV_MEDIA_FEED_CFG; + +typedef struct +{ + tBTIF_AV_CODEC_ID format; /* Media codec identifier */ + tBTIF_AV_MEDIA_FEED_CFG cfg; /* Media codec configuration */ +} tBTIF_AV_MEDIA_FEEDINGS; + + +#ifdef __cplusplus +} +#endif + +#endif /* BTIF_AV_API_H */ diff --git a/btif/include/btif_media.h b/btif/include/btif_media.h new file mode 100644 index 0000000..0280d5c --- /dev/null +++ b/btif/include/btif_media.h @@ -0,0 +1,265 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * This program is the proprietary software of Broadcom Corporation and/or its + * licensors, and may only be used, duplicated, modified or distributed + * pursuant to the terms and conditions of a separate, written license + * agreement executed between you and Broadcom (an "Authorized License"). + * Except as set forth in an Authorized License, Broadcom grants no license + * (express or implied), right to use, or waiver of any kind with respect to + * the Software, and Broadcom expressly reserves all rights in and to the + * Software and all intellectual property rights therein. + * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS + * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE + * ALL USE OF THE SOFTWARE. + * + * Except as expressly set forth in the Authorized License, + * + * 1. This program, including its structure, sequence and organization, + * constitutes the valuable trade secrets of Broadcom, and you shall + * use all reasonable efforts to protect the confidentiality thereof, + * and to use this information only in connection with your use of + * Broadcom integrated circuit products. + * + * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED + * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, + * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, + * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY + * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, + * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, + * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR + * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING + * OUT OF USE OR PERFORMANCE OF THE SOFTWARE. + * + * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM + * OR ITS LICENSORS BE LIABLE FOR + * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY + * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO + * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR + * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE + * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE + * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF + * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. + * + *****************************************************************************/ + +/**************************************************************************** + ** + ** Name: btif_media.h + ** + ** Description: This is the audio module for the BTIF system. It contains + ** task implementations of A2DP + ** + ******************************************************************************/ + +#ifndef BTIF_MEDIA_H +#define BTIF_MEDIA_H + +#include "bta_api.h" +#include "bd.h" +#include "gki.h" +#include "btif_av_api.h" + +/* Generic part */ +#define BTIF_SUCCESS 0 + +/* +* AV (Audio Video source) Errors + */ +#define BTIF_ERROR_SRV_AV_NOT_ENABLED 700 /* AV is not enabled */ +#define BTIF_ERROR_SRV_AV_FEEDING_NOT_SUPPORTED 701 /* Requested Feeding not supported */ +#define BTIF_ERROR_SRV_AV_BUSY 702 /* Another operation ongoing */ +#define BTIF_ERROR_SRV_AV_NOT_OPENED 703 /* No AV link opened */ +#define BTIF_ERROR_SRV_AV_NOT_STARTED 704 /* AV is not started */ +#define BTIF_ERROR_SRV_AV_CP_NOT_SUPPORTED 705 /* Content protection is not supported by all headsets */ + +/***************************************************************************** + ** Constants + *****************************************************************************/ + + +/* transcoding definition for TxTranscoding and RxTranscoding */ +#define BTIF_MEDIA_TRSCD_OFF 0 +#define BTIF_MEDIA_TRSCD_PCM_2_SBC 1 /* Tx */ + + +/***************************************************************************** + ** Data types + *****************************************************************************/ + +typedef int tBTIF_STATUS; + +/* tBTIF_MEDIA_INIT_AUDIO msg structure */ +typedef struct +{ + BT_HDR hdr; + UINT16 SamplingFreq; /* 16k, 32k, 44.1k or 48k*/ + UINT8 ChannelMode; /* mono, dual, stereo or joint stereo*/ + UINT8 NumOfSubBands; /* 4 or 8 */ + UINT8 NumOfBlocks; /* 4, 8, 12 or 16*/ + UINT8 AllocationMethod; /* loudness or SNR*/ + UINT16 MtuSize; /* peer mtu size */ +} tBTIF_MEDIA_INIT_AUDIO; + +#if (BTA_AV_INCLUDED == TRUE) +/* tBTIF_MEDIA_UPDATE_AUDIO msg structure */ +typedef struct +{ + BT_HDR hdr; + UINT16 MinMtuSize; /* Minimum peer mtu size */ + UINT8 MaxBitPool; /* Maximum peer bitpool */ + UINT8 MinBitPool; /* Minimum peer bitpool */ +} tBTIF_MEDIA_UPDATE_AUDIO; + +/* tBTIF_MEDIA_INIT_AUDIO_FEEDING msg structure */ +typedef struct +{ + BT_HDR hdr; + tBTIF_AV_FEEDING_MODE feeding_mode; + tBTIF_AV_MEDIA_FEEDINGS feeding; +} tBTIF_MEDIA_INIT_AUDIO_FEEDING; +#endif + + +/***************************************************************************** + ** Local data + *****************************************************************************/ + +/***************************************************************************** + ** public functions + *****************************************************************************/ + +/******************************************************************************* + ** + ** Function btif_av_task + ** + ** Description + ** + ** Returns void + ** + *******************************************************************************/ +extern int btif_media_task(void *p); + + +/******************************************************************************* + ** + ** Function btif_media_task_enc_init_req + ** + ** Description Request to initialize the media task encoder + ** + ** Returns TRUE is success + ** + *******************************************************************************/ +extern BOOLEAN btif_media_task_enc_init_req(tBTIF_MEDIA_INIT_AUDIO * p_msg); + +/******************************************************************************* + ** + ** Function btif_media_task_enc_update_req + ** + ** Description Request to update the media task encoder + ** + ** Returns TRUE is success + ** + *******************************************************************************/ +#if (BTA_AV_INCLUDED == TRUE) +extern BOOLEAN btif_media_task_enc_update_req(tBTIF_MEDIA_UPDATE_AUDIO * p_msg); +#endif +/******************************************************************************* + ** + ** Function btif_media_task_start_aa_req + ** + ** Description Request to start audio encoding task + ** + ** Returns TRUE is success + ** + *******************************************************************************/ +extern BOOLEAN btif_media_task_start_aa_req(void); + +/******************************************************************************* + ** + ** Function btif_media_task_stop_aa_req + ** + ** Description Request to stop audio encoding task + ** + ** Returns TRUE is success + ** + *******************************************************************************/ +extern BOOLEAN btif_media_task_stop_aa_req(void); + + +/******************************************************************************* + ** + ** Function btif_media_task_aa_tx_flush_req + ** + ** Description Request to flush audio encoding pipe + ** + ** Returns TRUE is success + ** + *******************************************************************************/ +extern BOOLEAN btif_media_task_aa_tx_flush_req(void); + +/******************************************************************************* + ** + ** Function btif_media_aa_readbuf + ** + ** Description Read an audio GKI buffer from the BTIF media TX queue + ** + ** Returns pointer on a GKI aa buffer ready to send + ** + *******************************************************************************/ +extern BT_HDR *btif_media_aa_readbuf(void); + +/******************************************************************************* + ** + ** Function btif_media_aa_writebuf + ** + ** Description Enqueue a Advance Audio media GKI buffer to be processed by btif media task. + ** + ** Returns TRUE is success + ** + *******************************************************************************/ +extern void btif_media_aa_writebuf(BT_HDR *pBuf, UINT32 timestamp, UINT16 seq_num); + +/******************************************************************************* + ** + ** Function btif_media_av_writebuf + ** + ** Description Enqueue a video media GKI buffer to be processed by btif media task. + ** + ** Returns TRUE is success + ** + *******************************************************************************/ +extern BOOLEAN btif_media_av_writebuf(UINT8 *p_media, UINT32 media_len, + UINT32 timestamp, UINT16 seq_num); + +#if (BTA_AV_INCLUDED == TRUE) + +/******************************************************************************* + ** + ** Function btif_media_task_audio_feeding_init_req + ** + ** Description Request to initialize audio feeding + ** + ** Returns TRUE is success + ** + *******************************************************************************/ + +extern BOOLEAN btif_media_task_audio_feeding_init_req(tBTIF_MEDIA_INIT_AUDIO_FEEDING *p_msg); +#endif + + +/******************************************************************************* + ** + ** Function dump_codec_info + ** + ** Description Decode and display codec_info (for debug) + ** + ** Returns void + ** + *******************************************************************************/ +extern void dump_codec_info(unsigned char *p_codec); + +#endif + diff --git a/btif/include/btif_sm.h b/btif/include/btif_sm.h new file mode 100644 index 0000000..f4d5ede --- /dev/null +++ b/btif/include/btif_sm.h @@ -0,0 +1,158 @@ +/****************************************************************************** + * + * Copyright (C) 2009-2012 Broadcom Corporation + * + * This program is the proprietary software of Broadcom Corporation and/or its + * licensors, and may only be used, duplicated, modified or distributed + * pursuant to the terms and conditions of a separate, written license + * agreement executed between you and Broadcom (an "Authorized License"). + * Except as set forth in an Authorized License, Broadcom grants no license + * (express or implied), right to use, or waiver of any kind with respect to + * the Software, and Broadcom expressly reserves all rights in and to the + * Software and all intellectual property rights therein. + * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS + * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE + * ALL USE OF THE SOFTWARE. + * + * Except as expressly set forth in the Authorized License, + * + * 1. This program, including its structure, sequence and organization, + * constitutes the valuable trade secrets of Broadcom, and you shall + * use all reasonable efforts to protect the confidentiality thereof, + * and to use this information only in connection with your use of + * Broadcom integrated circuit products. + * + * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED + * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, + * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, + * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY + * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, + * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, + * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR + * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING + * OUT OF USE OR PERFORMANCE OF THE SOFTWARE. + * + * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM + * OR ITS LICENSORS BE LIABLE FOR + * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY + * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO + * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR + * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE + * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE + * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF + * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. + * + *****************************************************************************/ + +/***************************************************************************** + * + * Filename: btif_sm.h + * + * Description: Generic BTIF state machine API + * + *****************************************************************************/ + +#ifndef BTIF_SM_H +#define BTIF_SM_H + +/***************************************************************************** +** Constants & Macros +******************************************************************************/ + +/***************************************************************************** +** Type definitions and return values +******************************************************************************/ +typedef UINT32 btif_sm_state_t; +typedef UINT32 btif_sm_event_t; +typedef void* btif_sm_handle_t; +typedef BOOLEAN(*btif_sm_handler_t)(btif_sm_event_t event, void *data); + +/* Generic Enter/Exit state machine events */ +#define BTIF_SM_ENTER_EVT 0xFFFF +#define BTIF_SM_EXIT_EVT 0xFFFE + +/***************************************************************************** +** Extern variables and functions +******************************************************************************/ + +/***************************************************************************** +** Functions +******************************************************************************/ + +/* + * + * ######################################################################## + * + * NOTE: THESE APIs SHOULD BE INVOKED ONLY IN THE BTIF CONTEXT + * + * ####################################################################### + * + */ + +/***************************************************************************** +** +** Function btif_sm_init +** +** Description Initializes the state machine with the state handlers +** The caller should ensure that the table and the corresponding +** states match. The location that 'p_handlers' points to shall +** be available until the btif_sm_shutdown API is invoked. +** +** Returns Returns a pointer to the initialized state machine handle. +** +******************************************************************************/ +btif_sm_handle_t btif_sm_init(const btif_sm_handler_t *p_handlers, + btif_sm_state_t initial_state); + +/***************************************************************************** +** +** Function btif_sm_shutdown +** +** Description Tears down the state machine +** +** Returns None +** +******************************************************************************/ +void btif_sm_shutdown(btif_sm_handle_t handle); + +/***************************************************************************** +** +** Function btif_sm_get_state +** +** Description Fetches the current state of the state machine +** +** Returns Current state +** +******************************************************************************/ +btif_sm_state_t btif_sm_get_state(btif_sm_handle_t handle); + +/***************************************************************************** +** +** Function btif_sm_dispatch +** +** Description Dispatches the 'event' along with 'data' to the current state handler +** +** Returns Returns BT_STATUS_OK on success, BT_STATUS_FAIL otherwise +** +******************************************************************************/ +bt_status_t btif_sm_dispatch(btif_sm_handle_t handle, btif_sm_event_t event, + void *data); + +/***************************************************************************** +** +** Function btif_sm_change_state +** +** Description Make a transition to the new 'state'. The 'BTIF_SM_EXIT_EVT' +** shall be invoked before exiting the current state. The +** 'BTIF_SM_ENTER_EVT' shall be invoked before entering the new state +** +** +** Returns Returns BT_STATUS_OK on success, BT_STATUS_FAIL otherwise +** +******************************************************************************/ +bt_status_t btif_sm_change_state(btif_sm_handle_t handle, btif_sm_state_t state); + +#endif /* BTIF_SM_H */ + + diff --git a/btif/include/btif_util.h b/btif/include/btif_util.h index 95a1279..d455e9e 100644 --- a/btif/include/btif_util.h +++ b/btif/include/btif_util.h @@ -94,6 +94,8 @@ const char* dump_hf_audio_state(UINT16 event); const char* dump_adapter_scan_mode(bt_scan_mode_t mode); const char* dump_thread_evt(bt_cb_thread_evt evt); +const char* dump_av_conn_state(UINT16 event); + int str2bd(char *str, bt_bdaddr_t *addr); char *bd2str(bt_bdaddr_t *addr, bdstr_t *bdstr); |