aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2008-12-03 12:34:03 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2008-12-03 13:27:04 -0500
commit384c89e2e4cb5879b86a38414d1b3bb2b23ec8ee (patch)
treee48d9a5fabe9399e26b42c66b5ace098c53a967f /sound
parent6f2a974bfc8d3be7a30674c71e2fef003b39a8d2 (diff)
ASoC: Push debugfs files out of the snd_soc_device structure
This is in preparation for the removal of struct snd_soc_device. The pop time configuration should really be a property of the card not the codec but since DAPM currently uses the codec rather than the card using the codec is fine for now. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/soc-core.c73
1 files changed, 41 insertions, 32 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fe89260c902..34114398b91 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -39,6 +39,10 @@ static DEFINE_MUTEX(pcm_mutex);
39static DEFINE_MUTEX(io_mutex); 39static DEFINE_MUTEX(io_mutex);
40static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq); 40static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq);
41 41
42#ifdef CONFIG_DEBUG_FS
43static struct dentry *debugfs_root;
44#endif
45
42/* 46/*
43 * This is a timeout to do a DAPM powerdown after a stream is closed(). 47 * This is a timeout to do a DAPM powerdown after a stream is closed().
44 * It can be used to eliminate pops between different playback streams, e.g. 48 * It can be used to eliminate pops between different playback streams, e.g.
@@ -1002,7 +1006,9 @@ static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf,
1002 size_t count, loff_t *ppos) 1006 size_t count, loff_t *ppos)
1003{ 1007{
1004 ssize_t ret; 1008 ssize_t ret;
1005 struct snd_soc_device *devdata = file->private_data; 1009 struct snd_soc_codec *codec = file->private_data;
1010 struct device *card_dev = codec->card->dev;
1011 struct snd_soc_device *devdata = card_dev->driver_data;
1006 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 1012 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
1007 if (!buf) 1013 if (!buf)
1008 return -ENOMEM; 1014 return -ENOMEM;
@@ -1021,8 +1027,7 @@ static ssize_t codec_reg_write_file(struct file *file,
1021 char *start = buf; 1027 char *start = buf;
1022 unsigned long reg, value; 1028 unsigned long reg, value;
1023 int step = 1; 1029 int step = 1;
1024 struct snd_soc_device *devdata = file->private_data; 1030 struct snd_soc_codec *codec = file->private_data;
1025 struct snd_soc_codec *codec = devdata->codec;
1026 1031
1027 buf_size = min(count, (sizeof(buf)-1)); 1032 buf_size = min(count, (sizeof(buf)-1));
1028 if (copy_from_user(buf, user_buf, buf_size)) 1033 if (copy_from_user(buf, user_buf, buf_size))
@@ -1051,44 +1056,36 @@ static const struct file_operations codec_reg_fops = {
1051 .write = codec_reg_write_file, 1056 .write = codec_reg_write_file,
1052}; 1057};
1053 1058
1054static void soc_init_debugfs(struct snd_soc_device *socdev) 1059static void soc_init_codec_debugfs(struct snd_soc_codec *codec)
1055{ 1060{
1056 struct dentry *root, *file; 1061 codec->debugfs_reg = debugfs_create_file("codec_reg", 0644,
1057 struct snd_soc_codec *codec = socdev->codec; 1062 debugfs_root, codec,
1058 root = debugfs_create_dir(dev_name(socdev->dev), NULL); 1063 &codec_reg_fops);
1059 if (IS_ERR(root) || !root) 1064 if (!codec->debugfs_reg)
1060 goto exit1; 1065 printk(KERN_WARNING
1061 1066 "ASoC: Failed to create codec register debugfs file\n");
1062 file = debugfs_create_file("codec_reg", 0644, 1067
1063 root, socdev, &codec_reg_fops); 1068 codec->debugfs_pop_time = debugfs_create_u32("dapm_pop_time", 0744,
1064 if (!file) 1069 debugfs_root,
1065 goto exit2; 1070 &codec->pop_time);
1066 1071 if (!codec->debugfs_pop_time)
1067 file = debugfs_create_u32("dapm_pop_time", 0744, 1072 printk(KERN_WARNING
1068 root, &codec->pop_time); 1073 "Failed to create pop time debugfs file\n");
1069 if (!file)
1070 goto exit2;
1071 socdev->debugfs_root = root;
1072 return;
1073exit2:
1074 debugfs_remove_recursive(root);
1075exit1:
1076 dev_err(socdev->dev, "debugfs is not available\n");
1077} 1074}
1078 1075
1079static void soc_cleanup_debugfs(struct snd_soc_device *socdev) 1076static void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec)
1080{ 1077{
1081 debugfs_remove_recursive(socdev->debugfs_root); 1078 debugfs_remove(codec->debugfs_pop_time);
1082 socdev->debugfs_root = NULL; 1079 debugfs_remove(codec->debugfs_reg);
1083} 1080}
1084 1081
1085#else 1082#else
1086 1083
1087static inline void soc_init_debugfs(struct snd_soc_device *socdev) 1084static inline void soc_init_codec_debugfs(struct snd_soc_codec *codec)
1088{ 1085{
1089} 1086}
1090 1087
1091static inline void soc_cleanup_debugfs(struct snd_soc_device *socdev) 1088static inline void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec)
1092{ 1089{
1093} 1090}
1094#endif 1091#endif
@@ -1305,7 +1302,7 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
1305 if (err < 0) 1302 if (err < 0)
1306 printk(KERN_WARNING "asoc: failed to add codec sysfs files\n"); 1303 printk(KERN_WARNING "asoc: failed to add codec sysfs files\n");
1307 1304
1308 soc_init_debugfs(socdev); 1305 soc_init_codec_debugfs(socdev->codec);
1309 mutex_unlock(&codec->mutex); 1306 mutex_unlock(&codec->mutex);
1310 1307
1311out: 1308out:
@@ -1329,7 +1326,7 @@ void snd_soc_free_pcms(struct snd_soc_device *socdev)
1329#endif 1326#endif
1330 1327
1331 mutex_lock(&codec->mutex); 1328 mutex_lock(&codec->mutex);
1332 soc_cleanup_debugfs(socdev); 1329 soc_cleanup_codec_debugfs(socdev->codec);
1333#ifdef CONFIG_SND_SOC_AC97_BUS 1330#ifdef CONFIG_SND_SOC_AC97_BUS
1334 for (i = 0; i < codec->num_dai; i++) { 1331 for (i = 0; i < codec->num_dai; i++) {
1335 codec_dai = &codec->dai[i]; 1332 codec_dai = &codec->dai[i];
@@ -1962,11 +1959,23 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute);
1962 1959
1963static int __devinit snd_soc_init(void) 1960static int __devinit snd_soc_init(void)
1964{ 1961{
1962#ifdef CONFIG_DEBUG_FS
1963 debugfs_root = debugfs_create_dir("asoc", NULL);
1964 if (IS_ERR(debugfs_root) || !debugfs_root) {
1965 printk(KERN_WARNING
1966 "ASoC: Failed to create debugfs directory\n");
1967 debugfs_root = NULL;
1968 }
1969#endif
1970
1965 return platform_driver_register(&soc_driver); 1971 return platform_driver_register(&soc_driver);
1966} 1972}
1967 1973
1968static void __exit snd_soc_exit(void) 1974static void __exit snd_soc_exit(void)
1969{ 1975{
1976#ifdef CONFIG_DEBUG_FS
1977 debugfs_remove_recursive(debugfs_root);
1978#endif
1970 platform_driver_unregister(&soc_driver); 1979 platform_driver_unregister(&soc_driver);
1971} 1980}
1972 1981