aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-20 05:12:10 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-21 12:27:32 -0400
commit3cf956eebe54cdb7cf1701642085507f0354e56a (patch)
treed89eaea525d68b6ed17b8802f62ac44886c6c694
parenta937536b868b8369b98967929045f1df54234323 (diff)
ASoC: wm8994: Support constraining the maximum number of channels clocked
Some systems use the audio CODEC to clock a DAI with multiple data lines in parallel, meaning that bit clocks are only required for a smaller number of channels than data is sent for. In some cases providing the extra bit clocks can take the other devices on the audio bus out of spec. Support such systems by allowing a maximum number of channels to be specified. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--include/linux/mfd/wm8994/pdata.h8
-rw-r--r--sound/soc/codecs/wm8994.c13
2 files changed, 19 insertions, 2 deletions
diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h
index 8e21a094836d..68e776594889 100644
--- a/include/linux/mfd/wm8994/pdata.h
+++ b/include/linux/mfd/wm8994/pdata.h
@@ -17,6 +17,7 @@
17 17
18#define WM8994_NUM_LDO 2 18#define WM8994_NUM_LDO 2
19#define WM8994_NUM_GPIO 11 19#define WM8994_NUM_GPIO 11
20#define WM8994_NUM_AIF 3
20 21
21struct wm8994_ldo_pdata { 22struct wm8994_ldo_pdata {
22 /** GPIOs to enable regulator, 0 or less if not available */ 23 /** GPIOs to enable regulator, 0 or less if not available */
@@ -215,6 +216,13 @@ struct wm8994_pdata {
215 * system. 216 * system.
216 */ 217 */
217 bool spkmode_pu; 218 bool spkmode_pu;
219
220 /**
221 * Maximum number of channels clocks will be generated for,
222 * useful for systems where and I2S bus with multiple data
223 * lines is mastered.
224 */
225 int max_channels_clocked[WM8994_NUM_AIF];
218}; 226};
219 227
220#endif 228#endif
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index c9bd445c4976..318ea64b9800 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -2656,6 +2656,8 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
2656{ 2656{
2657 struct snd_soc_codec *codec = dai->codec; 2657 struct snd_soc_codec *codec = dai->codec;
2658 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 2658 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
2659 struct wm8994 *control = wm8994->wm8994;
2660 struct wm8994_pdata *pdata = &control->pdata;
2659 int aif1_reg; 2661 int aif1_reg;
2660 int aif2_reg; 2662 int aif2_reg;
2661 int bclk_reg; 2663 int bclk_reg;
@@ -2723,7 +2725,14 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
2723 } 2725 }
2724 2726
2725 wm8994->channels[id] = params_channels(params); 2727 wm8994->channels[id] = params_channels(params);
2726 switch (params_channels(params)) { 2728 if (pdata->max_channels_clocked[id] &&
2729 wm8994->channels[id] > pdata->max_channels_clocked[id]) {
2730 dev_dbg(dai->dev, "Constraining channels to %d from %d\n",
2731 pdata->max_channels_clocked[id], wm8994->channels[id]);
2732 wm8994->channels[id] = pdata->max_channels_clocked[id];
2733 }
2734
2735 switch (wm8994->channels[id]) {
2727 case 1: 2736 case 1:
2728 case 2: 2737 case 2:
2729 bclk_rate *= 2; 2738 bclk_rate *= 2;
@@ -2745,7 +2754,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
2745 dev_dbg(dai->dev, "AIF%dCLK is %dHz, target BCLK %dHz\n", 2754 dev_dbg(dai->dev, "AIF%dCLK is %dHz, target BCLK %dHz\n",
2746 dai->id, wm8994->aifclk[id], bclk_rate); 2755 dai->id, wm8994->aifclk[id], bclk_rate);
2747 2756
2748 if (params_channels(params) == 1 && 2757 if (wm8994->channels[id] == 1 &&
2749 (snd_soc_read(codec, aif1_reg) & 0x18) == 0x18) 2758 (snd_soc_read(codec, aif1_reg) & 0x18) == 0x18)
2750 aif2 |= WM8994_AIF1_MONO; 2759 aif2 |= WM8994_AIF1_MONO;
2751 2760