aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c110
1 files changed, 60 insertions, 50 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 07aa54385ae0..12b7ff2426da 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -292,6 +292,9 @@ static const struct file_operations codec_reg_fops = {
292 292
293static void soc_init_component_debugfs(struct snd_soc_component *component) 293static void soc_init_component_debugfs(struct snd_soc_component *component)
294{ 294{
295 if (!component->card->debugfs_card_root)
296 return;
297
295 if (component->debugfs_prefix) { 298 if (component->debugfs_prefix) {
296 char *name; 299 char *name;
297 300
@@ -455,6 +458,9 @@ static const struct file_operations platform_list_fops = {
455 458
456static void soc_init_card_debugfs(struct snd_soc_card *card) 459static void soc_init_card_debugfs(struct snd_soc_card *card)
457{ 460{
461 if (!snd_soc_debugfs_root)
462 return;
463
458 card->debugfs_card_root = debugfs_create_dir(card->name, 464 card->debugfs_card_root = debugfs_create_dir(card->name,
459 snd_soc_debugfs_root); 465 snd_soc_debugfs_root);
460 if (!card->debugfs_card_root) { 466 if (!card->debugfs_card_root) {
@@ -476,6 +482,34 @@ static void soc_cleanup_card_debugfs(struct snd_soc_card *card)
476 debugfs_remove_recursive(card->debugfs_card_root); 482 debugfs_remove_recursive(card->debugfs_card_root);
477} 483}
478 484
485
486static void snd_soc_debugfs_init(void)
487{
488 snd_soc_debugfs_root = debugfs_create_dir("asoc", NULL);
489 if (IS_ERR(snd_soc_debugfs_root) || !snd_soc_debugfs_root) {
490 pr_warn("ASoC: Failed to create debugfs directory\n");
491 snd_soc_debugfs_root = NULL;
492 return;
493 }
494
495 if (!debugfs_create_file("codecs", 0444, snd_soc_debugfs_root, NULL,
496 &codec_list_fops))
497 pr_warn("ASoC: Failed to create CODEC list debugfs file\n");
498
499 if (!debugfs_create_file("dais", 0444, snd_soc_debugfs_root, NULL,
500 &dai_list_fops))
501 pr_warn("ASoC: Failed to create DAI list debugfs file\n");
502
503 if (!debugfs_create_file("platforms", 0444, snd_soc_debugfs_root, NULL,
504 &platform_list_fops))
505 pr_warn("ASoC: Failed to create platform list debugfs file\n");
506}
507
508static void snd_soc_debugfs_exit(void)
509{
510 debugfs_remove_recursive(snd_soc_debugfs_root);
511}
512
479#else 513#else
480 514
481#define soc_init_codec_debugfs NULL 515#define soc_init_codec_debugfs NULL
@@ -497,6 +531,15 @@ static inline void soc_init_card_debugfs(struct snd_soc_card *card)
497static inline void soc_cleanup_card_debugfs(struct snd_soc_card *card) 531static inline void soc_cleanup_card_debugfs(struct snd_soc_card *card)
498{ 532{
499} 533}
534
535static inline void snd_soc_debugfs_init(void)
536{
537}
538
539static inline void snd_soc_debugfs_exit(void)
540{
541}
542
500#endif 543#endif
501 544
502struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, 545struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
@@ -595,15 +638,9 @@ int snd_soc_suspend(struct device *dev)
595 cpu_dai->driver->suspend(cpu_dai); 638 cpu_dai->driver->suspend(cpu_dai);
596 } 639 }
597 640
598 /* close any waiting streams and save state */ 641 /* close any waiting streams */
599 for (i = 0; i < card->num_rtd; i++) { 642 for (i = 0; i < card->num_rtd; i++)
600 struct snd_soc_dai **codec_dais = card->rtd[i].codec_dais;
601 flush_delayed_work(&card->rtd[i].delayed_work); 643 flush_delayed_work(&card->rtd[i].delayed_work);
602 for (j = 0; j < card->rtd[i].num_codecs; j++) {
603 codec_dais[j]->codec->dapm.suspend_bias_level =
604 codec_dais[j]->codec->dapm.bias_level;
605 }
606 }
607 644
608 for (i = 0; i < card->num_rtd; i++) { 645 for (i = 0; i < card->num_rtd; i++) {
609 646
@@ -1261,7 +1298,8 @@ static int soc_link_dai_widgets(struct snd_soc_card *card,
1261 capture_w = cpu_dai->capture_widget; 1298 capture_w = cpu_dai->capture_widget;
1262 if (play_w && capture_w) { 1299 if (play_w && capture_w) {
1263 ret = snd_soc_dapm_new_pcm(card, dai_link->params, 1300 ret = snd_soc_dapm_new_pcm(card, dai_link->params,
1264 capture_w, play_w); 1301 dai_link->num_params, capture_w,
1302 play_w);
1265 if (ret != 0) { 1303 if (ret != 0) {
1266 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", 1304 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
1267 play_w->name, capture_w->name, ret); 1305 play_w->name, capture_w->name, ret);
@@ -1273,7 +1311,8 @@ static int soc_link_dai_widgets(struct snd_soc_card *card,
1273 capture_w = codec_dai->capture_widget; 1311 capture_w = codec_dai->capture_widget;
1274 if (play_w && capture_w) { 1312 if (play_w && capture_w) {
1275 ret = snd_soc_dapm_new_pcm(card, dai_link->params, 1313 ret = snd_soc_dapm_new_pcm(card, dai_link->params,
1276 capture_w, play_w); 1314 dai_link->num_params, capture_w,
1315 play_w);
1277 if (ret != 0) { 1316 if (ret != 0) {
1278 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", 1317 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
1279 play_w->name, capture_w->name, ret); 1318 play_w->name, capture_w->name, ret);
@@ -1322,21 +1361,17 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
1322 } 1361 }
1323 } 1362 }
1324 1363
1364 if (dai_link->dai_fmt)
1365 snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
1366
1325 ret = soc_post_component_init(rtd, dai_link->name); 1367 ret = soc_post_component_init(rtd, dai_link->name);
1326 if (ret) 1368 if (ret)
1327 return ret; 1369 return ret;
1328 1370
1329#ifdef CONFIG_DEBUG_FS 1371#ifdef CONFIG_DEBUG_FS
1330 /* add DPCM sysfs entries */ 1372 /* add DPCM sysfs entries */
1331 if (dai_link->dynamic) { 1373 if (dai_link->dynamic)
1332 ret = soc_dpcm_debugfs_add(rtd); 1374 soc_dpcm_debugfs_add(rtd);
1333 if (ret < 0) {
1334 dev_err(rtd->dev,
1335 "ASoC: failed to add dpcm sysfs entries: %d\n",
1336 ret);
1337 return ret;
1338 }
1339 }
1340#endif 1375#endif
1341 1376
1342 if (cpu_dai->driver->compress_dai) { 1377 if (cpu_dai->driver->compress_dai) {
@@ -1426,7 +1461,6 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
1426 1461
1427 /* unregister the rtd device */ 1462 /* unregister the rtd device */
1428 if (rtd->dev_registered) { 1463 if (rtd->dev_registered) {
1429 device_remove_file(rtd->dev, &dev_attr_codec_reg);
1430 device_unregister(rtd->dev); 1464 device_unregister(rtd->dev);
1431 rtd->dev_registered = 0; 1465 rtd->dev_registered = 0;
1432 } 1466 }
@@ -1560,6 +1594,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1560 goto base_error; 1594 goto base_error;
1561 } 1595 }
1562 1596
1597 soc_init_card_debugfs(card);
1598
1563 card->dapm.bias_level = SND_SOC_BIAS_OFF; 1599 card->dapm.bias_level = SND_SOC_BIAS_OFF;
1564 card->dapm.dev = card->dev; 1600 card->dapm.dev = card->dev;
1565 card->dapm.card = card; 1601 card->dapm.card = card;
@@ -1641,12 +1677,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1641 snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes, 1677 snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes,
1642 card->num_of_dapm_routes); 1678 card->num_of_dapm_routes);
1643 1679
1644 for (i = 0; i < card->num_links; i++) {
1645 if (card->dai_link[i].dai_fmt)
1646 snd_soc_runtime_set_dai_fmt(&card->rtd[i],
1647 card->dai_link[i].dai_fmt);
1648 }
1649
1650 snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname), 1680 snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname),
1651 "%s", card->name); 1681 "%s", card->name);
1652 snprintf(card->snd_card->longname, sizeof(card->snd_card->longname), 1682 snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
@@ -1702,6 +1732,7 @@ card_probe_error:
1702 if (card->remove) 1732 if (card->remove)
1703 card->remove(card); 1733 card->remove(card);
1704 1734
1735 soc_cleanup_card_debugfs(card);
1705 snd_card_free(card->snd_card); 1736 snd_card_free(card->snd_card);
1706 1737
1707base_error: 1738base_error:
@@ -2380,8 +2411,6 @@ int snd_soc_register_card(struct snd_soc_card *card)
2380 2411
2381 snd_soc_initialize_card_lists(card); 2412 snd_soc_initialize_card_lists(card);
2382 2413
2383 soc_init_card_debugfs(card);
2384
2385 card->rtd = devm_kzalloc(card->dev, 2414 card->rtd = devm_kzalloc(card->dev,
2386 sizeof(struct snd_soc_pcm_runtime) * 2415 sizeof(struct snd_soc_pcm_runtime) *
2387 (card->num_links + card->num_aux_devs), 2416 (card->num_links + card->num_aux_devs),
@@ -2412,7 +2441,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
2412 2441
2413 ret = snd_soc_instantiate_card(card); 2442 ret = snd_soc_instantiate_card(card);
2414 if (ret != 0) 2443 if (ret != 0)
2415 soc_cleanup_card_debugfs(card); 2444 return ret;
2416 2445
2417 /* deactivate pins to sleep state */ 2446 /* deactivate pins to sleep state */
2418 for (i = 0; i < card->num_rtd; i++) { 2447 for (i = 0; i < card->num_rtd; i++) {
@@ -3595,26 +3624,7 @@ EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_link_codecs);
3595 3624
3596static int __init snd_soc_init(void) 3625static int __init snd_soc_init(void)
3597{ 3626{
3598#ifdef CONFIG_DEBUG_FS 3627 snd_soc_debugfs_init();
3599 snd_soc_debugfs_root = debugfs_create_dir("asoc", NULL);
3600 if (IS_ERR(snd_soc_debugfs_root) || !snd_soc_debugfs_root) {
3601 pr_warn("ASoC: Failed to create debugfs directory\n");
3602 snd_soc_debugfs_root = NULL;
3603 }
3604
3605 if (!debugfs_create_file("codecs", 0444, snd_soc_debugfs_root, NULL,
3606 &codec_list_fops))
3607 pr_warn("ASoC: Failed to create CODEC list debugfs file\n");
3608
3609 if (!debugfs_create_file("dais", 0444, snd_soc_debugfs_root, NULL,
3610 &dai_list_fops))
3611 pr_warn("ASoC: Failed to create DAI list debugfs file\n");
3612
3613 if (!debugfs_create_file("platforms", 0444, snd_soc_debugfs_root, NULL,
3614 &platform_list_fops))
3615 pr_warn("ASoC: Failed to create platform list debugfs file\n");
3616#endif
3617
3618 snd_soc_util_init(); 3628 snd_soc_util_init();
3619 3629
3620 return platform_driver_register(&soc_driver); 3630 return platform_driver_register(&soc_driver);
@@ -3624,9 +3634,9 @@ module_init(snd_soc_init);
3624static void __exit snd_soc_exit(void) 3634static void __exit snd_soc_exit(void)
3625{ 3635{
3626 snd_soc_util_exit(); 3636 snd_soc_util_exit();
3637 snd_soc_debugfs_exit();
3627 3638
3628#ifdef CONFIG_DEBUG_FS 3639#ifdef CONFIG_DEBUG_FS
3629 debugfs_remove_recursive(snd_soc_debugfs_root);
3630#endif 3640#endif
3631 platform_driver_unregister(&soc_driver); 3641 platform_driver_unregister(&soc_driver);
3632} 3642}