hal: Add check for afe loopback for send app type config for HFP call
Add check for is afe loop back enabled based on platform file
Change-Id: I24b91db06769486b79a32c00bfb28f7b3ffcb445
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index a4d17b8..31ce934 100755
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -1101,50 +1101,57 @@
goto exit_send_app_type_cfg;
}
+ /*
+ * Value of afe_loopback gets read based on the property defined in
+ * audio_platform_info.xml. If afe loopback is set then do not execute
+ * session 1 path as app type mixer control will not be created for
+ * afe loopback
+ */
+
if (usecase->type == PCM_HFP_CALL) {
-
- /* config HFP session:1 playback path */
- if (is_bus_dev_usecase) {
- app_type = usecase->out_app_type_cfg.app_type;
- sample_rate= usecase->out_app_type_cfg.sample_rate;
- } else {
- snd_device = SND_DEVICE_NONE; // use legacy behavior
- app_type = platform_get_default_app_type_v2(adev->platform, PCM_PLAYBACK);
- sample_rate= CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
- }
- rc = set_stream_app_type_mixer_ctrl(adev, pcm_device_id, app_type,
- acdb_dev_id, sample_rate,
- PCM_PLAYBACK,
- snd_device);
- if (rc < 0)
- goto exit_send_app_type_cfg;
-
- /* config HFP session:1 capture path */
- if (is_bus_dev_usecase) {
- snd_device = usecase->in_snd_device;
- pcm_device_id = platform_get_pcm_device_id(usecase->id, PCM_CAPTURE);
- acdb_dev_id = platform_get_snd_device_acdb_id(snd_device);
- if (acdb_dev_id < 0) {
- ALOGE("%s: Couldn't get the acdb dev id", __func__);
- rc = -EINVAL;
- goto exit_send_app_type_cfg;
+ if (!(platform_get_is_afe_loopback_enabled(adev->platform))) {
+ /* config HFP session:1 playback path */
+ if (is_bus_dev_usecase) {
+ app_type = usecase->out_app_type_cfg.app_type;
+ sample_rate= usecase->out_app_type_cfg.sample_rate;
+ } else {
+ snd_device = SND_DEVICE_NONE; // use legacy behavior
+ app_type = platform_get_default_app_type_v2(adev->platform, PCM_PLAYBACK);
+ sample_rate= CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
}
- app_type = usecase->in_app_type_cfg.app_type;
- sample_rate= usecase->in_app_type_cfg.sample_rate;
- } else {
- snd_device = SND_DEVICE_NONE; // use legacy behavior
- app_type = platform_get_default_app_type_v2(adev->platform, PCM_CAPTURE);
+ rc = set_stream_app_type_mixer_ctrl(adev, pcm_device_id, app_type,
+ acdb_dev_id, sample_rate,
+ PCM_PLAYBACK,
+ snd_device);
+ if (rc < 0)
+ goto exit_send_app_type_cfg;
+
+ /* config HFP session:1 capture path */
+ if (is_bus_dev_usecase) {
+ snd_device = usecase->in_snd_device;
+ pcm_device_id = platform_get_pcm_device_id(usecase->id, PCM_CAPTURE);
+ acdb_dev_id = platform_get_snd_device_acdb_id(snd_device);
+ if (acdb_dev_id < 0) {
+ ALOGE("%s: Couldn't get the acdb dev id", __func__);
+ rc = -EINVAL;
+ goto exit_send_app_type_cfg;
+ }
+ app_type = usecase->in_app_type_cfg.app_type;
+ sample_rate= usecase->in_app_type_cfg.sample_rate;
+ } else {
+ snd_device = SND_DEVICE_NONE; // use legacy behavior
+ app_type = platform_get_default_app_type_v2(adev->platform, PCM_CAPTURE);
+ }
+ rc = set_stream_app_type_mixer_ctrl(adev, pcm_device_id, app_type,
+ acdb_dev_id, sample_rate,
+ PCM_CAPTURE,
+ snd_device);
+ if (rc < 0)
+ goto exit_send_app_type_cfg;
+
+ if (is_bus_dev_usecase)
+ goto exit_send_app_type_cfg;
}
- rc = set_stream_app_type_mixer_ctrl(adev, pcm_device_id, app_type,
- acdb_dev_id, sample_rate,
- PCM_CAPTURE,
- snd_device);
- if (rc < 0)
- goto exit_send_app_type_cfg;
-
- if (is_bus_dev_usecase)
- goto exit_send_app_type_cfg;
-
/* config HFP session:2 capture path */
pcm_device_id = HFP_ASM_RX_TX;
snd_device = usecase->in_snd_device;
@@ -1157,7 +1164,7 @@
app_type = platform_get_default_app_type_v2(adev->platform, PCM_CAPTURE);
rc = set_stream_app_type_mixer_ctrl(adev, pcm_device_id, app_type,
acdb_dev_id, sample_rate, PCM_CAPTURE,
- SND_DEVICE_NONE);
+ usecase->in_snd_device);
if (rc < 0)
goto exit_send_app_type_cfg;
@@ -1165,7 +1172,7 @@
app_type = platform_get_default_app_type_v2(adev->platform, PCM_PLAYBACK);
rc = set_stream_app_type_mixer_ctrl(adev, pcm_device_id, app_type,
acdb_dev_id, sample_rate,
- PCM_PLAYBACK, SND_DEVICE_NONE);
+ PCM_PLAYBACK, usecase->out_snd_device);
if (rc < 0)
goto exit_send_app_type_cfg;
}
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 2a335f0..d31df8e 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -7665,6 +7665,11 @@
return false;
}
+int platform_get_is_afe_loopback_enabled(void *platform __unused)
+{
+ return 0;
+}
+
int platform_set_edid_channels_configuration(void *platform, int channels, int backend_idx __unused, snd_device_t snd_device __unused) {
struct platform_data *my_data = (struct platform_data *)platform;
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index 439b6d7..aa4286f 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -1223,6 +1223,11 @@
return -ENOSYS;
}
+int platform_get_is_afe_loopback_enabled(void *platform __unused)
+{
+ return 0;
+}
+
int platform_set_edid_channels_configuration(void *platform __unused,
int channels __unused,
int backend_idx __unused)
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 9259150..e97fd5c 100755
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -317,6 +317,7 @@
bool fluence_nn_enabled;
int fluence_type;
int fluence_mode;
+ int afe_loopback;
char fluence_cap[PROPERTY_VALUE_MAX];
bool ambisonic_capture;
bool ambisonic_profile;
@@ -8513,6 +8514,12 @@
}
}
+ err = str_parms_get_str(parms, "afe_loopback", value, len);
+ if (err >= 0) {
+ my_data->afe_loopback = atoi(value);
+ ALOGD("Updating afe_loopback as %d from platform XML" , my_data->afe_loopback);
+ }
+
err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_MONO_SPEAKER, value, len);
if (err >= 0) {
if (!strncmp("left", value, sizeof("left")))
@@ -11495,6 +11502,12 @@
backend_idx, snd_device, 0, 0);
}
+int platform_get_is_afe_loopback_enabled(void *platform)
+{
+ struct platform_data *my_data = (struct platform_data *)platform;
+ return my_data->afe_loopback;
+}
+
int platform_set_edid_channels_configuration_v2(void *platform, int channels,
int backend_idx, snd_device_t snd_device,
int controller, int stream) {
diff --git a/hal/platform_api.h b/hal/platform_api.h
index 922d61e..f0b10f5 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -333,6 +333,7 @@
bool platform_check_codec_asrc_support(void *platform);
int platform_get_backend_index(snd_device_t snd_device);
int platform_get_ext_disp_type(void *platform);
+int platform_get_is_afe_loopback_enabled(void *platform);
void platform_invalidate_hdmi_config(void *platform);
void platform_invalidate_backend_config(void * platform,snd_device_t snd_device);
bool platform_get_spkr_hph_single_be_native_concurrency_flag();