Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5be00f77 authored by Yeleswarapu Nagaradhesh's avatar Yeleswarapu Nagaradhesh Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: msm: add support for wcd934x



Add support for wcd934x codec in machine
driver.

CRs-Fixed: 1041199
Change-Id: I98bbd10cc25e11f0411c94a4fdbedebc1ab56429
Signed-off-by: default avatarYeleswarapu Nagaradhesh <nagaradh@codeaurora.org>
parent c9338c07
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ config SND_SOC_MSMCOBALT
	select MSM_QDSP6_APRV2_GLINK
	select MSM_QDSP6V2_CODECS
	select SND_SOC_WCD9335
	select SND_SOC_WCD934X
	select SND_SOC_WSA881X
	select SND_SOC_MSM_HDMI_CODEC_RX
	select DTS_SRS_TM
+276 −52
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <device_event.h>
#include "qdsp6v2/msm-pcm-routing-v2.h"
#include "../codecs/wcd9335.h"
#include "../codecs/wcd934x/wcd934x.h"
#include "../codecs/wsa881x.h"

#define DRV_NAME "msmcobalt-asoc-snd"
@@ -239,7 +240,7 @@ static struct wcd_mbhc_config wcd_mbhc_cfg = {
	.moist_cfg = { V_45_MV, I_3P0_UA },
};

static struct snd_soc_dapm_route wcd9335_audio_paths[] = {
static struct snd_soc_dapm_route wcd_audio_paths[] = {
	{"MIC BIAS1", NULL, "MCLK"},
	{"MIC BIAS2", NULL, "MCLK"},
	{"MIC BIAS3", NULL, "MCLK"},
@@ -1107,6 +1108,8 @@ static int msm_snd_enable_codec_ext_clk(struct snd_soc_codec *codec,

	if (!strcmp(dev_name(codec->dev), "tasha_codec"))
		ret = tasha_cdc_mclk_enable(codec, enable, dapm);
	else if (!strcmp(dev_name(codec->dev), "tavil_codec"))
		ret = tavil_cdc_mclk_enable(codec, enable);
	else {
		dev_err(codec->dev, "%s: unknown codec to enable ext clk\n",
			__func__);
@@ -1528,8 +1531,8 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
	snd_soc_dapm_new_controls(dapm, msm_dapm_widgets,
				ARRAY_SIZE(msm_dapm_widgets));

	snd_soc_dapm_add_routes(dapm, wcd9335_audio_paths,
				ARRAY_SIZE(wcd9335_audio_paths));
	snd_soc_dapm_add_routes(dapm, wcd_audio_paths,
				ARRAY_SIZE(wcd_audio_paths));

	snd_soc_dapm_ignore_suspend(dapm, "Handset Mic");
	snd_soc_dapm_ignore_suspend(dapm, "Headset Mic");
@@ -1567,8 +1570,12 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
	snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
				    tx_ch, ARRAY_SIZE(rx_ch), rx_ch);

	if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
		msm_codec_fn.get_afe_config_fn = tavil_get_afe_config;
	} else {
		msm_codec_fn.get_afe_config_fn = tasha_get_afe_config;
		msm_codec_fn.mbhc_hs_detect_exit = tasha_mbhc_hs_detect_exit;
	}

	ret = msm_adsp_power_up_config(codec);
	if (ret) {
@@ -1576,6 +1583,7 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
		goto err_afe_cfg;
	}

	if (!strcmp(dev_name(codec_dai->dev), "tasha_codec")) {
		config_data = msm_codec_fn.get_afe_config_fn(codec,
							AFE_AANC_VERSION);
		if (config_data) {
@@ -1607,6 +1615,7 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
				goto err_afe_cfg;
			}
		}
	}
	adsp_state_notifier = subsys_notif_register_notifier("adsp",
						&adsp_state_notifier_block);
	if (!adsp_state_notifier) {
@@ -1619,6 +1628,15 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
	 * Send speaker configuration only for WSA8810.
	 * Defalut configuration is for WSA8815.
	 */
	if (!strcmp(dev_name(codec_dai->dev), "tavil_codec")) {
		if (rtd_aux && rtd_aux->component)
			if (!strcmp(rtd_aux->component->name, WSA8810_NAME_1) ||
			    !strcmp(rtd_aux->component->name, WSA8810_NAME_2)) {
				tavil_set_spkr_mode(rtd->codec, SPKR_MODE_1);
				tavil_set_spkr_gain_offset(rtd->codec,
							RX_GAIN_OFFSET_M1P5_DB);
		}
	} else {
		if (rtd_aux && rtd_aux->component)
			if (!strcmp(rtd_aux->component->name, WSA8810_NAME_1) ||
			    !strcmp(rtd_aux->component->name, WSA8810_NAME_2)) {
@@ -1626,8 +1644,6 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
				tasha_set_spkr_gain_offset(rtd->codec,
							RX_GAIN_OFFSET_M1P5_DB);
		}
	codec_reg_done = true;

		card = rtd->card->snd_card;
		entry = snd_register_module_info(card->module, "codecs",
						 card->proc_root);
@@ -1639,7 +1655,8 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
		}
		pdata->codec_root = entry;
		tasha_codec_info_create_codec_entry(pdata->codec_root, codec);

	}
	codec_reg_done = true;
	return 0;

err_snd_module:
@@ -2595,6 +2612,33 @@ static struct snd_soc_dai_link msm_tasha_fe_dai_links[] = {
	},
};

static struct snd_soc_dai_link msm_tavil_fe_dai_links[] = {
	/* Ultrasound RX DAI Link */
	{
		.name = "SLIMBUS_2 Hostless Playback",
		.stream_name = "SLIMBUS_2 Hostless Playback",
		.cpu_dai_name = "msm-dai-q6-dev.16388",
		.platform_name = "msm-pcm-hostless",
		.codec_name = "tavil_codec",
		.codec_dai_name = "tavil_rx2",
		.ignore_suspend = 1,
		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
		.ops = &msm_slimbus_2_be_ops,
	},
	/* Ultrasound TX DAI Link */
	{
		.name = "SLIMBUS_2 Hostless Capture",
		.stream_name = "SLIMBUS_2 Hostless Capture",
		.cpu_dai_name = "msm-dai-q6-dev.16389",
		.platform_name = "msm-pcm-hostless",
		.codec_name = "tavil_codec",
		.codec_dai_name = "tavil_tx2",
		.ignore_suspend = 1,
		.no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
		.ops = &msm_slimbus_2_be_ops,
	},
};

static struct snd_soc_dai_link msm_common_be_dai_links[] = {
	/* Backend AFE DAI Links */
	{
@@ -2867,6 +2911,132 @@ static struct snd_soc_dai_link msm_tasha_be_dai_links[] = {
	},
};

static struct snd_soc_dai_link msm_tavil_be_dai_links[] = {
	{
		.name = LPASS_BE_SLIMBUS_0_RX,
		.stream_name = "Slimbus Playback",
		.cpu_dai_name = "msm-dai-q6-dev.16384",
		.platform_name = "msm-pcm-routing",
		.codec_name = "tavil_codec",
		.codec_dai_name = "tavil_rx1",
		.no_pcm = 1,
		.dpcm_playback = 1,
		.be_id = MSM_BACKEND_DAI_SLIMBUS_0_RX,
		.init = &msm_audrx_init,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		/* this dainlink has playback support */
		.ignore_pmdown_time = 1,
		.ignore_suspend = 1,
		.ops = &msm_be_ops,
	},
	{
		.name = LPASS_BE_SLIMBUS_0_TX,
		.stream_name = "Slimbus Capture",
		.cpu_dai_name = "msm-dai-q6-dev.16385",
		.platform_name = "msm-pcm-routing",
		.codec_name = "tavil_codec",
		.codec_dai_name = "tavil_tx1",
		.no_pcm = 1,
		.dpcm_capture = 1,
		.be_id = MSM_BACKEND_DAI_SLIMBUS_0_TX,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ignore_suspend = 1,
		.ops = &msm_be_ops,
	},
	{
		.name = LPASS_BE_SLIMBUS_1_RX,
		.stream_name = "Slimbus1 Playback",
		.cpu_dai_name = "msm-dai-q6-dev.16386",
		.platform_name = "msm-pcm-routing",
		.codec_name = "tavil_codec",
		.codec_dai_name = "tavil_rx1",
		.no_pcm = 1,
		.dpcm_playback = 1,
		.be_id = MSM_BACKEND_DAI_SLIMBUS_1_RX,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ops = &msm_be_ops,
		/* dai link has playback support */
		.ignore_pmdown_time = 1,
		.ignore_suspend = 1,
	},
	{
		.name = LPASS_BE_SLIMBUS_1_TX,
		.stream_name = "Slimbus1 Capture",
		.cpu_dai_name = "msm-dai-q6-dev.16387",
		.platform_name = "msm-pcm-routing",
		.codec_name = "tavil_codec",
		.codec_dai_name = "tavil_tx3",
		.no_pcm = 1,
		.dpcm_capture = 1,
		.be_id = MSM_BACKEND_DAI_SLIMBUS_1_TX,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ops = &msm_be_ops,
		.ignore_suspend = 1,
	},
	{
		.name = LPASS_BE_SLIMBUS_3_RX,
		.stream_name = "Slimbus3 Playback",
		.cpu_dai_name = "msm-dai-q6-dev.16390",
		.platform_name = "msm-pcm-routing",
		.codec_name = "tavil_codec",
		.codec_dai_name = "tavil_rx1",
		.no_pcm = 1,
		.dpcm_playback = 1,
		.be_id = MSM_BACKEND_DAI_SLIMBUS_3_RX,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ops = &msm_be_ops,
		/* dai link has playback support */
		.ignore_pmdown_time = 1,
		.ignore_suspend = 1,
	},
	{
		.name = LPASS_BE_SLIMBUS_3_TX,
		.stream_name = "Slimbus3 Capture",
		.cpu_dai_name = "msm-dai-q6-dev.16391",
		.platform_name = "msm-pcm-routing",
		.codec_name = "tavil_codec",
		.codec_dai_name = "tavil_tx1",
		.no_pcm = 1,
		.dpcm_capture = 1,
		.be_id = MSM_BACKEND_DAI_SLIMBUS_3_TX,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ops = &msm_be_ops,
		.ignore_suspend = 1,
	},
	{
		.name = LPASS_BE_SLIMBUS_4_RX,
		.stream_name = "Slimbus4 Playback",
		.cpu_dai_name = "msm-dai-q6-dev.16392",
		.platform_name = "msm-pcm-routing",
		.codec_name = "tavil_codec",
		.codec_dai_name = "tavil_rx1",
		.no_pcm = 1,
		.dpcm_playback = 1,
		.be_id = MSM_BACKEND_DAI_SLIMBUS_4_RX,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ops = &msm_be_ops,
		/* dai link has playback support */
		.ignore_pmdown_time = 1,
		.ignore_suspend = 1,
	},
	{
		.name = LPASS_BE_SLIMBUS_5_RX,
		.stream_name = "Slimbus5 Playback",
		.cpu_dai_name = "msm-dai-q6-dev.16394",
		.platform_name = "msm-pcm-routing",
		.codec_name = "tavil_codec",
		.codec_dai_name = "tavil_rx3",
		.no_pcm = 1,
		.dpcm_playback = 1,
		.be_id = MSM_BACKEND_DAI_SLIMBUS_5_RX,
		.be_hw_params_fixup = msm_be_hw_params_fixup,
		.ops = &msm_be_ops,
		/* dai link has playback support */
		.ignore_pmdown_time = 1,
		.ignore_suspend = 1,
	},
};

static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
	{
		.name = LPASS_BE_SLIMBUS_7_RX,
@@ -2941,6 +3111,14 @@ static struct snd_soc_dai_link msm_tasha_dai_links[
			 ARRAY_SIZE(msm_wcn_be_dai_links) +
			 ARRAY_SIZE(hdmi_be_dai_link)];

static struct snd_soc_dai_link msm_tavil_dai_links[
			 ARRAY_SIZE(msm_common_dai_links) +
			 ARRAY_SIZE(msm_tavil_fe_dai_links) +
			 ARRAY_SIZE(msm_common_be_dai_links) +
			 ARRAY_SIZE(msm_tavil_be_dai_links) +
			 ARRAY_SIZE(msm_wcn_be_dai_links) +
			 ARRAY_SIZE(hdmi_be_dai_link)];

static int msm_snd_card_late_probe(struct snd_soc_card *card)
{
	const char *be_dl_name = LPASS_BE_SLIMBUS_0_RX;
@@ -2985,6 +3163,10 @@ struct snd_soc_card snd_soc_card_tasha_msm = {
	.late_probe	= msm_snd_card_late_probe,
};

struct snd_soc_card snd_soc_card_tavil_msm = {
	.name		= "msmcobalt-tavil-snd-card",
};

static int msm_populate_dai_link_component_of_node(
					struct snd_soc_card *card)
{
@@ -3247,6 +3429,8 @@ struct snd_soc_card snd_soc_card_stub_msm = {
static const struct of_device_id msmcobalt_asoc_machine_of_match[]  = {
	{ .compatible = "qcom,msmcobalt-asoc-snd-tasha",
	  .data = "tasha_codec"},
	{ .compatible = "qcom,msmcobalt-asoc-snd-tavil",
	  .data = "tavil_codec"},
	{ .compatible = "qcom,msmcobalt-asoc-snd-stub",
	  .data = "stub_codec"},
	{},
@@ -3304,6 +3488,43 @@ static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
		}

		dailink = msm_tasha_dai_links;
	}  else if (!strcmp(match->data, "tavil_codec")) {
		card = &snd_soc_card_tavil_msm;
		len_1 = ARRAY_SIZE(msm_common_dai_links);
		len_2 = len_1 + ARRAY_SIZE(msm_tavil_fe_dai_links);
		len_3 = len_2 + ARRAY_SIZE(msm_common_be_dai_links);
		total_links = len_3 + ARRAY_SIZE(msm_tavil_be_dai_links);
		memcpy(msm_tavil_dai_links,
		       msm_common_dai_links,
		       sizeof(msm_common_dai_links));
		memcpy(msm_tavil_dai_links + len_1,
		       msm_tavil_fe_dai_links,
		       sizeof(msm_tavil_fe_dai_links));
		memcpy(msm_tavil_dai_links + len_2,
		       msm_common_be_dai_links,
		       sizeof(msm_common_be_dai_links));
		memcpy(msm_tavil_dai_links + len_3,
		       msm_tavil_be_dai_links,
		       sizeof(msm_tavil_be_dai_links));

		if (of_property_read_bool(dev->of_node, "qcom,wcn-btfm")) {
			dev_dbg(dev, "%s(): WCN BTFM support present\n",
				__func__);
			memcpy(msm_tavil_dai_links + total_links,
			       msm_wcn_be_dai_links,
			       sizeof(msm_wcn_be_dai_links));
			total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
		}

		if (of_property_read_bool(dev->of_node, "qcom,hdmi-audio-rx")) {
			dev_dbg(dev, "%s(): HDMI support present\n", __func__);
			memcpy(msm_tavil_dai_links + total_links,
			       hdmi_be_dai_link,
			       sizeof(hdmi_be_dai_link));
			total_links += ARRAY_SIZE(hdmi_be_dai_link);
		}

		dailink = msm_tavil_dai_links;
	} else if (!strcmp(match->data, "stub_codec")) {
		card = &snd_soc_card_stub_msm;
		len_1 = ARRAY_SIZE(msm_stub_fe_dai_links);
@@ -3620,7 +3841,10 @@ static int msm_asoc_machine_probe(struct platform_device *pdev)
		goto err;
	}

	if (!strcmp(match->data, "tasha_codec"))
		mclk_freq_prop_name = "qcom,tasha-mclk-clk-freq";
	else
		mclk_freq_prop_name = "qcom,tavil-mclk-clk-freq";

	ret = of_property_read_u32(pdev->dev.of_node,
			mclk_freq_prop_name, &pdata->mclk_freq);