From: Philipp Zabel <philipp.zabel@gmail.com>
To: alsa-devel@alsa-project.org
Cc: Vasily Khoruzhick <anarsoul@gmail.com>,
Mark Brown <broonie@sirena.org.uk>,
Philipp Zabel <philipp.zabel@gmail.com>
Subject: [PATCH 1/4] ASoC: uda1380: split set_dai_fmt into _both, _playback and _capture variants
Date: Tue, 3 Feb 2009 17:19:40 +0100 [thread overview]
Message-ID: <1233677983-23710-2-git-send-email-philipp.zabel@gmail.com> (raw)
In-Reply-To: <1233677983-23710-1-git-send-email-philipp.zabel@gmail.com>
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: Philipp Zabel <philipp.zabel@gmail.com>
---
sound/soc/codecs/uda1380.c | 68 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 61 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index a957b43..6de37b2 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -356,7 +356,7 @@ static int uda1380_add_widgets(struct snd_soc_codec *codec)
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)
{
struct snd_soc_codec *codec = codec_dai->codec;
@@ -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 &= ~(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) {
case SND_SOC_DAIFMT_I2S:
iface |= R01_SFORI_I2S | R01_SFORO_I2S;
break;
case SND_SOC_DAIFMT_LSB:
- iface |= R01_SFORI_LSB16 | R01_SFORO_I2S;
+ iface |= R01_SFORI_LSB16 | R01_SFORO_LSB16;
break;
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)
@@ -549,7 +603,7 @@ struct snd_soc_dai uda1380_dai[] = {
.shutdown = uda1380_pcm_shutdown,
.prepare = uda1380_pcm_prepare,
.digital_mute = uda1380_mute,
- .set_fmt = uda1380_set_dai_fmt,
+ .set_fmt = uda1380_set_dai_fmt_both,
},
},
{ /* playback only - dual interface */
@@ -566,7 +620,7 @@ struct snd_soc_dai uda1380_dai[] = {
.shutdown = uda1380_pcm_shutdown,
.prepare = uda1380_pcm_prepare,
.digital_mute = uda1380_mute,
- .set_fmt = uda1380_set_dai_fmt,
+ .set_fmt = uda1380_set_dai_fmt_playback,
},
},
{ /* capture only - dual interface*/
@@ -582,7 +636,7 @@ struct snd_soc_dai uda1380_dai[] = {
.hw_params = uda1380_pcm_hw_params,
.shutdown = uda1380_pcm_shutdown,
.prepare = uda1380_pcm_prepare,
- .set_fmt = uda1380_set_dai_fmt,
+ .set_fmt = uda1380_set_dai_fmt_capture,
},
},
};
--
1.5.6.5
next prev parent reply other threads:[~2009-02-03 16:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-03 16:19 ASoC: UDA1380/I2S/SSP patches Philipp Zabel
2009-02-03 16:19 ` Philipp Zabel [this message]
2009-02-03 16:41 ` [PATCH 1/4] ASoC: uda1380: split set_dai_fmt into _both, _playback and _capture variants Mark Brown
2009-02-03 16:45 ` pHilipp Zabel
2009-02-04 7:19 ` Vasily Khoruzhick
2009-02-04 13:19 ` Mark Brown
2009-02-03 16:19 ` [PATCH 2/4] ASoC: pxa-ssp: PXA2xx/3xx SSP ports start from 1, not 0 Philipp Zabel
2009-02-03 16:47 ` Mark Brown
2009-02-03 17:13 ` pHilipp Zabel
2009-02-03 17:35 ` Mark Brown
2009-02-03 18:49 ` pHilipp Zabel
2009-02-03 18:56 ` Mark Brown
2009-02-03 16:19 ` [PATCH 3/4] ASoC: pxa2xx-i2s: remove GPIO pin setup Philipp Zabel
2009-02-03 16:32 ` Mark Brown
2009-02-03 16:56 ` pHilipp Zabel
2009-02-03 17:09 ` Mark Brown
2009-02-03 16:19 ` [PATCH 4/4] ASoC: pxa-ssp: select PXA_SSP Philipp Zabel
2009-02-03 16:35 ` Mark Brown
2009-02-03 17:15 ` pHilipp Zabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1233677983-23710-2-git-send-email-philipp.zabel@gmail.com \
--to=philipp.zabel@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=anarsoul@gmail.com \
--cc=broonie@sirena.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.