hal: update structure packing for decoders
- SBC decoder config is not properly extracted
in dai driver. Updating the structure packing
to properly extract the fields.
- Updating AFE sample rate for SBC decoder.
Change-Id: Ib708345fadaf091ab2bb6b311e7424fecca47169
diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c
index 5f8a7f4..a169527 100644
--- a/hal/audio_extn/a2dp.c
+++ b/hal/audio_extn/a2dp.c
@@ -214,28 +214,22 @@
uint32_t sample_rate;
} __attribute__ ((packed));
-/* Information about BT AAC decoder configuration
- * This data is used between audio HAL module and
- * BT IPC library to configure DSP decoder
- */
-typedef struct {
+typedef struct audio_aac_decoder_config_t audio_aac_decoder_config_t;
+struct audio_aac_decoder_config_t {
uint16_t aac_fmt_flag; /* LATM*/
uint16_t audio_object_type; /* LC */
uint16_t channels; /* Stereo */
uint16_t total_size_of_pce_bits; /* 0 - only for channel conf PCE */
uint32_t sampling_rate; /* 8k, 11.025k, 12k, 16k, 22.05k, 24k, 32k,
44.1k, 48k, 64k, 88.2k, 96k */
-} audio_aac_decoder_config_t;
+} __attribute__ ((packed));
-/* Information about BT SBC decoder configuration
- * This data is used between audio HAL module and
- * BT IPC library to configure DSP decoder
- */
-typedef struct {
+typedef struct audio_sbc_decoder_config_t audio_sbc_decoder_config_t;
+struct audio_sbc_decoder_config_t {
uint16_t channels; /* Mono, Stereo */
uint32_t sampling_rate; /* 8k, 11.025k, 12k, 16k, 22.05k, 24k, 32k,
44.1k, 48k, 64k, 88.2k, 96k */
-} audio_sbc_decoder_config_t;
+} __attribute__ ((packed));
/* AAC decoder configuration structure. */
typedef struct aac_dec_cfg_t aac_dec_cfg_t;
@@ -415,6 +409,29 @@
uint16_t mtu; /*679*/
} audio_ldac_encoder_config;
+/* Information about BT AAC decoder configuration
+ * This data is used between audio HAL module and
+ * BT IPC library to configure DSP decoder
+ */
+typedef struct {
+ uint16_t aac_fmt_flag; /* LATM*/
+ uint16_t audio_object_type; /* LC */
+ uint16_t channels; /* Stereo */
+ uint16_t total_size_of_pce_bits; /* 0 - only for channel conf PCE */
+ uint32_t sampling_rate; /* 8k, 11.025k, 12k, 16k, 22.05k, 24k, 32k,
+ 44.1k, 48k, 64k, 88.2k, 96k */
+} audio_aac_dec_config_t;
+
+/* Information about BT SBC decoder configuration
+ * This data is used between audio HAL module and
+ * BT IPC library to configure DSP decoder
+ */
+typedef struct {
+ uint16_t channels; /* Mono, Stereo */
+ uint32_t sampling_rate; /* 8k, 11.025k, 12k, 16k, 22.05k, 24k, 32k,
+ 44.1k, 48k, 64k, 88.2k, 96k */
+}audio_sbc_dec_config_t;
+
/*********** END of DSP configurable structures ********************/
/* API to identify DSP encoder captabilities */
@@ -647,6 +664,7 @@
//For LDAC encoder and AAC decoder open slimbus port at
//96Khz for 48Khz input and 88.2Khz for 44.1Khz input.
if (((a2dp.bt_encoder_format == CODEC_TYPE_LDAC) ||
+ (a2dp.bt_decoder_format == CODEC_TYPE_SBC) ||
(a2dp.bt_decoder_format == AUDIO_FORMAT_AAC)) &&
(sampling_rate == 48000 || sampling_rate == 44100 )) {
sampling_rate = sampling_rate *2;
@@ -735,7 +753,7 @@
return is_configured;
}
-bool configure_aac_dec_format(audio_aac_decoder_config_t *aac_bt_cfg)
+bool configure_aac_dec_format(audio_aac_dec_config_t *aac_bt_cfg)
{
struct mixer_ctl *ctl_dec_data = NULL, *ctrl_bit_format = NULL;
struct aac_dec_cfg_t aac_dsp_cfg;
@@ -802,7 +820,7 @@
return is_configured;
}
-bool configure_sbc_dec_format(audio_sbc_decoder_config_t *sbc_bt_cfg)
+bool configure_sbc_dec_format(audio_sbc_dec_config_t *sbc_bt_cfg)
{
struct mixer_ctl *ctl_dec_data = NULL, *ctrl_bit_format = NULL;
struct sbc_dec_cfg_t sbc_dsp_cfg;
@@ -825,6 +843,7 @@
sbc_dsp_cfg.data.sampling_rate = sbc_bt_cfg->sampling_rate;
ret = mixer_ctl_set_array(ctl_dec_data, (void *)&sbc_dsp_cfg,
sizeof(struct sbc_dec_cfg_t));
+
if (ret != 0) {
ALOGE("%s: failed to set SBC decoder config", __func__);
is_configured = false;
@@ -923,12 +942,12 @@
switch(codec_type) {
case CODEC_TYPE_SBC:
ALOGD(" SBC decoder supported BT device");
- is_configured = configure_sbc_dec_format((audio_sbc_decoder_config_t *)codec_info);
+ is_configured = configure_sbc_dec_format((audio_sbc_dec_config_t *)codec_info);
break;
case CODEC_TYPE_AAC:
ALOGD(" AAC decoder supported BT device");
is_configured =
- configure_aac_dec_format((audio_aac_decoder_config_t *)codec_info);
+ configure_aac_dec_format((audio_aac_dec_config_t *)codec_info);
break;
default:
ALOGD(" Received Unsupported decoder format");