Commit 5b247442 authored by Philipp Zabel's avatar Philipp Zabel Committed by Mark Brown

ASoC: uda1380: split set_dai_fmt into _both, _playback and _capture variants

This patch splits set_dai_fmt into three variants (single interface,
dual interface playback only, dual interface capture only) so that
data input and output formats can be configured separately for dual
interface setups.
Signed-off-by: default avatarPhilipp Zabel <philipp.zabel@gmail.com>
Tested-by: default avatarVasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 111f6fbe
...@@ -356,7 +356,7 @@ static int uda1380_add_widgets(struct snd_soc_codec *codec) ...@@ -356,7 +356,7 @@ static int uda1380_add_widgets(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int uda1380_set_dai_fmt(struct snd_soc_dai *codec_dai, static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_codec *codec = codec_dai->codec;
...@@ -366,16 +366,70 @@ static int uda1380_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -366,16 +366,70 @@ static int uda1380_set_dai_fmt(struct snd_soc_dai *codec_dai,
iface = uda1380_read_reg_cache(codec, UDA1380_IFACE); iface = uda1380_read_reg_cache(codec, UDA1380_IFACE);
iface &= ~(R01_SFORI_MASK | R01_SIM | R01_SFORO_MASK); iface &= ~(R01_SFORI_MASK | R01_SIM | R01_SFORO_MASK);
/* FIXME: how to select I2S for DATAO and MSB for DATAI correctly? */
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_I2S:
iface |= R01_SFORI_I2S | R01_SFORO_I2S; iface |= R01_SFORI_I2S | R01_SFORO_I2S;
break; break;
case SND_SOC_DAIFMT_LSB: case SND_SOC_DAIFMT_LSB:
iface |= R01_SFORI_LSB16 | R01_SFORO_I2S; iface |= R01_SFORI_LSB16 | R01_SFORO_LSB16;
break; break;
case SND_SOC_DAIFMT_MSB: case SND_SOC_DAIFMT_MSB:
iface |= R01_SFORI_MSB | R01_SFORO_I2S; iface |= R01_SFORI_MSB | R01_SFORO_MSB;
}
if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
iface |= R01_SIM;
uda1380_write(codec, UDA1380_IFACE, iface);
return 0;
}
static int uda1380_set_dai_fmt_playback(struct snd_soc_dai *codec_dai,
unsigned int fmt)
{
struct snd_soc_codec *codec = codec_dai->codec;
int iface;
/* set up DAI based upon fmt */
iface = uda1380_read_reg_cache(codec, UDA1380_IFACE);
iface &= ~R01_SFORI_MASK;
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
iface |= R01_SFORI_I2S;
break;
case SND_SOC_DAIFMT_LSB:
iface |= R01_SFORI_LSB16;
break;
case SND_SOC_DAIFMT_MSB:
iface |= R01_SFORI_MSB;
}
uda1380_write(codec, UDA1380_IFACE, iface);
return 0;
}
static int uda1380_set_dai_fmt_capture(struct snd_soc_dai *codec_dai,
unsigned int fmt)
{
struct snd_soc_codec *codec = codec_dai->codec;
int iface;
/* set up DAI based upon fmt */
iface = uda1380_read_reg_cache(codec, UDA1380_IFACE);
iface &= ~(R01_SIM | R01_SFORO_MASK);
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
iface |= R01_SFORO_I2S;
break;
case SND_SOC_DAIFMT_LSB:
iface |= R01_SFORO_LSB16;
break;
case SND_SOC_DAIFMT_MSB:
iface |= R01_SFORO_MSB;
} }
if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM) if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM)
...@@ -549,7 +603,7 @@ struct snd_soc_dai uda1380_dai[] = { ...@@ -549,7 +603,7 @@ struct snd_soc_dai uda1380_dai[] = {
.shutdown = uda1380_pcm_shutdown, .shutdown = uda1380_pcm_shutdown,
.prepare = uda1380_pcm_prepare, .prepare = uda1380_pcm_prepare,
.digital_mute = uda1380_mute, .digital_mute = uda1380_mute,
.set_fmt = uda1380_set_dai_fmt, .set_fmt = uda1380_set_dai_fmt_both,
}, },
}, },
{ /* playback only - dual interface */ { /* playback only - dual interface */
...@@ -566,7 +620,7 @@ struct snd_soc_dai uda1380_dai[] = { ...@@ -566,7 +620,7 @@ struct snd_soc_dai uda1380_dai[] = {
.shutdown = uda1380_pcm_shutdown, .shutdown = uda1380_pcm_shutdown,
.prepare = uda1380_pcm_prepare, .prepare = uda1380_pcm_prepare,
.digital_mute = uda1380_mute, .digital_mute = uda1380_mute,
.set_fmt = uda1380_set_dai_fmt, .set_fmt = uda1380_set_dai_fmt_playback,
}, },
}, },
{ /* capture only - dual interface*/ { /* capture only - dual interface*/
...@@ -582,7 +636,7 @@ struct snd_soc_dai uda1380_dai[] = { ...@@ -582,7 +636,7 @@ struct snd_soc_dai uda1380_dai[] = {
.hw_params = uda1380_pcm_hw_params, .hw_params = uda1380_pcm_hw_params,
.shutdown = uda1380_pcm_shutdown, .shutdown = uda1380_pcm_shutdown,
.prepare = uda1380_pcm_prepare, .prepare = uda1380_pcm_prepare,
.set_fmt = uda1380_set_dai_fmt, .set_fmt = uda1380_set_dai_fmt_capture,
}, },
}, },
}; };
......
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