4 * Created on: 15-Oct-2009
5 * Author: neil.jones@imgtec.com
7 * Copyright (C) 2009 Imagination Technologies Ltd.
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/kernel.h>
18 #include <linux/device.h>
19 #include <sound/core.h>
20 #include <sound/pcm.h>
21 #include <sound/ac97_codec.h>
22 #include <sound/initval.h>
23 #include <sound/soc.h>
27 * Note this is a simple chip with no configuration interface, sample rate is
28 * determined automatically by examining the Master clock and Bit clock ratios
30 #define WM8727_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
31 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |\
32 SNDRV_PCM_RATE_192000)
35 struct snd_soc_dai wm8727_dai = {
38 .stream_name = "Playback",
41 .rates = WM8727_RATES,
42 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
45 EXPORT_SYMBOL_GPL(wm8727_dai);
47 static int wm8727_soc_probe(struct platform_device *pdev)
49 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
50 struct snd_soc_codec *codec;
53 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
56 mutex_init(&codec->mutex);
57 codec->name = "WM8727";
58 codec->owner = THIS_MODULE;
59 codec->dai = &wm8727_dai;
61 socdev->card->codec = codec;
62 INIT_LIST_HEAD(&codec->dapm_widgets);
63 INIT_LIST_HEAD(&codec->dapm_paths);
66 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
68 printk(KERN_ERR "wm8727: failed to create pcms\n");
75 kfree(socdev->card->codec);
76 socdev->card->codec = NULL;
80 static int wm8727_soc_remove(struct platform_device *pdev)
82 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
83 struct snd_soc_codec *codec = socdev->card->codec;
87 snd_soc_free_pcms(socdev);
92 struct snd_soc_codec_device soc_codec_dev_wm8727 = {
93 .probe = wm8727_soc_probe,
94 .remove = wm8727_soc_remove,
96 EXPORT_SYMBOL_GPL(soc_codec_dev_wm8727);
99 static __devinit int wm8727_platform_probe(struct platform_device *pdev)
101 wm8727_dai.dev = &pdev->dev;
102 return snd_soc_register_dai(&wm8727_dai);
105 static int __devexit wm8727_platform_remove(struct platform_device *pdev)
107 snd_soc_unregister_dai(&wm8727_dai);
111 static struct platform_driver wm8727_codec_driver = {
113 .name = "wm8727-codec",
114 .owner = THIS_MODULE,
117 .probe = wm8727_platform_probe,
118 .remove = __devexit_p(wm8727_platform_remove),
121 static int __init wm8727_init(void)
123 return platform_driver_register(&wm8727_codec_driver);
125 module_init(wm8727_init);
127 static void __exit wm8727_exit(void)
129 platform_driver_unregister(&wm8727_codec_driver);
131 module_exit(wm8727_exit);
133 MODULE_DESCRIPTION("ASoC wm8727 driver");
134 MODULE_AUTHOR("Neil Jones");
135 MODULE_LICENSE("GPL");