aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/cq93vc.c
diff options
context:
space:
mode:
authorLiam Girdwood <lrg@slimlogic.co.uk>2010-03-17 16:15:21 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-08-12 09:00:00 -0400
commitf0fba2ad1b6b53d5360125c41953b7afcd6deff0 (patch)
treef6ad50905f8daa616593c978d7ae992e73241180 /sound/soc/codecs/cq93vc.c
parentbda7d2a862e6b788bca2d02d38a07966a9c92e48 (diff)
ASoC: multi-component - ASoC Multi-Component Support
This patch extends the ASoC API to allow sound cards to have more than one CODEC and more than one platform DMA controller. This is achieved by dividing some current ASoC structures that contain both driver data and device data into structures that only either contain device data or driver data. i.e. struct snd_soc_codec ---> struct snd_soc_codec (device data) +-> struct snd_soc_codec_driver (driver data) struct snd_soc_platform ---> struct snd_soc_platform (device data) +-> struct snd_soc_platform_driver (driver data) struct snd_soc_dai ---> struct snd_soc_dai (device data) +-> struct snd_soc_dai_driver (driver data) struct snd_soc_device ---> deleted This now allows ASoC to be more tightly aligned with the Linux driver model and also means that every ASoC codec, platform and (platform) DAI is a kernel device. ASoC component private data is now stored as device private data. The ASoC sound card struct snd_soc_card has also been updated to store lists of it's components rather than a pointer to a codec and platform. The PCM runtime struct soc_pcm_runtime now has pointers to all its components. This patch adds DAPM support for ASoC multi-component and removes struct snd_soc_socdev from DAPM core. All DAPM calls are now made on a card, codec or runtime PCM level basis rather than using snd_soc_socdev. Other notable multi-component changes:- * Stream operations now de-reference less structures. * close_delayed work() now runs on a DAI basis rather than looping all DAIs in a card. * PM suspend()/resume() operations can now handle N CODECs and Platforms per sound card. * Added soc_bind_dai_link() to bind the component devices to the sound card. * Added soc_dai_link_probe() and soc_dai_link_remove() to probe and remove DAI link components. * sysfs entries can now be registered per component per card. * snd_soc_new_pcms() functionailty rolled into dai_link_probe(). * snd_soc_register_codec() now does all the codec list and mutex init. This patch changes the probe() and remove() of the CODEC drivers as follows:- o Make CODEC driver a platform driver o Moved all struct snd_soc_codec list, mutex, etc initialiasation to core. o Removed all static codec pointers (drivers now support > 1 codec dev) o snd_soc_register_pcms() now done by core. o snd_soc_register_dai() folded into snd_soc_register_codec(). CS4270 portions: Acked-by: Timur Tabi <timur@freescale.com> Some TLV320aic23 and Cirrus platform fixes. Signed-off-by: Ryan Mallon <ryan@bluewatersys.com> TI CODEC and OMAP fixes Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Signed-off-by: Jarkko Nikula <jhnikula@gmail.com> Samsung platform and misc fixes :- Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Jassi Brar <jassi.brar@samsung.com> Signed-off-by: Seungwhan Youn <sw.youn@samsung.com> MPC8610 and PPC fixes. Signed-off-by: Timur Tabi <timur@freescale.com> i.MX fixes and some core fixes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> J4740 platform fixes:- Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> CC: Tony Lindgren <tony@atomide.com> CC: Nicolas Ferre <nicolas.ferre@atmel.com> CC: Kevin Hilman <khilman@deeprootsystems.com> CC: Sascha Hauer <s.hauer@pengutronix.de> CC: Atsushi Nemoto <anemo@mba.ocn.ne.jp> CC: Kuninori Morimoto <morimoto.kuninori@renesas.com> CC: Daniel Gloeckner <dg@emlix.com> CC: Manuel Lauss <mano@roarinelk.homelinux.net> CC: Mike Frysinger <vapier.adi@gmail.com> CC: Arnaud Patard <apatard@mandriva.com> CC: Wan ZongShun <mcuos.com@gmail.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc/codecs/cq93vc.c')
-rw-r--r--sound/soc/codecs/cq93vc.c132
1 files changed, 29 insertions, 103 deletions
diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c
index a320fb5a0e26..823643932dde 100644
--- a/sound/soc/codecs/cq93vc.c
+++ b/sound/soc/codecs/cq93vc.c
@@ -30,6 +30,7 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/clk.h> 31#include <linux/clk.h>
32#include <linux/mfd/davinci_voicecodec.h> 32#include <linux/mfd/davinci_voicecodec.h>
33#include <linux/spi/spi.h>
33 34
34#include <sound/core.h> 35#include <sound/core.h>
35#include <sound/pcm.h> 36#include <sound/pcm.h>
@@ -41,8 +42,6 @@
41 42
42#include <mach/dm365.h> 43#include <mach/dm365.h>
43 44
44#include "cq93vc.h"
45
46static inline unsigned int cq93vc_read(struct snd_soc_codec *codec, 45static inline unsigned int cq93vc_read(struct snd_soc_codec *codec,
47 unsigned int reg) 46 unsigned int reg)
48{ 47{
@@ -130,8 +129,8 @@ static struct snd_soc_dai_ops cq93vc_dai_ops = {
130 .set_sysclk = cq93vc_set_dai_sysclk, 129 .set_sysclk = cq93vc_set_dai_sysclk,
131}; 130};
132 131
133struct snd_soc_dai cq93vc_dai = { 132static struct snd_soc_dai_driver cq93vc_dai = {
134 .name = "CQ93VC", 133 .name = "cq93vc-hifi",
135 .playback = { 134 .playback = {
136 .stream_name = "Playback", 135 .stream_name = "Playback",
137 .channels_min = 1, 136 .channels_min = 1,
@@ -146,36 +145,20 @@ struct snd_soc_dai cq93vc_dai = {
146 .formats = CQ93VC_FORMATS,}, 145 .formats = CQ93VC_FORMATS,},
147 .ops = &cq93vc_dai_ops, 146 .ops = &cq93vc_dai_ops,
148}; 147};
149EXPORT_SYMBOL_GPL(cq93vc_dai);
150 148
151static int cq93vc_resume(struct platform_device *pdev) 149static int cq93vc_resume(struct snd_soc_codec *codec)
152{ 150{
153 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
154 struct snd_soc_codec *codec = socdev->card->codec;
155
156 cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 151 cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
157 152
158 return 0; 153 return 0;
159} 154}
160 155
161static struct snd_soc_codec *cq93vc_codec; 156static int cq93vc_probe(struct snd_soc_codec *codec)
162
163static int cq93vc_probe(struct platform_device *pdev)
164{ 157{
165 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 158 struct davinci_vc *davinci_vc = codec->dev->platform_data;
166 struct device *dev = &pdev->dev; 159
167 struct snd_soc_codec *codec; 160 davinci_vc->cq93vc.codec = codec;
168 int ret; 161 codec->control_data = davinci_vc;
169
170 socdev->card->codec = cq93vc_codec;
171 codec = socdev->card->codec;
172
173 /* Register pcms */
174 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
175 if (ret < 0) {
176 dev_err(dev, "%s: failed to create pcms\n", pdev->name);
177 return ret;
178 }
179 162
180 /* Set controls */ 163 /* Set controls */
181 snd_soc_add_controls(codec, cq93vc_snd_controls, 164 snd_soc_add_controls(codec, cq93vc_snd_controls,
@@ -187,108 +170,51 @@ static int cq93vc_probe(struct platform_device *pdev)
187 return 0; 170 return 0;
188} 171}
189 172
190static int cq93vc_remove(struct platform_device *pdev) 173static int cq93vc_remove(struct snd_soc_codec *codec)
191{ 174{
192 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 175 cq93vc_set_bias_level(codec, SND_SOC_BIAS_OFF);
193
194 snd_soc_free_pcms(socdev);
195 snd_soc_dapm_free(socdev);
196 176
197 return 0; 177 return 0;
198} 178}
199 179
200struct snd_soc_codec_device soc_codec_dev_cq93vc = { 180static struct snd_soc_codec_driver soc_codec_dev_cq93vc = {
181 .read = cq93vc_read,
182 .write = cq93vc_write,
183 .set_bias_level = cq93vc_set_bias_level,
201 .probe = cq93vc_probe, 184 .probe = cq93vc_probe,
202 .remove = cq93vc_remove, 185 .remove = cq93vc_remove,
203 .resume = cq93vc_resume, 186 .resume = cq93vc_resume,
204}; 187};
205EXPORT_SYMBOL_GPL(soc_codec_dev_cq93vc);
206 188
207static __init int cq93vc_codec_probe(struct platform_device *pdev) 189static int cq93vc_platform_probe(struct platform_device *pdev)
208{ 190{
209 struct davinci_vc *davinci_vc = platform_get_drvdata(pdev); 191 return snd_soc_register_codec(&pdev->dev,
210 struct snd_soc_codec *codec; 192 &soc_codec_dev_cq93vc, &cq93vc_dai, 1);
211 int ret;
212
213 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
214 if (codec == NULL) {
215 dev_dbg(davinci_vc->dev,
216 "could not allocate memory for codec data\n");
217 return -ENOMEM;
218 }
219
220 davinci_vc->cq93vc.codec = codec;
221
222 cq93vc_dai.dev = &pdev->dev;
223
224 mutex_init(&codec->mutex);
225 INIT_LIST_HEAD(&codec->dapm_widgets);
226 INIT_LIST_HEAD(&codec->dapm_paths);
227 codec->dev = &pdev->dev;
228 codec->name = "CQ93VC";
229 codec->owner = THIS_MODULE;
230 codec->read = cq93vc_read;
231 codec->write = cq93vc_write;
232 codec->set_bias_level = cq93vc_set_bias_level;
233 codec->dai = &cq93vc_dai;
234 codec->num_dai = 1;
235 codec->control_data = davinci_vc;
236
237 cq93vc_codec = codec;
238
239 ret = snd_soc_register_codec(codec);
240 if (ret) {
241 dev_err(davinci_vc->dev, "failed to register codec\n");
242 goto fail1;
243 }
244
245 ret = snd_soc_register_dai(&cq93vc_dai);
246 if (ret) {
247 dev_err(davinci_vc->dev, "could register dai\n");
248 goto fail2;
249 }
250 return 0;
251
252fail2:
253 snd_soc_unregister_codec(codec);
254
255fail1:
256 kfree(codec);
257 cq93vc_codec = NULL;
258
259 return ret;
260} 193}
261 194
262static int __devexit cq93vc_codec_remove(struct platform_device *pdev) 195static int cq93vc_platform_remove(struct platform_device *pdev)
263{ 196{
264 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 197 snd_soc_unregister_codec(&pdev->dev);
265 struct snd_soc_codec *codec = socdev->card->codec;
266
267 snd_soc_unregister_dai(&cq93vc_dai);
268 snd_soc_unregister_codec(&codec);
269
270 kfree(codec);
271 cq93vc_codec = NULL;
272
273 return 0; 198 return 0;
274} 199}
275 200
276static struct platform_driver cq93vc_codec_driver = { 201static struct platform_driver cq93vc_codec_driver = {
277 .driver = { 202 .driver = {
278 .name = "cq93vc", 203 .name = "cq93vc-codec",
279 .owner = THIS_MODULE, 204 .owner = THIS_MODULE,
280 }, 205 },
281 .probe = cq93vc_codec_probe, 206
282 .remove = __devexit_p(cq93vc_codec_remove), 207 .probe = cq93vc_platform_probe,
208 .remove = __devexit_p(cq93vc_platform_remove),
283}; 209};
284 210
285static __init int cq93vc_init(void) 211static int __init cq93vc_init(void)
286{ 212{
287 return platform_driver_probe(&cq93vc_codec_driver, cq93vc_codec_probe); 213 return platform_driver_register(&cq93vc_codec_driver);
288} 214}
289module_init(cq93vc_init); 215module_init(cq93vc_init);
290 216
291static __exit void cq93vc_exit(void) 217static void __exit cq93vc_exit(void)
292{ 218{
293 platform_driver_unregister(&cq93vc_codec_driver); 219 platform_driver_unregister(&cq93vc_codec_driver);
294} 220}