All of lore.kernel.org
 help / color / mirror / Atom feed
* Dynamically registering a codec
@ 2009-05-13 19:18 Jon Smirl
  2009-05-13 22:44 ` Mark Brown
  0 siblings, 1 reply; 12+ messages in thread
From: Jon Smirl @ 2009-05-13 19:18 UTC (permalink / raw)
  To: alsa-devel mailing list, Mark Brown

On PowerPC the device tree is used to dynamically load the correct
codec module. How am I supposed to get this dynamically loaded module
registered? The WM8580 codec registers itself.

Modifying the WM9712 codec to register itself on device load works for
me. If I don't do this how am I supposed to dynamically find the DAI
pointer so that I can call snd_soc_register_dais()?

diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index 550c903..cb0e679 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -20,6 +20,7 @@
 #include <sound/initval.h>
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
+#include <sound/soc-of-simple.h>
 #include "wm9712.h"

 #define WM9712_VERSION "0.4"
@@ -740,6 +741,39 @@ struct snd_soc_codec_device soc_codec_dev_wm9712 = {
 };
 EXPORT_SYMBOL_GPL(soc_codec_dev_wm9712);

+static int __init wm9712_probe(struct platform_device *pdev)
+{
+	snd_soc_register_dais(wm9712_dai, ARRAY_SIZE(wm9712_dai));
+#if defined(CONFIG_SND_SOC_OF_SIMPLE)
+	/* Tell the of_soc helper about this codec */
+	of_snd_soc_register_codec(&soc_codec_dev_wm9712, pdev->dev.archdata.of_node,
+									wm9712_dai, ARRAY_SIZE(wm9712_dai),
+									pdev->dev.archdata.of_node);
+#endif
+	return 0;
+}
+
+static struct platform_driver wm9712_driver =
+{
+	.probe = wm9712_probe,
+	.driver = {
+			.name = "wm9712",
+	},
+};
+
+static __init int wm9712_driver_init(void)
+{
+	return platform_driver_register(&wm9712_driver);
+}
+
+static __exit void wm9712_driver_exit(void)
+{
+}
+
+module_init(wm9712_driver_init);
+module_exit(wm9712_driver_exit);
+
+
 MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver");
 MODULE_AUTHOR("Liam Girdwood");
 MODULE_LICENSE("GPL");

-- 
Jon Smirl
jonsmirl@gmail.com

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-05-14 19:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-13 19:18 Dynamically registering a codec Jon Smirl
2009-05-13 22:44 ` Mark Brown
2009-05-14 15:44   ` Jon Smirl
2009-05-14 16:15     ` Mark Brown
2009-05-14 16:43       ` Jon Smirl
2009-05-14 17:40         ` Mark Brown
2009-05-14 17:57           ` Jon Smirl
2009-05-14 18:15             ` Jon Smirl
2009-05-14 18:49               ` Mark Brown
2009-05-14 18:38             ` Mark Brown
2009-05-14 18:56               ` Jon Smirl
2009-05-14 19:13                 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.