From 508eca4954eac1e8e7be9ed359757cf18ccfe41d Mon Sep 17 00:00:00 2001 From: Karthik Reddy Katta Date: Mon, 11 May 2015 13:43:18 +0530 Subject: [PATCH] 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 --- hal/msm8916/platform.c | 36 +++++++++++++++++++++++++----------- hal/msm8960/platform.c | 3 ++- hal/msm8974/platform.c | 3 ++- hal/platform_api.h | 3 ++- hal/platform_info.c | 12 ++++++++++-- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c index e9780bc9..4ef84b7c 100644 --- a/hal/msm8916/platform.c +++ b/hal/msm8916/platform.c @@ -707,7 +707,9 @@ static void update_codec_type(const char *snd_card_name) { !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 @@ int platform_get_subsys_image_name(char *buf) /* * 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 @@ int platform_set_audio_device_interface(const char * device_name, 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 bbfa0421..f9b7851f 100644 --- a/hal/msm8960/platform.c +++ b/hal/msm8960/platform.c @@ -1155,7 +1155,8 @@ int platform_set_device_params(struct stream_out *out __unused, } 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 24e23e6a..b4c4c44e 100644 --- a/hal/msm8974/platform.c +++ b/hal/msm8974/platform.c @@ -3757,7 +3757,8 @@ struct audio_device_to_audio_interface audio_device_to_interface_table[] = { 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 3808b148..4ecdd36d 100644 --- a/hal/platform_api.h +++ b/hal/platform_api.h @@ -109,5 +109,6 @@ void platform_cache_edid(void * platform); 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 13a314eb..b65411fc 100644 --- a/hal/platform_info.c +++ b/hal/platform_info.c @@ -87,7 +87,7 @@ static section_t section; * ... * * - * + * * ... * ... * @@ -262,7 +262,15 @@ static void process_interface_name(const XML_Char **attr) 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__);