diff options
Diffstat (limited to 'sound/soc/omap/omap-abe-twl6040.c')
-rw-r--r-- | sound/soc/omap/omap-abe-twl6040.c | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index 93bb8eee22b3..9d93793d3077 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c | |||
@@ -40,6 +40,11 @@ | |||
40 | #include "omap-pcm.h" | 40 | #include "omap-pcm.h" |
41 | #include "../codecs/twl6040.h" | 41 | #include "../codecs/twl6040.h" |
42 | 42 | ||
43 | struct abe_twl6040 { | ||
44 | int jack_detection; /* board can detect jack events */ | ||
45 | int mclk_freq; /* MCLK frequency speed for twl6040 */ | ||
46 | }; | ||
47 | |||
43 | static int omap_abe_hw_params(struct snd_pcm_substream *substream, | 48 | static int omap_abe_hw_params(struct snd_pcm_substream *substream, |
44 | struct snd_pcm_hw_params *params) | 49 | struct snd_pcm_hw_params *params) |
45 | { | 50 | { |
@@ -47,13 +52,13 @@ static int omap_abe_hw_params(struct snd_pcm_substream *substream, | |||
47 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 52 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
48 | struct snd_soc_codec *codec = rtd->codec; | 53 | struct snd_soc_codec *codec = rtd->codec; |
49 | struct snd_soc_card *card = codec->card; | 54 | struct snd_soc_card *card = codec->card; |
50 | struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev); | 55 | struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card); |
51 | int clk_id, freq; | 56 | int clk_id, freq; |
52 | int ret; | 57 | int ret; |
53 | 58 | ||
54 | clk_id = twl6040_get_clk_id(rtd->codec); | 59 | clk_id = twl6040_get_clk_id(rtd->codec); |
55 | if (clk_id == TWL6040_SYSCLK_SEL_HPPLL) | 60 | if (clk_id == TWL6040_SYSCLK_SEL_HPPLL) |
56 | freq = pdata->mclk_freq; | 61 | freq = priv->mclk_freq; |
57 | else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL) | 62 | else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL) |
58 | freq = 32768; | 63 | freq = 32768; |
59 | else | 64 | else |
@@ -128,6 +133,9 @@ static const struct snd_soc_dapm_widget twl6040_dapm_widgets[] = { | |||
128 | SND_SOC_DAPM_MIC("Main Handset Mic", NULL), | 133 | SND_SOC_DAPM_MIC("Main Handset Mic", NULL), |
129 | SND_SOC_DAPM_MIC("Sub Handset Mic", NULL), | 134 | SND_SOC_DAPM_MIC("Sub Handset Mic", NULL), |
130 | SND_SOC_DAPM_LINE("Line In", NULL), | 135 | SND_SOC_DAPM_LINE("Line In", NULL), |
136 | |||
137 | /* Digital microphones */ | ||
138 | SND_SOC_DAPM_MIC("Digital Mic", NULL), | ||
131 | }; | 139 | }; |
132 | 140 | ||
133 | static const struct snd_soc_dapm_route audio_map[] = { | 141 | static const struct snd_soc_dapm_route audio_map[] = { |
@@ -173,6 +181,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) | |||
173 | struct snd_soc_card *card = codec->card; | 181 | struct snd_soc_card *card = codec->card; |
174 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 182 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
175 | struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev); | 183 | struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev); |
184 | struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card); | ||
176 | int hs_trim; | 185 | int hs_trim; |
177 | int ret = 0; | 186 | int ret = 0; |
178 | 187 | ||
@@ -196,7 +205,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) | |||
196 | TWL6040_HSF_TRIM_RIGHT(hs_trim)); | 205 | TWL6040_HSF_TRIM_RIGHT(hs_trim)); |
197 | 206 | ||
198 | /* Headset jack detection only if it is supported */ | 207 | /* Headset jack detection only if it is supported */ |
199 | if (pdata->jack_detection) { | 208 | if (priv->jack_detection) { |
200 | ret = snd_soc_jack_new(codec, "Headset Jack", | 209 | ret = snd_soc_jack_new(codec, "Headset Jack", |
201 | SND_JACK_HEADSET, &hs_jack); | 210 | SND_JACK_HEADSET, &hs_jack); |
202 | if (ret) | 211 | if (ret) |
@@ -210,10 +219,6 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) | |||
210 | return ret; | 219 | return ret; |
211 | } | 220 | } |
212 | 221 | ||
213 | static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = { | ||
214 | SND_SOC_DAPM_MIC("Digital Mic", NULL), | ||
215 | }; | ||
216 | |||
217 | static const struct snd_soc_dapm_route dmic_audio_map[] = { | 222 | static const struct snd_soc_dapm_route dmic_audio_map[] = { |
218 | {"DMic", NULL, "Digital Mic"}, | 223 | {"DMic", NULL, "Digital Mic"}, |
219 | {"Digital Mic", NULL, "Digital Mic1 Bias"}, | 224 | {"Digital Mic", NULL, "Digital Mic1 Bias"}, |
@@ -223,19 +228,13 @@ static int omap_abe_dmic_init(struct snd_soc_pcm_runtime *rtd) | |||
223 | { | 228 | { |
224 | struct snd_soc_codec *codec = rtd->codec; | 229 | struct snd_soc_codec *codec = rtd->codec; |
225 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 230 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
226 | int ret; | ||
227 | |||
228 | ret = snd_soc_dapm_new_controls(dapm, dmic_dapm_widgets, | ||
229 | ARRAY_SIZE(dmic_dapm_widgets)); | ||
230 | if (ret) | ||
231 | return ret; | ||
232 | 231 | ||
233 | return snd_soc_dapm_add_routes(dapm, dmic_audio_map, | 232 | return snd_soc_dapm_add_routes(dapm, dmic_audio_map, |
234 | ARRAY_SIZE(dmic_audio_map)); | 233 | ARRAY_SIZE(dmic_audio_map)); |
235 | } | 234 | } |
236 | 235 | ||
237 | /* Digital audio interface glue - connects codec <--> CPU */ | 236 | /* Digital audio interface glue - connects codec <--> CPU */ |
238 | static struct snd_soc_dai_link twl6040_dmic_dai[] = { | 237 | static struct snd_soc_dai_link abe_twl6040_dai_links[] = { |
239 | { | 238 | { |
240 | .name = "TWL6040", | 239 | .name = "TWL6040", |
241 | .stream_name = "TWL6040", | 240 | .stream_name = "TWL6040", |
@@ -258,19 +257,6 @@ static struct snd_soc_dai_link twl6040_dmic_dai[] = { | |||
258 | }, | 257 | }, |
259 | }; | 258 | }; |
260 | 259 | ||
261 | static struct snd_soc_dai_link twl6040_only_dai[] = { | ||
262 | { | ||
263 | .name = "TWL6040", | ||
264 | .stream_name = "TWL6040", | ||
265 | .cpu_dai_name = "omap-mcpdm", | ||
266 | .codec_dai_name = "twl6040-legacy", | ||
267 | .platform_name = "omap-pcm-audio", | ||
268 | .codec_name = "twl6040-codec", | ||
269 | .init = omap_abe_twl6040_init, | ||
270 | .ops = &omap_abe_ops, | ||
271 | }, | ||
272 | }; | ||
273 | |||
274 | /* Audio machine driver */ | 260 | /* Audio machine driver */ |
275 | static struct snd_soc_card omap_abe_card = { | 261 | static struct snd_soc_card omap_abe_card = { |
276 | .owner = THIS_MODULE, | 262 | .owner = THIS_MODULE, |
@@ -285,6 +271,8 @@ static __devinit int omap_abe_probe(struct platform_device *pdev) | |||
285 | { | 271 | { |
286 | struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev); | 272 | struct omap_abe_twl6040_data *pdata = dev_get_platdata(&pdev->dev); |
287 | struct snd_soc_card *card = &omap_abe_card; | 273 | struct snd_soc_card *card = &omap_abe_card; |
274 | struct abe_twl6040 *priv; | ||
275 | int num_links = 0; | ||
288 | int ret; | 276 | int ret; |
289 | 277 | ||
290 | card->dev = &pdev->dev; | 278 | card->dev = &pdev->dev; |
@@ -294,6 +282,10 @@ static __devinit int omap_abe_probe(struct platform_device *pdev) | |||
294 | return -ENODEV; | 282 | return -ENODEV; |
295 | } | 283 | } |
296 | 284 | ||
285 | priv = devm_kzalloc(&pdev->dev, sizeof(struct abe_twl6040), GFP_KERNEL); | ||
286 | if (priv == NULL) | ||
287 | return -ENOMEM; | ||
288 | |||
297 | if (pdata->card_name) { | 289 | if (pdata->card_name) { |
298 | card->name = pdata->card_name; | 290 | card->name = pdata->card_name; |
299 | } else { | 291 | } else { |
@@ -301,18 +293,24 @@ static __devinit int omap_abe_probe(struct platform_device *pdev) | |||
301 | return -ENODEV; | 293 | return -ENODEV; |
302 | } | 294 | } |
303 | 295 | ||
304 | if (!pdata->mclk_freq) { | 296 | priv->jack_detection = pdata->jack_detection; |
297 | priv->mclk_freq = pdata->mclk_freq; | ||
298 | |||
299 | |||
300 | if (!priv->mclk_freq) { | ||
305 | dev_err(&pdev->dev, "MCLK frequency missing\n"); | 301 | dev_err(&pdev->dev, "MCLK frequency missing\n"); |
306 | return -ENODEV; | 302 | return -ENODEV; |
307 | } | 303 | } |
308 | 304 | ||
309 | if (pdata->has_dmic) { | 305 | if (pdata->has_dmic) |
310 | card->dai_link = twl6040_dmic_dai; | 306 | num_links = 2; |
311 | card->num_links = ARRAY_SIZE(twl6040_dmic_dai); | 307 | else |
312 | } else { | 308 | num_links = 1; |
313 | card->dai_link = twl6040_only_dai; | 309 | |
314 | card->num_links = ARRAY_SIZE(twl6040_only_dai); | 310 | card->dai_link = abe_twl6040_dai_links; |
315 | } | 311 | card->num_links = num_links; |
312 | |||
313 | snd_soc_card_set_drvdata(card, priv); | ||
316 | 314 | ||
317 | ret = snd_soc_register_card(card); | 315 | ret = snd_soc_register_card(card); |
318 | if (ret) | 316 | if (ret) |