hal: add new proxy usecase for hearding aid
Add a dedicated proxy usecase for hearing aid.
Change-Id: Iacc828f23393e3b44e9eefed89bbb365240a9813
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 9b8f29d..2a33f9e 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -383,6 +383,7 @@
[USECASE_AUDIO_PLAYBACK_AFE_PROXY] = "afe-proxy-playback",
[USECASE_AUDIO_RECORD_AFE_PROXY] = "afe-proxy-record",
+ [USECASE_AUDIO_RECORD_AFE_PROXY2] = "afe-proxy-record2",
[USECASE_AUDIO_PLAYBACK_SILENCE] = "silence-playback",
/* Transcode loopback cases */
@@ -880,6 +881,7 @@
static inline bool is_mmap_usecase(audio_usecase_t uc_id)
{
return (uc_id == USECASE_AUDIO_RECORD_AFE_PROXY) ||
+ (uc_id == USECASE_AUDIO_RECORD_AFE_PROXY2) ||
(uc_id == USECASE_AUDIO_PLAYBACK_AFE_PROXY);
}
@@ -2707,7 +2709,10 @@
usecase->stream.in->enable_ec_port = false;
- if (usecase->id == USECASE_AUDIO_RECORD_AFE_PROXY) {
+ bool is_ha_usecase = adev->ha_proxy_enable ?
+ usecase->id == USECASE_AUDIO_RECORD_AFE_PROXY2 :
+ usecase->id == USECASE_AUDIO_RECORD_AFE_PROXY;
+ if (is_ha_usecase) {
reassign_device_list(&out_devices, AUDIO_DEVICE_OUT_TELEPHONY_TX, "");
} else if (voip_usecase) {
assign_devices(&out_devices, &voip_usecase->stream.out->device_list);
@@ -3117,7 +3122,8 @@
unsigned int flags = PCM_IN | PCM_MONOTONIC;
unsigned int pcm_open_retry_count = 0;
- if (in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY) {
+ if ((in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY) ||
+ (in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY2)) {
flags |= PCM_MMAP | PCM_NOIRQ;
pcm_open_retry_count = PROXY_OPEN_RETRY_COUNT;
} else if (in->realtime) {
@@ -6921,7 +6927,8 @@
*/
if ((ret == 0 && voice_get_mic_mute(adev) &&
!voice_is_in_call_rec_stream(in) &&
- in->usecase != USECASE_AUDIO_RECORD_AFE_PROXY) ||
+ (in->usecase != USECASE_AUDIO_RECORD_AFE_PROXY &&
+ in->usecase != USECASE_AUDIO_RECORD_AFE_PROXY2)) ||
(adev->num_va_sessions &&
in->source != AUDIO_SOURCE_VOICE_RECOGNITION &&
property_get_bool("persist.vendor.audio.va_concurrency_mute_enabled",
@@ -7396,6 +7403,7 @@
struct stream_in *in = (struct stream_in *)stream;
struct audio_device *adev = in->dev;
struct listnode devices;
+ bool is_ha_usecase = false;
list_init(&devices);
@@ -7406,8 +7414,10 @@
pthread_mutex_lock(&adev->lock);
ALOGV("%s: in->usecase: %d, device: %x", __func__, in->usecase, get_device_types(&devices));
- if (in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY
- && !list_empty(&devices)
+ is_ha_usecase = adev->ha_proxy_enable ?
+ in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY2 :
+ in->usecase == USECASE_AUDIO_RECORD_AFE_PROXY;
+ if (is_ha_usecase && !list_empty(&devices)
&& adev->voice_tx_output != NULL) {
/* Use the rx device from afe-proxy record to route voice call because
there is no routing if tx device is on primary hal and rx device
@@ -9235,6 +9245,10 @@
}
in->usecase = USECASE_AUDIO_RECORD_AFE_PROXY;
+ if (adev->ha_proxy_enable &&
+ is_single_device_type_equal(&in->device_list,
+ AUDIO_DEVICE_IN_TELEPHONY_RX))
+ in->usecase = USECASE_AUDIO_RECORD_AFE_PROXY2;
in->config = pcm_config_afe_proxy_record;
in->config.rate = config->sample_rate;
in->af_period_multiplier = 1;
@@ -10427,6 +10441,7 @@
audio_extn_qdsp_init(adev->platform);
adev->multi_offload_enable = property_get_bool("vendor.audio.offload.multiple.enabled", false);
+ adev->ha_proxy_enable = property_get_bool("persist.vendor.audio.ha_proxy.enabled", false);
pthread_mutex_unlock(&adev_init_lock);
if (adev->adm_init)