#include <linux/bitfield.h>
#include <linux/input.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/pm_runtime.h>
#include <sound/jack.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include "mt8188-afe-common.h"
#include "../../codecs/nau8825.h"
#include "../../codecs/mt6359.h"
#include "../../codecs/rt5682.h"
#include "../common/mtk-afe-platform-driver.h"
#include "../common/mtk-soundcard-driver.h"
#include "../common/mtk-dsp-sof-common.h"
#include "../common/mtk-soc-card.h"
#define CKSYS_AUD_TOP_CFG …
#define RG_TEST_ON …
#define RG_TEST_TYPE …
#define CKSYS_AUD_TOP_MON …
#define TEST_MISO_COUNT_1 …
#define TEST_MISO_COUNT_2 …
#define TEST_MISO_DONE_1 …
#define TEST_MISO_DONE_2 …
#define NAU8825_HS_PRESENT …
#define RT5682S_HS_PRESENT …
#define ES8326_HS_PRESENT …
#define MAX98390_TWO_AMP …
#define MAX98390_CODEC_DAI …
#define MAX98390_DEV0_NAME …
#define MAX98390_DEV1_NAME …
#define MAX98390_DEV2_NAME …
#define MAX98390_DEV3_NAME …
#define NAU8825_CODEC_DAI …
#define ES8326_CODEC_DAI …
#define SOF_DMA_DL2 …
#define SOF_DMA_DL3 …
#define SOF_DMA_UL4 …
#define SOF_DMA_UL5 …
#define RT5682S_CODEC_DAI …
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
SND_SOC_DAILINK_DEFS(…);
static const struct sof_conn_stream g_sof_conn_streams[] = …;
enum mt8188_jacks { … };
static struct snd_soc_jack_pin mt8188_hdmi_jack_pins[] = …;
static struct snd_soc_jack_pin mt8188_dp_jack_pins[] = …;
static struct snd_soc_jack_pin nau8825_jack_pins[] = …;
static const struct snd_kcontrol_new mt8188_dumb_spk_controls[] = …;
static const struct snd_soc_dapm_widget mt8188_dumb_spk_widgets[] = …;
static const struct snd_kcontrol_new mt8188_dual_spk_controls[] = …;
static const struct snd_soc_dapm_widget mt8188_dual_spk_widgets[] = …;
static const struct snd_kcontrol_new mt8188_rear_spk_controls[] = …;
static const struct snd_soc_dapm_widget mt8188_rear_spk_widgets[] = …;
static const struct snd_soc_dapm_widget mt8188_mt6359_widgets[] = …;
static const struct snd_kcontrol_new mt8188_mt6359_controls[] = …;
static const struct snd_soc_dapm_widget mt8188_nau8825_widgets[] = …;
static const struct snd_kcontrol_new mt8188_nau8825_controls[] = …;
static const struct snd_soc_dapm_route mt8188_mt6359_routes[] = …;
static int mt8188_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)
{ … }
static int mt8188_mt6359_init(struct snd_soc_pcm_runtime *rtd)
{ … }
enum { … };
#define DAI_LINK_REGULAR_NUM …
static int mt8188_dptx_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{ … }
static const struct snd_soc_ops mt8188_dptx_ops = …;
static int mt8188_dptx_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params)
{ … }
static int mt8188_hdmi_codec_init(struct snd_soc_pcm_runtime *rtd)
{ … }
static int mt8188_dptx_codec_init(struct snd_soc_pcm_runtime *rtd)
{ … }
static int mt8188_dumb_amp_init(struct snd_soc_pcm_runtime *rtd)
{ … }
static int mt8188_max98390_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{ … }
static const struct snd_soc_ops mt8188_max98390_ops = …;
static int mt8188_max98390_codec_init(struct snd_soc_pcm_runtime *rtd)
{ … }
static int mt8188_headset_codec_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_card *card = rtd->card;
struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_jack *jack = &soc_card_data->card_data->jacks[MT8188_JACK_HEADSET];
struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component;
struct mtk_platform_card_data *card_data = soc_card_data->card_data;
int ret;
ret = snd_soc_dapm_new_controls(&card->dapm, mt8188_nau8825_widgets,
ARRAY_SIZE(mt8188_nau8825_widgets));
if (ret) {
dev_err(rtd->dev, "unable to add nau8825 card widget, ret %d\n", ret);
return ret;
}
ret = snd_soc_add_card_controls(card, mt8188_nau8825_controls,
ARRAY_SIZE(mt8188_nau8825_controls));
if (ret) {
dev_err(rtd->dev, "unable to add nau8825 card controls, ret %d\n", ret);
return ret;
}
ret = snd_soc_card_jack_new_pins(rtd->card, "Headset Jack",
SND_JACK_HEADSET | SND_JACK_BTN_0 |
SND_JACK_BTN_1 | SND_JACK_BTN_2 |
SND_JACK_BTN_3,
jack,
nau8825_jack_pins,
ARRAY_SIZE(nau8825_jack_pins));
if (ret) {
dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret);
return ret;
}
if (card_data->flags & ES8326_HS_PRESENT) {
snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
} else {
snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
}
ret = snd_soc_component_set_jack(component, jack, NULL);
if (ret) {
dev_err(rtd->dev, "Headset Jack call-back failed: %d\n", ret);
return ret;
}
return 0;
};
static void mt8188_headset_codec_exit(struct snd_soc_pcm_runtime *rtd)
{ … }
static int mt8188_nau8825_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{ … }
static const struct snd_soc_ops mt8188_nau8825_ops = …;
static int mt8188_rt5682s_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{ … }
static const struct snd_soc_ops mt8188_rt5682s_i2s_ops = …;
static int mt8188_sof_be_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{ … }
static const struct snd_soc_ops mt8188_sof_be_ops = …;
static int mt8188_es8326_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{ … }
static const struct snd_soc_ops mt8188_es8326_ops = …;
static struct snd_soc_dai_link mt8188_mt6359_dai_links[] = …;
static void mt8188_fixup_controls(struct snd_soc_card *card)
{ … }
static struct snd_soc_card mt8188_mt6359_soc_card = …;
static int mt8188_mt6359_soc_card_probe(struct mtk_soc_card_data *soc_card_data, bool legacy)
{ … }
static const struct mtk_sof_priv mt8188_sof_priv = …;
static const struct mtk_soundcard_pdata mt8188_evb_card = …;
static const struct mtk_soundcard_pdata mt8188_nau8825_card = …;
static const struct mtk_soundcard_pdata mt8188_rt5682s_card = …;
static const struct mtk_soundcard_pdata mt8188_es8326_card = …;
static const struct of_device_id mt8188_mt6359_dt_match[] = …;
MODULE_DEVICE_TABLE(of, mt8188_mt6359_dt_match);
static struct platform_driver mt8188_mt6359_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;
MODULE_ALIAS(…) …;