aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2014-04-18 13:02:49 -0400
committerMark Brown <broonie@linaro.org>2014-04-18 13:02:49 -0400
commitab052d465bf7d52c1db176b762a91448e16d62c3 (patch)
treef586b28e117d57bfcdfa0bca53f9417b17b70ec4
parent40448e5e977b59a4753fce3619f537b63fcedc02 (diff)
parentfe7b5868809a89a7316eef064f0bb7796aa8c225 (diff)
Merge commit 'topic/omap' into asoc-davinci
-rw-r--r--include/sound/soc.h2
-rw-r--r--sound/soc/omap/ams-delta.c64
-rw-r--r--sound/soc/omap/omap-pcm.c6
-rw-r--r--sound/soc/omap/omap-pcm.h30
-rw-r--r--sound/soc/omap/omap3pandora.c31
-rw-r--r--sound/soc/omap/rx51.c47
-rw-r--r--sound/soc/soc-devres.c34
7 files changed, 109 insertions, 105 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 0b83168d8ff4..34c34d6e095c 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -377,6 +377,8 @@ int snd_soc_resume(struct device *dev);
377int snd_soc_poweroff(struct device *dev); 377int snd_soc_poweroff(struct device *dev);
378int snd_soc_register_platform(struct device *dev, 378int snd_soc_register_platform(struct device *dev,
379 const struct snd_soc_platform_driver *platform_drv); 379 const struct snd_soc_platform_driver *platform_drv);
380int devm_snd_soc_register_platform(struct device *dev,
381 const struct snd_soc_platform_driver *platform_drv);
380void snd_soc_unregister_platform(struct device *dev); 382void snd_soc_unregister_platform(struct device *dev);
381int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, 383int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
382 const struct snd_soc_platform_driver *platform_drv); 384 const struct snd_soc_platform_driver *platform_drv);
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index 56a5219c0a00..2ac0a0c3b570 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -38,7 +38,6 @@
38#include "omap-mcbsp.h" 38#include "omap-mcbsp.h"
39#include "../codecs/cx20442.h" 39#include "../codecs/cx20442.h"
40 40
41
42/* Board specific DAPM widgets */ 41/* Board specific DAPM widgets */
43static const struct snd_soc_dapm_widget ams_delta_dapm_widgets[] = { 42static const struct snd_soc_dapm_widget ams_delta_dapm_widgets[] = {
44 /* Handset */ 43 /* Handset */
@@ -90,17 +89,23 @@ static const unsigned short ams_delta_audio_mode_pins[] = {
90 89
91static unsigned short ams_delta_audio_agc; 90static unsigned short ams_delta_audio_agc;
92 91
92/*
93 * Used for passing a codec structure pointer
94 * from the board initialization code to the tty line discipline.
95 */
96static struct snd_soc_codec *cx20442_codec;
97
93static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, 98static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
94 struct snd_ctl_elem_value *ucontrol) 99 struct snd_ctl_elem_value *ucontrol)
95{ 100{
96 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 101 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
97 struct snd_soc_dapm_context *dapm = &codec->dapm; 102 struct snd_soc_dapm_context *dapm = &card->dapm;
98 struct soc_enum *control = (struct soc_enum *)kcontrol->private_value; 103 struct soc_enum *control = (struct soc_enum *)kcontrol->private_value;
99 unsigned short pins; 104 unsigned short pins;
100 int pin, changed = 0; 105 int pin, changed = 0;
101 106
102 /* Refuse any mode changes if we are not able to control the codec. */ 107 /* Refuse any mode changes if we are not able to control the codec. */
103 if (!codec->hw_write) 108 if (!cx20442_codec->hw_write)
104 return -EUNATCH; 109 return -EUNATCH;
105 110
106 if (ucontrol->value.enumerated.item[0] >= control->items) 111 if (ucontrol->value.enumerated.item[0] >= control->items)
@@ -166,8 +171,8 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
166static int ams_delta_get_audio_mode(struct snd_kcontrol *kcontrol, 171static int ams_delta_get_audio_mode(struct snd_kcontrol *kcontrol,
167 struct snd_ctl_elem_value *ucontrol) 172 struct snd_ctl_elem_value *ucontrol)
168{ 173{
169 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 174 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
170 struct snd_soc_dapm_context *dapm = &codec->dapm; 175 struct snd_soc_dapm_context *dapm = &card->dapm;
171 unsigned short pins, mode; 176 unsigned short pins, mode;
172 177
173 pins = ((snd_soc_dapm_get_pin_status(dapm, "Mouthpiece") << 178 pins = ((snd_soc_dapm_get_pin_status(dapm, "Mouthpiece") <<
@@ -270,12 +275,6 @@ static void cx81801_timeout(unsigned long data)
270 ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, 0); 275 ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, 0);
271} 276}
272 277
273/*
274 * Used for passing a codec structure pointer
275 * from the board initialization code to the tty line discipline.
276 */
277static struct snd_soc_codec *cx20442_codec;
278
279/* Line discipline .open() */ 278/* Line discipline .open() */
280static int cx81801_open(struct tty_struct *tty) 279static int cx81801_open(struct tty_struct *tty)
281{ 280{
@@ -302,7 +301,7 @@ static int cx81801_open(struct tty_struct *tty)
302static void cx81801_close(struct tty_struct *tty) 301static void cx81801_close(struct tty_struct *tty)
303{ 302{
304 struct snd_soc_codec *codec = tty->disc_data; 303 struct snd_soc_codec *codec = tty->disc_data;
305 struct snd_soc_dapm_context *dapm = &codec->dapm; 304 struct snd_soc_dapm_context *dapm = &codec->card->dapm;
306 305
307 del_timer_sync(&cx81801_timer); 306 del_timer_sync(&cx81801_timer);
308 307
@@ -475,15 +474,14 @@ static void ams_delta_shutdown(struct snd_pcm_substream *substream)
475 474
476static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) 475static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
477{ 476{
478 struct snd_soc_codec *codec = rtd->codec;
479 struct snd_soc_dapm_context *dapm = &codec->dapm;
480 struct snd_soc_dai *codec_dai = rtd->codec_dai; 477 struct snd_soc_dai *codec_dai = rtd->codec_dai;
481 struct snd_soc_card *card = rtd->card; 478 struct snd_soc_card *card = rtd->card;
479 struct snd_soc_dapm_context *dapm = &card->dapm;
482 int ret; 480 int ret;
483 /* Codec is ready, now add/activate board specific controls */ 481 /* Codec is ready, now add/activate board specific controls */
484 482
485 /* Store a pointer to the codec structure for tty ldisc use */ 483 /* Store a pointer to the codec structure for tty ldisc use */
486 cx20442_codec = codec; 484 cx20442_codec = rtd->codec;
487 485
488 /* Set up digital mute if not provided by the codec */ 486 /* Set up digital mute if not provided by the codec */
489 if (!codec_dai->driver->ops) { 487 if (!codec_dai->driver->ops) {
@@ -520,25 +518,6 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
520 return 0; 518 return 0;
521 } 519 }
522 520
523 /* Add board specific DAPM widgets and routes */
524 ret = snd_soc_dapm_new_controls(dapm, ams_delta_dapm_widgets,
525 ARRAY_SIZE(ams_delta_dapm_widgets));
526 if (ret) {
527 dev_warn(card->dev,
528 "Failed to register DAPM controls, "
529 "will continue without any.\n");
530 return 0;
531 }
532
533 ret = snd_soc_dapm_add_routes(dapm, ams_delta_audio_map,
534 ARRAY_SIZE(ams_delta_audio_map));
535 if (ret) {
536 dev_warn(card->dev,
537 "Failed to set up DAPM routes, "
538 "will continue with codec default map.\n");
539 return 0;
540 }
541
542 /* Set up initial pin constellation */ 521 /* Set up initial pin constellation */
543 snd_soc_dapm_disable_pin(dapm, "Mouthpiece"); 522 snd_soc_dapm_disable_pin(dapm, "Mouthpiece");
544 snd_soc_dapm_enable_pin(dapm, "Earpiece"); 523 snd_soc_dapm_enable_pin(dapm, "Earpiece");
@@ -547,14 +526,6 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
547 snd_soc_dapm_disable_pin(dapm, "AGCIN"); 526 snd_soc_dapm_disable_pin(dapm, "AGCIN");
548 snd_soc_dapm_disable_pin(dapm, "AGCOUT"); 527 snd_soc_dapm_disable_pin(dapm, "AGCOUT");
549 528
550 /* Add virtual switch */
551 ret = snd_soc_add_codec_controls(codec, ams_delta_audio_controls,
552 ARRAY_SIZE(ams_delta_audio_controls));
553 if (ret)
554 dev_warn(card->dev,
555 "Failed to register audio mode control, "
556 "will continue without it.\n");
557
558 return 0; 529 return 0;
559} 530}
560 531
@@ -576,6 +547,13 @@ static struct snd_soc_card ams_delta_audio_card = {
576 .owner = THIS_MODULE, 547 .owner = THIS_MODULE,
577 .dai_link = &ams_delta_dai_link, 548 .dai_link = &ams_delta_dai_link,
578 .num_links = 1, 549 .num_links = 1,
550
551 .controls = ams_delta_audio_controls,
552 .num_controls = ARRAY_SIZE(ams_delta_audio_controls),
553 .dapm_widgets = ams_delta_dapm_widgets,
554 .num_dapm_widgets = ARRAY_SIZE(ams_delta_dapm_widgets),
555 .dapm_routes = ams_delta_audio_map,
556 .num_dapm_routes = ARRAY_SIZE(ams_delta_audio_map),
579}; 557};
580 558
581/* Module init/exit */ 559/* Module init/exit */
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 07b8b7bc9d20..c3711b582d5f 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -232,6 +232,12 @@ static struct snd_soc_platform_driver omap_soc_platform = {
232 .pcm_free = omap_pcm_free_dma_buffers, 232 .pcm_free = omap_pcm_free_dma_buffers,
233}; 233};
234 234
235int omap_pcm_platform_register(struct device *dev)
236{
237 return devm_snd_soc_register_platform(dev, &omap_soc_platform);
238}
239EXPORT_SYMBOL_GPL(omap_pcm_platform_register);
240
235static int omap_pcm_probe(struct platform_device *pdev) 241static int omap_pcm_probe(struct platform_device *pdev)
236{ 242{
237 return snd_soc_register_platform(&pdev->dev, 243 return snd_soc_register_platform(&pdev->dev,
diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h
new file mode 100644
index 000000000000..c1d2f31d71e9
--- /dev/null
+++ b/sound/soc/omap/omap-pcm.h
@@ -0,0 +1,30 @@
1/*
2 * omap-pcm.h - OMAP PCM driver
3 *
4 * Copyright (C) 2014 Texas Instruments, Inc.
5 *
6 * Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef __OMAP_PCM_H__
19#define __OMAP_PCM_H__
20
21#if IS_ENABLED(CONFIG_SND_OMAP_SOC)
22int omap_pcm_platform_register(struct device *dev);
23#else
24static inline int omap_pcm_platform_register(struct device *dev)
25{
26 return 0;
27}
28#endif /* CONFIG_SND_OMAP_SOC */
29
30#endif /* __OMAP_PCM_H__ */
diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c
index cf604a2faa18..02181bb70400 100644
--- a/sound/soc/omap/omap3pandora.c
+++ b/sound/soc/omap/omap3pandora.c
@@ -121,7 +121,7 @@ static int omap3pandora_hp_event(struct snd_soc_dapm_widget *w,
121 * |A| <~~clk~~+ 121 * |A| <~~clk~~+
122 * |P| <--- TWL4030 <--------- Line In and MICs 122 * |P| <--- TWL4030 <--------- Line In and MICs
123 */ 123 */
124static const struct snd_soc_dapm_widget omap3pandora_out_dapm_widgets[] = { 124static const struct snd_soc_dapm_widget omap3pandora_dapm_widgets[] = {
125 SND_SOC_DAPM_DAC_E("PCM DAC", "HiFi Playback", SND_SOC_NOPM, 125 SND_SOC_DAPM_DAC_E("PCM DAC", "HiFi Playback", SND_SOC_NOPM,
126 0, 0, omap3pandora_dac_event, 126 0, 0, omap3pandora_dac_event,
127 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 127 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
@@ -130,22 +130,18 @@ static const struct snd_soc_dapm_widget omap3pandora_out_dapm_widgets[] = {
130 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), 130 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
131 SND_SOC_DAPM_HP("Headphone Jack", NULL), 131 SND_SOC_DAPM_HP("Headphone Jack", NULL),
132 SND_SOC_DAPM_LINE("Line Out", NULL), 132 SND_SOC_DAPM_LINE("Line Out", NULL),
133};
134 133
135static const struct snd_soc_dapm_widget omap3pandora_in_dapm_widgets[] = {
136 SND_SOC_DAPM_MIC("Mic (internal)", NULL), 134 SND_SOC_DAPM_MIC("Mic (internal)", NULL),
137 SND_SOC_DAPM_MIC("Mic (external)", NULL), 135 SND_SOC_DAPM_MIC("Mic (external)", NULL),
138 SND_SOC_DAPM_LINE("Line In", NULL), 136 SND_SOC_DAPM_LINE("Line In", NULL),
139}; 137};
140 138
141static const struct snd_soc_dapm_route omap3pandora_out_map[] = { 139static const struct snd_soc_dapm_route omap3pandora_map[] = {
142 {"PCM DAC", NULL, "APLL Enable"}, 140 {"PCM DAC", NULL, "APLL Enable"},
143 {"Headphone Amplifier", NULL, "PCM DAC"}, 141 {"Headphone Amplifier", NULL, "PCM DAC"},
144 {"Line Out", NULL, "PCM DAC"}, 142 {"Line Out", NULL, "PCM DAC"},
145 {"Headphone Jack", NULL, "Headphone Amplifier"}, 143 {"Headphone Jack", NULL, "Headphone Amplifier"},
146};
147 144
148static const struct snd_soc_dapm_route omap3pandora_in_map[] = {
149 {"AUXL", NULL, "Line In"}, 145 {"AUXL", NULL, "Line In"},
150 {"AUXR", NULL, "Line In"}, 146 {"AUXR", NULL, "Line In"},
151 147
@@ -160,7 +156,6 @@ static int omap3pandora_out_init(struct snd_soc_pcm_runtime *rtd)
160{ 156{
161 struct snd_soc_codec *codec = rtd->codec; 157 struct snd_soc_codec *codec = rtd->codec;
162 struct snd_soc_dapm_context *dapm = &codec->dapm; 158 struct snd_soc_dapm_context *dapm = &codec->dapm;
163 int ret;
164 159
165 /* All TWL4030 output pins are floating */ 160 /* All TWL4030 output pins are floating */
166 snd_soc_dapm_nc_pin(dapm, "EARPIECE"); 161 snd_soc_dapm_nc_pin(dapm, "EARPIECE");
@@ -174,20 +169,13 @@ static int omap3pandora_out_init(struct snd_soc_pcm_runtime *rtd)
174 snd_soc_dapm_nc_pin(dapm, "HFR"); 169 snd_soc_dapm_nc_pin(dapm, "HFR");
175 snd_soc_dapm_nc_pin(dapm, "VIBRA"); 170 snd_soc_dapm_nc_pin(dapm, "VIBRA");
176 171
177 ret = snd_soc_dapm_new_controls(dapm, omap3pandora_out_dapm_widgets, 172 return 0;
178 ARRAY_SIZE(omap3pandora_out_dapm_widgets));
179 if (ret < 0)
180 return ret;
181
182 return snd_soc_dapm_add_routes(dapm, omap3pandora_out_map,
183 ARRAY_SIZE(omap3pandora_out_map));
184} 173}
185 174
186static int omap3pandora_in_init(struct snd_soc_pcm_runtime *rtd) 175static int omap3pandora_in_init(struct snd_soc_pcm_runtime *rtd)
187{ 176{
188 struct snd_soc_codec *codec = rtd->codec; 177 struct snd_soc_codec *codec = rtd->codec;
189 struct snd_soc_dapm_context *dapm = &codec->dapm; 178 struct snd_soc_dapm_context *dapm = &codec->dapm;
190 int ret;
191 179
192 /* Not comnnected */ 180 /* Not comnnected */
193 snd_soc_dapm_nc_pin(dapm, "HSMIC"); 181 snd_soc_dapm_nc_pin(dapm, "HSMIC");
@@ -195,13 +183,7 @@ static int omap3pandora_in_init(struct snd_soc_pcm_runtime *rtd)
195 snd_soc_dapm_nc_pin(dapm, "DIGIMIC0"); 183 snd_soc_dapm_nc_pin(dapm, "DIGIMIC0");
196 snd_soc_dapm_nc_pin(dapm, "DIGIMIC1"); 184 snd_soc_dapm_nc_pin(dapm, "DIGIMIC1");
197 185
198 ret = snd_soc_dapm_new_controls(dapm, omap3pandora_in_dapm_widgets, 186 return 0;
199 ARRAY_SIZE(omap3pandora_in_dapm_widgets));
200 if (ret < 0)
201 return ret;
202
203 return snd_soc_dapm_add_routes(dapm, omap3pandora_in_map,
204 ARRAY_SIZE(omap3pandora_in_map));
205} 187}
206 188
207static struct snd_soc_ops omap3pandora_ops = { 189static struct snd_soc_ops omap3pandora_ops = {
@@ -241,6 +223,11 @@ static struct snd_soc_card snd_soc_card_omap3pandora = {
241 .owner = THIS_MODULE, 223 .owner = THIS_MODULE,
242 .dai_link = omap3pandora_dai, 224 .dai_link = omap3pandora_dai,
243 .num_links = ARRAY_SIZE(omap3pandora_dai), 225 .num_links = ARRAY_SIZE(omap3pandora_dai),
226
227 .dapm_widgets = omap3pandora_dapm_widgets,
228 .num_dapm_widgets = ARRAY_SIZE(omap3pandora_dapm_widgets),
229 .dapm_routes = omap3pandora_map,
230 .num_dapm_routes = ARRAY_SIZE(omap3pandora_map),
244}; 231};
245 232
246static struct platform_device *omap3pandora_snd_device; 233static struct platform_device *omap3pandora_snd_device;
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c
index 7fb3d4b10370..2b4641123142 100644
--- a/sound/soc/omap/rx51.c
+++ b/sound/soc/omap/rx51.c
@@ -237,9 +237,6 @@ static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = {
237 SND_SOC_DAPM_HP("Headphone Jack", rx51_hp_event), 237 SND_SOC_DAPM_HP("Headphone Jack", rx51_hp_event),
238 SND_SOC_DAPM_MIC("HS Mic", NULL), 238 SND_SOC_DAPM_MIC("HS Mic", NULL),
239 SND_SOC_DAPM_LINE("FM Transmitter", NULL), 239 SND_SOC_DAPM_LINE("FM Transmitter", NULL),
240};
241
242static const struct snd_soc_dapm_widget aic34_dapm_widgetsb[] = {
243 SND_SOC_DAPM_SPK("Earphone", NULL), 240 SND_SOC_DAPM_SPK("Earphone", NULL),
244}; 241};
245 242
@@ -253,9 +250,7 @@ static const struct snd_soc_dapm_route audio_map[] = {
253 250
254 {"DMic Rate 64", NULL, "Mic Bias"}, 251 {"DMic Rate 64", NULL, "Mic Bias"},
255 {"Mic Bias", NULL, "DMic"}, 252 {"Mic Bias", NULL, "DMic"},
256};
257 253
258static const struct snd_soc_dapm_route audio_mapb[] = {
259 {"b LINE2R", NULL, "MONO_LOUT"}, 254 {"b LINE2R", NULL, "MONO_LOUT"},
260 {"Earphone", NULL, "b HPLOUT"}, 255 {"Earphone", NULL, "b HPLOUT"},
261 256
@@ -281,9 +276,6 @@ static const struct snd_kcontrol_new aic34_rx51_controls[] = {
281 SOC_ENUM_EXT("Jack Function", rx51_enum[2], 276 SOC_ENUM_EXT("Jack Function", rx51_enum[2],
282 rx51_get_jack, rx51_set_jack), 277 rx51_get_jack, rx51_set_jack),
283 SOC_DAPM_PIN_SWITCH("FM Transmitter"), 278 SOC_DAPM_PIN_SWITCH("FM Transmitter"),
284};
285
286static const struct snd_kcontrol_new aic34_rx51_controlsb[] = {
287 SOC_DAPM_PIN_SWITCH("Earphone"), 279 SOC_DAPM_PIN_SWITCH("Earphone"),
288}; 280};
289 281
@@ -298,19 +290,6 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
298 snd_soc_dapm_nc_pin(dapm, "MIC3R"); 290 snd_soc_dapm_nc_pin(dapm, "MIC3R");
299 snd_soc_dapm_nc_pin(dapm, "LINE1R"); 291 snd_soc_dapm_nc_pin(dapm, "LINE1R");
300 292
301 /* Add RX-51 specific controls */
302 err = snd_soc_add_card_controls(rtd->card, aic34_rx51_controls,
303 ARRAY_SIZE(aic34_rx51_controls));
304 if (err < 0)
305 return err;
306
307 /* Add RX-51 specific widgets */
308 snd_soc_dapm_new_controls(dapm, aic34_dapm_widgets,
309 ARRAY_SIZE(aic34_dapm_widgets));
310
311 /* Set up RX-51 specific audio path audio_map */
312 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
313
314 err = tpa6130a2_add_controls(codec); 293 err = tpa6130a2_add_controls(codec);
315 if (err < 0) 294 if (err < 0)
316 return err; 295 return err;
@@ -333,24 +312,6 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
333 return err; 312 return err;
334} 313}
335 314
336static int rx51_aic34b_init(struct snd_soc_dapm_context *dapm)
337{
338 int err;
339
340 err = snd_soc_add_card_controls(dapm->card, aic34_rx51_controlsb,
341 ARRAY_SIZE(aic34_rx51_controlsb));
342 if (err < 0)
343 return err;
344
345 err = snd_soc_dapm_new_controls(dapm, aic34_dapm_widgetsb,
346 ARRAY_SIZE(aic34_dapm_widgetsb));
347 if (err < 0)
348 return 0;
349
350 return snd_soc_dapm_add_routes(dapm, audio_mapb,
351 ARRAY_SIZE(audio_mapb));
352}
353
354/* Digital audio interface glue - connects codec <--> CPU */ 315/* Digital audio interface glue - connects codec <--> CPU */
355static struct snd_soc_dai_link rx51_dai[] = { 316static struct snd_soc_dai_link rx51_dai[] = {
356 { 317 {
@@ -371,7 +332,6 @@ static struct snd_soc_aux_dev rx51_aux_dev[] = {
371 { 332 {
372 .name = "TLV320AIC34b", 333 .name = "TLV320AIC34b",
373 .codec_name = "tlv320aic3x-codec.2-0019", 334 .codec_name = "tlv320aic3x-codec.2-0019",
374 .init = rx51_aic34b_init,
375 }, 335 },
376}; 336};
377 337
@@ -392,6 +352,13 @@ static struct snd_soc_card rx51_sound_card = {
392 .num_aux_devs = ARRAY_SIZE(rx51_aux_dev), 352 .num_aux_devs = ARRAY_SIZE(rx51_aux_dev),
393 .codec_conf = rx51_codec_conf, 353 .codec_conf = rx51_codec_conf,
394 .num_configs = ARRAY_SIZE(rx51_codec_conf), 354 .num_configs = ARRAY_SIZE(rx51_codec_conf),
355
356 .controls = aic34_rx51_controls,
357 .num_controls = ARRAY_SIZE(aic34_rx51_controls),
358 .dapm_widgets = aic34_dapm_widgets,
359 .num_dapm_widgets = ARRAY_SIZE(aic34_dapm_widgets),
360 .dapm_routes = audio_map,
361 .num_dapm_routes = ARRAY_SIZE(audio_map),
395}; 362};
396 363
397static struct platform_device *rx51_snd_device; 364static struct platform_device *rx51_snd_device;
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
index 7ac745df1412..e94aa0277250 100644
--- a/sound/soc/soc-devres.c
+++ b/sound/soc/soc-devres.c
@@ -52,6 +52,40 @@ int devm_snd_soc_register_component(struct device *dev,
52} 52}
53EXPORT_SYMBOL_GPL(devm_snd_soc_register_component); 53EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
54 54
55static void devm_platform_release(struct device *dev, void *res)
56{
57 snd_soc_unregister_platform(*(struct device **)res);
58}
59
60/**
61 * devm_snd_soc_register_platform - resource managed platform registration
62 * @dev: Device used to manage platform
63 * @platform: platform to register
64 *
65 * Register a platform driver with automatic unregistration when the device is
66 * unregistered.
67 */
68int devm_snd_soc_register_platform(struct device *dev,
69 const struct snd_soc_platform_driver *platform_drv)
70{
71 struct device **ptr;
72 int ret;
73
74 ptr = devres_alloc(devm_platform_release, sizeof(*ptr), GFP_KERNEL);
75 if (!ptr)
76 return -ENOMEM;
77
78 ret = snd_soc_register_platform(dev, platform_drv);
79 if (ret == 0) {
80 *ptr = dev;
81 devres_add(dev, ptr);
82 } else {
83 devres_free(ptr);
84 }
85
86 return ret;
87}
88
55static void devm_card_release(struct device *dev, void *res) 89static void devm_card_release(struct device *dev, void *res)
56{ 90{
57 snd_soc_unregister_card(*(struct snd_soc_card **)res); 91 snd_soc_unregister_card(*(struct snd_soc_card **)res);