]>
Commit | Line | Data |
---|---|---|
a10e763b | 1 | // SPDX-License-Identifier: GPL-2.0-only |
ab40d4f1 IM |
2 | /* |
3 | * e800-wm9712.c -- SoC audio for e800 | |
4 | * | |
ab40d4f1 | 5 | * Copyright 2007 (c) Ian Molton <spyro@f2s.com> |
ab40d4f1 IM |
6 | */ |
7 | ||
8 | #include <linux/module.h> | |
9 | #include <linux/moduleparam.h> | |
0465c7aa | 10 | #include <linux/gpio.h> |
ab40d4f1 IM |
11 | |
12 | #include <sound/core.h> | |
13 | #include <sound/pcm.h> | |
14 | #include <sound/soc.h> | |
ab40d4f1 | 15 | |
c91cf25e | 16 | #include <asm/mach-types.h> |
a09e64fb | 17 | #include <mach/audio.h> |
0465c7aa IM |
18 | #include <mach/eseries-gpio.h> |
19 | ||
0465c7aa IM |
20 | static int e800_spk_amp_event(struct snd_soc_dapm_widget *w, |
21 | struct snd_kcontrol *kcontrol, int event) | |
22 | { | |
23 | if (event & SND_SOC_DAPM_PRE_PMU) | |
24 | gpio_set_value(GPIO_E800_SPK_AMP_ON, 1); | |
25 | else if (event & SND_SOC_DAPM_POST_PMD) | |
26 | gpio_set_value(GPIO_E800_SPK_AMP_ON, 0); | |
ab40d4f1 | 27 | |
0465c7aa IM |
28 | return 0; |
29 | } | |
30 | ||
31 | static int e800_hp_amp_event(struct snd_soc_dapm_widget *w, | |
32 | struct snd_kcontrol *kcontrol, int event) | |
ab40d4f1 | 33 | { |
0465c7aa IM |
34 | if (event & SND_SOC_DAPM_PRE_PMU) |
35 | gpio_set_value(GPIO_E800_HP_AMP_OFF, 0); | |
36 | else if (event & SND_SOC_DAPM_POST_PMD) | |
37 | gpio_set_value(GPIO_E800_HP_AMP_OFF, 1); | |
38 | ||
39 | return 0; | |
40 | } | |
41 | ||
42 | static const struct snd_soc_dapm_widget e800_dapm_widgets[] = { | |
43 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | |
44 | SND_SOC_DAPM_MIC("Mic (Internal1)", NULL), | |
45 | SND_SOC_DAPM_MIC("Mic (Internal2)", NULL), | |
46 | SND_SOC_DAPM_SPK("Speaker", NULL), | |
47 | SND_SOC_DAPM_PGA_E("Headphone Amp", SND_SOC_NOPM, 0, 0, NULL, 0, | |
48 | e800_hp_amp_event, SND_SOC_DAPM_PRE_PMU | | |
49 | SND_SOC_DAPM_POST_PMD), | |
50 | SND_SOC_DAPM_PGA_E("Speaker Amp", SND_SOC_NOPM, 0, 0, NULL, 0, | |
51 | e800_spk_amp_event, SND_SOC_DAPM_PRE_PMU | | |
52 | SND_SOC_DAPM_POST_PMD), | |
53 | }; | |
54 | ||
55 | static const struct snd_soc_dapm_route audio_map[] = { | |
56 | {"Headphone Jack", NULL, "HPOUTL"}, | |
57 | {"Headphone Jack", NULL, "HPOUTR"}, | |
58 | {"Headphone Jack", NULL, "Headphone Amp"}, | |
59 | ||
60 | {"Speaker Amp", NULL, "MONOOUT"}, | |
61 | {"Speaker", NULL, "Speaker Amp"}, | |
62 | ||
63 | {"MIC1", NULL, "Mic (Internal1)"}, | |
64 | {"MIC2", NULL, "Mic (Internal2)"}, | |
65 | }; | |
66 | ||
32b787a0 KM |
67 | |
68 | SND_SOC_DAILINK_DEFS(ac97, | |
69 | DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97")), | |
70 | DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec", "wm9712-hifi")), | |
71 | DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio"))); | |
72 | ||
73 | SND_SOC_DAILINK_DEFS(ac97_aux, | |
74 | DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97-aux")), | |
75 | DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec", "wm9712-aux")), | |
76 | DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio"))); | |
77 | ||
0465c7aa IM |
78 | static struct snd_soc_dai_link e800_dai[] = { |
79 | { | |
80 | .name = "AC97", | |
81 | .stream_name = "AC97 HiFi", | |
32b787a0 | 82 | SND_SOC_DAILINK_REG(ac97), |
0465c7aa IM |
83 | }, |
84 | { | |
85 | .name = "AC97 Aux", | |
86 | .stream_name = "AC97 Aux", | |
32b787a0 | 87 | SND_SOC_DAILINK_REG(ac97_aux), |
0465c7aa | 88 | }, |
ab40d4f1 IM |
89 | }; |
90 | ||
87506549 | 91 | static struct snd_soc_card e800 = { |
ab40d4f1 | 92 | .name = "Toshiba e800", |
561c6a17 | 93 | .owner = THIS_MODULE, |
ab40d4f1 IM |
94 | .dai_link = e800_dai, |
95 | .num_links = ARRAY_SIZE(e800_dai), | |
1bdd301f LPC |
96 | |
97 | .dapm_widgets = e800_dapm_widgets, | |
98 | .num_dapm_widgets = ARRAY_SIZE(e800_dapm_widgets), | |
99 | .dapm_routes = audio_map, | |
100 | .num_dapm_routes = ARRAY_SIZE(audio_map), | |
ab40d4f1 IM |
101 | }; |
102 | ||
1eb0202d AL |
103 | static struct gpio e800_audio_gpios[] = { |
104 | { GPIO_E800_SPK_AMP_ON, GPIOF_OUT_INIT_HIGH, "Headphone amp" }, | |
105 | { GPIO_E800_HP_AMP_OFF, GPIOF_OUT_INIT_HIGH, "Speaker amp" }, | |
106 | }; | |
ab40d4f1 | 107 | |
570f6fe1 | 108 | static int e800_probe(struct platform_device *pdev) |
ab40d4f1 | 109 | { |
1eb0202d | 110 | struct snd_soc_card *card = &e800; |
ab40d4f1 IM |
111 | int ret; |
112 | ||
1eb0202d AL |
113 | ret = gpio_request_array(e800_audio_gpios, |
114 | ARRAY_SIZE(e800_audio_gpios)); | |
0465c7aa IM |
115 | if (ret) |
116 | return ret; | |
117 | ||
1eb0202d | 118 | card->dev = &pdev->dev; |
0465c7aa | 119 | |
2fd7076a | 120 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
1eb0202d AL |
121 | if (ret) { |
122 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | |
123 | ret); | |
124 | gpio_free_array(e800_audio_gpios, ARRAY_SIZE(e800_audio_gpios)); | |
8faab941 | 125 | } |
ab40d4f1 IM |
126 | return ret; |
127 | } | |
128 | ||
570f6fe1 | 129 | static int e800_remove(struct platform_device *pdev) |
ab40d4f1 | 130 | { |
1eb0202d | 131 | gpio_free_array(e800_audio_gpios, ARRAY_SIZE(e800_audio_gpios)); |
1eb0202d | 132 | return 0; |
ab40d4f1 IM |
133 | } |
134 | ||
1eb0202d AL |
135 | static struct platform_driver e800_driver = { |
136 | .driver = { | |
137 | .name = "e800-audio", | |
7db1698f | 138 | .pm = &snd_soc_pm_ops, |
1eb0202d AL |
139 | }, |
140 | .probe = e800_probe, | |
570f6fe1 | 141 | .remove = e800_remove, |
1eb0202d AL |
142 | }; |
143 | ||
144 | module_platform_driver(e800_driver); | |
ab40d4f1 IM |
145 | |
146 | /* Module information */ | |
147 | MODULE_AUTHOR("Ian Molton <spyro@f2s.com>"); | |
148 | MODULE_DESCRIPTION("ALSA SoC driver for e800"); | |
0465c7aa | 149 | MODULE_LICENSE("GPL v2"); |
1eb0202d | 150 | MODULE_ALIAS("platform:e800-audio"); |