Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
b883f363 QZ |
2 | /* |
3 | * linux/sound/soc/pxa/ttc_dkb.c | |
4 | * | |
5 | * Copyright (C) 2012 Marvell International Ltd. | |
b883f363 QZ |
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 | ||
17 | static struct snd_soc_jack hs_jack, mic_jack; | |
18 | ||
19 | static struct snd_soc_jack_pin hs_jack_pins[] = { | |
20 | { .pin = "Headset Stereophone", .mask = SND_JACK_HEADPHONE, }, | |
21 | }; | |
22 | ||
23 | static struct snd_soc_jack_pin mic_jack_pins[] = { | |
24 | { .pin = "Headset Mic 2", .mask = SND_JACK_MICROPHONE, }, | |
25 | }; | |
26 | ||
27 | /* ttc machine dapm widgets */ | |
28 | static 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 */ | |
39 | static 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 | ||
62 | static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd) | |
63 | { | |
5783994b | 64 | struct snd_soc_component *component = rtd->codec_dai->component; |
b883f363 QZ |
65 | |
66 | /* Headset jack detection */ | |
3b14125b LPC |
67 | snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE | |
68 | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2, | |
69 | &hs_jack, hs_jack_pins, ARRAY_SIZE(hs_jack_pins)); | |
70 | snd_soc_card_jack_new(rtd->card, "Microphone Jack", SND_JACK_MICROPHONE, | |
71 | &mic_jack, mic_jack_pins, | |
72 | ARRAY_SIZE(mic_jack_pins)); | |
b883f363 QZ |
73 | |
74 | /* headphone, microphone detection & headset short detection */ | |
5783994b | 75 | pm860x_hs_jack_detect(component, &hs_jack, SND_JACK_HEADPHONE, |
b883f363 | 76 | SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2); |
5783994b | 77 | pm860x_mic_jack_detect(component, &hs_jack, SND_JACK_MICROPHONE); |
b883f363 QZ |
78 | |
79 | return 0; | |
80 | } | |
81 | ||
82 | /* ttc/td-dkb digital audio interface glue - connects codec <--> CPU */ | |
0d246384 KM |
83 | SND_SOC_DAILINK_DEFS(i2s, |
84 | DAILINK_COMP_ARRAY(COMP_CPU("pxa-ssp-dai.1")), | |
85 | DAILINK_COMP_ARRAY(COMP_CODEC("88pm860x-codec", "88pm860x-i2s")), | |
86 | DAILINK_COMP_ARRAY(COMP_PLATFORM("mmp-pcm-audio"))); | |
87 | ||
b883f363 QZ |
88 | static struct snd_soc_dai_link ttc_pm860x_hifi_dai[] = { |
89 | { | |
90 | .name = "88pm860x i2s", | |
91 | .stream_name = "audio playback", | |
b883f363 QZ |
92 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
93 | SND_SOC_DAIFMT_CBM_CFM, | |
94 | .init = ttc_pm860x_init, | |
0d246384 | 95 | SND_SOC_DAILINK_REG(i2s), |
b883f363 QZ |
96 | }, |
97 | }; | |
98 | ||
99 | /* ttc/td audio machine driver */ | |
100 | static struct snd_soc_card ttc_dkb_card = { | |
101 | .name = "ttc-dkb-hifi", | |
3986b982 | 102 | .owner = THIS_MODULE, |
b883f363 QZ |
103 | .dai_link = ttc_pm860x_hifi_dai, |
104 | .num_links = ARRAY_SIZE(ttc_pm860x_hifi_dai), | |
105 | ||
106 | .dapm_widgets = ttc_dapm_widgets, | |
107 | .num_dapm_widgets = ARRAY_SIZE(ttc_dapm_widgets), | |
108 | .dapm_routes = ttc_audio_map, | |
109 | .num_dapm_routes = ARRAY_SIZE(ttc_audio_map), | |
110 | }; | |
111 | ||
570f6fe1 | 112 | static int ttc_dkb_probe(struct platform_device *pdev) |
b883f363 QZ |
113 | { |
114 | struct snd_soc_card *card = &ttc_dkb_card; | |
115 | int ret; | |
116 | ||
117 | card->dev = &pdev->dev; | |
118 | ||
2fd7076a | 119 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
b883f363 QZ |
120 | if (ret) |
121 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | |
122 | ret); | |
123 | ||
124 | return ret; | |
125 | } | |
126 | ||
b883f363 QZ |
127 | static struct platform_driver ttc_dkb_driver = { |
128 | .driver = { | |
129 | .name = "ttc-dkb-audio", | |
7db1698f | 130 | .pm = &snd_soc_pm_ops, |
b883f363 QZ |
131 | }, |
132 | .probe = ttc_dkb_probe, | |
b883f363 QZ |
133 | }; |
134 | ||
135 | module_platform_driver(ttc_dkb_driver); | |
136 | ||
137 | /* Module information */ | |
138 | MODULE_AUTHOR("Qiao Zhou, <zhouqiao@marvell.com>"); | |
139 | MODULE_DESCRIPTION("ALSA SoC TTC DKB"); | |
140 | MODULE_LICENSE("GPL"); | |
141 | MODULE_ALIAS("platform:ttc-dkb-audio"); |