Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.13.7.
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3 * linux/sound/soc/pxa/ttc_dkb.c
  4 *
  5 * Copyright (C) 2012 Marvell International Ltd.
  6 */
  7#include <linux/module.h>
  8#include <linux/moduleparam.h>
  9#include <sound/core.h>
 10#include <sound/pcm.h>
 11#include <sound/soc.h>
 12#include <sound/jack.h>
 13#include <asm/mach-types.h>
 14#include <sound/pcm_params.h>
 15#include "../codecs/88pm860x-codec.h"
 16
 17static struct snd_soc_jack hs_jack, mic_jack;
 18
 19static struct snd_soc_jack_pin hs_jack_pins[] = {
 20	{ .pin = "Headset Stereophone",	.mask = SND_JACK_HEADPHONE, },
 21};
 22
 23static struct snd_soc_jack_pin mic_jack_pins[] = {
 24	{ .pin = "Headset Mic 2",	.mask = SND_JACK_MICROPHONE, },
 25};
 26
 27/* ttc machine dapm widgets */
 28static const struct snd_soc_dapm_widget ttc_dapm_widgets[] = {
 29	SND_SOC_DAPM_HP("Headset Stereophone", NULL),
 30	SND_SOC_DAPM_LINE("Lineout Out 1", NULL),
 31	SND_SOC_DAPM_LINE("Lineout Out 2", NULL),
 32	SND_SOC_DAPM_SPK("Ext Speaker", NULL),
 33	SND_SOC_DAPM_MIC("Ext Mic 1", NULL),
 34	SND_SOC_DAPM_MIC("Headset Mic 2", NULL),
 35	SND_SOC_DAPM_MIC("Ext Mic 3", NULL),
 36};
 37
 38/* ttc machine audio map */
 39static const struct snd_soc_dapm_route ttc_audio_map[] = {
 40	{"Headset Stereophone", NULL, "HS1"},
 41	{"Headset Stereophone", NULL, "HS2"},
 42
 43	{"Ext Speaker", NULL, "LSP"},
 44	{"Ext Speaker", NULL, "LSN"},
 45
 46	{"Lineout Out 1", NULL, "LINEOUT1"},
 47	{"Lineout Out 2", NULL, "LINEOUT2"},
 48
 49	{"MIC1P", NULL, "Mic1 Bias"},
 50	{"MIC1N", NULL, "Mic1 Bias"},
 51	{"Mic1 Bias", NULL, "Ext Mic 1"},
 52
 53	{"MIC2P", NULL, "Mic1 Bias"},
 54	{"MIC2N", NULL, "Mic1 Bias"},
 55	{"Mic1 Bias", NULL, "Headset Mic 2"},
 56
 57	{"MIC3P", NULL, "Mic3 Bias"},
 58	{"MIC3N", NULL, "Mic3 Bias"},
 59	{"Mic3 Bias", NULL, "Ext Mic 3"},
 60};
 61
 62static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd)
 63{
 64	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
 65
 66	/* Headset jack detection */
 67	snd_soc_card_jack_new_pins(rtd->card, "Headphone Jack",
 68				   SND_JACK_HEADPHONE | SND_JACK_BTN_0 |
 69				   SND_JACK_BTN_1 | SND_JACK_BTN_2,
 70				   &hs_jack,
 71				   hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
 72	snd_soc_card_jack_new_pins(rtd->card, "Microphone Jack",
 73				   SND_JACK_MICROPHONE, &mic_jack,
 74				   mic_jack_pins, ARRAY_SIZE(mic_jack_pins));
 75
 76	/* headphone, microphone detection & headset short detection */
 77	pm860x_hs_jack_detect(component, &hs_jack, SND_JACK_HEADPHONE,
 78			      SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2);
 79	pm860x_mic_jack_detect(component, &hs_jack, SND_JACK_MICROPHONE);
 80
 81	return 0;
 82}
 83
 84/* ttc/td-dkb digital audio interface glue - connects codec <--> CPU */
 85SND_SOC_DAILINK_DEFS(i2s,
 86	DAILINK_COMP_ARRAY(COMP_CPU("pxa-ssp-dai.1")),
 87	DAILINK_COMP_ARRAY(COMP_CODEC("88pm860x-codec", "88pm860x-i2s")),
 88	DAILINK_COMP_ARRAY(COMP_PLATFORM("mmp-pcm-audio")));
 89
 90static struct snd_soc_dai_link ttc_pm860x_hifi_dai[] = {
 91{
 92	 .name = "88pm860x i2s",
 93	 .stream_name = "audio playback",
 94	 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
 95			SND_SOC_DAIFMT_CBM_CFM,
 96	 .init = ttc_pm860x_init,
 97	 SND_SOC_DAILINK_REG(i2s),
 98},
 99};
100
101/* ttc/td audio machine driver */
102static struct snd_soc_card ttc_dkb_card = {
103	.name = "ttc-dkb-hifi",
104	.owner = THIS_MODULE,
105	.dai_link = ttc_pm860x_hifi_dai,
106	.num_links = ARRAY_SIZE(ttc_pm860x_hifi_dai),
107
108	.dapm_widgets = ttc_dapm_widgets,
109	.num_dapm_widgets = ARRAY_SIZE(ttc_dapm_widgets),
110	.dapm_routes = ttc_audio_map,
111	.num_dapm_routes = ARRAY_SIZE(ttc_audio_map),
112};
113
114static int ttc_dkb_probe(struct platform_device *pdev)
115{
116	struct snd_soc_card *card = &ttc_dkb_card;
117	int ret;
118
119	card->dev = &pdev->dev;
120
121	ret = devm_snd_soc_register_card(&pdev->dev, card);
122	if (ret)
123		dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
124			ret);
125
126	return ret;
127}
128
129static struct platform_driver ttc_dkb_driver = {
130	.driver		= {
131		.name	= "ttc-dkb-audio",
132		.pm     = &snd_soc_pm_ops,
133	},
134	.probe		= ttc_dkb_probe,
135};
136
137module_platform_driver(ttc_dkb_driver);
138
139/* Module information */
140MODULE_AUTHOR("Qiao Zhou, <zhouqiao@marvell.com>");
141MODULE_DESCRIPTION("ALSA SoC TTC DKB");
142MODULE_LICENSE("GPL");
143MODULE_ALIAS("platform:ttc-dkb-audio");