hal: set bt sco sample rate from hal instead of mixer path xml
Configure the bt sco device sample rate explicitly from hal and
don't reset it during disabling.
The initial value of mixer "BT SampleRate" will also be removed.
This is to avoid resetting sample rate to 8K for the scenario
of switching SCO to A2DP, causing A2DP playback failed.
Change-Id: I99e254b7b97f9b4abb21249b8e31b99eb401adfb
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 79f619b..4b1cbe6 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -510,6 +510,8 @@
static void in_snd_mon_cb(void * stream, struct str_parms * parms);
static void out_snd_mon_cb(void * stream, struct str_parms * parms);
+static int configure_btsco_sample_rate(snd_device_t snd_device);
+
#ifdef AUDIO_FEATURE_ENABLED_GCOV
extern void __gcov_flush();
static void enable_gcov()
@@ -1302,6 +1304,7 @@
goto err;
}
+ configure_btsco_sample_rate(snd_device);
/* due to the possibility of calibration overwrite between listen
and audio, notify listen hal before audio calibration is sent */
audio_extn_sound_trigger_update_device_status(snd_device,
@@ -2291,6 +2294,50 @@
return bt_soc_status;
}
+static int configure_btsco_sample_rate(snd_device_t snd_device)
+{
+ struct mixer_ctl *ctl = NULL;
+ struct mixer_ctl *ctl_sr_rx = NULL, *ctl_sr_tx = NULL, *ctl_sr = NULL;
+ char *rate_str = NULL;
+ bool is_rx_dev = true;
+
+ if (is_btsco_device(snd_device, snd_device)) {
+ ctl_sr_tx = mixer_get_ctl_by_name(adev->mixer, "BT SampleRate TX");
+ ctl_sr_rx = mixer_get_ctl_by_name(adev->mixer, "BT SampleRate RX");
+ if (!ctl_sr_tx || !ctl_sr_rx) {
+ ctl_sr = mixer_get_ctl_by_name(adev->mixer, "BT SampleRate");
+ if (!ctl_sr)
+ return -ENOSYS;
+ }
+
+ switch (snd_device) {
+ case SND_DEVICE_OUT_BT_SCO:
+ rate_str = "KHZ_8";
+ break;
+ case SND_DEVICE_IN_BT_SCO_MIC_NREC:
+ case SND_DEVICE_IN_BT_SCO_MIC:
+ rate_str = "KHZ_8";
+ is_rx_dev = false;
+ break;
+ case SND_DEVICE_OUT_BT_SCO_WB:
+ rate_str = "KHZ_16";
+ break;
+ case SND_DEVICE_IN_BT_SCO_MIC_WB_NREC:
+ case SND_DEVICE_IN_BT_SCO_MIC_WB:
+ rate_str = "KHZ_16";
+ is_rx_dev = false;
+ break;
+ default:
+ return 0;
+ }
+
+ ctl = (ctl_sr == NULL) ? (is_rx_dev ? ctl_sr_rx : ctl_sr_tx) : ctl_sr;
+ if (mixer_ctl_set_enum_by_string(ctl, rate_str) != 0)
+ return -ENOSYS;
+ }
+ return 0;
+}
+
int out_standby_l(struct audio_stream *stream);
struct stream_in *adev_get_active_input(const struct audio_device *adev)