ASoC: Decouple DAPM from CODECs
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / sound / soc / s3c24xx / s3c24xx_simtec_hermes.c
1 /* sound/soc/s3c24xx/s3c24xx_simtec_hermes.c
2 *
3 * Copyright 2009 Simtec Electronics
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10 #include <linux/module.h>
11 #include <linux/clk.h>
12 #include <linux/platform_device.h>
13
14 #include <sound/core.h>
15 #include <sound/pcm.h>
16 #include <sound/soc.h>
17 #include <sound/soc-dapm.h>
18
19 #include <plat/audio-simtec.h>
20
21 #include "s3c-dma.h"
22 #include "s3c24xx-i2s.h"
23 #include "s3c24xx_simtec.h"
24
25 #include "../codecs/tlv320aic3x.h"
26
27 static const struct snd_soc_dapm_widget dapm_widgets[] = {
28 SND_SOC_DAPM_LINE("GSM Out", NULL),
29 SND_SOC_DAPM_LINE("GSM In", NULL),
30 SND_SOC_DAPM_LINE("Line In", NULL),
31 SND_SOC_DAPM_LINE("Line Out", NULL),
32 SND_SOC_DAPM_LINE("ZV", NULL),
33 SND_SOC_DAPM_MIC("Mic Jack", NULL),
34 SND_SOC_DAPM_HP("Headphone Jack", NULL),
35 };
36
37 static const struct snd_soc_dapm_route base_map[] = {
38 /* Headphone connected to HP{L,R}OUT and HP{L,R}COM */
39
40 { "Headphone Jack", NULL, "HPLOUT" },
41 { "Headphone Jack", NULL, "HPLCOM" },
42 { "Headphone Jack", NULL, "HPROUT" },
43 { "Headphone Jack", NULL, "HPRCOM" },
44
45 /* ZV connected to Line1 */
46
47 { "LINE1L", NULL, "ZV" },
48 { "LINE1R", NULL, "ZV" },
49
50 /* Line In connected to Line2 */
51
52 { "LINE2L", NULL, "Line In" },
53 { "LINE2R", NULL, "Line In" },
54
55 /* Microphone connected to MIC3R and MIC_BIAS */
56
57 { "MIC3L", NULL, "Mic Jack" },
58
59 /* GSM connected to MONO_LOUT and MIC3L (in) */
60
61 { "GSM Out", NULL, "MONO_LOUT" },
62 { "MIC3L", NULL, "GSM In" },
63
64 /* Speaker is connected to LINEOUT{LN,LP,RN,RP}, however we are
65 * not using the DAPM to power it up and down as there it makes
66 * a click when powering up. */
67 };
68
69 /**
70 * simtec_hermes_init - initialise and add controls
71 * @codec; The codec instance to attach to.
72 *
73 * Attach our controls and configure the necessary codec
74 * mappings for our sound card instance.
75 */
76 static int simtec_hermes_init(struct snd_soc_pcm_runtime *rtd)
77 {
78 struct snd_soc_codec *codec = rtd->codec;
79 struct snd_soc_dapm_context *dapm = &codec->dapm;
80
81 snd_soc_dapm_new_controls(dapm, dapm_widgets,
82 ARRAY_SIZE(dapm_widgets));
83
84 snd_soc_dapm_add_routes(dapm, base_map, ARRAY_SIZE(base_map));
85
86 snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
87 snd_soc_dapm_enable_pin(dapm, "Line In");
88 snd_soc_dapm_enable_pin(dapm, "Line Out");
89 snd_soc_dapm_enable_pin(dapm, "Mic Jack");
90
91 simtec_audio_init(rtd);
92 snd_soc_dapm_sync(dapm);
93
94 return 0;
95 }
96
97 static struct snd_soc_dai_link simtec_dai_aic33 = {
98 .name = "tlv320aic33",
99 .stream_name = "TLV320AIC33",
100 .codec_name = "tlv320aic3x-codec.0-0x1a",
101 .cpu_dai_name = "s3c24xx-i2s",
102 .codec_dai_name = "tlv320aic3x-hifi",
103 .platform_name = "s3c24xx-pcm-audio",
104 .init = simtec_hermes_init,
105 };
106
107 /* simtec audio machine driver */
108 static struct snd_soc_card snd_soc_machine_simtec_aic33 = {
109 .name = "Simtec-Hermes",
110 .dai_link = &simtec_dai_aic33,
111 .num_links = 1,
112 };
113
114 static int __devinit simtec_audio_hermes_probe(struct platform_device *pd)
115 {
116 dev_info(&pd->dev, "probing....\n");
117 return simtec_audio_core_probe(pd, &snd_soc_machine_simtec_aic33);
118 }
119
120 static struct platform_driver simtec_audio_hermes_platdrv = {
121 .driver = {
122 .owner = THIS_MODULE,
123 .name = "s3c24xx-simtec-hermes-snd",
124 .pm = simtec_audio_pm,
125 },
126 .probe = simtec_audio_hermes_probe,
127 .remove = __devexit_p(simtec_audio_remove),
128 };
129
130 MODULE_ALIAS("platform:s3c24xx-simtec-hermes-snd");
131
132 static int __init simtec_hermes_modinit(void)
133 {
134 return platform_driver_register(&simtec_audio_hermes_platdrv);
135 }
136
137 static void __exit simtec_hermes_modexit(void)
138 {
139 platform_driver_unregister(&simtec_audio_hermes_platdrv);
140 }
141
142 module_init(simtec_hermes_modinit);
143 module_exit(simtec_hermes_modexit);
144
145 MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
146 MODULE_DESCRIPTION("ALSA SoC Simtec Audio support");
147 MODULE_LICENSE("GPL");