]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - sound/soc/au1x/db1200.c
ASoC: au1x: Add .owner to struct snd_soc_card
[mirror_ubuntu-jammy-kernel.git] / sound / soc / au1x / db1200.c
1 /*
2 * DB1200 ASoC audio fabric support code.
3 *
4 * (c) 2008-2011 Manuel Lauss <manuel.lauss@googlemail.com>
5 *
6 */
7
8 #include <linux/module.h>
9 #include <linux/moduleparam.h>
10 #include <linux/timer.h>
11 #include <linux/interrupt.h>
12 #include <linux/platform_device.h>
13 #include <sound/core.h>
14 #include <sound/pcm.h>
15 #include <sound/soc.h>
16 #include <asm/mach-au1x00/au1000.h>
17 #include <asm/mach-au1x00/au1xxx_psc.h>
18 #include <asm/mach-au1x00/au1xxx_dbdma.h>
19 #include <asm/mach-db1x00/bcsr.h>
20
21 #include "../codecs/wm8731.h"
22 #include "psc.h"
23
24 static struct platform_device_id db1200_pids[] = {
25 {
26 .name = "db1200-ac97",
27 .driver_data = 0,
28 }, {
29 .name = "db1200-i2s",
30 .driver_data = 1,
31 },
32 {},
33 };
34
35 /*------------------------- AC97 PART ---------------------------*/
36
37 static struct snd_soc_dai_link db1200_ac97_dai = {
38 .name = "AC97",
39 .stream_name = "AC97 HiFi",
40 .codec_dai_name = "ac97-hifi",
41 .cpu_dai_name = "au1xpsc_ac97.1",
42 .platform_name = "au1xpsc-pcm.1",
43 .codec_name = "ac97-codec.1",
44 };
45
46 static struct snd_soc_card db1200_ac97_machine = {
47 .name = "DB1200_AC97",
48 .owner = THIS_MODULE,
49 .dai_link = &db1200_ac97_dai,
50 .num_links = 1,
51 };
52
53 /*------------------------- I2S PART ---------------------------*/
54
55 static int db1200_i2s_startup(struct snd_pcm_substream *substream)
56 {
57 struct snd_soc_pcm_runtime *rtd = substream->private_data;
58 struct snd_soc_dai *codec_dai = rtd->codec_dai;
59 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
60 int ret;
61
62 /* WM8731 has its own 12MHz crystal */
63 snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK_XTAL,
64 12000000, SND_SOC_CLOCK_IN);
65
66 /* codec is bitclock and lrclk master */
67 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J |
68 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
69 if (ret < 0)
70 goto out;
71
72 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J |
73 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
74 if (ret < 0)
75 goto out;
76
77 ret = 0;
78 out:
79 return ret;
80 }
81
82 static struct snd_soc_ops db1200_i2s_wm8731_ops = {
83 .startup = db1200_i2s_startup,
84 };
85
86 static struct snd_soc_dai_link db1200_i2s_dai = {
87 .name = "WM8731",
88 .stream_name = "WM8731 PCM",
89 .codec_dai_name = "wm8731-hifi",
90 .cpu_dai_name = "au1xpsc_i2s.1",
91 .platform_name = "au1xpsc-pcm.1",
92 .codec_name = "wm8731.0-001b",
93 .ops = &db1200_i2s_wm8731_ops,
94 };
95
96 static struct snd_soc_card db1200_i2s_machine = {
97 .name = "DB1200_I2S",
98 .owner = THIS_MODULE,
99 .dai_link = &db1200_i2s_dai,
100 .num_links = 1,
101 };
102
103 /*------------------------- COMMON PART ---------------------------*/
104
105 static struct snd_soc_card *db1200_cards[] __devinitdata = {
106 &db1200_ac97_machine,
107 &db1200_i2s_machine,
108 };
109
110 static int __devinit db1200_audio_probe(struct platform_device *pdev)
111 {
112 const struct platform_device_id *pid = platform_get_device_id(pdev);
113 struct snd_soc_card *card;
114
115 card = db1200_cards[pid->driver_data];
116 card->dev = &pdev->dev;
117 return snd_soc_register_card(card);
118 }
119
120 static int __devexit db1200_audio_remove(struct platform_device *pdev)
121 {
122 struct snd_soc_card *card = platform_get_drvdata(pdev);
123 snd_soc_unregister_card(card);
124 return 0;
125 }
126
127 static struct platform_driver db1200_audio_driver = {
128 .driver = {
129 .name = "db1200-ac97",
130 .owner = THIS_MODULE,
131 .pm = &snd_soc_pm_ops,
132 },
133 .id_table = db1200_pids,
134 .probe = db1200_audio_probe,
135 .remove = __devexit_p(db1200_audio_remove),
136 };
137
138 module_platform_driver(db1200_audio_driver);
139
140 MODULE_LICENSE("GPL");
141 MODULE_DESCRIPTION("DB1200 ASoC audio support");
142 MODULE_AUTHOR("Manuel Lauss");