From: Daniel Mack <daniel@caiaq.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH] cs4270: add support for slave mode configurations
Date: Wed, 25 Feb 2009 14:37:21 +0100 [thread overview]
Message-ID: <1235569041-856-1-git-send-email-daniel@caiaq.de> (raw)
Added support for scenarios where the Cirrus CS4270 audio codec is slave
to the bitclk and lrclk. Mixed setups are unsupported.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
---
sound/soc/codecs/cs4270.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index cd4a9ee..339e0f6 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -109,6 +109,7 @@ struct cs4270_private {
u8 reg_cache[CS4270_NUMREGS];
unsigned int mclk; /* Input frequency of the MCLK pin */
unsigned int mode; /* The mode (I2S or left-justified) */
+ unsigned int slave_mode;
};
/**
@@ -247,6 +248,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
struct cs4270_private *cs4270 = codec->private_data;
int ret = 0;
+ /* set DAI format */
switch (format & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
case SND_SOC_DAIFMT_LEFT_J:
@@ -257,6 +259,21 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
ret = -EINVAL;
}
+ /* set master/slave audio interface */
+ switch (format & SND_SOC_DAIFMT_MASTER_MASK) {
+ case SND_SOC_DAIFMT_CBS_CFS:
+ cs4270->slave_mode = 1;
+ break;
+ case SND_SOC_DAIFMT_CBM_CFM:
+ cs4270->slave_mode = 0;
+ break;
+ case SND_SOC_DAIFMT_CBM_CFS:
+ /* unsupported - cs4270 can eigther be slave or master to
+ * both the bitclk and the lrclk. */
+ default:
+ ret = -EINVAL;
+ }
+
return ret;
}
@@ -399,7 +416,12 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
reg = snd_soc_read(codec, CS4270_MODE);
reg &= ~(CS4270_MODE_SPEED_MASK | CS4270_MODE_DIV_MASK);
- reg |= cs4270_mode_ratios[i].speed_mode | cs4270_mode_ratios[i].mclk;
+ reg |= cs4270_mode_ratios[i].mclk;
+
+ if (cs4270->slave_mode)
+ reg |= CS4270_MODE_SLAVE;
+ else
+ reg |= cs4270_mode_ratios[i].speed_mode;
ret = snd_soc_write(codec, CS4270_MODE, reg);
if (ret < 0) {
--
1.6.1.3
next reply other threads:[~2009-02-25 13:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-25 13:37 Daniel Mack [this message]
2009-02-25 15:34 ` [PATCH] cs4270: add support for slave mode configurations Mark Brown
2009-02-25 15:45 ` Daniel Mack
2009-02-25 15:48 ` Mark Brown
2009-02-27 21:51 ` Timur Tabi
2009-02-28 12:13 ` Daniel Mack
2009-02-28 16:32 ` Timur Tabi
2009-02-28 17:47 ` Daniel Mack
2009-03-01 1:09 ` Timur Tabi
2009-02-28 12:21 ` [PATCH] fix typo and removed unneeded switch case Daniel Mack
2009-03-01 1:11 ` Timur Tabi
2009-03-02 14:38 ` Mark Brown
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=1235569041-856-1-git-send-email-daniel@caiaq.de \
--to=daniel@caiaq.de \
--cc=alsa-devel@alsa-project.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox