hal: Update the FM_RX_VOLUME control to SEC MI2S LOOPBACK Volume
Add API to update FM_RX_VOLUME control for yupik target.
Change-Id: I6f8065b4ff130ba609a28d0c15a2b83659c501a5
Signed-off-by: Harshal Ahire <hahire@codeaurora.org>
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c
index 30f6f5c..7ff1b7b 100644
--- a/hal/audio_extn/fm.c
+++ b/hal/audio_extn/fm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -85,11 +85,18 @@
{
int32_t vol, ret = 0;
struct mixer_ctl *ctl;
- const char *mixer_ctl_name = FM_RX_VOLUME;
+ const char *mixer_ctl_name;
ALOGV("%s: entry", __func__);
ALOGD("%s: (%f)\n", __func__, value);
+ mixer_ctl_name = platform_get_mixer_FM_RX_control(adev);
+ if (!mixer_ctl_name) {
+ ALOGE("%s: Could not get FM_RX mixer control",
+ __func__);
+ return -EINVAL;
+ }
+
if (value < 0.0) {
ALOGW("%s: (%f) Under 0.0, assuming 0.0\n", __func__, value);
value = 0.0;
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 2f8a6f2..98122f2 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -8819,3 +8819,8 @@
bool platform_is_call_proxy_snd_device(snd_device_t snd_device __unused) {
return false;
}
+
+const char *platform_get_mixer_FM_RX_control(struct audio_device *adev) {
+ return FM_RX_VOLUME;
+}
+
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 86c1cc9..4e7deba 100755
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -1950,6 +1950,22 @@
}
}
+const char *platform_get_mixer_FM_RX_control(struct audio_device *adev) {
+ char *snd_card_name = NULL;
+
+ snd_card_name = strdup(mixer_get_name(adev->mixer));
+ if (!snd_card_name) {
+ ALOGE("%s: failed to allocate memory for snd_card_name\n",__func__);
+ return NULL;
+ }
+
+ if (!strncmp(snd_card_name, "lahaina-yupikidp-snd-card",
+ sizeof("lahaina-yupikidp-snd-card")))
+ return "SEC MI2S LOOPBACK Volume";
+
+ return FM_RX_VOLUME;
+}
+
bool platform_send_gain_dep_cal(void *platform, int level) {
bool ret_val = false;
struct platform_data *my_data = (struct platform_data *)platform;
diff --git a/hal/platform_api.h b/hal/platform_api.h
index ca72708..9d08378 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -435,4 +435,5 @@
bool enable);
void platform_reset_island_power_status(void *platform, snd_device_t snd_device);
void platform_is_volume_boost_supported_device(void *platform, struct listnode *devices);
+const char *platform_get_mixer_FM_RX_control(struct audio_device *adev);
#endif // AUDIO_PLATFORM_API_H