Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: mediatek: Add second I2S on mt8173-rt5650 machine driver

This patch adds second I2S connection to rt5650 codec for capture path on
mt8173-rt5650 machine driver.

Signed-off-by: PC Liao <pc.liao@mediatek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

PC Liao and committed by
Mark Brown
d349caeb f55532a0

+57 -3
+10
Documentation/devicetree/bindings/sound/mt8173-rt5650.txt
··· 5 5 - mediatek,audio-codec: the phandles of rt5650 codecs 6 6 - mediatek,platform: the phandle of MT8173 ASoC platform 7 7 8 + Optional subnodes: 9 + - codec-capture : the subnode of rt5650 codec capture 10 + Required codec-capture subnode properties: 11 + - sound-dai: audio codec dai name on capture path 12 + <&rt5650 0> : Default setting. Connect rt5650 I2S1 for capture. (dai_name = rt5645-aif1) 13 + <&rt5650 1> : Connect rt5650 I2S2 for capture. (dai_name = rt5645-aif2) 14 + 8 15 Example: 9 16 10 17 sound { 11 18 compatible = "mediatek,mt8173-rt5650"; 12 19 mediatek,audio-codec = <&rt5650>; 13 20 mediatek,platform = <&afe>; 21 + codec-capture { 22 + sound-dai = <&rt5650 1>; 23 + }; 14 24 }; 15 25
+47 -3
sound/soc/mediatek/mt8173-rt5650.c
··· 85 85 { 86 86 struct snd_soc_card *card = runtime->card; 87 87 struct snd_soc_codec *codec = runtime->codec_dais[0]->codec; 88 + const char *codec_capture_dai = runtime->codec_dais[1]->name; 88 89 int ret; 89 90 90 91 rt5645_sel_asrc_clk_src(codec, 91 - RT5645_DA_STEREO_FILTER | 92 - RT5645_AD_STEREO_FILTER, 92 + RT5645_DA_STEREO_FILTER, 93 93 RT5645_CLK_SEL_I2S1_ASRC); 94 + 95 + if (!strcmp(codec_capture_dai, "rt5645-aif1")) { 96 + rt5645_sel_asrc_clk_src(codec, 97 + RT5645_AD_STEREO_FILTER, 98 + RT5645_CLK_SEL_I2S1_ASRC); 99 + } else if (!strcmp(codec_capture_dai, "rt5645-aif2")) { 100 + rt5645_sel_asrc_clk_src(codec, 101 + RT5645_AD_STEREO_FILTER, 102 + RT5645_CLK_SEL_I2S2_ASRC); 103 + } else { 104 + dev_warn(card->dev, 105 + "Only one dai codec found in DTS, enabled rt5645 AD filter\n"); 106 + rt5645_sel_asrc_clk_src(codec, 107 + RT5645_AD_STEREO_FILTER, 108 + RT5645_CLK_SEL_I2S1_ASRC); 109 + } 110 + 94 111 /* enable jack detection */ 95 112 ret = snd_soc_card_jack_new(card, "Headset Jack", 96 113 SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | ··· 127 110 128 111 static struct snd_soc_dai_link_component mt8173_rt5650_codecs[] = { 129 112 { 113 + /* Playback */ 114 + .dai_name = "rt5645-aif1", 115 + }, 116 + { 117 + /* Capture */ 130 118 .dai_name = "rt5645-aif1", 131 119 }, 132 120 }; ··· 171 149 .cpu_dai_name = "I2S", 172 150 .no_pcm = 1, 173 151 .codecs = mt8173_rt5650_codecs, 174 - .num_codecs = 1, 152 + .num_codecs = 2, 175 153 .init = mt8173_rt5650_init, 176 154 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 177 155 SND_SOC_DAIFMT_CBS_CFS, ··· 199 177 { 200 178 struct snd_soc_card *card = &mt8173_rt5650_card; 201 179 struct device_node *platform_node; 180 + struct device_node *np; 181 + const char *codec_capture_dai; 202 182 int i, ret; 203 183 204 184 platform_node = of_parse_phandle(pdev->dev.of_node, ··· 223 199 "Property 'audio-codec' missing or invalid\n"); 224 200 return -EINVAL; 225 201 } 202 + mt8173_rt5650_codecs[1].of_node = mt8173_rt5650_codecs[0].of_node; 203 + 204 + if (of_find_node_by_name(platform_node, "codec-capture")) { 205 + np = of_get_child_by_name(pdev->dev.of_node, "codec-capture"); 206 + if (!np) { 207 + dev_err(&pdev->dev, 208 + "%s: Can't find codec-capture DT node\n", 209 + __func__); 210 + return -EINVAL; 211 + } 212 + ret = snd_soc_of_get_dai_name(np, &codec_capture_dai); 213 + if (ret < 0) { 214 + dev_err(&pdev->dev, 215 + "%s codec_capture_dai name fail %d\n", 216 + __func__, ret); 217 + return ret; 218 + } 219 + mt8173_rt5650_codecs[1].dai_name = codec_capture_dai; 220 + } 221 + 226 222 card->dev = &pdev->dev; 227 223 platform_set_drvdata(pdev, card); 228 224