Skip to content

Commit e581e30

Browse files
wenliangwubroonie
authored andcommitted
ASoC: mediatek: mt8195: add DPTX audio support
This patch adds DPTX audio support on mt8195-mt6359-rt1019-rt5682 board. Signed-off-by: Trevor Wu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 40d605d commit e581e30

File tree

2 files changed

+84
-5
lines changed

2 files changed

+84
-5
lines changed

sound/soc/mediatek/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ config SND_SOC_MT8195_MT6359_RT1019_RT5682
202202
select SND_SOC_RT1015P
203203
select SND_SOC_RT5682_I2C
204204
select SND_SOC_DMIC
205+
select SND_SOC_HDMI_CODEC
205206
help
206207
This adds ASoC driver for Mediatek MT8195 boards
207208
with the MT6359 RT1019 RT5682 audio codec.

sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
struct mt8195_mt6359_rt1019_rt5682_priv {
2929
struct snd_soc_jack headset_jack;
30+
struct snd_soc_jack dp_jack;
3031
};
3132

3233
static const struct snd_soc_dapm_widget
@@ -327,6 +328,52 @@ static int mt8195_etdm_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
327328
return 0;
328329
}
329330

331+
static int mt8195_hdmitx_dptx_startup(struct snd_pcm_substream *substream)
332+
{
333+
static const unsigned int rates[] = {
334+
48000
335+
};
336+
static const unsigned int channels[] = {
337+
2, 4, 6, 8
338+
};
339+
static const struct snd_pcm_hw_constraint_list constraints_rates = {
340+
.count = ARRAY_SIZE(rates),
341+
.list = rates,
342+
.mask = 0,
343+
};
344+
static const struct snd_pcm_hw_constraint_list constraints_channels = {
345+
.count = ARRAY_SIZE(channels),
346+
.list = channels,
347+
.mask = 0,
348+
};
349+
350+
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
351+
struct snd_pcm_runtime *runtime = substream->runtime;
352+
int ret;
353+
354+
ret = snd_pcm_hw_constraint_list(runtime, 0,
355+
SNDRV_PCM_HW_PARAM_RATE,
356+
&constraints_rates);
357+
if (ret < 0) {
358+
dev_err(rtd->dev, "hw_constraint_list rate failed\n");
359+
return ret;
360+
}
361+
362+
ret = snd_pcm_hw_constraint_list(runtime, 0,
363+
SNDRV_PCM_HW_PARAM_CHANNELS,
364+
&constraints_channels);
365+
if (ret < 0) {
366+
dev_err(rtd->dev, "hw_constraint_list channel failed\n");
367+
return ret;
368+
}
369+
370+
return 0;
371+
}
372+
373+
static const struct snd_soc_ops mt8195_hdmitx_dptx_playback_ops = {
374+
.startup = mt8195_hdmitx_dptx_startup,
375+
};
376+
330377
static int mt8195_dptx_hw_params(struct snd_pcm_substream *substream,
331378
struct snd_pcm_hw_params *params)
332379
{
@@ -344,8 +391,25 @@ static struct snd_soc_ops mt8195_dptx_ops = {
344391
.hw_params = mt8195_dptx_hw_params,
345392
};
346393

347-
static int mt8195_dptx_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
348-
struct snd_pcm_hw_params *params)
394+
static int mt8195_dptx_codec_init(struct snd_soc_pcm_runtime *rtd)
395+
{
396+
struct mt8195_mt6359_rt1019_rt5682_priv *priv =
397+
snd_soc_card_get_drvdata(rtd->card);
398+
struct snd_soc_component *cmpnt_codec =
399+
asoc_rtd_to_codec(rtd, 0)->component;
400+
int ret = 0;
401+
402+
ret = snd_soc_card_jack_new(rtd->card, "DP Jack", SND_JACK_LINEOUT,
403+
&priv->dp_jack, NULL, 0);
404+
if (ret)
405+
return ret;
406+
407+
return snd_soc_component_set_jack(cmpnt_codec, &priv->dp_jack, NULL);
408+
}
409+
410+
static int mt8195_hdmitx_dptx_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
411+
struct snd_pcm_hw_params *params)
412+
349413
{
350414
/* fix BE i2s format to 32bit, clean param mask first */
351415
snd_mask_reset_range(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT),
@@ -687,6 +751,7 @@ static struct snd_soc_dai_link mt8195_mt6359_rt1019_rt5682_dai_links[] = {
687751
},
688752
.dynamic = 1,
689753
.dpcm_playback = 1,
754+
.ops = &mt8195_hdmitx_dptx_playback_ops,
690755
SND_SOC_DAILINK_REG(DL10_FE),
691756
},
692757
[DAI_LINK_DL11_FE] = {
@@ -820,7 +885,7 @@ static struct snd_soc_dai_link mt8195_mt6359_rt1019_rt5682_dai_links[] = {
820885
.no_pcm = 1,
821886
.dpcm_playback = 1,
822887
.ops = &mt8195_dptx_ops,
823-
.be_hw_params_fixup = mt8195_dptx_hw_params_fixup,
888+
.be_hw_params_fixup = mt8195_hdmitx_dptx_hw_params_fixup,
824889
SND_SOC_DAILINK_REG(DPTX_BE),
825890
},
826891
[DAI_LINK_ETDM1_IN_BE] = {
@@ -915,7 +980,6 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
915980
struct device_node *platform_node;
916981
struct snd_soc_dai_link *dai_link;
917982
struct mt8195_mt6359_rt1019_rt5682_priv *priv = NULL;
918-
919983
int ret, i;
920984

921985
card->dev = &pdev->dev;
@@ -930,6 +994,20 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
930994
for_each_card_prelinks(card, i, dai_link) {
931995
if (!dai_link->platforms->name)
932996
dai_link->platforms->of_node = platform_node;
997+
998+
if (strcmp(dai_link->name, "DPTX_BE") == 0) {
999+
dai_link->codecs->of_node =
1000+
of_parse_phandle(pdev->dev.of_node,
1001+
"mediatek,dptx-codec", 0);
1002+
if (!dai_link->codecs->of_node) {
1003+
dev_err(&pdev->dev, "Property 'dptx-codec' missing or invalid\n");
1004+
return -EINVAL;
1005+
}
1006+
1007+
dai_link->codecs->name = NULL;
1008+
dai_link->codecs->dai_name = "i2s-hifi";
1009+
dai_link->init = mt8195_dptx_codec_init;
1010+
}
9331011
}
9341012

9351013
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -940,7 +1018,7 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
9401018

9411019
ret = devm_snd_soc_register_card(&pdev->dev, card);
9421020
if (ret)
943-
dev_dbg(&pdev->dev, "%s snd_soc_register_card fail %d\n",
1021+
dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
9441022
__func__, ret);
9451023
return ret;
9461024
}

0 commit comments

Comments
 (0)