From d304a912a68b983c655d436b124452f4d7aa3591 Mon Sep 17 00:00:00 2001 From: Zhou Song Date: Fri, 19 Jul 2019 12:28:31 +0800 Subject: hal: remove output device force switch from bt sco to handset Trailing sound may leak to handset after doing force switch from bt sco output device. Since when a2dp device is selected, all active output streams will also route to a2dp during check_usecases_codec_backend, then a2dp and bt sco won't be active concurrently. But sco input device can be concurrent with a2dp device, so only check force switch of input device when SCO is off. Change-Id: I8225859dc9a3da987ace6cee3225c375785d3bea --- hal/audio_hw.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 94c9c50d..faaf865e 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -8110,16 +8110,13 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs) if (strcmp(value, AUDIO_PARAMETER_VALUE_ON) == 0){ adev->bt_sco_on = true; } else { - ALOGD("sco is off, reset sco and route device to handset/mic"); + ALOGD("sco is off, reset sco and route device to handset mic"); adev->bt_sco_on = false; audio_extn_sco_reset_configuration(); list_for_each(node, &adev->usecase_list) { usecase = node_to_item(node, struct audio_usecase, list); - if ((usecase->type == PCM_PLAYBACK) && usecase->stream.out && - (usecase->stream.out->devices & AUDIO_DEVICE_OUT_ALL_SCO)) - usecase->stream.out->devices = AUDIO_DEVICE_OUT_EARPIECE; - else if ((usecase->type == PCM_CAPTURE) && usecase->stream.in && - (usecase->stream.in->device & AUDIO_DEVICE_IN_ALL_SCO)) + if ((usecase->type == PCM_CAPTURE) && usecase->stream.in && + (usecase->stream.in->device & AUDIO_DEVICE_IN_ALL_SCO)) usecase->stream.in->device = AUDIO_DEVICE_IN_BUILTIN_MIC; else continue; -- cgit v1.2.3 From 280230029f8f20b7cc9d92be5f57c453dac0301c Mon Sep 17 00:00:00 2001 From: Zhou Song Date: Mon, 9 Sep 2019 14:17:40 +0800 Subject: hal: tear down a2dp path for non-offloaded streams when suspended When A2dp device is already active and A2dpsuspended=true is received, audio route will be switched to sco mic and BT firmware will open the RX path as 8KHz, while a2dp playback can still keep sending data over slimbus, this can cause noise heard in the BT headset. To avoid this, tear down the A2dp playback before SCO is enabled. Change-Id: Ic0b8d1c725340a3a2878d11717631c45c81dc721 --- hal/audio_hw.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hal/audio_hw.c b/hal/audio_hw.c index b17e4b2f..4e851027 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -9509,11 +9509,10 @@ static int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *ou pthread_mutex_unlock(&out->compr_mute_lock); } } else { - // mute compress stream if suspended - pthread_mutex_lock(&out->compr_mute_lock); - if ((out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) && - (!out->a2dp_compress_mute)) { - if (!out->standby) { + if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) { + // mute compress stream if suspended + pthread_mutex_lock(&out->compr_mute_lock); + if (!out->a2dp_compress_mute && !out->standby) { ALOGD("%s: selecting speaker and muting stream", __func__); devices = out->devices; out->devices = AUDIO_DEVICE_OUT_SPEAKER; @@ -9530,8 +9529,12 @@ static int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *ou out->volume_l = left_p; out->volume_r = right_p; } + pthread_mutex_unlock(&out->compr_mute_lock); + } else { + // tear down a2dp path for non offloaded streams + if (audio_extn_a2dp_source_is_suspended()) + out_standby_l(&out->stream.common); } - pthread_mutex_unlock(&out->compr_mute_lock); } ALOGV("%s: exit", __func__); return 0; -- cgit v1.2.3 From 6e691c01baae41f4449a97f7a882a68152d0e2ea Mon Sep 17 00:00:00 2001 From: Manisha Agarwal Date: Fri, 20 Sep 2019 14:03:57 +0530 Subject: A2dp: Send default channel mapping for TWS+ mono. Audio loss observed when encoder configured with mono mode. This occurs because when configuration of encoder with mono mode happens 0 channel mapping is sent to ADSP which rejects it as invalid channel mapping. To avoid this send default stereo channel mapping for both mono and dual mono case. CRs-Fixed: 2528391 Change-Id: Ie8d04965fb43f1beea747b23ae86464f943afdae --- hal/audio_extn/a2dp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c index bcdcb1cc..534abb36 100644 --- a/hal/audio_extn/a2dp.c +++ b/hal/audio_extn/a2dp.c @@ -1807,10 +1807,14 @@ static void audio_a2dp_update_tws_channel_mode() { char* channel_mode; struct mixer_ctl *ctl_channel_mode; + + ALOGD("Update tws for mono_mode on=%d",a2dp.is_tws_mono_mode_on); + if (a2dp.is_tws_mono_mode_on) channel_mode = "One"; else channel_mode = "Two"; + ctl_channel_mode = mixer_get_ctl_by_name(a2dp.adev->mixer,MIXER_FMT_TWS_CHANNEL_MODE); if (!ctl_channel_mode) { ALOGE("failed to get tws mixer ctl"); @@ -1851,14 +1855,8 @@ static int update_aptx_dsp_config_v2(struct aptx_enc_cfg_t *aptx_dsp_cfg, break; case 2: default: - if (!a2dp.is_tws_mono_mode_on) { aptx_dsp_cfg->custom_cfg.channel_mapping[0] = PCM_CHANNEL_L; aptx_dsp_cfg->custom_cfg.channel_mapping[1] = PCM_CHANNEL_R; - } - else { - a2dp.is_tws_mono_mode_on = true; - ALOGD("Update tws for mono_mode_on: %d",a2dp.is_tws_mono_mode_on); - } break; } a2dp.enc_channels = aptx_dsp_cfg->custom_cfg.num_channels; -- cgit v1.2.3 From a8a6525bc95ccb3a3ebd6a326e70bfcbff813079 Mon Sep 17 00:00:00 2001 From: Manisha Agarwal Date: Tue, 27 Aug 2019 14:46:36 +0530 Subject: configs: Add TWSP format for targets. Add support for TWS plus format for targets. Change-Id: I252158059a00f2b28379ddac6594bf8d49fffc51 --- configs/sdm710/audio_policy_configuration.xml | 6 +++--- configs/sdm845/audio_policy_configuration.xml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configs/sdm710/audio_policy_configuration.xml b/configs/sdm710/audio_policy_configuration.xml index b8bca1c1..d3497a81 100644 --- a/configs/sdm710/audio_policy_configuration.xml +++ b/configs/sdm710/audio_policy_configuration.xml @@ -251,17 +251,17 @@ samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO"/> + encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TWSP"> + encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TWSP"> + encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TWSP"> diff --git a/configs/sdm845/audio_policy_configuration.xml b/configs/sdm845/audio_policy_configuration.xml index 6099b32d..f6a842c0 100644 --- a/configs/sdm845/audio_policy_configuration.xml +++ b/configs/sdm845/audio_policy_configuration.xml @@ -245,17 +245,17 @@ samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO"/> + encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TWSP"> + encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TWSP"> + encodedFormats="AUDIO_FORMAT_SBC AUDIO_FORMAT_AAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_LDAC AUDIO_FORMAT_CELT AUDIO_FORMAT_APTX_ADAPTIVE AUDIO_FORMAT_APTX_TWSP"> -- cgit v1.2.3 From 10d22b9b49a0208df18acef45bb5a0ad5c290d8d Mon Sep 17 00:00:00 2001 From: Ramlal Karra Date: Thu, 8 Aug 2019 19:02:35 +0530 Subject: audio: Add HiFi Filter support - Enable HiFi filter for 48kHz, 44.1kHz Music playback Change-Id: I87a87b0d719ac4ba82b3d16331711b85459a3edb Signed-off-by: Ramlal Karra --- hal/audio_extn/audio_extn.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ hal/audio_extn/audio_extn.h | 10 ++++++ hal/msm8974/hw_info.c | 3 +- hal/msm8974/platform.c | 71 +++++++++++++++++++++++++++++++++++++-- hal/msm8974/platform.h | 2 ++ 5 files changed, 165 insertions(+), 3 deletions(-) diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c index 05da79fd..d5f303fc 100644 --- a/hal/audio_extn/audio_extn.c +++ b/hal/audio_extn/audio_extn.c @@ -192,6 +192,7 @@ static bool audio_extn_compress_in_enabled = false; static bool audio_extn_battery_listener_enabled = false; static bool audio_extn_maxx_audio_enabled = false; static bool audio_extn_audiozoom_enabled = false; +static bool audio_extn_hifi_filter_enabled = false; #define AUDIO_PARAMETER_KEY_AANC_NOISE_LEVEL "aanc_noise_level" #define AUDIO_PARAMETER_KEY_ANC "anc_enabled" @@ -5164,6 +5165,87 @@ bool audio_extn_battery_properties_is_charging() } // END: BATTERY_LISTENER ================================================================ +// START: HiFi Filter Feature ============================================================ +void audio_extn_enable_hifi_filter(struct audio_device *adev, bool value) +{ + const char *mixer_ctl_name = "HiFi Filter"; + struct mixer_ctl *ctl = NULL; + ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); + if (!ctl) { + ALOGE("%s: Could not get ctl for mixer cmd - %s, using default control", + __func__, mixer_ctl_name); + return; + } else { + mixer_ctl_set_value(ctl, 0, value); + ALOGD("%s: mixer_value set %d", __func__, value); + } + return; +} + +void audio_extn_hifi_filter_set_params(struct str_parms *parms, + char *value, int len) +{ + int ret = 0; + ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HIFI_AUDIO_FILTER, value,len); + if (ret >= 0) { + if (value && !strncmp(value, "true", sizeof("true"))) + audio_extn_hifi_filter_enabled = true; + else + audio_extn_hifi_filter_enabled = false; + str_parms_del(parms, AUDIO_PARAMETER_KEY_HIFI_AUDIO_FILTER); + } +} + +bool audio_extn_hifi_check_usecase_params(int sample_rate, int usecase) +{ + if (sample_rate != 48000 && sample_rate != 44100) + return false; + if (usecase == USECASE_AUDIO_PLAYBACK_LOW_LATENCY || usecase == USECASE_AUDIO_PLAYBACK_ULL) + return false; + return true; +} + +bool audio_extn_is_hifi_filter_enabled(struct audio_device* adev, struct stream_out *out, + snd_device_t snd_device, char *codec_variant, + int channels, int usecase_init) +{ + int na_mode = platform_get_native_support(); + struct audio_usecase *uc = NULL; + struct listnode *node = NULL; + bool hifi_active = false; + + if (audio_extn_hifi_filter_enabled) { + /*Restricting the feature for Tavil and WCD9375 codecs only*/ + if ((strstr(codec_variant, "WCD9385") || strstr(codec_variant, "WCD9375")) + && (na_mode == NATIVE_AUDIO_MODE_MULTIPLE_MIX_IN_DSP) && channels <=2) { + /*Upsampling 8 time should be restricited to headphones playback only */ + if (snd_device == SND_DEVICE_OUT_HEADPHONES + || snd_device == SND_DEVICE_OUT_HEADPHONES_44_1 + || snd_device == SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER + || usecase_init) { + if (audio_extn_hifi_check_usecase_params(out->sample_rate, + out->usecase) && !usecase_init) + return true; + + list_for_each(node, &adev->usecase_list) { + /* checking if hifi_filter is already active to set */ + /* concurrent playback sessions with hifi_filter enabled*/ + uc = node_to_item(node, struct audio_usecase, list); + struct stream_out *curr_out = (struct stream_out*) uc->stream.out; + if (uc->type == PCM_PLAYBACK && curr_out + && audio_extn_hifi_check_usecase_params( + curr_out->sample_rate, curr_out->usecase) && + (curr_out->channel_mask == AUDIO_CHANNEL_OUT_STEREO || + curr_out->channel_mask == AUDIO_CHANNEL_OUT_MONO)) + hifi_active = true; + } + } + } + } + return hifi_active; +} +// END: HiFi Filter Feature ============================================================== + // START: AUDIOZOOM_FEATURE ===================================================================== #ifdef __LP64__ #define AUDIOZOOM_LIB_PATH "/vendor/lib64/libaudiozoom.so" diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h index b1f4dda7..74581cd8 100644 --- a/hal/audio_extn/audio_extn.h +++ b/hal/audio_extn/audio_extn.h @@ -116,6 +116,8 @@ int audio_extn_parse_compress_metadata(struct stream_out *out, #define MAX_LENGTH_MIXER_CONTROL_IN_INT (128) #define HW_INFO_ARRAY_MAX_SIZE 32 +#define AUDIO_PARAMETER_KEY_HIFI_AUDIO_FILTER "hifi_filter" + struct snd_card_split { char device[HW_INFO_ARRAY_MAX_SIZE]; char snd_card[HW_INFO_ARRAY_MAX_SIZE]; @@ -261,6 +263,14 @@ int32_t audio_extn_read_afe_proxy_channel_masks(struct stream_out *out); int32_t audio_extn_get_afe_proxy_channel_count(); //END: AFE_PROXY_FEATURE +//START: HIFI FILTER +void audio_extn_enable_hifi_filter(struct audio_device *adev, bool value); +void audio_extn_hifi_filter_set_params(struct str_parms *parms, char *value, int len); +bool audio_extn_is_hifi_filter_enabled(struct audio_device* adev,struct stream_out *out, + snd_device_t snd_device, char *codec_variant, + int channels, int usecase_init); +//END: HIFI FILTER + /// ---- USB feature --------------------------------------------------------------- void audio_extn_usb_init(void *adev); void audio_extn_usb_deinit(); diff --git a/hal/msm8974/hw_info.c b/hal/msm8974/hw_info.c index 8e3ad293..5113cffc 100644 --- a/hal/msm8974/hw_info.c +++ b/hal/msm8974/hw_info.c @@ -64,7 +64,8 @@ static const snd_device_t wsa_combo_devices[] = { SND_DEVICE_OUT_SPEAKER_AND_LINE, SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1, SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2, - SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET + SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET, + SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_HIFI_FILTER }; static const snd_device_t taiko_fluid_variant_devices[] = { diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c index 297c2dcb..91a04e76 100644 --- a/hal/msm8974/platform.c +++ b/hal/msm8974/platform.c @@ -498,6 +498,8 @@ static const char * const device_table[SND_DEVICE_MAX] = { [SND_DEVICE_OUT_SPEAKER_SAFE] = "speaker-safe", [SND_DEVICE_OUT_HEADPHONES] = "headphones", [SND_DEVICE_OUT_HEADPHONES_DSD] = "headphones-dsd", + [SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER] = "headphones-hifi-filter", + [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_HIFI_FILTER] = "speaker-and-headphones-hifi-filter", [SND_DEVICE_OUT_HEADPHONES_44_1] = "headphones-44.1", [SND_DEVICE_OUT_LINE] = "line", [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones", @@ -830,6 +832,8 @@ static int acdb_device_table[SND_DEVICE_MAX] = { [SND_DEVICE_OUT_TRANSMISSION_FM] = 0, [SND_DEVICE_OUT_ANC_HEADSET] = 26, [SND_DEVICE_OUT_ANC_FB_HEADSET] = 27, + [SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER] = 188, + [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_HIFI_FILTER] = 188, [SND_DEVICE_OUT_VOICE_ANC_HEADSET] = 26, [SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET] = 27, [SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = 26, @@ -999,6 +1003,8 @@ static struct name_to_index snd_device_name_index[SND_DEVICE_MAX] = { {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_SAFE)}, {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES)}, {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES_DSD)}, + {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER)}, + {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_HIFI_FILTER)}, {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES_44_1)}, {TO_NAME_INDEX(SND_DEVICE_OUT_LINE)}, {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES)}, @@ -2118,6 +2124,9 @@ static void set_platform_defaults(struct platform_data * my_data) backend_tag_table[SND_DEVICE_IN_CAPTURE_FM] = strdup("capture-fm"); backend_tag_table[SND_DEVICE_OUT_TRANSMISSION_FM] = strdup("transmission-fm"); backend_tag_table[SND_DEVICE_OUT_HEADPHONES_DSD] = strdup("headphones-dsd"); + backend_tag_table[SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER] = strdup("headphones-hifi-filter"); + backend_tag_table[SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_HIFI_FILTER] = + strdup("speaker-and-headphones-hifi-filter"); backend_tag_table[SND_DEVICE_OUT_HEADPHONES_44_1] = strdup("headphones-44.1"); backend_tag_table[SND_DEVICE_OUT_VOICE_SPEAKER_VBAT] = strdup("voice-speaker-vbat"); backend_tag_table[SND_DEVICE_OUT_VOICE_SPEAKER_2_VBAT] = strdup("voice-speaker-2-vbat"); @@ -4882,6 +4891,9 @@ int platform_get_backend_index(snd_device_t snd_device) if (strncmp(backend_tag_table[snd_device], "headphones-44.1", sizeof("headphones-44.1")) == 0) port = HEADPHONE_44_1_BACKEND; + else if (strncmp(backend_tag_table[snd_device], "headphones-hifi-filter", + sizeof("headphones-hifi-filter")) == 0) + port = HEADPHONE_BACKEND; else if (strncmp(backend_tag_table[snd_device], "headphones-dsd", sizeof("headphones-dsd")) == 0) port = DSD_NATIVE_BACKEND; @@ -5508,6 +5520,12 @@ int platform_split_snd_device(void *platform, new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER; new_snd_devices[1] = SND_DEVICE_OUT_USB_HEADSET; ret = 0; + } else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_HIFI_FILTER && + !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER)) { + *num_devices = 2; + new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER; + new_snd_devices[1] = SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER; + ret = 0; } else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_BT_SCO && !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, SND_DEVICE_OUT_BT_SCO)) { *num_devices = 2; @@ -5691,6 +5709,9 @@ snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *o snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2; else if (is_active_voice_call) snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_AND_VOICE_HEADPHONES; + else if (audio_extn_is_hifi_filter_enabled(adev, out, snd_device, + my_data->codec_variant, channel_count, 1)) + snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_HIFI_FILTER; else snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; } else if (devices == (AUDIO_DEVICE_OUT_LINE | @@ -5714,6 +5735,9 @@ snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *o snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1; else if (my_data->external_spk_2) snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2; + else if (audio_extn_is_hifi_filter_enabled(adev, out, snd_device, + my_data->codec_variant, channel_count, 1)) + snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_HIFI_FILTER; else { if (is_active_voice_call) snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_AND_VOICE_HEADPHONES; @@ -5980,6 +6004,11 @@ snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *o snd_device = SND_DEVICE_OUT_HEADPHONES_44_1; } else if (out->format == AUDIO_FORMAT_DSD) { snd_device = SND_DEVICE_OUT_HEADPHONES_DSD; + } else if (audio_extn_is_hifi_filter_enabled(adev, out, snd_device, + my_data->codec_variant, channel_count, 1)) { + snd_device = SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER; + } else if (devices & SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER) { + snd_device = SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER; } else if (devices & AUDIO_DEVICE_OUT_LINE) { snd_device = SND_DEVICE_OUT_LINE; } else @@ -7177,7 +7206,7 @@ static void true_32_bit_set_params(struct str_parms *parms, ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_TRUE_32_BIT, value,len); if (ret >= 0) { - if (value && !strncmp(value, "true", sizeof("src"))) + if (value && !strncmp(value, "true", sizeof("true"))) supports_true_32_bit = true; else supports_true_32_bit = false; @@ -7527,6 +7556,7 @@ int platform_set_parameters(void *platform, struct str_parms *parms) audio_extn_hfp_set_parameters(my_data->adev, parms); perf_lock_set_params(platform, parms, value, len); true_32_bit_set_params(parms, value, len); + audio_extn_hifi_filter_set_params(parms, value, len); platform_spkr_device_set_params(platform, parms, value, len); done: ALOGV("%s: exit with code(%d)", __func__, ret); @@ -8602,6 +8632,12 @@ static bool platform_check_codec_backend_cfg(struct audio_device* adev, if (channels < out_channels) channels = out_channels; } + if ((snd_device == SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER) && + (usecase->id==USECASE_AUDIO_PLAYBACK_LOW_LATENCY || + usecase->id == USECASE_AUDIO_PLAYBACK_ULL)) { + sample_rate = my_data->current_backend_cfg[backend_idx].sample_rate; + bit_width = my_data->current_backend_cfg[backend_idx].bit_width; + } } } } @@ -8701,6 +8737,37 @@ static bool platform_check_codec_backend_cfg(struct audio_device* adev, } } + if (backend_idx != platform_get_voice_call_backend(adev) + && usecase->type == PCM_PLAYBACK) { + struct stream_out *out = (struct stream_out*) usecase->stream.out; + if(audio_extn_is_hifi_filter_enabled(adev, out, snd_device, + my_data->codec_variant, channels, 0)) { + switch (sample_rate) { + case 48000: + audio_extn_enable_hifi_filter(adev, true); + if (audio_is_true_native_stream_active(adev)) + sample_rate = 352800; + else + sample_rate = 384000; + bit_width = 32; + break; + case 44100: + audio_extn_enable_hifi_filter(adev, true); + sample_rate = 352800; + bit_width = 32; + break; + default: + audio_extn_enable_hifi_filter(adev, false); + } + } + if (snd_device != SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER) + audio_extn_enable_hifi_filter(adev, false); + ALOGD("%s:becf: updated afe: bitwidth %d, samplerate %d channels %d," + "backend_idx %d usecase = %d device (%s)", __func__, bit_width, + sample_rate, channels, backend_idx, usecase->id, + platform_get_snd_device_name(snd_device)); + } + /* * Handset and speaker may have diffrent backend. Check if the device is speaker or handset, * and these devices are restricited to 48kHz. @@ -8813,7 +8880,7 @@ static bool platform_check_codec_backend_cfg(struct audio_device* adev, } if (snd_device == SND_DEVICE_OUT_HEADPHONES || snd_device == - SND_DEVICE_OUT_HEADPHONES_44_1) { + SND_DEVICE_OUT_HEADPHONES_44_1 || snd_device == SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER) { if (sample_rate > 48000 || (bit_width >= 24 && (sample_rate == 48000 || sample_rate == 44100))) { ALOGI("%s: apply HPH HQ mode\n", __func__); diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h index f638b44a..dc2dc5cd 100644 --- a/hal/msm8974/platform.h +++ b/hal/msm8974/platform.h @@ -92,8 +92,10 @@ enum { SND_DEVICE_OUT_LINE, SND_DEVICE_OUT_HEADPHONES, SND_DEVICE_OUT_HEADPHONES_DSD, + SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER, SND_DEVICE_OUT_HEADPHONES_44_1, SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES, + SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_HIFI_FILTER, SND_DEVICE_OUT_SPEAKER_SAFE_AND_HEADPHONES, SND_DEVICE_OUT_SPEAKER_AND_LINE, SND_DEVICE_OUT_SPEAKER_SAFE_AND_LINE, -- cgit v1.2.3 From f2be3c9a945ed8e3e14094de875c5995808a9f97 Mon Sep 17 00:00:00 2001 From: Aditya Bavanari Date: Fri, 11 Oct 2019 19:46:43 +0530 Subject: hal: Reset HPH power mode to class AB for wcd9370 variant As wcd9370 codec only supports Class AB HPH power mode, reset the power mode for that variant Change-Id: I791aad8447c89bf43e573f080f6c610c6c7c539b --- hal/msm8974/platform.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c index 91a04e76..742b1a43 100644 --- a/hal/msm8974/platform.c +++ b/hal/msm8974/platform.c @@ -298,6 +298,7 @@ struct platform_data { bool ec_ref_enabled; bool is_wsa_speaker; bool hifi_audio; + bool is_cls_ab_only_supported; bool is_i2s_ext_modem; bool is_acdb_initialized; /* Vbat monitor related flags */ @@ -3194,7 +3195,6 @@ void *platform_init(struct audio_device *adev) my_data->hifi_audio = true; set_platform_defaults(my_data); - /* Initialize ACDB ID's */ if (my_data->is_i2s_ext_modem && !is_auto_snd_card(snd_card_name)) platform_info_init(PLATFORM_INFO_XML_PATH_I2S, my_data, PLATFORM); @@ -3685,6 +3685,11 @@ acdb_init_fail: my_data->adev->snd_card, my_data->codec_version); + /* WCD9370 codec variant only supports Class AB power mode */ + if (strstr(my_data->codec_variant, "WCD9370")) { + my_data->is_cls_ab_only_supported = true; + } + if (NATIVE_AUDIO_MODE_INVALID != platform_get_native_support()) { /* * Native playback is enabled from the UI. @@ -8881,13 +8886,18 @@ static bool platform_check_codec_backend_cfg(struct audio_device* adev, if (snd_device == SND_DEVICE_OUT_HEADPHONES || snd_device == SND_DEVICE_OUT_HEADPHONES_44_1 || snd_device == SND_DEVICE_OUT_HEADPHONES_HIFI_FILTER) { - if (sample_rate > 48000 || - (bit_width >= 24 && (sample_rate == 48000 || sample_rate == 44100))) { - ALOGI("%s: apply HPH HQ mode\n", __func__); - audio_route_apply_and_update_path(adev->audio_route, "hph-highquality-mode"); + if (my_data->is_cls_ab_only_supported) { + ALOGI("%s: apply CLS AB HPH power mode\n", __func__); + audio_route_apply_and_update_path(adev->audio_route, "hph-class-ab-mode"); } else { - ALOGI("%s: apply HPH LP mode\n", __func__); - audio_route_apply_and_update_path(adev->audio_route, "hph-lowpower-mode"); + if (sample_rate > 48000 || + (bit_width >= 24 && (sample_rate == 48000 || sample_rate == 44100))) { + ALOGI("%s: apply HPH HQ mode\n", __func__); + audio_route_apply_and_update_path(adev->audio_route, "hph-highquality-mode"); + } else { + ALOGI("%s: apply HPH LP mode\n", __func__); + audio_route_apply_and_update_path(adev->audio_route, "hph-lowpower-mode"); + } } } -- cgit v1.2.3 From b6ce7af29efa3a4d69592a9a7bd528e383662b7c Mon Sep 17 00:00:00 2001 From: Aditya Bavanari Date: Fri, 11 Oct 2019 19:53:35 +0530 Subject: configs: atoll: Add hph-class-ab-mode for wcd9370 variant WCD9370 codec variant supports only class AB HPH power mode. Add a mixer path to set the HPH power mode ctl to class AB. Change-Id: Id5825fc3809a6e4d73b6b3b1779507282b72b046 --- configs/atoll/mixer_paths_wcd937x.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/configs/atoll/mixer_paths_wcd937x.xml b/configs/atoll/mixer_paths_wcd937x.xml index 4195193f..c4784fd2 100644 --- a/configs/atoll/mixer_paths_wcd937x.xml +++ b/configs/atoll/mixer_paths_wcd937x.xml @@ -2769,11 +2769,19 @@ + + + + + + + + -- cgit v1.2.3 From 803dfe88365566b38b26d5f0fc6955d74877ce73 Mon Sep 17 00:00:00 2001 From: Dhananjay Kumar Date: Tue, 15 Oct 2019 21:45:57 +0530 Subject: hal: voice_extn: update error handling for incall music usecase Update error handling for incall music usecase initialization to return error when feature is not enabled. Not returning error was setting output configs to 0 or other unexpected values, resulting in busy loops and other system errors. Change-Id: I971b8c49cda407aff5b7986bc285f72e6b56cd99 --- hal/voice_extn/voice_extn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hal/voice_extn/voice_extn.c b/hal/voice_extn/voice_extn.c index e6a4ed65..1d7a2840 100644 --- a/hal/voice_extn/voice_extn.c +++ b/hal/voice_extn/voice_extn.c @@ -753,8 +753,9 @@ int voice_extn_check_and_set_incall_music_usecase(struct audio_device *adev, out->config.rate = out->sample_rate; ALOGV("%s: mode=%d, usecase id=%d", __func__, adev->mode, out->usecase); + return 0; } - return 0; + return -ENOSYS; } -- cgit v1.2.3 From ed67b03d500b89674a817bbc6d44f066673fa16d Mon Sep 17 00:00:00 2001 From: Vikram Panduranga Date: Fri, 13 Sep 2019 12:55:27 -0700 Subject: hal: remove sending apply audio path for speaker swap For speaker swap channels, apply audio path need not be sent when swap is not requested or device switch is not needed. Sending apply audio path will increment the ref count in audio route which can lead to erroneous condition. Change-Id: I64e3a867cd749c56d3432f1443f2cc4a92894374 --- hal/msm8974/platform.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c index 297c2dcb..60992627 100644 --- a/hal/msm8974/platform.c +++ b/hal/msm8974/platform.c @@ -10523,7 +10523,6 @@ int platform_set_swap_mixer(struct audio_device *adev, bool swap_channels) { const char *mixer_ctl_name = "Swap channel"; struct mixer_ctl *ctl; - const char *mixer_path; struct platform_data *my_data = (struct platform_data *)adev->platform; // forced to set to swap, but device not rotated ... ignore set @@ -10532,14 +10531,6 @@ int platform_set_swap_mixer(struct audio_device *adev, bool swap_channels) ALOGV("%s:", __func__); - if (swap_channels) { - mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER_REVERSE); - audio_route_apply_and_update_path(adev->audio_route, mixer_path); - } else { - mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER); - audio_route_apply_and_update_path(adev->audio_route, mixer_path); - } - ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); if (!ctl) { ALOGE("%s: Could not get ctl for mixer cmd - %s",__func__, mixer_ctl_name); -- cgit v1.2.3