aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2009-01-23 17:55:23 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-01-27 05:30:54 -0500
commit6627a653bceb3a54e55e5cdc478ec5b8d5c9cc44 (patch)
tree9a6f157ad1123e4f047689bbf3c4ef88ec1259a4 /sound/soc/soc-core.c
parent0db4d0705260dd4bddf1e5a5441c58bdf08bdc9f (diff)
ASoC: Push the codec runtime storage into the card structure
This is a further stage on the road to refactoring away the ASoC platform device. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 8313d52a6e8c..f18c7a3e36d1 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -234,7 +234,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
234 cpu_dai->capture.active = codec_dai->capture.active = 1; 234 cpu_dai->capture.active = codec_dai->capture.active = 1;
235 cpu_dai->active = codec_dai->active = 1; 235 cpu_dai->active = codec_dai->active = 1;
236 cpu_dai->runtime = runtime; 236 cpu_dai->runtime = runtime;
237 socdev->codec->active++; 237 card->codec->active++;
238 mutex_unlock(&pcm_mutex); 238 mutex_unlock(&pcm_mutex);
239 return 0; 239 return 0;
240 240
@@ -264,7 +264,7 @@ static void close_delayed_work(struct work_struct *work)
264 struct snd_soc_card *card = container_of(work, struct snd_soc_card, 264 struct snd_soc_card *card = container_of(work, struct snd_soc_card,
265 delayed_work.work); 265 delayed_work.work);
266 struct snd_soc_device *socdev = card->socdev; 266 struct snd_soc_device *socdev = card->socdev;
267 struct snd_soc_codec *codec = socdev->codec; 267 struct snd_soc_codec *codec = card->codec;
268 struct snd_soc_dai *codec_dai; 268 struct snd_soc_dai *codec_dai;
269 int i; 269 int i;
270 270
@@ -319,7 +319,7 @@ static int soc_codec_close(struct snd_pcm_substream *substream)
319 struct snd_soc_platform *platform = card->platform; 319 struct snd_soc_platform *platform = card->platform;
320 struct snd_soc_dai *cpu_dai = machine->cpu_dai; 320 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
321 struct snd_soc_dai *codec_dai = machine->codec_dai; 321 struct snd_soc_dai *codec_dai = machine->codec_dai;
322 struct snd_soc_codec *codec = socdev->codec; 322 struct snd_soc_codec *codec = card->codec;
323 323
324 mutex_lock(&pcm_mutex); 324 mutex_lock(&pcm_mutex);
325 325
@@ -387,7 +387,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
387 struct snd_soc_platform *platform = card->platform; 387 struct snd_soc_platform *platform = card->platform;
388 struct snd_soc_dai *cpu_dai = machine->cpu_dai; 388 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
389 struct snd_soc_dai *codec_dai = machine->codec_dai; 389 struct snd_soc_dai *codec_dai = machine->codec_dai;
390 struct snd_soc_codec *codec = socdev->codec; 390 struct snd_soc_codec *codec = card->codec;
391 int ret = 0; 391 int ret = 0;
392 392
393 mutex_lock(&pcm_mutex); 393 mutex_lock(&pcm_mutex);
@@ -553,7 +553,7 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
553 struct snd_soc_platform *platform = card->platform; 553 struct snd_soc_platform *platform = card->platform;
554 struct snd_soc_dai *cpu_dai = machine->cpu_dai; 554 struct snd_soc_dai *cpu_dai = machine->cpu_dai;
555 struct snd_soc_dai *codec_dai = machine->codec_dai; 555 struct snd_soc_dai *codec_dai = machine->codec_dai;
556 struct snd_soc_codec *codec = socdev->codec; 556 struct snd_soc_codec *codec = card->codec;
557 557
558 mutex_lock(&pcm_mutex); 558 mutex_lock(&pcm_mutex);
559 559
@@ -629,7 +629,7 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state)
629 struct snd_soc_card *card = socdev->card; 629 struct snd_soc_card *card = socdev->card;
630 struct snd_soc_platform *platform = card->platform; 630 struct snd_soc_platform *platform = card->platform;
631 struct snd_soc_codec_device *codec_dev = socdev->codec_dev; 631 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
632 struct snd_soc_codec *codec = socdev->codec; 632 struct snd_soc_codec *codec = card->codec;
633 int i; 633 int i;
634 634
635 /* Due to the resume being scheduled into a workqueue we could 635 /* Due to the resume being scheduled into a workqueue we could
@@ -705,7 +705,7 @@ static void soc_resume_deferred(struct work_struct *work)
705 struct snd_soc_device *socdev = card->socdev; 705 struct snd_soc_device *socdev = card->socdev;
706 struct snd_soc_platform *platform = card->platform; 706 struct snd_soc_platform *platform = card->platform;
707 struct snd_soc_codec_device *codec_dev = socdev->codec_dev; 707 struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
708 struct snd_soc_codec *codec = socdev->codec; 708 struct snd_soc_codec *codec = card->codec;
709 struct platform_device *pdev = to_platform_device(socdev->dev); 709 struct platform_device *pdev = to_platform_device(socdev->dev);
710 int i; 710 int i;
711 711
@@ -982,8 +982,8 @@ static struct platform_driver soc_driver = {
982static int soc_new_pcm(struct snd_soc_device *socdev, 982static int soc_new_pcm(struct snd_soc_device *socdev,
983 struct snd_soc_dai_link *dai_link, int num) 983 struct snd_soc_dai_link *dai_link, int num)
984{ 984{
985 struct snd_soc_codec *codec = socdev->codec;
986 struct snd_soc_card *card = socdev->card; 985 struct snd_soc_card *card = socdev->card;
986 struct snd_soc_codec *codec = card->codec;
987 struct snd_soc_platform *platform = card->platform; 987 struct snd_soc_platform *platform = card->platform;
988 struct snd_soc_dai *codec_dai = dai_link->codec_dai; 988 struct snd_soc_dai *codec_dai = dai_link->codec_dai;
989 struct snd_soc_dai *cpu_dai = dai_link->cpu_dai; 989 struct snd_soc_dai *cpu_dai = dai_link->cpu_dai;
@@ -998,7 +998,7 @@ static int soc_new_pcm(struct snd_soc_device *socdev,
998 998
999 rtd->dai = dai_link; 999 rtd->dai = dai_link;
1000 rtd->socdev = socdev; 1000 rtd->socdev = socdev;
1001 codec_dai->codec = socdev->codec; 1001 codec_dai->codec = card->codec;
1002 1002
1003 /* check client and interface hw capabilities */ 1003 /* check client and interface hw capabilities */
1004 sprintf(new_name, "%s %s-%d", dai_link->stream_name, codec_dai->name, 1004 sprintf(new_name, "%s %s-%d", dai_link->stream_name, codec_dai->name,
@@ -1048,9 +1048,8 @@ static int soc_new_pcm(struct snd_soc_device *socdev,
1048} 1048}
1049 1049
1050/* codec register dump */ 1050/* codec register dump */
1051static ssize_t soc_codec_reg_show(struct snd_soc_device *devdata, char *buf) 1051static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)
1052{ 1052{
1053 struct snd_soc_codec *codec = devdata->codec;
1054 int i, step = 1, count = 0; 1053 int i, step = 1, count = 0;
1055 1054
1056 if (!codec->reg_cache_size) 1055 if (!codec->reg_cache_size)
@@ -1090,7 +1089,7 @@ static ssize_t codec_reg_show(struct device *dev,
1090 struct device_attribute *attr, char *buf) 1089 struct device_attribute *attr, char *buf)
1091{ 1090{
1092 struct snd_soc_device *devdata = dev_get_drvdata(dev); 1091 struct snd_soc_device *devdata = dev_get_drvdata(dev);
1093 return soc_codec_reg_show(devdata, buf); 1092 return soc_codec_reg_show(devdata->card->codec, buf);
1094} 1093}
1095 1094
1096static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL); 1095static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
@@ -1107,12 +1106,10 @@ static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf,
1107{ 1106{
1108 ssize_t ret; 1107 ssize_t ret;
1109 struct snd_soc_codec *codec = file->private_data; 1108 struct snd_soc_codec *codec = file->private_data;
1110 struct device *card_dev = codec->card->dev;
1111 struct snd_soc_device *devdata = card_dev->driver_data;
1112 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 1109 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
1113 if (!buf) 1110 if (!buf)
1114 return -ENOMEM; 1111 return -ENOMEM;
1115 ret = soc_codec_reg_show(devdata, buf); 1112 ret = soc_codec_reg_show(codec, buf);
1116 if (ret >= 0) 1113 if (ret >= 0)
1117 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); 1114 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
1118 kfree(buf); 1115 kfree(buf);
@@ -1309,8 +1306,8 @@ EXPORT_SYMBOL_GPL(snd_soc_test_bits);
1309 */ 1306 */
1310int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid) 1307int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
1311{ 1308{
1312 struct snd_soc_codec *codec = socdev->codec;
1313 struct snd_soc_card *card = socdev->card; 1309 struct snd_soc_card *card = socdev->card;
1310 struct snd_soc_codec *codec = card->codec;
1314 int ret = 0, i; 1311 int ret = 0, i;
1315 1312
1316 mutex_lock(&codec->mutex); 1313 mutex_lock(&codec->mutex);
@@ -1355,8 +1352,8 @@ EXPORT_SYMBOL_GPL(snd_soc_new_pcms);
1355 */ 1352 */
1356int snd_soc_init_card(struct snd_soc_device *socdev) 1353int snd_soc_init_card(struct snd_soc_device *socdev)
1357{ 1354{
1358 struct snd_soc_codec *codec = socdev->codec;
1359 struct snd_soc_card *card = socdev->card; 1355 struct snd_soc_card *card = socdev->card;
1356 struct snd_soc_codec *codec = card->codec;
1360 int ret = 0, i, ac97 = 0, err = 0; 1357 int ret = 0, i, ac97 = 0, err = 0;
1361 1358
1362 for (i = 0; i < card->num_links; i++) { 1359 for (i = 0; i < card->num_links; i++) {
@@ -1404,7 +1401,7 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
1404 if (err < 0) 1401 if (err < 0)
1405 printk(KERN_WARNING "asoc: failed to add codec sysfs files\n"); 1402 printk(KERN_WARNING "asoc: failed to add codec sysfs files\n");
1406 1403
1407 soc_init_codec_debugfs(socdev->codec); 1404 soc_init_codec_debugfs(codec);
1408 mutex_unlock(&codec->mutex); 1405 mutex_unlock(&codec->mutex);
1409 1406
1410out: 1407out:
@@ -1421,14 +1418,14 @@ EXPORT_SYMBOL_GPL(snd_soc_init_card);
1421 */ 1418 */
1422void snd_soc_free_pcms(struct snd_soc_device *socdev) 1419void snd_soc_free_pcms(struct snd_soc_device *socdev)
1423{ 1420{
1424 struct snd_soc_codec *codec = socdev->codec; 1421 struct snd_soc_codec *codec = socdev->card->codec;
1425#ifdef CONFIG_SND_SOC_AC97_BUS 1422#ifdef CONFIG_SND_SOC_AC97_BUS
1426 struct snd_soc_dai *codec_dai; 1423 struct snd_soc_dai *codec_dai;
1427 int i; 1424 int i;
1428#endif 1425#endif
1429 1426
1430 mutex_lock(&codec->mutex); 1427 mutex_lock(&codec->mutex);
1431 soc_cleanup_codec_debugfs(socdev->codec); 1428 soc_cleanup_codec_debugfs(codec);
1432#ifdef CONFIG_SND_SOC_AC97_BUS 1429#ifdef CONFIG_SND_SOC_AC97_BUS
1433 for (i = 0; i < codec->num_dai; i++) { 1430 for (i = 0; i < codec->num_dai; i++) {
1434 codec_dai = &codec->dai[i]; 1431 codec_dai = &codec->dai[i];