hal: Add provision to select backend based on codec type
SLIMBUS_0 is the backend on 8952 external codec PLs.
Whereas TERT_MI2S is the backend on 8952 internal codec PLs.
Since both these PLs are supported on same code base,
provision is required to select backend based on codec type.
Change-Id: I9c0dd7d952ab9d6b9bf738074d97597622e09590
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index e9780bc..4ef84b7 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -707,7 +707,9 @@
!strncmp(snd_card_name, "msm8939-tapan9302-snd-card",
sizeof("msm8939-tapan9302-snd-card"))||
!strncmp(snd_card_name, "msm8939-tomtom9330-snd-card",
- sizeof("msm8939-tomtom9330-snd-card"))) {
+ sizeof("msm8939-tomtom9330-snd-card")) ||
+ !strncmp(snd_card_name, "msm8952-tomtom-snd-card",
+ sizeof("msm8952-tomtom-snd-card"))) {
ALOGI("%s: snd_card_name: %s",__func__,snd_card_name);
is_external_codec = true;
}
@@ -4009,32 +4011,33 @@
/*
* This is a lookup table to map android audio input device to audio h/w interface (backend).
* The table can be extended for other input devices by adding appropriate entries.
- * Also the audio interface for a particular input device can be overriden by adding
- * corresponding entry in audio_platform_info.xml file.
+ * The audio interface for a particular input device need to be added in
+ * audio_platform_info.xml file.
*/
struct audio_device_to_audio_interface audio_device_to_interface_table[] = {
- {AUDIO_DEVICE_IN_BUILTIN_MIC, ENUM_TO_STRING(AUDIO_DEVICE_IN_BUILTIN_MIC), "TERT_MI2S"},
- {AUDIO_DEVICE_IN_BACK_MIC, ENUM_TO_STRING(AUDIO_DEVICE_IN_BACK_MIC), "TERT_MI2S"},
+ {AUDIO_DEVICE_IN_BUILTIN_MIC, ENUM_TO_STRING(AUDIO_DEVICE_IN_BUILTIN_MIC), ""},
+ {AUDIO_DEVICE_IN_BACK_MIC, ENUM_TO_STRING(AUDIO_DEVICE_IN_BACK_MIC), ""},
};
int audio_device_to_interface_table_len =
sizeof(audio_device_to_interface_table) / sizeof(audio_device_to_interface_table[0]);
-
int platform_set_audio_device_interface(const char * device_name,
- const char *intf_name)
+ const char *intf_name,
+ const char *codec_type)
{
int ret = 0;
int i;
- if (device_name == NULL || intf_name == NULL) {
+ if (device_name == NULL || intf_name == NULL || codec_type == NULL) {
ALOGE("%s: Invalid input", __func__);
ret = -EINVAL;
goto done;
}
- ALOGD("%s: Enter, device name:%s, intf name:%s", __func__, device_name, intf_name);
+ ALOGD("%s: Enter, device name:%s, intf name:%s, codec_type:%s", __func__,
+ device_name, intf_name, codec_type);
size_t device_name_len = strlen(device_name);
for (i = 0; i < audio_device_to_interface_table_len; i++) {
@@ -4042,11 +4045,22 @@
size_t name_len = strlen(name);
if ((name_len == device_name_len) &&
(strncmp(device_name, name, name_len) == 0)) {
- ALOGD("%s: Matched device name:%s, overwrite intf name with %s",
+ if (is_external_codec &&
+ (strncmp(codec_type, "external", strlen(codec_type)) == 0)) {
+ ALOGD("%s: Matched device name:%s, overwrite intf name with %s",
__func__, device_name, intf_name);
- strlcpy(audio_device_to_interface_table[i].interface_name, intf_name,
+ strlcpy(audio_device_to_interface_table[i].interface_name, intf_name,
sizeof(audio_device_to_interface_table[i].interface_name));
+ } else if (!is_external_codec &&
+ (strncmp(codec_type, "internal", strlen(codec_type)) == 0)) {
+ ALOGD("%s: Matched device name:%s, overwrite intf name with %s",
+ __func__, device_name, intf_name);
+
+ strlcpy(audio_device_to_interface_table[i].interface_name, intf_name,
+ sizeof(audio_device_to_interface_table[i].interface_name));
+ } else
+ ALOGE("Invalid codec_type specified. Ignoring this interface entry.");
goto done;
}
}
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index bbfa042..f9b7851 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -1155,7 +1155,8 @@
}
int platform_set_audio_device_interface(const char * device_name __unused,
- const char *intf_name __unused)
+ const char *intf_name __unused,
+ const char *codec_type __unused)
{
return -ENOSYS;
}
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 24e23e6..b4c4c44 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -3757,7 +3757,8 @@
int audio_device_to_interface_table_len =
sizeof(audio_device_to_interface_table) / sizeof(audio_device_to_interface_table[0]);
-int platform_set_audio_device_interface(const char *device_name, const char *intf_name)
+int platform_set_audio_device_interface(const char *device_name, const char *intf_name,
+ const char *codec_type __unused)
{
int ret = 0;
int i;
diff --git a/hal/platform_api.h b/hal/platform_api.h
index 3808b14..4ecdd36 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -109,5 +109,6 @@
void platform_invalidate_edid(void * platform);
int platform_set_hdmi_config(struct stream_out *out);
int platform_set_device_params(struct stream_out *out, int param, int value);
-int platform_set_audio_device_interface(const char * device_name, const char *intf_name);
+int platform_set_audio_device_interface(const char * device_name, const char *intf_name,
+ const char * codec_type);
#endif // AUDIO_PLATFORM_API_H
diff --git a/hal/platform_info.c b/hal/platform_info.c
index 13a314e..b65411f 100644
--- a/hal/platform_info.c
+++ b/hal/platform_info.c
@@ -87,7 +87,7 @@
* ...
* </pcm_ids>
* <interface_names>
- * <device name="Use audio device name here, not sound device name" interface="PRIMARY_I2S"/>
+ * <device name="Use audio device name here, not sound device name" interface="PRIMARY_I2S" codec_type="external/internal"/>
* ...
* ...
* </interface_names>
@@ -262,7 +262,15 @@
goto done;
}
- ret = platform_set_audio_device_interface((char *)attr[1], (char *)attr[3]);
+ if (strcmp(attr[4], "codec_type") != 0) {
+ ALOGE("%s: Device %s has no codec type set!",
+ __func__, attr[1]);
+
+ goto done;
+ }
+
+ ret = platform_set_audio_device_interface((char *)attr[1], (char *)attr[3],
+ (char *)attr[5]);
if (ret < 0) {
ALOGE("%s: Audio Interface not set!", __func__);