hal: Support HFP volume mixer in platform info xml
Add support to get hfp volume mixer control from platform info
xml
Change-Id: I6ef7508de3da16fa61ae9634b7c580b9c1f8a82c
diff --git a/hal/audio_extn/hfp.c b/hal/audio_extn/hfp.c
index cb85e1a..ca5d3bb 100644
--- a/hal/audio_extn/hfp.c
+++ b/hal/audio_extn/hfp.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -50,6 +50,8 @@
#define AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE "hfp_set_sampling_rate"
#define AUDIO_PARAMETER_KEY_HFP_VOLUME "hfp_volume"
#define AUDIO_PARAMETER_HFP_PCM_DEV_ID "hfp_pcm_dev_id"
+#define AUDIO_PARAMETER_HFP_VOL_MIXER_CTL "hfp_vol_mixer_ctl"
+#define AUDIO_PARAMETER_HFP_VALUE_MAX 128
#define AUDIO_PARAMETER_KEY_HFP_MIC_VOLUME "hfp_mic_volume"
#define PLAYBACK_VOLUME_MAX 0x2000
@@ -85,6 +87,7 @@
struct pcm *hfp_pcm_tx;
bool is_hfp_running;
float hfp_volume;
+ char hfp_vol_mixer_ctl[AUDIO_PARAMETER_HFP_VALUE_MAX];
int32_t hfp_pcm_dev_id;
audio_usecase_t ucid;
float mic_volume;
@@ -98,6 +101,7 @@
.hfp_pcm_tx = NULL,
.is_hfp_running = 0,
.hfp_volume = 0,
+ .hfp_vol_mixer_ctl = {0, },
.hfp_pcm_dev_id = HFP_ASM_RX_TX,
.ucid = USECASE_AUDIO_HFP_SCO,
.mic_volume = CAPTURE_VOLUME_DEFAULT,
@@ -155,8 +159,13 @@
}
ALOGD("%s: Setting HFP volume to %d \n", __func__, vol);
- ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
- if (!ctl) {
+
+ if (0 == hfpmod.hfp_vol_mixer_ctl[0])
+ ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+ else
+ ctl = mixer_get_ctl_by_name(adev->mixer, hfpmod.hfp_vol_mixer_ctl);
+
+ if(!ctl) {
ALOGE("%s: Could not get ctl for mixer cmd - %s",
__func__, mixer_ctl_name);
return -EINVAL;
@@ -584,6 +593,15 @@
}
memset(value, 0, sizeof(value));
+ ret = str_parms_get_str(parms, AUDIO_PARAMETER_HFP_VOL_MIXER_CTL,
+ value, sizeof(value));
+ if (ret >= 0) {
+ ALOGD("%s: mixer ctl name: %s", __func__, value);
+ strlcpy(hfpmod.hfp_vol_mixer_ctl, value, sizeof(value));
+ str_parms_del(parms, AUDIO_PARAMETER_HFP_VOL_MIXER_CTL);
+ }
+
+ memset(value, 0, sizeof(value));
ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HFP_VOLUME,
value, sizeof(value));
if (ret >= 0) {