Revert "hal: update combo device handling"
This reverts commit 993e1f42e79729da2cd80df56072f954ad666b42.
Change-Id: I758f222fdb861feb730b7caba1416ba2e393b5b7
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 03f6e25..c8edd3e 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -636,8 +636,7 @@
{TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS)},
};
-static char * backend_tag_table[SND_DEVICE_MAX] = {0};
-static char * hw_interface_table[SND_DEVICE_MAX] = {0};
+static char * backend_table[SND_DEVICE_MAX] = {0};
static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = {
{TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_DEEP_BUFFER)},
@@ -1036,39 +1035,35 @@
const char *MEDIA_MIMETYPE_AUDIO_APE = "audio/x-ape";
for (dev = 0; dev < SND_DEVICE_MAX; dev++) {
- backend_tag_table[dev] = NULL;
- hw_interface_table[dev] = NULL;
+ backend_table[dev] = NULL;
}
for (dev = 0; dev < SND_DEVICE_MAX; dev++) {
backend_bit_width_table[dev] = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
}
- // To overwrite these go to the audio_platform_info.xml file.
- backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC] = strdup("bt-sco");
- backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_WB] = strdup("bt-sco-wb");
- backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_NREC] = strdup("bt-sco");
- backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = strdup("bt-sco-wb");
- backend_tag_table[SND_DEVICE_OUT_BT_SCO] = strdup("bt-sco");
- backend_tag_table[SND_DEVICE_OUT_BT_SCO_WB] = strdup("bt-sco-wb");
- backend_tag_table[SND_DEVICE_OUT_HDMI] = strdup("hdmi");
- backend_tag_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("speaker-and-hdmi");
- backend_tag_table[SND_DEVICE_OUT_VOICE_TX] = strdup("afe-proxy");
- backend_tag_table[SND_DEVICE_IN_VOICE_RX] = strdup("afe-proxy");
- backend_tag_table[SND_DEVICE_OUT_AFE_PROXY] = strdup("afe-proxy");
- backend_tag_table[SND_DEVICE_OUT_USB_HEADSET] = strdup("usb-headphones");
- backend_tag_table[SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] =
- strdup("speaker-and-usb-headphones");
- backend_tag_table[SND_DEVICE_IN_USB_HEADSET_MIC] = strdup("usb-headset-mic");
- backend_tag_table[SND_DEVICE_IN_CAPTURE_FM] = strdup("capture-fm");
- backend_tag_table[SND_DEVICE_OUT_TRANSMISSION_FM] = strdup("transmission-fm");
- backend_tag_table[SND_DEVICE_OUT_HEADPHONES] = strdup("headphones");
- backend_tag_table[SND_DEVICE_OUT_HEADPHONES_44_1] = strdup("headphones-44.1");
- backend_tag_table[SND_DEVICE_OUT_VOICE_SPEAKER_VBAT] = strdup("voice-speaker-vbat");
+ // TBD - do these go to the platform-info.xml file.
+ // will help in avoiding strdups here
+ backend_table[SND_DEVICE_IN_BT_SCO_MIC] = strdup("bt-sco");
+ backend_table[SND_DEVICE_IN_BT_SCO_MIC_WB] = strdup("bt-sco-wb");
+ backend_table[SND_DEVICE_IN_BT_SCO_MIC_NREC] = strdup("bt-sco");
+ backend_table[SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = strdup("bt-sco-wb");
+ backend_table[SND_DEVICE_OUT_BT_SCO] = strdup("bt-sco");
+ backend_table[SND_DEVICE_OUT_BT_SCO_WB] = strdup("bt-sco-wb");
+ backend_table[SND_DEVICE_OUT_HDMI] = strdup("hdmi");
+ backend_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("speaker-and-hdmi");
+ backend_table[SND_DEVICE_OUT_VOICE_TX] = strdup("afe-proxy");
+ backend_table[SND_DEVICE_IN_VOICE_RX] = strdup("afe-proxy");
- hw_interface_table[SND_DEVICE_OUT_HEADPHONES_44_1] = strdup("SLIMBUS_5_RX");
- hw_interface_table[SND_DEVICE_OUT_HDMI] = strdup("HDMI_RX");
- hw_interface_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("SLIMBUS_0_RX-and-HDMI_RX");
- hw_interface_table[SND_DEVICE_OUT_VOICE_TX] = strdup("AFE_PCM_RX");
+ backend_table[SND_DEVICE_OUT_AFE_PROXY] = strdup("afe-proxy");
+ backend_table[SND_DEVICE_OUT_USB_HEADSET] = strdup("usb-headphones");
+ backend_table[SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] =
+ strdup("speaker-and-usb-headphones");
+ backend_table[SND_DEVICE_IN_USB_HEADSET_MIC] = strdup("usb-headset-mic");
+ backend_table[SND_DEVICE_IN_CAPTURE_FM] = strdup("capture-fm");
+ backend_table[SND_DEVICE_OUT_TRANSMISSION_FM] = strdup("transmission-fm");
+ backend_table[SND_DEVICE_OUT_HEADPHONES] = strdup("headphones");
+ backend_table[SND_DEVICE_OUT_HEADPHONES_44_1] = strdup("headphones-44.1");
+ backend_table[SND_DEVICE_OUT_VOICE_SPEAKER_VBAT] = strdup("voice-speaker-vbat");
/*remove ALAC & APE from DSP decoder list based on software decoder availability*/
@@ -1649,11 +1644,6 @@
}
}
- my_data->current_backend_cfg[HEADPHONE_BACKEND].bitwidth_mixer_ctl =
- strdup("SLIM_6_RX Format");
- my_data->current_backend_cfg[HEADPHONE_BACKEND].samplerate_mixer_ctl =
- strdup("SLIM_6_RX SampleRate");
-
my_data->edid_info = NULL;
free(snd_card_name);
free(snd_card_name_t);
@@ -1679,9 +1669,9 @@
int32_t dev;
for (dev = 0; dev < SND_DEVICE_MAX; dev++) {
- if (backend_tag_table[dev]) {
- free(backend_tag_table[dev]);
- backend_tag_table[dev]= NULL;
+ if (backend_table[dev]) {
+ free(backend_table[dev]);
+ backend_table[dev]= NULL;
}
}
@@ -1758,7 +1748,7 @@
return;
}
- const char * suffix = backend_tag_table[snd_device];
+ const char * suffix = backend_table[snd_device];
if (suffix != NULL) {
strlcat(mixer_path, " ", MIXER_PATH_MAX_LENGTH);
@@ -1766,40 +1756,6 @@
}
}
-bool platform_check_backends_match(snd_device_t snd_device1, snd_device_t snd_device2)
-{
- bool result = true;
-
- ALOGV("%s: snd_device1 = %s, snd_device2 = %s", __func__,
- platform_get_snd_device_name(snd_device1),
- platform_get_snd_device_name(snd_device2));
-
- if ((snd_device1 < SND_DEVICE_MIN) || (snd_device1 >= SND_DEVICE_OUT_END)) {
- ALOGE("%s: Invalid snd_device = %s", __func__,
- platform_get_snd_device_name(snd_device1));
- return false;
- }
- if ((snd_device2 < SND_DEVICE_MIN) || (snd_device2 >= SND_DEVICE_OUT_END)) {
- ALOGE("%s: Invalid snd_device = %s", __func__,
- platform_get_snd_device_name(snd_device2));
- return false;
- }
- const char * be_itf1 = hw_interface_table[snd_device1];
- const char * be_itf2 = hw_interface_table[snd_device2];
-
- if (NULL != be_itf1 && NULL != be_itf2) {
- if (0 != strcmp(be_itf1, be_itf2))
- result = false;
- } else if (NULL == be_itf1 && NULL != be_itf2) {
- result = false;
- } else if (NULL != be_itf1 && NULL == be_itf2) {
- result = false;
- }
-
- ALOGV("%s: be_itf1 = %s, be_itf2 = %s, match %d", __func__, be_itf1, be_itf2, result);
- return result;
-}
-
int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
{
int device_id;
@@ -1923,8 +1879,6 @@
goto done;
}
- ALOGV("%s: acdb_device_table[%s]: old = %d new = %d", __func__,
- platform_get_snd_device_name(snd_device), acdb_device_table[snd_device], acdb_id);
acdb_device_table[snd_device] = acdb_id;
done:
return ret;
@@ -2115,26 +2069,21 @@
return ret;
}
-static int platform_get_backend_index(snd_device_t snd_device)
+int platform_get_backend_index(snd_device_t snd_device)
{
int32_t port = DEFAULT_CODEC_BACKEND;
if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) {
- if (backend_tag_table[snd_device] != NULL) {
- if (strncmp(backend_tag_table[snd_device], "headphones-44.1",
- sizeof("headphones-44.1")) == 0)
- port = HEADPHONE_44_1_BACKEND;
- else if (strncmp(backend_tag_table[snd_device], "headphones",
- sizeof("headphones")) == 0)
- port = HEADPHONE_BACKEND;
- else if (strcmp(backend_tag_table[snd_device], "hdmi") == 0)
- port = HDMI_RX_BACKEND;
- }
+ if (backend_table[snd_device] != NULL &&
+ strcmp(backend_table[snd_device], "headphones-44.1") == 0)
+ port = HEADPHONE_44_1_BACKEND;
+ else
+ port = DEFAULT_CODEC_BACKEND;
} else {
ALOGV("%s:napb: Invalid device - %d ", __func__, snd_device);
}
- ALOGV("%s:napb: backend port - %d snd_device %d", __func__, port, snd_device);
+ ALOGV("%s:napb: backend port - %d", __func__, port);
return port;
}
@@ -2145,11 +2094,9 @@
int acdb_dev_id, acdb_dev_type;
struct audio_device *adev = my_data->adev;
int snd_device = SND_DEVICE_OUT_SPEAKER;
- int new_snd_device[SND_DEVICE_OUT_END];
- int i, num_devices = 1;
if (usecase->type == PCM_PLAYBACK)
- snd_device = usecase->out_snd_device;
+ snd_device = usecase->out_snd_device;
else if ((usecase->type == PCM_CAPTURE) &&
voice_is_in_call_rec_stream(usecase->stream.in))
snd_device = voice_get_incall_rec_snd_device(usecase->in_snd_device);
@@ -2162,32 +2109,17 @@
__func__, snd_device);
return -EINVAL;
}
-
- if(!platform_can_split_snd_device(my_data, snd_device,
- &num_devices, new_snd_device)) {
- new_snd_device[0] = snd_device;
+ if (my_data->acdb_send_audio_cal) {
+ ALOGV("%s: sending audio calibration for snd_device(%d) acdb_id(%d)",
+ __func__, snd_device, acdb_dev_id);
+ if (snd_device >= SND_DEVICE_OUT_BEGIN &&
+ snd_device < SND_DEVICE_OUT_END)
+ acdb_dev_type = ACDB_DEV_TYPE_OUT;
+ else
+ acdb_dev_type = ACDB_DEV_TYPE_IN;
+ my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type, app_type,
+ sample_rate);
}
-
- for (i = 0; i < num_devices; i++) {
- acdb_dev_id = acdb_device_table[platform_get_spkr_prot_snd_device(new_snd_device[i])];
- if (acdb_dev_id < 0) {
- ALOGE("%s: Could not find acdb id for device(%d)",
- __func__, new_snd_device[i]);
- return -EINVAL;
- }
- if (my_data->acdb_send_audio_cal) {
- ALOGV("%s: sending audio calibration for snd_device(%d) acdb_id(%d)",
- __func__, new_snd_device[i], acdb_dev_id);
- if (new_snd_device[i] >= SND_DEVICE_OUT_BEGIN &&
- new_snd_device[i] < SND_DEVICE_OUT_END)
- acdb_dev_type = ACDB_DEV_TYPE_OUT;
- else
- acdb_dev_type = ACDB_DEV_TYPE_IN;
- my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type, app_type,
- sample_rate);
- }
- }
-
return 0;
}
@@ -2456,43 +2388,6 @@
return ret;
}
-bool platform_can_split_snd_device(void *platform,
- snd_device_t snd_device,
- int *num_devices,
- snd_device_t *new_snd_devices)
-{
- bool status = false;
- struct platform_data *my_data = (struct platform_data *)platform;
-
- if (NULL == num_devices || NULL == new_snd_devices) {
- ALOGE("%s: NULL pointer ..", __func__);
- return false;
- }
-
- /*
- * If wired headset/headphones/line devices share the same backend
- * with speaker/earpiece this routine returns false.
- */
- if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES &&
- !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, SND_DEVICE_OUT_HEADPHONES)) {
- *num_devices = 2;
- new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER;
- new_snd_devices[1] = SND_DEVICE_OUT_HEADPHONES;
- status = true;
- } else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI &&
- !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, SND_DEVICE_OUT_HDMI)) {
- *num_devices = 2;
- new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER;
- new_snd_devices[1] = SND_DEVICE_OUT_HDMI;
- status = true;
- }
-
- ALOGD("%s: snd_device(%d) num devices(%d) new_snd_devices(%d)", __func__,
- snd_device, *num_devices, *new_snd_devices);
-
- return status;
-}
-
snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *out)
{
struct platform_data *my_data = (struct platform_data *)platform;
@@ -3817,7 +3712,7 @@
/*
* configures afe with bit width and Sample Rate
*/
-static int platform_set_codec_backend_cfg(struct audio_device* adev,
+int platform_set_codec_backend_cfg(struct audio_device* adev,
snd_device_t snd_device,
unsigned int bit_width, unsigned int sample_rate)
{
@@ -3915,7 +3810,7 @@
* goes through all the current usecases and picks the highest
* bitwidth & samplerate
*/
-static bool platform_check_codec_backend_cfg(struct audio_device* adev,
+bool platform_check_codec_backend_cfg(struct audio_device* adev,
struct audio_usecase* usecase,
snd_device_t snd_device,
unsigned int* new_bit_width,
@@ -3927,6 +3822,7 @@
unsigned int bit_width;
unsigned int sample_rate;
int backend_idx = DEFAULT_CODEC_BACKEND;
+ int usecase_backend_idx = DEFAULT_CODEC_BACKEND;
struct platform_data *my_data = (struct platform_data *)adev->platform;
int na_mode = platform_get_native_support();
@@ -3965,6 +3861,8 @@
uc = node_to_item(node, struct audio_usecase, list);
struct stream_out *out = (struct stream_out*) uc->stream.out;
if (uc->type == PCM_PLAYBACK && out && usecase != uc) {
+ usecase_backend_idx =
+ platform_get_backend_index(uc->out_snd_device);
ALOGD("%s:napb: (%d) - (%s)id (%d) sr %d bw "
"(%d) device %s", __func__, i++, use_case_table[uc->id],
@@ -3972,7 +3870,7 @@
out->bit_width,
platform_get_snd_device_name(uc->out_snd_device));
- if (platform_check_backends_match(snd_device, uc->out_snd_device)) {
+ if (usecase_backend_idx == backend_idx) {
if (bit_width < out->bit_width)
bit_width = out->bit_width;
if (sample_rate < out->sample_rate)
@@ -4010,12 +3908,10 @@
* hifi playback not supported on spkr devices, limit the Sample Rate
* to 48 khz.
*/
- if (SND_DEVICE_OUT_SPEAKER == snd_device ||
- SND_DEVICE_OUT_SPEAKER_WSA == snd_device ||
- SND_DEVICE_OUT_SPEAKER_VBAT == snd_device) {
+ if (usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER) {
sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
- ALOGD("%s:becf: afe: playback on speaker device Configure afe to "
- "default Sample Rate(48k)", __func__);
+ ALOGD("%s:becf: afe: playback on speakers Configure afe to \
+ default Sample Rate(48k)", __func__);
}
/*
@@ -4051,9 +3947,6 @@
unsigned int new_sample_rate;
int backend_idx = DEFAULT_CODEC_BACKEND;
struct platform_data *my_data = (struct platform_data *)adev->platform;
- int new_snd_devices[SND_DEVICE_OUT_END];
- int i, num_devices = 1;
- bool ret = false;
backend_idx = platform_get_backend_index(snd_device);
@@ -4065,25 +3958,17 @@
new_sample_rate, backend_idx, usecase->id,
platform_get_snd_device_name(snd_device));
-
- if (!platform_can_split_snd_device(my_data, snd_device, &num_devices, new_snd_devices))
- new_snd_devices[0] = snd_device;
-
- for (i = 0; i < num_devices; i++) {
- ALOGI("%s: new_snd_devices[%d] is %d", __func__, i, new_snd_devices[i]);
- if (platform_check_codec_backend_cfg(adev, usecase, new_snd_devices[i],
- &new_bit_width, &new_sample_rate)) {
- platform_set_codec_backend_cfg(adev, new_snd_devices[i],
- new_bit_width, new_sample_rate);
- ret = true;
- }
+ if (platform_check_codec_backend_cfg(adev, usecase, snd_device,
+ &new_bit_width, &new_sample_rate)) {
+ platform_set_codec_backend_cfg(adev, snd_device,
+ new_bit_width, new_sample_rate);
+ return true;
}
- return ret;
+ return false;
}
-int platform_set_snd_device_backend(snd_device_t device, const char *backend_tag,
- const char * hw_interface)
+int platform_set_snd_device_backend(snd_device_t device, const char *backend)
{
int ret = 0;
@@ -4094,22 +3979,10 @@
goto done;
}
- ALOGD("%s: backend_tag_table[%s]: old = %s new = %s", __func__,
- platform_get_snd_device_name(device),
- backend_tag_table[device] != NULL ? backend_tag_table[device]: "null",
- backend_tag);
- if (backend_tag_table[device]) {
- free(backend_tag_table[device]);
+ if (backend_table[device]) {
+ free(backend_table[device]);
}
- backend_tag_table[device] = strdup(backend_tag);
-
- if (hw_interface != NULL) {
- if (hw_interface_table[device])
- free(hw_interface_table[device]);
-
- ALOGD("%s: hw_interface_table[%d] = %s", __func__, device, hw_interface);
- hw_interface_table[device] = strdup(hw_interface);
- }
+ backend_table[device] = strdup(backend);
done:
return ret;
}
@@ -4127,7 +4000,6 @@
ALOGE("%s: invalid usecase type", __func__);
ret = -EINVAL;
}
- ALOGV("%s: pcm_device_table[%d][%d] = %d", __func__, usecase, type, pcm_id);
pcm_device_table[usecase][type] = pcm_id;
done:
return ret;