system/bt
Revision | 386994eb81029f73055da4cad2093d6add1cc234 (tree) |
---|---|
Time | 2016-10-03 18:36:39 |
Author | Linux Build Service Account <lnxbuild@loca...> |
Commiter | Gerrit - the friendly Code Review server |
Merge "Bluetooth: split-a2dp: APTx-HD support" into bt.lnx.2.1-dev
@@ -421,8 +421,10 @@ static void* a2dp_codec_parser(uint8_t *codec_cfg, audio_format_t *codec_type) | ||
421 | 421 | default: |
422 | 422 | ERROR("Unknown channel mode"); |
423 | 423 | } |
424 | - if (*codec_type == AUDIO_FORMAT_APTX_HD) | |
424 | + if (*codec_type == AUDIO_FORMAT_APTX_HD) { | |
425 | + p_cfg += 4; | |
425 | 426 | len -= 4;//ignore 4 bytes not used |
427 | + } | |
426 | 428 | if (len == 0) |
427 | 429 | INFO("Codec config copied"); |
428 | 430 |
@@ -80,7 +80,7 @@ enum | ||
80 | 80 | { |
81 | 81 | APTX = 1, |
82 | 82 | AAC, |
83 | - APTX_HD | |
83 | + APTXHD | |
84 | 84 | }; |
85 | 85 | |
86 | 86 | /* state machine states */ |
@@ -709,19 +709,36 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data) | ||
709 | 709 | { |
710 | 710 | if((*bta_av_a2d_cos.cap)(APTX) != TRUE) |
711 | 711 | { |
712 | + APPL_TRACE_DEBUG("%s: aptx-Classic offload codec not supported",__func__); | |
712 | 713 | index++; |
713 | 714 | continue; |
714 | 715 | } |
715 | 716 | else |
716 | - APPL_TRACE_DEBUG("%s:codec supported",__func__) | |
717 | + APPL_TRACE_DEBUG("%s:aptx-Classic offload codec supported",__func__) | |
718 | + } else { | |
719 | + if (codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH && | |
720 | + vendorId == A2D_APTX_HD_VENDOR_ID ) { | |
721 | + if((*bta_av_a2d_cos.cap)(APTXHD) != TRUE) | |
722 | + { | |
723 | + APPL_TRACE_DEBUG("%s: aptx-HD offload codec not supported",__func__) | |
724 | + index++; | |
725 | + continue; | |
726 | + } | |
727 | + else | |
728 | + APPL_TRACE_DEBUG("%s: aptx-HD offload codec supported",__func__) | |
729 | + | |
730 | + } | |
717 | 731 | } |
718 | 732 | } |
719 | 733 | else if (codec_type == AAC) |
720 | 734 | { |
721 | 735 | if ((*bta_av_a2d_cos.cap)(AAC) != TRUE) |
722 | 736 | { |
737 | + APPL_TRACE_DEBUG("%s: AAC offload codec not supported",__func__); | |
723 | 738 | index++; |
724 | 739 | continue; |
740 | + } else { | |
741 | + APPL_TRACE_DEBUG("%s: AAC offload codec supported",__func__); | |
725 | 742 | } |
726 | 743 | } |
727 | 744 | } else if (codec_type == A2D_NON_A2DP_MEDIA_CT) { |
@@ -122,9 +122,10 @@ const tA2D_SBC_CIE bta_av_co_sbc_sink_caps = | ||
122 | 122 | #endif |
123 | 123 | |
124 | 124 | /* A2dp offload capabilities */ |
125 | -#define SBC 0 | |
126 | -#define APTX 1 | |
127 | -#define AAC 2 | |
125 | +#define SBC 0 | |
126 | +#define APTX 1 | |
127 | +#define AAC 2 | |
128 | +#define APTXHD 3 | |
128 | 129 | /* Default SBC codec configuration */ |
129 | 130 | const tA2D_SBC_CIE btif_av_sbc_default_config = |
130 | 131 | { |
@@ -170,7 +171,11 @@ const tA2D_APTX_HD_CIE bta_av_co_aptx_hd_caps = | ||
170 | 171 | { |
171 | 172 | A2D_APTX_HD_VENDOR_ID, |
172 | 173 | A2D_APTX_HD_CODEC_ID_BLUETOOTH, |
174 | +#ifndef BTA_AV_SPLIT_A2DP_DEF_FREQ_48KHZ | |
173 | 175 | A2D_APTX_HD_SAMPLERATE_44100, |
176 | +#else | |
177 | + A2D_APTX_HD_SAMPLERATE_48000, | |
178 | +#endif | |
174 | 179 | A2D_APTX_HD_CHANNELS_STEREO, |
175 | 180 | A2D_APTX_HD_ACL_SPRINT_RESERVED0, |
176 | 181 | A2D_APTX_HD_ACL_SPRINT_RESERVED1, |
@@ -183,7 +188,11 @@ const tA2D_APTX_HD_CIE btif_av_aptx_hd_default_config = | ||
183 | 188 | { |
184 | 189 | A2D_APTX_HD_VENDOR_ID, |
185 | 190 | A2D_APTX_HD_CODEC_ID_BLUETOOTH, |
191 | +#ifndef BTA_AV_SPLIT_A2DP_DEF_FREQ_48KHZ | |
186 | 192 | A2D_APTX_HD_SAMPLERATE_44100, |
193 | +#else | |
194 | + A2D_APTX_HD_SAMPLERATE_48000, | |
195 | +#endif | |
187 | 196 | A2D_APTX_HD_CHANNELS_STEREO, |
188 | 197 | A2D_APTX_HD_ACL_SPRINT_RESERVED0, |
189 | 198 | A2D_APTX_HD_ACL_SPRINT_RESERVED1, |
@@ -1698,13 +1707,13 @@ static BOOLEAN bta_av_co_audio_peer_supports_codec(tBTA_AV_CO_PEER *p_peer, UINT | ||
1698 | 1707 | * multicast is not supported for aptX |
1699 | 1708 | */ |
1700 | 1709 | if ((!bt_split_a2dp_enabled && isA2dAptXEnabled && (btif_av_is_multicast_supported() == FALSE)) || |
1701 | - (bt_split_a2dp_enabled && btif_av_is_codec_offload_supported(APTX))) | |
1710 | + (bt_split_a2dp_enabled && (btif_av_is_codec_offload_supported(APTX)|| btif_av_is_codec_offload_supported(APTXHD)))) | |
1702 | 1711 | { |
1703 | 1712 | UINT16 codecId; |
1704 | 1713 | UINT32 vendorId; |
1705 | 1714 | UINT8* aptx_capabilities; |
1706 | 1715 | |
1707 | - if (isA2dAptXHdEnabled) { | |
1716 | + if ((bt_split_a2dp_enabled && btif_av_is_codec_offload_supported(APTXHD)) || isA2dAptXHdEnabled) { | |
1708 | 1717 | for (index = 0; index < p_peer->num_sup_snks; index++) |
1709 | 1718 | { |
1710 | 1719 | if (p_peer->snks[index].codec_type == A2D_NON_A2DP_MEDIA_CT) |
@@ -117,12 +117,14 @@ typedef struct | ||
117 | 117 | BOOLEAN sbc_offload; |
118 | 118 | BOOLEAN aptx_offload; |
119 | 119 | BOOLEAN aac_offload; |
120 | + BOOLEAN aptxhd_offload; | |
120 | 121 | } btif_av_a2dp_offloaded_codec_cap_t; |
121 | 122 | |
122 | 123 | typedef enum { |
123 | 124 | SBC, |
124 | 125 | APTX, |
125 | 126 | AAC, |
127 | + APTXHD, | |
126 | 128 | }btif_av_codec_list; |
127 | 129 | |
128 | 130 | /***************************************************************************** |
@@ -299,6 +301,7 @@ const char *dump_av_codec_name(btif_av_codec_list codec) | ||
299 | 301 | CASE_RETURN_STR(SBC) |
300 | 302 | CASE_RETURN_STR(APTX) |
301 | 303 | CASE_RETURN_STR(AAC) |
304 | + CASE_RETURN_STR(APTXHD) | |
302 | 305 | default: return "UNKNOWN_CODEC"; |
303 | 306 | } |
304 | 307 | } |
@@ -2247,6 +2250,11 @@ static void a2dp_offload_codec_cap_parser(const char *value) | ||
2247 | 2250 | BTIF_TRACE_ERROR("%s: AAC offload supported",__func__); |
2248 | 2251 | btif_av_codec_offload.aac_offload = TRUE; |
2249 | 2252 | } |
2253 | + else if (strcmp(tok,"aptxhd") == 0) | |
2254 | + { | |
2255 | + BTIF_TRACE_ERROR("%s: APTXHD offload supported",__func__); | |
2256 | + btif_av_codec_offload.aptxhd_offload = TRUE; | |
2257 | + } | |
2250 | 2258 | tok = strtok_r(NULL, "-", &tmp_token); |
2251 | 2259 | }; |
2252 | 2260 | } |
@@ -3645,10 +3653,13 @@ BOOLEAN btif_av_is_codec_offload_supported(int codec) | ||
3645 | 3653 | case AAC: |
3646 | 3654 | ret = btif_av_codec_offload.aac_offload; |
3647 | 3655 | break; |
3656 | + case APTXHD: | |
3657 | + ret = btif_av_codec_offload.aptxhd_offload; | |
3658 | + break; | |
3648 | 3659 | default: |
3649 | 3660 | ret = FALSE; |
3650 | 3661 | } |
3651 | - BTIF_TRACE_DEBUG("btif_av_is_codec_offload_supported %s code supported = %d",dump_av_codec_name(codec),ret); | |
3662 | + BTIF_TRACE_DEBUG("btif_av_is_codec_offload_supported %s codec supported = %d",dump_av_codec_name(codec),ret); | |
3652 | 3663 | return ret; |
3653 | 3664 | } |
3654 | 3665 |
@@ -4312,6 +4312,8 @@ static void btif_media_send_aa_frame(uint64_t timestamp_us) | ||
4312 | 4312 | #define A2DP_CODEC_AAC 2 |
4313 | 4313 | /* Below type is not defined in spec, it is for our convenience */ |
4314 | 4314 | #define A2DP_CODEC_APTX 8 |
4315 | + | |
4316 | +#define A2DP_CODEC_APTX_HD 9 | |
4315 | 4317 | /* Need to check if we need a different type for APTX low latency |
4316 | 4318 | * or just we can handle with reducing the MTU updated in media |
4317 | 4319 | * channel configuration. |
@@ -4324,6 +4326,7 @@ static void btif_media_send_aa_frame(uint64_t timestamp_us) | ||
4324 | 4326 | #define A2DP_TRANSPORT_STREAM_TYPE_SBC 0 |
4325 | 4327 | #define A2DP_TRANSPORT_STREAM_TYPE_AAC 2 |
4326 | 4328 | #define A2DP_TRANSPORT_STREAM_TYPE_APTX 8 |
4329 | +#define A2DP_TRANSPORT_STREAM_TYPE_APTX_HD 9 | |
4327 | 4330 | |
4328 | 4331 | void disconnect_a2dp_on_vendor_start_failure() |
4329 | 4332 | { |
@@ -4506,8 +4509,16 @@ BOOLEAN btif_media_send_vendor_selected_codec() | ||
4506 | 4509 | UINT16 index = 0; |
4507 | 4510 | |
4508 | 4511 | codec_type = bta_av_co_get_current_codec(); |
4509 | - if (codec_type == A2D_NON_A2DP_MEDIA_CT) | |
4510 | - codec_type = A2DP_CODEC_APTX; | |
4512 | + if (codec_type == A2D_NON_A2DP_MEDIA_CT) { | |
4513 | + UINT8* ptr = bta_av_co_get_current_codecInfo(); | |
4514 | + if (ptr) { | |
4515 | + tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[BTA_AV_CFG_START_IDX]; | |
4516 | + if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH) | |
4517 | + codec_type = A2DP_CODEC_APTX; | |
4518 | + else if (codecInfo && codecInfo->vendorId == A2D_APTX_HD_VENDOR_ID && codecInfo->codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH) | |
4519 | + codec_type = A2DP_CODEC_APTX_HD; | |
4520 | + } | |
4521 | + } | |
4511 | 4522 | |
4512 | 4523 | APPL_TRACE_IMP("btif_media_send_selected_codec: codec: %d", codec_type); |
4513 | 4524 | param[index++] = VS_QHCI_A2DP_SELECTED_CODEC; |
@@ -4566,8 +4577,18 @@ BOOLEAN btif_media_send_vendor_transport_cfg() | ||
4566 | 4577 | UINT8 stream_type; |
4567 | 4578 | APPL_TRACE_IMP("btif_media_send_vendor_transport_cfg: codec: %d", codec_type); |
4568 | 4579 | stream_type = codec_type; |
4569 | - if (codec_type == A2D_NON_A2DP_MEDIA_CT) | |
4570 | - stream_type = A2DP_TRANSPORT_STREAM_TYPE_APTX; | |
4580 | + | |
4581 | + if (codec_type == A2D_NON_A2DP_MEDIA_CT) { | |
4582 | + UINT8* ptr = bta_av_co_get_current_codecInfo(); | |
4583 | + if (ptr) { | |
4584 | + tA2D_APTX_CIE* codecInfo = (tA2D_APTX_CIE*) &ptr[BTA_AV_CFG_START_IDX]; | |
4585 | + if (codecInfo && codecInfo->vendorId == A2D_APTX_VENDOR_ID && codecInfo->codecId == A2D_APTX_CODEC_ID_BLUETOOTH) | |
4586 | + stream_type = A2DP_TRANSPORT_STREAM_TYPE_APTX; | |
4587 | + else if (codecInfo && codecInfo->vendorId == A2D_APTX_HD_VENDOR_ID && codecInfo->codecId == A2D_APTX_HD_CODEC_ID_BLUETOOTH) | |
4588 | + stream_type = A2DP_TRANSPORT_STREAM_TYPE_APTX_HD; | |
4589 | + } | |
4590 | + } | |
4591 | + | |
4571 | 4592 | param[0] = VS_QHCI_A2DP_TRANSPORT_CONFIGURATION; |
4572 | 4593 | param[1] = A2DP_TRANSPORT_TYPE_SLIMBUS; |
4573 | 4594 | param[2] = stream_type; |