wm8523.c (cf0dbba515415bb19b11f9323d5f7bebd7f24fd6) wm8523.c (b2c812e22de88bb79c290c0e718280f10b64a48d)
1/*
2 * wm8523.c -- WM8523 ALSA SoC Audio driver
3 *
4 * Copyright 2009 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 *

--- 5 unchanged lines hidden (view full) ---

14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/pm.h>
19#include <linux/i2c.h>
20#include <linux/platform_device.h>
21#include <linux/regulator/consumer.h>
1/*
2 * wm8523.c -- WM8523 ALSA SoC Audio driver
3 *
4 * Copyright 2009 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 *

--- 5 unchanged lines hidden (view full) ---

14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/pm.h>
19#include <linux/i2c.h>
20#include <linux/platform_device.h>
21#include <linux/regulator/consumer.h>
22#include <linux/slab.h>
23#include <sound/core.h>
24#include <sound/pcm.h>
25#include <sound/pcm_params.h>
26#include <sound/soc.h>
27#include <sound/soc-dapm.h>
28#include <sound/initval.h>
29#include <sound/tlv.h>
30

--- 102 unchanged lines hidden (view full) ---

133 { 6, 768 },
134 { 7, 1152 },
135};
136
137static int wm8523_startup(struct snd_pcm_substream *substream,
138 struct snd_soc_dai *dai)
139{
140 struct snd_soc_codec *codec = dai->codec;
22#include <sound/core.h>
23#include <sound/pcm.h>
24#include <sound/pcm_params.h>
25#include <sound/soc.h>
26#include <sound/soc-dapm.h>
27#include <sound/initval.h>
28#include <sound/tlv.h>
29

--- 102 unchanged lines hidden (view full) ---

132 { 6, 768 },
133 { 7, 1152 },
134};
135
136static int wm8523_startup(struct snd_pcm_substream *substream,
137 struct snd_soc_dai *dai)
138{
139 struct snd_soc_codec *codec = dai->codec;
141 struct wm8523_priv *wm8523 = codec->private_data;
140 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
142
143 /* The set of sample rates that can be supported depends on the
144 * MCLK supplied to the CODEC - enforce this.
145 */
146 if (!wm8523->sysclk) {
147 dev_err(codec->dev,
148 "No MCLK configured, call set_sysclk() on init\n");
149 return -EINVAL;

--- 9 unchanged lines hidden (view full) ---

159
160static int wm8523_hw_params(struct snd_pcm_substream *substream,
161 struct snd_pcm_hw_params *params,
162 struct snd_soc_dai *dai)
163{
164 struct snd_soc_pcm_runtime *rtd = substream->private_data;
165 struct snd_soc_device *socdev = rtd->socdev;
166 struct snd_soc_codec *codec = socdev->card->codec;
141
142 /* The set of sample rates that can be supported depends on the
143 * MCLK supplied to the CODEC - enforce this.
144 */
145 if (!wm8523->sysclk) {
146 dev_err(codec->dev,
147 "No MCLK configured, call set_sysclk() on init\n");
148 return -EINVAL;

--- 9 unchanged lines hidden (view full) ---

158
159static int wm8523_hw_params(struct snd_pcm_substream *substream,
160 struct snd_pcm_hw_params *params,
161 struct snd_soc_dai *dai)
162{
163 struct snd_soc_pcm_runtime *rtd = substream->private_data;
164 struct snd_soc_device *socdev = rtd->socdev;
165 struct snd_soc_codec *codec = socdev->card->codec;
167 struct wm8523_priv *wm8523 = codec->private_data;
166 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
168 int i;
169 u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1);
170 u16 aifctrl2 = snd_soc_read(codec, WM8523_AIF_CTRL2);
171
172 /* Find a supported LRCLK ratio */
173 for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) {
174 if (wm8523->sysclk / params_rate(params) ==
175 lrclk_ratios[i].ratio)

--- 30 unchanged lines hidden (view full) ---

206
207 return 0;
208}
209
210static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
211 int clk_id, unsigned int freq, int dir)
212{
213 struct snd_soc_codec *codec = codec_dai->codec;
167 int i;
168 u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1);
169 u16 aifctrl2 = snd_soc_read(codec, WM8523_AIF_CTRL2);
170
171 /* Find a supported LRCLK ratio */
172 for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) {
173 if (wm8523->sysclk / params_rate(params) ==
174 lrclk_ratios[i].ratio)

--- 30 unchanged lines hidden (view full) ---

205
206 return 0;
207}
208
209static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai,
210 int clk_id, unsigned int freq, int dir)
211{
212 struct snd_soc_codec *codec = codec_dai->codec;
214 struct wm8523_priv *wm8523 = codec->private_data;
213 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
215 unsigned int val;
216 int i;
217
218 wm8523->sysclk = freq;
219
220 wm8523->rate_constraint.count = 0;
221 for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) {
222 val = freq / lrclk_ratios[i].ratio;

--- 90 unchanged lines hidden (view full) ---

313 snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1);
314
315 return 0;
316}
317
318static int wm8523_set_bias_level(struct snd_soc_codec *codec,
319 enum snd_soc_bias_level level)
320{
214 unsigned int val;
215 int i;
216
217 wm8523->sysclk = freq;
218
219 wm8523->rate_constraint.count = 0;
220 for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) {
221 val = freq / lrclk_ratios[i].ratio;

--- 90 unchanged lines hidden (view full) ---

312 snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1);
313
314 return 0;
315}
316
317static int wm8523_set_bias_level(struct snd_soc_codec *codec,
318 enum snd_soc_bias_level level)
319{
321 struct wm8523_priv *wm8523 = codec->private_data;
320 struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec);
322 int ret, i;
323
324 switch (level) {
325 case SND_SOC_BIAS_ON:
326 break;
327
328 case SND_SOC_BIAS_PREPARE:
329 /* Full power on */

--- 154 unchanged lines hidden (view full) ---

484 dev_err(codec->dev, "Another WM8523 is registered\n");
485 return -EINVAL;
486 }
487
488 mutex_init(&codec->mutex);
489 INIT_LIST_HEAD(&codec->dapm_widgets);
490 INIT_LIST_HEAD(&codec->dapm_paths);
491
321 int ret, i;
322
323 switch (level) {
324 case SND_SOC_BIAS_ON:
325 break;
326
327 case SND_SOC_BIAS_PREPARE:
328 /* Full power on */

--- 154 unchanged lines hidden (view full) ---

483 dev_err(codec->dev, "Another WM8523 is registered\n");
484 return -EINVAL;
485 }
486
487 mutex_init(&codec->mutex);
488 INIT_LIST_HEAD(&codec->dapm_widgets);
489 INIT_LIST_HEAD(&codec->dapm_paths);
490
492 codec->private_data = wm8523;
491 snd_soc_codec_set_drvdata(codec, wm8523);
493 codec->name = "WM8523";
494 codec->owner = THIS_MODULE;
495 codec->bias_level = SND_SOC_BIAS_OFF;
496 codec->set_bias_level = wm8523_set_bias_level;
497 codec->dai = &wm8523_dai;
498 codec->num_dai = 1;
499 codec->reg_cache_size = WM8523_REGISTER_COUNT;
500 codec->reg_cache = &wm8523->reg_cache;

--- 174 unchanged lines hidden ---
492 codec->name = "WM8523";
493 codec->owner = THIS_MODULE;
494 codec->bias_level = SND_SOC_BIAS_OFF;
495 codec->set_bias_level = wm8523_set_bias_level;
496 codec->dai = &wm8523_dai;
497 codec->num_dai = 1;
498 codec->reg_cache_size = WM8523_REGISTER_COUNT;
499 codec->reg_cache = &wm8523->reg_cache;

--- 174 unchanged lines hidden ---