diff options
author | Julian Scheel <julian@jusst.de> | 2015-06-12 09:57:32 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-06-12 12:16:57 -0400 |
commit | ef5294fd250adc8c340ffeb410b62e1b777ddf6f (patch) | |
tree | e03b77e9163d9c9995d62babf4edea8d90a54e1a /sound | |
parent | b787f68c36d49bb1d9236f403813641efa74a031 (diff) |
ASoC: wm8523: Set bclk ratio for master mode
When running in master mode the bclk divider must be configured to generate a
sane bitclock. Pick the smallest fs multiplicator, which can hold all
transmitted bits.
Signed-off-by: Julian Scheel <julian@jusst.de>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/wm8523.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c index b1cc94f5fc4b..f9dffd2d5eea 100644 --- a/sound/soc/codecs/wm8523.c +++ b/sound/soc/codecs/wm8523.c | |||
@@ -113,6 +113,15 @@ static struct { | |||
113 | { 7, 1152 }, | 113 | { 7, 1152 }, |
114 | }; | 114 | }; |
115 | 115 | ||
116 | static struct { | ||
117 | int value; | ||
118 | int ratio; | ||
119 | } bclk_ratios[WM8523_NUM_RATES] = { | ||
120 | { 2, 32 }, | ||
121 | { 3, 64 }, | ||
122 | { 4, 128 }, | ||
123 | }; | ||
124 | |||
116 | static int wm8523_startup(struct snd_pcm_substream *substream, | 125 | static int wm8523_startup(struct snd_pcm_substream *substream, |
117 | struct snd_soc_dai *dai) | 126 | struct snd_soc_dai *dai) |
118 | { | 127 | { |
@@ -162,6 +171,23 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, | |||
162 | aifctrl2 &= ~WM8523_SR_MASK; | 171 | aifctrl2 &= ~WM8523_SR_MASK; |
163 | aifctrl2 |= lrclk_ratios[i].value; | 172 | aifctrl2 |= lrclk_ratios[i].value; |
164 | 173 | ||
174 | if (aifctrl1 & WM8523_AIF_MSTR) { | ||
175 | /* Find a fs->bclk ratio */ | ||
176 | for (i = 0; i < ARRAY_SIZE(bclk_ratios); i++) | ||
177 | if (params_width(params) * 2 <= bclk_ratios[i].ratio) | ||
178 | break; | ||
179 | |||
180 | if (i == ARRAY_SIZE(bclk_ratios)) { | ||
181 | dev_err(codec->dev, | ||
182 | "No matching BCLK/fs ratio for word length %d\n", | ||
183 | params_width(params)); | ||
184 | return -EINVAL; | ||
185 | } | ||
186 | |||
187 | aifctrl2 &= ~WM8523_BCLKDIV_MASK; | ||
188 | aifctrl2 |= bclk_ratios[i].value << WM8523_BCLKDIV_SHIFT; | ||
189 | } | ||
190 | |||
165 | aifctrl1 &= ~WM8523_WL_MASK; | 191 | aifctrl1 &= ~WM8523_WL_MASK; |
166 | switch (params_width(params)) { | 192 | switch (params_width(params)) { |
167 | case 16: | 193 | case 16: |