ASoC: mediatek: mt8195: merge machine driver
Because most functions can be reused in different codec combinations, mt8195 machine drivers are combined to one common file. The model and compatible string are used to decide which codecs are being used. As a result, We can prevent from copy-paste functions when new codec combination is introduced. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20220324053851.27350-3-trevor.wu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
4dbc714fe0
Коммит
094e30efa4
|
@ -198,34 +198,19 @@ config SND_SOC_MT8195
|
|||
Select Y if you have such device.
|
||||
If unsure select "N".
|
||||
|
||||
config SND_SOC_MT8195_MT6359_RT1019_RT5682
|
||||
tristate "ASoC Audio driver for MT8195 with MT6359 RT1019 RT5682 codec"
|
||||
config SND_SOC_MT8195_MT6359
|
||||
tristate "ASoC Audio driver for MT8195 with MT6359 and I2S codecs"
|
||||
depends on I2C && GPIOLIB
|
||||
depends on SND_SOC_MT8195 && MTK_PMIC_WRAP
|
||||
select SND_SOC_MT6359
|
||||
select SND_SOC_RT1011
|
||||
select SND_SOC_RT1015P
|
||||
select SND_SOC_RT5682_I2C
|
||||
select SND_SOC_RT5682S
|
||||
select SND_SOC_DMIC
|
||||
select SND_SOC_HDMI_CODEC
|
||||
help
|
||||
This adds ASoC driver for Mediatek MT8195 boards
|
||||
with the MT6359 RT1019 RT5682 audio codec.
|
||||
Select Y if you have such device.
|
||||
If unsure select "N".
|
||||
|
||||
config SND_SOC_MT8195_MT6359_RT1011_RT5682
|
||||
tristate "ASoC Audio driver for MT8195 with MT6359 RT1011 RT5682 codec"
|
||||
depends on I2C && GPIOLIB
|
||||
depends on SND_SOC_MT8195 && MTK_PMIC_WRAP
|
||||
select SND_SOC_MT6359
|
||||
select SND_SOC_RT1011
|
||||
select SND_SOC_RT5682_I2C
|
||||
select SND_SOC_RT5682S
|
||||
select SND_SOC_DMIC
|
||||
select SND_SOC_HDMI_CODEC
|
||||
help
|
||||
This adds ASoC driver for Mediatek MT8195 boards
|
||||
with the MT6359 RT1011 RT5682 audio codec.
|
||||
This adds support for ASoC machine driver for Mediatek MT8195
|
||||
boards with the MT6359 and other I2S audio codecs.
|
||||
Select Y if you have such device.
|
||||
If unsure select "N".
|
||||
|
|
|
@ -12,5 +12,4 @@ snd-soc-mt8195-afe-objs := \
|
|||
obj-$(CONFIG_SND_SOC_MT8195) += snd-soc-mt8195-afe.o
|
||||
|
||||
# machine driver
|
||||
obj-$(CONFIG_SND_SOC_MT8195_MT6359_RT1019_RT5682) += mt8195-mt6359-rt1019-rt5682.o
|
||||
obj-$(CONFIG_SND_SOC_MT8195_MT6359_RT1011_RT5682) += mt8195-mt6359-rt1011-rt5682.o
|
||||
obj-$(CONFIG_SND_SOC_MT8195_MT6359) += mt8195-mt6359.o
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,26 +1,35 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* mt8195-mt6359-rt1019-rt5682.c --
|
||||
* MT8195-MT6359-RT1019-RT5682 ALSA SoC machine driver
|
||||
* mt8195-mt6359.c --
|
||||
* MT8195-MT6359 ALSA SoC machine driver code
|
||||
*
|
||||
* Copyright (c) 2021 MediaTek Inc.
|
||||
* Copyright (c) 2022 MediaTek Inc.
|
||||
* Author: Trevor Wu <trevor.wu@mediatek.com>
|
||||
* YC Hung <yc.hung@mediatek.com>
|
||||
*/
|
||||
|
||||
#include <linux/input.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <sound/jack.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/rt5682.h>
|
||||
#include <sound/soc.h>
|
||||
#include "../../codecs/mt6359.h"
|
||||
#include "../../codecs/rt1011.h"
|
||||
#include "../../codecs/rt5682.h"
|
||||
#include "../common/mtk-afe-platform-driver.h"
|
||||
#include "mt8195-afe-clk.h"
|
||||
#include "mt8195-afe-common.h"
|
||||
|
||||
#define RT1011_SPEAKER_AMP_PRESENT BIT(0)
|
||||
#define RT1019_SPEAKER_AMP_PRESENT BIT(1)
|
||||
|
||||
#define RT1011_CODEC_DAI "rt1011-aif"
|
||||
#define RT1011_DEV0_NAME "rt1011.2-0038"
|
||||
#define RT1011_DEV1_NAME "rt1011.2-0039"
|
||||
|
||||
#define RT1019_CODEC_DAI "HiFi"
|
||||
#define RT1019_DEV0_NAME "rt1019p"
|
||||
|
||||
|
@ -35,6 +44,11 @@
|
|||
#define SOF_DMA_UL4 "SOF_DMA_UL4"
|
||||
#define SOF_DMA_UL5 "SOF_DMA_UL5"
|
||||
|
||||
struct mt8195_card_data {
|
||||
const char *name;
|
||||
unsigned long quirk;
|
||||
};
|
||||
|
||||
struct sof_conn_stream {
|
||||
const char *normal_link;
|
||||
const char *sof_link;
|
||||
|
@ -42,16 +56,14 @@ struct sof_conn_stream {
|
|||
int stream_dir;
|
||||
};
|
||||
|
||||
struct mt8195_mt6359_rt1019_rt5682_priv {
|
||||
struct mt8195_mt6359_priv {
|
||||
struct snd_soc_jack headset_jack;
|
||||
struct snd_soc_jack dp_jack;
|
||||
struct snd_soc_jack hdmi_jack;
|
||||
struct clk *i2so1_mclk;
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_widget
|
||||
mt8195_mt6359_rt1019_rt5682_widgets[] = {
|
||||
SND_SOC_DAPM_SPK("Speakers", NULL),
|
||||
static const struct snd_soc_dapm_widget mt8195_mt6359_widgets[] = {
|
||||
SND_SOC_DAPM_HP("Headphone Jack", NULL),
|
||||
SND_SOC_DAPM_MIC("Headset Mic", NULL),
|
||||
SND_SOC_DAPM_MIXER(SOF_DMA_DL2, SND_SOC_NOPM, 0, 0, NULL, 0),
|
||||
|
@ -60,9 +72,7 @@ static const struct snd_soc_dapm_widget
|
|||
SND_SOC_DAPM_MIXER(SOF_DMA_UL5, SND_SOC_NOPM, 0, 0, NULL, 0),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route mt8195_mt6359_rt1019_rt5682_routes[] = {
|
||||
/* speaker */
|
||||
{ "Speakers", NULL, "Speaker" },
|
||||
static const struct snd_soc_dapm_route mt8195_mt6359_routes[] = {
|
||||
/* headset */
|
||||
{ "Headphone Jack", NULL, "HPOL" },
|
||||
{ "Headphone Jack", NULL, "HPOR" },
|
||||
|
@ -79,12 +89,38 @@ static const struct snd_soc_dapm_route mt8195_mt6359_rt1019_rt5682_routes[] = {
|
|||
{"I021", NULL, SOF_DMA_DL3},
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new mt8195_mt6359_rt1019_rt5682_controls[] = {
|
||||
SOC_DAPM_PIN_SWITCH("Speakers"),
|
||||
static const struct snd_kcontrol_new mt8195_mt6359_controls[] = {
|
||||
SOC_DAPM_PIN_SWITCH("Headphone Jack"),
|
||||
SOC_DAPM_PIN_SWITCH("Headset Mic"),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_widget mt8195_dual_speaker_widgets[] = {
|
||||
SND_SOC_DAPM_SPK("Left Speaker", NULL),
|
||||
SND_SOC_DAPM_SPK("Right Speaker", NULL),
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new mt8195_dual_speaker_controls[] = {
|
||||
SOC_DAPM_PIN_SWITCH("Left Speaker"),
|
||||
SOC_DAPM_PIN_SWITCH("Right Speaker"),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_widget mt8195_speaker_widgets[] = {
|
||||
SND_SOC_DAPM_SPK("Speakers", NULL),
|
||||
};
|
||||
|
||||
static const struct snd_kcontrol_new mt8195_speaker_controls[] = {
|
||||
SOC_DAPM_PIN_SWITCH("Speakers"),
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route mt8195_rt1011_routes[] = {
|
||||
{ "Left Speaker", NULL, "Left SPO" },
|
||||
{ "Right Speaker", NULL, "Right SPO" },
|
||||
};
|
||||
|
||||
static const struct snd_soc_dapm_route mt8195_rt1019_routes[] = {
|
||||
{ "Speakers", NULL, "Speaker" },
|
||||
};
|
||||
|
||||
#define CKSYS_AUD_TOP_CFG 0x032c
|
||||
#define CKSYS_AUD_TOP_MON 0x0330
|
||||
|
||||
|
@ -328,8 +364,7 @@ static const struct snd_soc_ops mt8195_dptx_ops = {
|
|||
|
||||
static int mt8195_dptx_codec_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct mt8195_mt6359_rt1019_rt5682_priv *priv =
|
||||
snd_soc_card_get_drvdata(rtd->card);
|
||||
struct mt8195_mt6359_priv *priv = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_component *cmpnt_codec =
|
||||
asoc_rtd_to_codec(rtd, 0)->component;
|
||||
int ret;
|
||||
|
@ -344,8 +379,7 @@ static int mt8195_dptx_codec_init(struct snd_soc_pcm_runtime *rtd)
|
|||
|
||||
static int mt8195_hdmi_codec_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct mt8195_mt6359_rt1019_rt5682_priv *priv =
|
||||
snd_soc_card_get_drvdata(rtd->card);
|
||||
struct mt8195_mt6359_priv *priv = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_component *cmpnt_codec =
|
||||
asoc_rtd_to_codec(rtd, 0)->component;
|
||||
int ret;
|
||||
|
@ -511,8 +545,7 @@ static int mt8195_rt5682_init(struct snd_soc_pcm_runtime *rtd)
|
|||
{
|
||||
struct snd_soc_component *cmpnt_codec =
|
||||
asoc_rtd_to_codec(rtd, 0)->component;
|
||||
struct mt8195_mt6359_rt1019_rt5682_priv *priv =
|
||||
snd_soc_card_get_drvdata(rtd->card);
|
||||
struct mt8195_mt6359_priv *priv = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_jack *jack = &priv->headset_jack;
|
||||
struct snd_soc_component *cmpnt_afe =
|
||||
snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
|
||||
|
@ -546,6 +579,95 @@ static int mt8195_rt5682_init(struct snd_soc_pcm_runtime *rtd)
|
|||
return 0;
|
||||
};
|
||||
|
||||
static int mt8195_rt1011_etdm_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
||||
struct snd_soc_dai *codec_dai;
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
int srate, i, ret;
|
||||
|
||||
srate = params_rate(params);
|
||||
|
||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
||||
ret = snd_soc_dai_set_pll(codec_dai, 0, RT1011_PLL1_S_BCLK,
|
||||
64 * srate, 256 * srate);
|
||||
if (ret < 0) {
|
||||
dev_err(card->dev, "codec_dai clock not set\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_dai_set_sysclk(codec_dai,
|
||||
RT1011_FS_SYS_PRE_S_PLL1,
|
||||
256 * srate, SND_SOC_CLOCK_IN);
|
||||
if (ret < 0) {
|
||||
dev_err(card->dev, "codec_dai clock not set\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_ops mt8195_rt1011_etdm_ops = {
|
||||
.hw_params = mt8195_rt1011_etdm_hw_params,
|
||||
};
|
||||
|
||||
static int mt8195_rt1011_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
int ret;
|
||||
|
||||
ret = snd_soc_dapm_new_controls(&card->dapm, mt8195_dual_speaker_widgets,
|
||||
ARRAY_SIZE(mt8195_dual_speaker_widgets));
|
||||
if (ret) {
|
||||
dev_err(rtd->dev, "unable to add dapm controls, ret %d\n", ret);
|
||||
/* Don't need to add routes if widget addition failed */
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_add_card_controls(card, mt8195_dual_speaker_controls,
|
||||
ARRAY_SIZE(mt8195_dual_speaker_controls));
|
||||
if (ret) {
|
||||
dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_dapm_add_routes(&card->dapm, mt8195_rt1011_routes,
|
||||
ARRAY_SIZE(mt8195_rt1011_routes));
|
||||
if (ret)
|
||||
dev_err(rtd->dev, "unable to add dapm routes, ret %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mt8195_rt1019_init(struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_soc_card *card = rtd->card;
|
||||
int ret;
|
||||
|
||||
ret = snd_soc_dapm_new_controls(&card->dapm, mt8195_speaker_widgets,
|
||||
ARRAY_SIZE(mt8195_speaker_widgets));
|
||||
if (ret) {
|
||||
dev_err(rtd->dev, "unable to add dapm controls, ret %d\n", ret);
|
||||
/* Don't need to add routes if widget addition failed */
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_add_card_controls(card, mt8195_speaker_controls,
|
||||
ARRAY_SIZE(mt8195_speaker_controls));
|
||||
if (ret) {
|
||||
dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = snd_soc_dapm_add_routes(&card->dapm, mt8195_rt1019_routes,
|
||||
ARRAY_SIZE(mt8195_rt1019_routes));
|
||||
if (ret)
|
||||
dev_err(rtd->dev, "unable to add dapm routes, ret %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mt8195_etdm_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
|
@ -562,8 +684,7 @@ static int mt8195_set_bias_level_post(struct snd_soc_card *card,
|
|||
struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level)
|
||||
{
|
||||
struct snd_soc_component *component = dapm->component;
|
||||
struct mt8195_mt6359_rt1019_rt5682_priv *priv =
|
||||
snd_soc_card_get_drvdata(card);
|
||||
struct mt8195_mt6359_priv *priv = snd_soc_card_get_drvdata(card);
|
||||
int ret;
|
||||
|
||||
/*
|
||||
|
@ -747,8 +868,7 @@ SND_SOC_DAILINK_DEFS(ETDM1_OUT_BE,
|
|||
|
||||
SND_SOC_DAILINK_DEFS(ETDM2_OUT_BE,
|
||||
DAILINK_COMP_ARRAY(COMP_CPU("ETDM2_OUT")),
|
||||
DAILINK_COMP_ARRAY(COMP_CODEC(RT1019_DEV0_NAME,
|
||||
RT1019_CODEC_DAI)),
|
||||
DAILINK_COMP_ARRAY(COMP_DUMMY()),
|
||||
DAILINK_COMP_ARRAY(COMP_EMPTY()));
|
||||
|
||||
SND_SOC_DAILINK_DEFS(ETDM3_OUT_BE,
|
||||
|
@ -795,6 +915,17 @@ SND_SOC_DAILINK_DEFS(AFE_SOF_UL5,
|
|||
DAILINK_COMP_ARRAY(COMP_DUMMY()),
|
||||
DAILINK_COMP_ARRAY(COMP_EMPTY()));
|
||||
|
||||
/* codec */
|
||||
SND_SOC_DAILINK_DEF(rt1019_comps,
|
||||
DAILINK_COMP_ARRAY(COMP_CODEC(RT1019_DEV0_NAME,
|
||||
RT1019_CODEC_DAI)));
|
||||
|
||||
SND_SOC_DAILINK_DEF(rt1011_comps,
|
||||
DAILINK_COMP_ARRAY(COMP_CODEC(RT1011_DEV0_NAME,
|
||||
RT1011_CODEC_DAI),
|
||||
COMP_CODEC(RT1011_DEV1_NAME,
|
||||
RT1011_CODEC_DAI)));
|
||||
|
||||
static const struct sof_conn_stream g_sof_conn_streams[] = {
|
||||
{ "ETDM2_OUT_BE", "AFE_SOF_DL2", SOF_DMA_DL2, SNDRV_PCM_STREAM_PLAYBACK},
|
||||
{ "ETDM1_OUT_BE", "AFE_SOF_DL3", SOF_DMA_DL3, SNDRV_PCM_STREAM_PLAYBACK},
|
||||
|
@ -802,7 +933,7 @@ static const struct sof_conn_stream g_sof_conn_streams[] = {
|
|||
{ "ETDM2_IN_BE", "AFE_SOF_UL5", SOF_DMA_UL5, SNDRV_PCM_STREAM_CAPTURE},
|
||||
};
|
||||
|
||||
static struct snd_soc_dai_link mt8195_mt6359_rt1019_rt5682_dai_links[] = {
|
||||
static struct snd_soc_dai_link mt8195_mt6359_dai_links[] = {
|
||||
/* FE */
|
||||
[DAI_LINK_DL2_FE] = {
|
||||
.name = "DL2_FE",
|
||||
|
@ -1107,17 +1238,27 @@ static struct snd_soc_dai_link mt8195_mt6359_rt1019_rt5682_dai_links[] = {
|
|||
},
|
||||
};
|
||||
|
||||
static struct snd_soc_card mt8195_mt6359_rt1019_rt5682_soc_card = {
|
||||
.name = "mt8195_r1019_5682",
|
||||
static struct snd_soc_codec_conf rt1011_codec_conf[] = {
|
||||
{
|
||||
.dlc = COMP_CODEC_CONF(RT1011_DEV0_NAME),
|
||||
.name_prefix = "Left",
|
||||
},
|
||||
{
|
||||
.dlc = COMP_CODEC_CONF(RT1011_DEV1_NAME),
|
||||
.name_prefix = "Right",
|
||||
},
|
||||
};
|
||||
|
||||
static struct snd_soc_card mt8195_mt6359_soc_card = {
|
||||
.owner = THIS_MODULE,
|
||||
.dai_link = mt8195_mt6359_rt1019_rt5682_dai_links,
|
||||
.num_links = ARRAY_SIZE(mt8195_mt6359_rt1019_rt5682_dai_links),
|
||||
.controls = mt8195_mt6359_rt1019_rt5682_controls,
|
||||
.num_controls = ARRAY_SIZE(mt8195_mt6359_rt1019_rt5682_controls),
|
||||
.dapm_widgets = mt8195_mt6359_rt1019_rt5682_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(mt8195_mt6359_rt1019_rt5682_widgets),
|
||||
.dapm_routes = mt8195_mt6359_rt1019_rt5682_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(mt8195_mt6359_rt1019_rt5682_routes),
|
||||
.dai_link = mt8195_mt6359_dai_links,
|
||||
.num_links = ARRAY_SIZE(mt8195_mt6359_dai_links),
|
||||
.controls = mt8195_mt6359_controls,
|
||||
.num_controls = ARRAY_SIZE(mt8195_mt6359_controls),
|
||||
.dapm_widgets = mt8195_mt6359_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(mt8195_mt6359_widgets),
|
||||
.dapm_routes = mt8195_mt6359_routes,
|
||||
.num_dapm_routes = ARRAY_SIZE(mt8195_mt6359_routes),
|
||||
.set_bias_level_post = mt8195_set_bias_level_post,
|
||||
};
|
||||
|
||||
|
@ -1164,7 +1305,7 @@ static int mt8195_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int mt8195_mt6359_rt1019_rt5682_card_late_probe(struct snd_soc_card *card)
|
||||
static int mt8195_mt6359_card_late_probe(struct snd_soc_card *card)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *runtime;
|
||||
struct snd_soc_component *sof_comp = NULL;
|
||||
|
@ -1252,7 +1393,7 @@ static int mt8195_dailink_parse_of(struct snd_soc_card *card, struct device_node
|
|||
|
||||
num_links = of_property_count_strings(np, "mediatek,dai-link");
|
||||
|
||||
if (num_links < 0 || num_links > ARRAY_SIZE(mt8195_mt6359_rt1019_rt5682_dai_links)) {
|
||||
if (num_links < 0 || num_links > ARRAY_SIZE(mt8195_mt6359_dai_links)) {
|
||||
dev_dbg(dev, "number of dai-link is invalid\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -1272,9 +1413,9 @@ static int mt8195_dailink_parse_of(struct snd_soc_card *card, struct device_node
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (j = 0; j < ARRAY_SIZE(mt8195_mt6359_rt1019_rt5682_dai_links); j++) {
|
||||
if (!strcmp(dai_name, mt8195_mt6359_rt1019_rt5682_dai_links[j].name)) {
|
||||
memcpy(link, &mt8195_mt6359_rt1019_rt5682_dai_links[j],
|
||||
for (j = 0; j < ARRAY_SIZE(mt8195_mt6359_dai_links); j++) {
|
||||
if (!strcmp(dai_name, mt8195_mt6359_dai_links[j].name)) {
|
||||
memcpy(link, &mt8195_mt6359_dai_links[j],
|
||||
sizeof(struct snd_soc_dai_link));
|
||||
link++;
|
||||
card->num_links++;
|
||||
|
@ -1289,17 +1430,19 @@ static int mt8195_dailink_parse_of(struct snd_soc_card *card, struct device_node
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
|
||||
static int mt8195_mt6359_dev_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct snd_soc_card *card = &mt8195_mt6359_rt1019_rt5682_soc_card;
|
||||
struct snd_soc_card *card = &mt8195_mt6359_soc_card;
|
||||
struct snd_soc_dai_link *dai_link;
|
||||
struct mt8195_mt6359_rt1019_rt5682_priv *priv;
|
||||
struct mt8195_mt6359_priv *priv;
|
||||
struct device_node *platform_node, *adsp_node, *dp_node, *hdmi_node;
|
||||
struct mt8195_card_data *card_data;
|
||||
int is5682s = 0;
|
||||
int init6359 = 0;
|
||||
int sof_on = 0;
|
||||
int ret, i;
|
||||
|
||||
card_data = (struct mt8195_card_data *)of_device_get_match_data(&pdev->dev);
|
||||
card->dev = &pdev->dev;
|
||||
|
||||
ret = snd_soc_of_parse_card_name(card, "model");
|
||||
|
@ -1309,6 +1452,9 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
if (!card->name)
|
||||
card->name = card_data->name;
|
||||
|
||||
if (strstr(card->name, "_5682s"))
|
||||
is5682s = 1;
|
||||
|
||||
|
@ -1382,11 +1528,30 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
|
|||
dai_link->init = mt8195_mt6359_init;
|
||||
init6359 = 1;
|
||||
}
|
||||
} else if (strcmp(dai_link->name, "ETDM2_OUT_BE") == 0) {
|
||||
switch (card_data->quirk) {
|
||||
case RT1011_SPEAKER_AMP_PRESENT:
|
||||
dai_link->codecs = rt1011_comps;
|
||||
dai_link->num_codecs = ARRAY_SIZE(rt1011_comps);
|
||||
dai_link->init = mt8195_rt1011_init;
|
||||
dai_link->ops = &mt8195_rt1011_etdm_ops;
|
||||
dai_link->be_hw_params_fixup = mt8195_etdm_hw_params_fixup;
|
||||
card->codec_conf = rt1011_codec_conf;
|
||||
card->num_configs = ARRAY_SIZE(rt1011_codec_conf);
|
||||
break;
|
||||
case RT1019_SPEAKER_AMP_PRESENT:
|
||||
dai_link->codecs = rt1019_comps;
|
||||
dai_link->num_codecs = ARRAY_SIZE(rt1019_comps);
|
||||
dai_link->init = mt8195_rt1019_init;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sof_on)
|
||||
card->late_probe = mt8195_mt6359_rt1019_rt5682_card_late_probe;
|
||||
card->late_probe = mt8195_mt6359_card_late_probe;
|
||||
|
||||
snd_soc_card_set_drvdata(card, priv);
|
||||
|
||||
|
@ -1399,34 +1564,50 @@ static int mt8195_mt6359_rt1019_rt5682_dev_probe(struct platform_device *pdev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static struct mt8195_card_data mt8195_mt6359_rt1019_rt5682_card = {
|
||||
.name = "mt8195_r1019_5682",
|
||||
.quirk = RT1019_SPEAKER_AMP_PRESENT,
|
||||
};
|
||||
|
||||
static struct mt8195_card_data mt8195_mt6359_rt1011_rt5682_card = {
|
||||
.name = "mt8195_r1011_5682",
|
||||
.quirk = RT1011_SPEAKER_AMP_PRESENT,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id mt8195_mt6359_rt1019_rt5682_dt_match[] = {
|
||||
{.compatible = "mediatek,mt8195_mt6359_rt1019_rt5682",},
|
||||
{}
|
||||
static const struct of_device_id mt8195_mt6359_dt_match[] = {
|
||||
{
|
||||
.compatible = "mediatek,mt8195_mt6359_rt1019_rt5682",
|
||||
.data = &mt8195_mt6359_rt1019_rt5682_card,
|
||||
},
|
||||
{
|
||||
.compatible = "mediatek,mt8195_mt6359_rt1011_rt5682",
|
||||
.data = &mt8195_mt6359_rt1011_rt5682_card,
|
||||
},
|
||||
};
|
||||
#endif
|
||||
|
||||
static const struct dev_pm_ops mt8195_mt6359_rt1019_rt5682_pm_ops = {
|
||||
static const struct dev_pm_ops mt8195_mt6359_pm_ops = {
|
||||
.poweroff = snd_soc_poweroff,
|
||||
.restore = snd_soc_resume,
|
||||
};
|
||||
|
||||
static struct platform_driver mt8195_mt6359_rt1019_rt5682_driver = {
|
||||
static struct platform_driver mt8195_mt6359_driver = {
|
||||
.driver = {
|
||||
.name = "mt8195_mt6359_rt1019_rt5682",
|
||||
.name = "mt8195_mt6359",
|
||||
#ifdef CONFIG_OF
|
||||
.of_match_table = mt8195_mt6359_rt1019_rt5682_dt_match,
|
||||
.of_match_table = mt8195_mt6359_dt_match,
|
||||
#endif
|
||||
.pm = &mt8195_mt6359_rt1019_rt5682_pm_ops,
|
||||
.pm = &mt8195_mt6359_pm_ops,
|
||||
},
|
||||
.probe = mt8195_mt6359_rt1019_rt5682_dev_probe,
|
||||
.probe = mt8195_mt6359_dev_probe,
|
||||
};
|
||||
|
||||
module_platform_driver(mt8195_mt6359_rt1019_rt5682_driver);
|
||||
module_platform_driver(mt8195_mt6359_driver);
|
||||
|
||||
/* Module information */
|
||||
MODULE_DESCRIPTION("MT8195-MT6359-RT1019-RT5682 ALSA SoC machine driver");
|
||||
MODULE_DESCRIPTION("MT8195-MT6359 ALSA SoC machine driver");
|
||||
MODULE_AUTHOR("Trevor Wu <trevor.wu@mediatek.com>");
|
||||
MODULE_AUTHOR("YC Hung <yc.hung@mediatek.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS("mt8195_mt6359_rt1019_rt5682 soc card");
|
||||
MODULE_ALIAS("mt8195_mt6359 soc card");
|
Загрузка…
Ссылка в новой задаче