aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/omap/sdp3430.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/omap/sdp3430.c')
-rw-r--r--sound/soc/omap/sdp3430.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c
index e226fa75669c..10f1c867f11d 100644
--- a/sound/soc/omap/sdp3430.c
+++ b/sound/soc/omap/sdp3430.c
@@ -28,6 +28,7 @@
28#include <sound/pcm.h> 28#include <sound/pcm.h>
29#include <sound/soc.h> 29#include <sound/soc.h>
30#include <sound/soc-dapm.h> 30#include <sound/soc-dapm.h>
31#include <sound/jack.h>
31 32
32#include <asm/mach-types.h> 33#include <asm/mach-types.h>
33#include <mach/hardware.h> 34#include <mach/hardware.h>
@@ -38,6 +39,8 @@
38#include "omap-pcm.h" 39#include "omap-pcm.h"
39#include "../codecs/twl4030.h" 40#include "../codecs/twl4030.h"
40 41
42static struct snd_soc_card snd_soc_sdp3430;
43
41static int sdp3430_hw_params(struct snd_pcm_substream *substream, 44static int sdp3430_hw_params(struct snd_pcm_substream *substream,
42 struct snd_pcm_hw_params *params) 45 struct snd_pcm_hw_params *params)
43{ 46{
@@ -81,12 +84,121 @@ static struct snd_soc_ops sdp3430_ops = {
81 .hw_params = sdp3430_hw_params, 84 .hw_params = sdp3430_hw_params,
82}; 85};
83 86
87/* Headset jack */
88static struct snd_soc_jack hs_jack;
89
90/* Headset jack detection DAPM pins */
91static struct snd_soc_jack_pin hs_jack_pins[] = {
92 {
93 .pin = "Headset Mic",
94 .mask = SND_JACK_MICROPHONE,
95 },
96 {
97 .pin = "Headset Stereophone",
98 .mask = SND_JACK_HEADPHONE,
99 },
100};
101
102/* Headset jack detection gpios */
103static struct snd_soc_jack_gpio hs_jack_gpios[] = {
104 {
105 .gpio = (OMAP_MAX_GPIO_LINES + 2),
106 .name = "hsdet-gpio",
107 .report = SND_JACK_HEADSET,
108 .debounce_time = 200,
109 },
110};
111
112/* SDP3430 machine DAPM */
113static const struct snd_soc_dapm_widget sdp3430_twl4030_dapm_widgets[] = {
114 SND_SOC_DAPM_MIC("Ext Mic", NULL),
115 SND_SOC_DAPM_SPK("Ext Spk", NULL),
116 SND_SOC_DAPM_MIC("Headset Mic", NULL),
117 SND_SOC_DAPM_HP("Headset Stereophone", NULL),
118};
119
120static const struct snd_soc_dapm_route audio_map[] = {
121 /* External Mics: MAINMIC, SUBMIC with bias*/
122 {"MAINMIC", NULL, "Mic Bias 1"},
123 {"SUBMIC", NULL, "Mic Bias 2"},
124 {"Mic Bias 1", NULL, "Ext Mic"},
125 {"Mic Bias 2", NULL, "Ext Mic"},
126
127 /* External Speakers: HFL, HFR */
128 {"Ext Spk", NULL, "HFL"},
129 {"Ext Spk", NULL, "HFR"},
130
131 /* Headset Mic: HSMIC with bias */
132 {"HSMIC", NULL, "Headset Mic Bias"},
133 {"Headset Mic Bias", NULL, "Headset Mic"},
134
135 /* Headset Stereophone (Headphone): HSOL, HSOR */
136 {"Headset Stereophone", NULL, "HSOL"},
137 {"Headset Stereophone", NULL, "HSOR"},
138};
139
140static int sdp3430_twl4030_init(struct snd_soc_codec *codec)
141{
142 int ret;
143
144 /* Add SDP3430 specific widgets */
145 ret = snd_soc_dapm_new_controls(codec, sdp3430_twl4030_dapm_widgets,
146 ARRAY_SIZE(sdp3430_twl4030_dapm_widgets));
147 if (ret)
148 return ret;
149
150 /* Set up SDP3430 specific audio path audio_map */
151 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
152
153 /* SDP3430 connected pins */
154 snd_soc_dapm_enable_pin(codec, "Ext Mic");
155 snd_soc_dapm_enable_pin(codec, "Ext Spk");
156 snd_soc_dapm_disable_pin(codec, "Headset Mic");
157 snd_soc_dapm_disable_pin(codec, "Headset Stereophone");
158
159 /* TWL4030 not connected pins */
160 snd_soc_dapm_nc_pin(codec, "AUXL");
161 snd_soc_dapm_nc_pin(codec, "AUXR");
162 snd_soc_dapm_nc_pin(codec, "CARKITMIC");
163 snd_soc_dapm_nc_pin(codec, "DIGIMIC0");
164 snd_soc_dapm_nc_pin(codec, "DIGIMIC1");
165
166 snd_soc_dapm_nc_pin(codec, "OUTL");
167 snd_soc_dapm_nc_pin(codec, "OUTR");
168 snd_soc_dapm_nc_pin(codec, "EARPIECE");
169 snd_soc_dapm_nc_pin(codec, "PREDRIVEL");
170 snd_soc_dapm_nc_pin(codec, "PREDRIVER");
171 snd_soc_dapm_nc_pin(codec, "CARKITL");
172 snd_soc_dapm_nc_pin(codec, "CARKITR");
173
174 ret = snd_soc_dapm_sync(codec);
175 if (ret)
176 return ret;
177
178 /* Headset jack detection */
179 ret = snd_soc_jack_new(&snd_soc_sdp3430, "Headset Jack",
180 SND_JACK_HEADSET, &hs_jack);
181 if (ret)
182 return ret;
183
184 ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
185 hs_jack_pins);
186 if (ret)
187 return ret;
188
189 ret = snd_soc_jack_add_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios),
190 hs_jack_gpios);
191
192 return ret;
193}
194
84/* Digital audio interface glue - connects codec <--> CPU */ 195/* Digital audio interface glue - connects codec <--> CPU */
85static struct snd_soc_dai_link sdp3430_dai = { 196static struct snd_soc_dai_link sdp3430_dai = {
86 .name = "TWL4030", 197 .name = "TWL4030",
87 .stream_name = "TWL4030", 198 .stream_name = "TWL4030",
88 .cpu_dai = &omap_mcbsp_dai[0], 199 .cpu_dai = &omap_mcbsp_dai[0],
89 .codec_dai = &twl4030_dai, 200 .codec_dai = &twl4030_dai,
201 .init = sdp3430_twl4030_init,
90 .ops = &sdp3430_ops, 202 .ops = &sdp3430_ops,
91}; 203};
92 204
@@ -142,6 +254,9 @@ module_init(sdp3430_soc_init);
142 254
143static void __exit sdp3430_soc_exit(void) 255static void __exit sdp3430_soc_exit(void)
144{ 256{
257 snd_soc_jack_free_gpios(&hs_jack, ARRAY_SIZE(hs_jack_gpios),
258 hs_jack_gpios);
259
145 platform_device_unregister(sdp3430_snd_device); 260 platform_device_unregister(sdp3430_snd_device);
146} 261}
147module_exit(sdp3430_soc_exit); 262module_exit(sdp3430_soc_exit);