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
This commit is contained in:
Karthik Reddy Katta 2015-05-11 13:43:18 +05:30
parent 9aee331b49
commit 508eca4954
5 changed files with 41 additions and 16 deletions

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -87,7 +87,7 @@ static section_t section;
* ...
* </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 @@ 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__);