From 67e19082df44b32641f3cb9f9b4983e9d25f37c1 Mon Sep 17 00:00:00 2001 From: Xiaojun Sang Date: Thu, 6 Aug 2020 16:57:07 +0800 Subject: [PATCH] AsoC: lahaina: support right speaker as mono device Current design assumes mono device uses left speaker. Modify the logic to remove the limitation. Change-Id: I6a7cd2b14ed5a4c10106593fe707a449d05efe48 Signed-off-by: Xiaojun Sang --- asoc/lahaina.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/asoc/lahaina.c b/asoc/lahaina.c index 11b8a782ec..bd4f18e553 100644 --- a/asoc/lahaina.c +++ b/asoc/lahaina.c @@ -7525,32 +7525,35 @@ static int msm_int_audrx_init(struct snd_soc_pcm_runtime *rtd) struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(rtd->card); int ret = 0; + int wsa_active_devs = 0; if (codec_reg_done) { return 0; } if (pdata->wsa_max_devs > 0) { component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1"); - if (!component) { - pr_err("%s: wsa-codec.1 component is NULL\n", __func__); - return -EINVAL; + if (component) { + dapm = snd_soc_component_get_dapm(component); + + wsa883x_set_channel_map(component, &spkleft_ports[0], + WSA883X_MAX_SWR_PORTS, &ch_mask[0], + &ch_rate[0], &spkleft_port_types[0]); + + wsa883x_codec_info_create_codec_entry(pdata->codec_root, + component); + wsa_active_devs++; + } else { + pr_info("%s: wsa-codec.1 component is NULL\n", __func__); } - - dapm = snd_soc_component_get_dapm(component); - - wsa883x_set_channel_map(component, &spkleft_ports[0], - WSA883X_MAX_SWR_PORTS, &ch_mask[0], - &ch_rate[0], &spkleft_port_types[0]); - - wsa883x_codec_info_create_codec_entry(pdata->codec_root, - component); } /* If current platform has more than one WSA */ - if (pdata->wsa_max_devs > 1) { + if (pdata->wsa_max_devs > wsa_active_devs) { component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2"); if (!component) { pr_err("%s: wsa-codec.2 component is NULL\n", __func__); + pr_err("%s: %d WSA is found. Expect %d WSA.", + __func__, wsa_active_devs, pdata->wsa_max_devs); return -EINVAL; }