diff options
author | Liam Girdwood <lg@opensource.wolfsonmicro.com> | 2006-10-19 14:35:56 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2007-02-09 03:01:07 -0500 |
commit | a71a468a50f1385855e28864e26251b02df829bb (patch) | |
tree | 243daee96ea5c55c88a186aa03b7917f7ad533f6 /sound/soc/codecs | |
parent | 543a0fbe18d0b44f3d037fe6b59458fa0c0d5e4b (diff) |
[ALSA] ASoC: Add support for BCLK based on (Rate * Chn * Word Size)
This patch adds support for the DAI BCLK to be generated by multiplying
Rate * Channels * Word Size (RCW).
This now gives 3 options for BCLK clocking and synchronisation :-
1. BCLK = Rate * x
2. BCLK = MCLK / x
3. BCLK = Rate * Chn * Word Size. (New)
Changes:-
o Add support for RCW generation of BCLK
o Update Documentation to include RCW.
o Update DAI documentation for label = value DAI modes.
o Add RCW support to wm8731, wm8750 and pxa2xx-i2s drivers.
Signed-off-by: Liam Girdwood <lg@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r-- | sound/soc/codecs/wm8731.c | 33 | ||||
-rw-r--r-- | sound/soc/codecs/wm8750.c | 15 |
2 files changed, 27 insertions, 21 deletions
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 9adbd2d401c4..412291241ece 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c | |||
@@ -90,32 +90,36 @@ static struct snd_soc_dai_mode wm8731_modes[] = { | |||
90 | .pcmfmt = WM8731_HIFI_BITS, | 90 | .pcmfmt = WM8731_HIFI_BITS, |
91 | .pcmrate = SNDRV_PCM_RATE_8000, | 91 | .pcmrate = SNDRV_PCM_RATE_8000, |
92 | .pcmdir = WM8731_DIR, | 92 | .pcmdir = WM8731_DIR, |
93 | .flags = SND_SOC_DAI_BFS_RATE, | ||
93 | .fs = 1536, | 94 | .fs = 1536, |
94 | .bfs = SND_SOC_FSB(64), | 95 | .bfs = 64, |
95 | }, | 96 | }, |
96 | { | 97 | { |
97 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, | 98 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, |
98 | .pcmfmt = WM8731_HIFI_BITS, | 99 | .pcmfmt = WM8731_HIFI_BITS, |
99 | .pcmrate = SNDRV_PCM_RATE_8000, | 100 | .pcmrate = SNDRV_PCM_RATE_8000, |
100 | .pcmdir = WM8731_DIR, | 101 | .pcmdir = WM8731_DIR, |
102 | .flags = SND_SOC_DAI_BFS_RATE, | ||
101 | .fs = 2304, | 103 | .fs = 2304, |
102 | .bfs = SND_SOC_FSB(64), | 104 | .bfs = 64, |
103 | }, | 105 | }, |
104 | { | 106 | { |
105 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, | 107 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, |
106 | .pcmfmt = WM8731_HIFI_BITS, | 108 | .pcmfmt = WM8731_HIFI_BITS, |
107 | .pcmrate = SNDRV_PCM_RATE_8000, | 109 | .pcmrate = SNDRV_PCM_RATE_8000, |
108 | .pcmdir = WM8731_DIR, | 110 | .pcmdir = WM8731_DIR, |
111 | .flags = SND_SOC_DAI_BFS_RATE, | ||
109 | .fs = 1408, | 112 | .fs = 1408, |
110 | .bfs = SND_SOC_FSB(64), | 113 | .bfs = 64, |
111 | }, | 114 | }, |
112 | { | 115 | { |
113 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, | 116 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, |
114 | .pcmfmt = WM8731_HIFI_BITS, | 117 | .pcmfmt = WM8731_HIFI_BITS, |
115 | .pcmrate = SNDRV_PCM_RATE_8000, | 118 | .pcmrate = SNDRV_PCM_RATE_8000, |
116 | .pcmdir = WM8731_DIR, | 119 | .pcmdir = WM8731_DIR, |
120 | .flags = SND_SOC_DAI_BFS_RATE, | ||
117 | .fs = 2112, | 121 | .fs = 2112, |
118 | .bfs = SND_SOC_FSB(64), | 122 | .bfs = 64, |
119 | }, | 123 | }, |
120 | 124 | ||
121 | /* 32k */ | 125 | /* 32k */ |
@@ -124,16 +128,18 @@ static struct snd_soc_dai_mode wm8731_modes[] = { | |||
124 | .pcmfmt = WM8731_HIFI_BITS, | 128 | .pcmfmt = WM8731_HIFI_BITS, |
125 | .pcmrate = SNDRV_PCM_RATE_32000, | 129 | .pcmrate = SNDRV_PCM_RATE_32000, |
126 | .pcmdir = WM8731_DIR, | 130 | .pcmdir = WM8731_DIR, |
131 | .flags = SND_SOC_DAI_BFS_RATE, | ||
127 | .fs = 384, | 132 | .fs = 384, |
128 | .bfs = SND_SOC_FSB(64), | 133 | .bfs = 64, |
129 | }, | 134 | }, |
130 | { | 135 | { |
131 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, | 136 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, |
132 | .pcmfmt = WM8731_HIFI_BITS, | 137 | .pcmfmt = WM8731_HIFI_BITS, |
133 | .pcmrate = SNDRV_PCM_RATE_32000, | 138 | .pcmrate = SNDRV_PCM_RATE_32000, |
134 | .pcmdir = WM8731_DIR, | 139 | .pcmdir = WM8731_DIR, |
140 | .flags = SND_SOC_DAI_BFS_RATE, | ||
135 | .fs = 576, | 141 | .fs = 576, |
136 | .bfs = SND_SOC_FSB(64), | 142 | .bfs = 64, |
137 | }, | 143 | }, |
138 | 144 | ||
139 | /* 44.1k & 48k */ | 145 | /* 44.1k & 48k */ |
@@ -142,16 +148,18 @@ static struct snd_soc_dai_mode wm8731_modes[] = { | |||
142 | .pcmfmt = WM8731_HIFI_BITS, | 148 | .pcmfmt = WM8731_HIFI_BITS, |
143 | .pcmrate = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, | 149 | .pcmrate = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, |
144 | .pcmdir = WM8731_DIR, | 150 | .pcmdir = WM8731_DIR, |
151 | .flags = SND_SOC_DAI_BFS_RATE, | ||
145 | .fs = 256, | 152 | .fs = 256, |
146 | .bfs = SND_SOC_FSB(64), | 153 | .bfs = 64, |
147 | }, | 154 | }, |
148 | { | 155 | { |
149 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, | 156 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, |
150 | .pcmfmt = WM8731_HIFI_BITS, | 157 | .pcmfmt = WM8731_HIFI_BITS, |
151 | .pcmrate = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, | 158 | .pcmrate = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, |
152 | .pcmdir = WM8731_DIR, | 159 | .pcmdir = WM8731_DIR, |
160 | .flags = SND_SOC_DAI_BFS_RATE, | ||
153 | .fs = 384, | 161 | .fs = 384, |
154 | .bfs = SND_SOC_FSB(64), | 162 | .bfs = 64, |
155 | }, | 163 | }, |
156 | 164 | ||
157 | /* 88.2 & 96k */ | 165 | /* 88.2 & 96k */ |
@@ -160,17 +168,18 @@ static struct snd_soc_dai_mode wm8731_modes[] = { | |||
160 | .pcmfmt = WM8731_HIFI_BITS, | 168 | .pcmfmt = WM8731_HIFI_BITS, |
161 | .pcmrate = SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000, | 169 | .pcmrate = SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000, |
162 | .pcmdir = WM8731_DIR, | 170 | .pcmdir = WM8731_DIR, |
171 | .flags = SND_SOC_DAI_BFS_RATE, | ||
163 | .fs = 128, | 172 | .fs = 128, |
164 | .bfs = SND_SOC_FSB(64), | 173 | .bfs = 64, |
165 | |||
166 | }, | 174 | }, |
167 | { | 175 | { |
168 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, | 176 | .fmt = WM8731_DAIFMT | SND_SOC_DAIFMT_CBM_CFM, |
169 | .pcmfmt = WM8731_HIFI_BITS, | 177 | .pcmfmt = WM8731_HIFI_BITS, |
170 | .pcmrate = SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000, | 178 | .pcmrate = SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000, |
171 | .pcmdir = WM8731_DIR, | 179 | .pcmdir = WM8731_DIR, |
180 | .flags = SND_SOC_DAI_BFS_RATE, | ||
172 | .fs = 192, | 181 | .fs = 192, |
173 | .bfs = SND_SOC_FSB(64), | 182 | .bfs = 64, |
174 | }, | 183 | }, |
175 | 184 | ||
176 | /* USB codec frame and clock master modes */ | 185 | /* USB codec frame and clock master modes */ |
@@ -237,7 +246,7 @@ static struct snd_soc_dai_mode wm8731_modes[] = { | |||
237 | .pcmdir = WM8731_DIR, | 246 | .pcmdir = WM8731_DIR, |
238 | .flags = SND_SOC_DAI_BFS_DIV, | 247 | .flags = SND_SOC_DAI_BFS_DIV, |
239 | .fs = SND_SOC_FS_ALL, | 248 | .fs = SND_SOC_FS_ALL, |
240 | .bfs = SND_SOC_FSBD_ALL, | 249 | .bfs = SND_SOC_FSB_ALL, |
241 | }, | 250 | }, |
242 | }; | 251 | }; |
243 | 252 | ||
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 243da712d9c1..c5d13a9454d9 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c | |||
@@ -343,7 +343,7 @@ static struct snd_soc_dai_mode wm8750_modes[] = { | |||
343 | .pcmdir = WM8750_DIR, | 343 | .pcmdir = WM8750_DIR, |
344 | .flags = SND_SOC_DAI_BFS_DIV, | 344 | .flags = SND_SOC_DAI_BFS_DIV, |
345 | .fs = SND_SOC_FS_ALL, | 345 | .fs = SND_SOC_FS_ALL, |
346 | .bfs = SND_SOC_FSBD_ALL, | 346 | .bfs = SND_SOC_FSB_ALL, |
347 | }, | 347 | }, |
348 | }; | 348 | }; |
349 | 349 | ||
@@ -829,6 +829,9 @@ static inline int get_coeff(int mclk, int rate) | |||
829 | if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk) | 829 | if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk) |
830 | return i; | 830 | return i; |
831 | } | 831 | } |
832 | |||
833 | printk(KERN_ERR "wm8750: could not get coeff for mclk %d @ rate %d\n", | ||
834 | mclk, rate); | ||
832 | return -EINVAL; | 835 | return -EINVAL; |
833 | } | 836 | } |
834 | 837 | ||
@@ -836,13 +839,7 @@ static inline int get_coeff(int mclk, int rate) | |||
836 | static unsigned int wm8750_config_sysclk(struct snd_soc_codec_dai *dai, | 839 | static unsigned int wm8750_config_sysclk(struct snd_soc_codec_dai *dai, |
837 | struct snd_soc_clock_info *info, unsigned int clk) | 840 | struct snd_soc_clock_info *info, unsigned int clk) |
838 | { | 841 | { |
839 | dai->mclk = 0; | 842 | dai->mclk = clk; |
840 | |||
841 | /* check that the calculated FS and rate actually match a clock from | ||
842 | * the machine driver */ | ||
843 | if (info->fs * info->rate == clk) | ||
844 | dai->mclk = clk; | ||
845 | |||
846 | return dai->mclk; | 843 | return dai->mclk; |
847 | } | 844 | } |
848 | 845 | ||
@@ -859,7 +856,7 @@ static int wm8750_pcm_prepare(struct snd_pcm_substream *substream) | |||
859 | if (i < 0) | 856 | if (i < 0) |
860 | return i; | 857 | return i; |
861 | 858 | ||
862 | bfs = SND_SOC_FSB_REAL(rtd->codec_dai->dai_runtime.bfs); | 859 | bfs = SND_SOC_FSBD_REAL(rtd->codec_dai->dai_runtime.bfs); |
863 | 860 | ||
864 | /* set master/slave audio interface */ | 861 | /* set master/slave audio interface */ |
865 | switch (rtd->codec_dai->dai_runtime.fmt & SND_SOC_DAIFMT_CLOCK_MASK) { | 862 | switch (rtd->codec_dai->dai_runtime.fmt & SND_SOC_DAIFMT_CLOCK_MASK) { |