Commit b1e43d93 authored by Mark Brown's avatar Mark Brown

ASoC: Support WM8994 mono AIF configurations

The WM8994 supports mono signals - enable this in the driver. With DSP
mode an automatic data channel selector is available, activate this
when in mono mode.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent e4f078d8
...@@ -2099,10 +2099,12 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -2099,10 +2099,12 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
struct wm8994 *control = codec->control_data; struct wm8994 *control = codec->control_data;
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
int aif1_reg; int aif1_reg;
int aif2_reg;
int bclk_reg; int bclk_reg;
int lrclk_reg; int lrclk_reg;
int rate_reg; int rate_reg;
int aif1 = 0; int aif1 = 0;
int aif2 = 0;
int bclk = 0; int bclk = 0;
int lrclk = 0; int lrclk = 0;
int rate_val = 0; int rate_val = 0;
...@@ -2113,6 +2115,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -2113,6 +2115,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
switch (dai->id) { switch (dai->id) {
case 1: case 1:
aif1_reg = WM8994_AIF1_CONTROL_1; aif1_reg = WM8994_AIF1_CONTROL_1;
aif2_reg = WM8994_AIF1_CONTROL_2;
bclk_reg = WM8994_AIF1_BCLK; bclk_reg = WM8994_AIF1_BCLK;
rate_reg = WM8994_AIF1_RATE; rate_reg = WM8994_AIF1_RATE;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
...@@ -2125,6 +2128,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -2125,6 +2128,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
break; break;
case 2: case 2:
aif1_reg = WM8994_AIF2_CONTROL_1; aif1_reg = WM8994_AIF2_CONTROL_1;
aif2_reg = WM8994_AIF2_CONTROL_2;
bclk_reg = WM8994_AIF2_BCLK; bclk_reg = WM8994_AIF2_BCLK;
rate_reg = WM8994_AIF2_RATE; rate_reg = WM8994_AIF2_RATE;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
...@@ -2180,6 +2184,10 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -2180,6 +2184,10 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
dev_dbg(dai->dev, "AIF%dCLK is %dHz, target BCLK %dHz\n", dev_dbg(dai->dev, "AIF%dCLK is %dHz, target BCLK %dHz\n",
dai->id, wm8994->aifclk[id], bclk_rate); dai->id, wm8994->aifclk[id], bclk_rate);
if (params_channels(params) == 1 &&
(snd_soc_read(codec, aif1_reg) & 0x18) == 0x18)
aif2 |= WM8994_AIF1_MONO;
if (wm8994->aifclk[id] == 0) { if (wm8994->aifclk[id] == 0) {
dev_err(dai->dev, "AIF%dCLK not configured\n", dai->id); dev_err(dai->dev, "AIF%dCLK not configured\n", dai->id);
return -EINVAL; return -EINVAL;
...@@ -2223,6 +2231,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -2223,6 +2231,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
lrclk, bclk_rate / lrclk); lrclk, bclk_rate / lrclk);
snd_soc_update_bits(codec, aif1_reg, WM8994_AIF1_WL_MASK, aif1); snd_soc_update_bits(codec, aif1_reg, WM8994_AIF1_WL_MASK, aif1);
snd_soc_update_bits(codec, aif2_reg, WM8994_AIF1_MONO, aif2);
snd_soc_update_bits(codec, bclk_reg, WM8994_AIF1_BCLK_DIV_MASK, bclk); snd_soc_update_bits(codec, bclk_reg, WM8994_AIF1_BCLK_DIV_MASK, bclk);
snd_soc_update_bits(codec, lrclk_reg, WM8994_AIF1DAC_RATE_MASK, snd_soc_update_bits(codec, lrclk_reg, WM8994_AIF1DAC_RATE_MASK,
lrclk); lrclk);
...@@ -2378,14 +2387,14 @@ static struct snd_soc_dai_driver wm8994_dai[] = { ...@@ -2378,14 +2387,14 @@ static struct snd_soc_dai_driver wm8994_dai[] = {
.id = 1, .id = 1,
.playback = { .playback = {
.stream_name = "AIF1 Playback", .stream_name = "AIF1 Playback",
.channels_min = 2, .channels_min = 1,
.channels_max = 2, .channels_max = 2,
.rates = WM8994_RATES, .rates = WM8994_RATES,
.formats = WM8994_FORMATS, .formats = WM8994_FORMATS,
}, },
.capture = { .capture = {
.stream_name = "AIF1 Capture", .stream_name = "AIF1 Capture",
.channels_min = 2, .channels_min = 1,
.channels_max = 2, .channels_max = 2,
.rates = WM8994_RATES, .rates = WM8994_RATES,
.formats = WM8994_FORMATS, .formats = WM8994_FORMATS,
...@@ -2397,14 +2406,14 @@ static struct snd_soc_dai_driver wm8994_dai[] = { ...@@ -2397,14 +2406,14 @@ static struct snd_soc_dai_driver wm8994_dai[] = {
.id = 2, .id = 2,
.playback = { .playback = {
.stream_name = "AIF2 Playback", .stream_name = "AIF2 Playback",
.channels_min = 2, .channels_min = 1,
.channels_max = 2, .channels_max = 2,
.rates = WM8994_RATES, .rates = WM8994_RATES,
.formats = WM8994_FORMATS, .formats = WM8994_FORMATS,
}, },
.capture = { .capture = {
.stream_name = "AIF2 Capture", .stream_name = "AIF2 Capture",
.channels_min = 2, .channels_min = 1,
.channels_max = 2, .channels_max = 2,
.rates = WM8994_RATES, .rates = WM8994_RATES,
.formats = WM8994_FORMATS, .formats = WM8994_FORMATS,
...@@ -2416,14 +2425,14 @@ static struct snd_soc_dai_driver wm8994_dai[] = { ...@@ -2416,14 +2425,14 @@ static struct snd_soc_dai_driver wm8994_dai[] = {
.id = 3, .id = 3,
.playback = { .playback = {
.stream_name = "AIF3 Playback", .stream_name = "AIF3 Playback",
.channels_min = 2, .channels_min = 1,
.channels_max = 2, .channels_max = 2,
.rates = WM8994_RATES, .rates = WM8994_RATES,
.formats = WM8994_FORMATS, .formats = WM8994_FORMATS,
}, },
.capture = { .capture = {
.stream_name = "AIF3 Capture", .stream_name = "AIF3 Capture",
.channels_min = 2, .channels_min = 1,
.channels_max = 2, .channels_max = 2,
.rates = WM8994_RATES, .rates = WM8994_RATES,
.formats = WM8994_FORMATS, .formats = WM8994_FORMATS,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment