Merge 539575f907757ee3f81266f477c111cf0bc61b76 on remote branch
Change-Id: I925b85c1732bfc73f16edcd503b208f2b80b7f06
diff --git a/bthost_ipc/bthost_ipc.c b/bthost_ipc/bthost_ipc.c
index ee28ba2..7691ecf 100644
--- a/bthost_ipc/bthost_ipc.c
+++ b/bthost_ipc/bthost_ipc.c
@@ -108,6 +108,7 @@
audio_sbc_encoder_config_t sbc_codec;
audio_aptx_encoder_config_t aptx_codec;
+audio_aptx_adaptive_encoder_config_t aptx_adaptive_codec;
audio_aptx_tws_encoder_config_t aptx_tws_codec;
audio_aac_encoder_config_t aac_codec;
audio_ldac_encoder_config_t ldac_codec;
@@ -412,6 +413,98 @@
*codec_type = AUDIO_FORMAT_APTX_HD;
}
+ if (codec_cfg[VENDOR_ID_OFFSET] == VENDOR_APTX_ADAPTIVE &&
+ codec_cfg[CODEC_ID_OFFSET] == APTX_ADAPTIVE_CODEC_ID)
+ {
+ ALOGW("AptX-Adaptive codec");
+ *codec_type = ENC_CODEC_TYPE_APTX_ADAPTIVE;
+
+ memset(&aptx_adaptive_codec, 0, sizeof(audio_aptx_adaptive_encoder_config_t));
+ p_cfg++; //skip dev_idx
+ len = *p_cfg++;//LOSC
+ p_cfg++; // Skip media type
+ len--;
+ p_cfg++; //codec_type
+ len--;
+ p_cfg+=4;//skip vendor id
+ len -= 4;
+ p_cfg += 2; //skip codec id
+ len -= 2;
+
+ switch(*p_cfg++ & A2D_APTX_ADAPTIVE_SAMP_FREQ_MASK)
+ {
+ case A2DP_APTX_ADAPTIVE_SAMPLERATE_44100:
+ aptx_adaptive_codec.sampling_rate = 0x2;
+ if(sample_freq) *sample_freq = 44100;
+ break;
+ case A2DP_APTX_ADAPTIVE_SAMPLERATE_48000:
+ aptx_adaptive_codec.sampling_rate = 0x1;
+ if(sample_freq) *sample_freq = 48000;
+ break;
+ case A2DP_APTX_ADAPTIVE_SAMPLERATE_88000:
+ aptx_adaptive_codec.sampling_rate = 0;
+ break;
+ case A2DP_APTX_ADAPTIVE_SAMPLERATE_192000:
+ aptx_adaptive_codec.sampling_rate = 0;
+ break;
+ default:
+ ALOGE("Unknown sampling rate");
+ }
+ len--;
+
+ switch(*p_cfg++ & A2D_APTX_ADAPTIVE_CHAN_MASK)
+ {
+ case A2DP_APTX_ADAPTIVE_CHANNELS_MONO:
+ aptx_adaptive_codec.channel_mode = 1;
+ break;
+ /*case A2DP_APTX_ADAPTIVE_CHANNELS_STEREO:
+ aptx_adaptive_codec.channel_mode = 2;
+ break;*/
+ case A2DP_APTX_ADAPTIVE_CHANNELS_JOINT_STEREO:
+ aptx_adaptive_codec.channel_mode = 0;
+ break;
+ case A2DP_APTX_ADAPTIVE_CHANNELS_TWS_STEREO:
+ aptx_adaptive_codec.channel_mode = 4;
+ break;
+ default:
+ ALOGE("Unknown sampling rate");
+ }
+ len--;
+
+ aptx_adaptive_codec.min_sink_buffering_LL = 20; // gghai temp setting to default value
+ aptx_adaptive_codec.max_sink_buffering_LL = 50;
+ aptx_adaptive_codec.min_sink_buffering_HQ = 20;
+ aptx_adaptive_codec.max_sink_buffering_HQ = 50;
+ aptx_adaptive_codec.min_sink_buffering_TWS = 20;
+ aptx_adaptive_codec.max_sink_buffering_TWS = 50;
+
+ aptx_adaptive_codec.TTP_LL_low = *(p_cfg ++);
+ aptx_adaptive_codec.TTP_LL_high = *(p_cfg ++);
+ aptx_adaptive_codec.TTP_HQ_low = *(p_cfg ++);
+ aptx_adaptive_codec.TTP_HQ_high = *(p_cfg ++);
+ aptx_adaptive_codec.TTP_TWS_low = *(p_cfg ++);
+ aptx_adaptive_codec.TTP_TWS_high = *(p_cfg ++);
+ len -= 6;
+
+ p_cfg += 3; // ignoring eoc bits
+ len -= 3;
+ ALOGW("%s: ## aptXAdaptive ## sampleRate 0x%x", __func__, aptx_adaptive_codec.sampling_rate);
+ ALOGW("%s: ## aptXAdaptive ## channelMode 0x%x", __func__, aptx_adaptive_codec.channel_mode);
+ ALOGW("%s: ## aptXAdaptive ## ttp_ll_0 0x%x", __func__, aptx_adaptive_codec.TTP_LL_low);
+ ALOGW("%s: ## aptXAdaptive ## ttp_ll_1 0x%x", __func__, aptx_adaptive_codec.TTP_LL_high);
+ ALOGW("%s: ## aptXAdaptive ## ttp_hq_0 0x%x", __func__, aptx_adaptive_codec.TTP_HQ_low);
+ ALOGW("%s: ## aptXAdaptive ## ttp_hq_1 0x%x", __func__, aptx_adaptive_codec.TTP_HQ_high);
+ ALOGW("%s: ## aptXAdaptive ## ttp_tws_0 0x%x", __func__, aptx_adaptive_codec.TTP_TWS_low);
+ ALOGW("%s: ## aptXAdaptive ## ttp_tws_1 0x%x", __func__, aptx_adaptive_codec.TTP_TWS_high);
+
+ if(len == 0)
+ ALOGW("%s: codec config copied", __func__);
+ else
+ ALOGW("%s: codec config length error: %d", __func__, len);
+
+ return ((void *)&aptx_adaptive_codec);
+ }
+
if (vendor_ldac_id == VENDOR_LDAC &&
codec_cfg[CODEC_ID_OFFSET] == LDAC_CODEC_ID)
{
@@ -1412,6 +1505,7 @@
ALOGE("Error in fetching persist.vendor.bluetooth.soc.scram_freqs property");
return false;
}
+ ALOGE("scram_freqs Prop value = %s", value);
pthread_mutex_lock(&audio_stream.lock);
for (i = 0; i < STREAM_START_MAX_RETRY_COUNT; i++)
@@ -1433,6 +1527,12 @@
pthread_mutex_unlock(&audio_stream.lock);
return false;
}
+ if (codec_type == ENC_CODEC_TYPE_APTX_ADAPTIVE) {
+ ALOGW("%s:aptX Adaptive codec, return false",__func__);
+ pthread_mutex_unlock(&audio_stream.lock);
+ return false;
+ }
+
if(status == A2DP_CTRL_ACK_SUCCESS) {
if (codec_type == CODEC_TYPE_CELT) {
diff --git a/bthost_ipc/bthost_ipc.h b/bthost_ipc/bthost_ipc.h
index a962c0d..5d81bbf 100644
--- a/bthost_ipc/bthost_ipc.h
+++ b/bthost_ipc/bthost_ipc.h
@@ -124,6 +124,7 @@
*/
#define AUDIO_CODEC_TYPE_CELT 603979776u // 0x24000000UL
#define ENC_CODEC_TYPE_APTX_DUAL_MONO 570425344u // 0x22000000UL
+#define ENC_CODEC_TYPE_APTX_ADAPTIVE 620756992u // 0x25000000UL
#define CODEC_TYPE_SBC 0x00
#define CODEC_TYPE_AAC 0x02
#define CODEC_TYPE_CELT 0xEF
@@ -139,6 +140,9 @@
#ifndef VENDOR_APTX_HD
#define VENDOR_APTX_HD 0xD7
#endif
+#ifndef VENDOR_APTX_ADAPTIVE
+#define VENDOR_APTX_ADAPTIVE 0xD7
+#endif
#ifndef VENDOR_APTX_LL
#define VENDOR_APTX_LL 0x0A
#endif
@@ -148,6 +152,9 @@
#ifndef APTX_HD_CODEC_ID
#define APTX_HD_CODEC_ID 0x24
#endif
+#ifndef APTX_ADAPTIVE_CODEC_ID
+#define APTX_ADAPTIVE_CODEC_ID 0xAD
+#endif
#ifndef APTX_TWS_CODEC_ID
#define APTX_TWS_CODEC_ID 0x25
#endif
@@ -192,6 +199,19 @@
#define A2D_APTX_CHAN_MONO 0x01
#define A2D_APTX_TWS_CHAN_MODE 0x08
+/* APTX Adaptive bitmask helper */
+#define A2D_APTX_ADAPTIVE_SAMP_FREQ_MASK (0xF8)
+#define A2D_APTX_ADAPTIVE_CHAN_MASK (0x0F)
+#define A2DP_APTX_ADAPTIVE_SAMPLERATE_44100 (0x08)
+#define A2DP_APTX_ADAPTIVE_SAMPLERATE_48000 (0x10)
+#define A2DP_APTX_ADAPTIVE_SAMPLERATE_88000 (0x20)
+#define A2DP_APTX_ADAPTIVE_SAMPLERATE_192000 (0x40)
+#define A2DP_APTX_ADAPTIVE_CHANNELS_MONO (0x01)
+#define A2DP_APTX_ADAPTIVE_CHANNELS_STEREO (0x02)
+#define A2DP_APTX_ADAPTIVE_CHANNELS_TWS_STEREO (0x04)
+#define A2DP_APTX_ADAPTIVE_CHANNELS_JOINT_STEREO (0x08)
+#define A2DP_APTX_ADAPTIVE_CHANNELS_TWS_MONO (0x10)
+
/* LDAC bitmask helper */
#define A2D_LDAC_SAMP_FREQ_MASK 0x3F
@@ -271,6 +291,29 @@
uint32_t bitrate;
} audio_aptx_encoder_config_t;
+/* Information about BT APTX Adaptive encoder
+ * configuration. This data is used between audio HAL
+ * module and BT IPC library to configure DSP encoder
+ */
+
+typedef struct {
+ uint8_t sampling_rate;
+ uint8_t channel_mode;
+ uint16_t mtu;
+ uint8_t min_sink_buffering_LL;
+ uint8_t max_sink_buffering_LL;
+ uint8_t min_sink_buffering_HQ;
+ uint8_t max_sink_buffering_HQ;
+ uint8_t min_sink_buffering_TWS;
+ uint8_t max_sink_buffering_TWS;
+ uint8_t TTP_LL_low;
+ uint8_t TTP_LL_high;
+ uint8_t TTP_HQ_low;
+ uint8_t TTP_HQ_high;
+ uint8_t TTP_TWS_low;
+ uint8_t TTP_TWS_high;
+} audio_aptx_adaptive_encoder_config_t;
+
struct bit_rate_level_map_t {
uint32_t link_quality_level;
uint32_t bitrate;
diff --git a/tools/btconfig/btconfig.c b/tools/btconfig/btconfig.c
index 2963040..13728d6 100644
--- a/tools/btconfig/btconfig.c
+++ b/tools/btconfig/btconfig.c
@@ -6795,7 +6795,7 @@
{
int iRet;
UCHAR resultBuf[MAX_EVENT_SIZE];
- if (!strcasecmp(soc_type, "smd")){
+ if (!strcasecmp(soc_type, "pronto")){
UCHAR buf[5] = {(unsigned char)0x10, (unsigned char)0x02,( unsigned char)0x0,(unsigned char) 0x0,( unsigned char)0x01 };
iRet = hci_send_cmd( fd, HCI_VENDOR_CMD_OGF, 0x17, 5, buf);
}
@@ -6833,8 +6833,7 @@
}
#ifdef ANDROID
- property_get("ro.vendor.qti.bt.hci_transport", prop, NULL);
- property_get("vendor.qti.bluetooth.soc", soc_type, NULL);
+ property_get("vendor.qcom.bluetooth.soc", soc_type, "pronto");
#endif
if((!strcasecmp(soc_type, "rome")) || (!strcasecmp(soc_type, "cherokee")))
@@ -6851,7 +6850,7 @@
exit(0);
}
- if (!strcasecmp(prop, "smd")) {
+ if (!strcasecmp(soc_type, "pronto")) {
printf("SOC is WCN\n");
fd = wcn_init_smd(argv[optind]);