aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/cs4270.c
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2009-02-25 08:37:21 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-02-28 12:18:25 -0500
commit4eae080dda3a563160be2f642cfbda27ffc42178 (patch)
tree6f42eba245638910cca8defd5bdaf13f0a2ab10e /sound/soc/codecs/cs4270.c
parentc8efef1745d168b80c800e98cce48a59630dbbfc (diff)
ASoC: Add cs4270 support for slave mode configurations
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> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/cs4270.c')
-rw-r--r--sound/soc/codecs/cs4270.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index cd4a9ee38e46..339e0f6b0fe2 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -109,6 +109,7 @@ struct cs4270_private {
109 u8 reg_cache[CS4270_NUMREGS]; 109 u8 reg_cache[CS4270_NUMREGS];
110 unsigned int mclk; /* Input frequency of the MCLK pin */ 110 unsigned int mclk; /* Input frequency of the MCLK pin */
111 unsigned int mode; /* The mode (I2S or left-justified) */ 111 unsigned int mode; /* The mode (I2S or left-justified) */
112 unsigned int slave_mode;
112}; 113};
113 114
114/** 115/**
@@ -247,6 +248,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
247 struct cs4270_private *cs4270 = codec->private_data; 248 struct cs4270_private *cs4270 = codec->private_data;
248 int ret = 0; 249 int ret = 0;
249 250
251 /* set DAI format */
250 switch (format & SND_SOC_DAIFMT_FORMAT_MASK) { 252 switch (format & SND_SOC_DAIFMT_FORMAT_MASK) {
251 case SND_SOC_DAIFMT_I2S: 253 case SND_SOC_DAIFMT_I2S:
252 case SND_SOC_DAIFMT_LEFT_J: 254 case SND_SOC_DAIFMT_LEFT_J:
@@ -257,6 +259,21 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
257 ret = -EINVAL; 259 ret = -EINVAL;
258 } 260 }
259 261
262 /* set master/slave audio interface */
263 switch (format & SND_SOC_DAIFMT_MASTER_MASK) {
264 case SND_SOC_DAIFMT_CBS_CFS:
265 cs4270->slave_mode = 1;
266 break;
267 case SND_SOC_DAIFMT_CBM_CFM:
268 cs4270->slave_mode = 0;
269 break;
270 case SND_SOC_DAIFMT_CBM_CFS:
271 /* unsupported - cs4270 can eigther be slave or master to
272 * both the bitclk and the lrclk. */
273 default:
274 ret = -EINVAL;
275 }
276
260 return ret; 277 return ret;
261} 278}
262 279
@@ -399,7 +416,12 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
399 416
400 reg = snd_soc_read(codec, CS4270_MODE); 417 reg = snd_soc_read(codec, CS4270_MODE);
401 reg &= ~(CS4270_MODE_SPEED_MASK | CS4270_MODE_DIV_MASK); 418 reg &= ~(CS4270_MODE_SPEED_MASK | CS4270_MODE_DIV_MASK);
402 reg |= cs4270_mode_ratios[i].speed_mode | cs4270_mode_ratios[i].mclk; 419 reg |= cs4270_mode_ratios[i].mclk;
420
421 if (cs4270->slave_mode)
422 reg |= CS4270_MODE_SLAVE;
423 else
424 reg |= cs4270_mode_ratios[i].speed_mode;
403 425
404 ret = snd_soc_write(codec, CS4270_MODE, reg); 426 ret = snd_soc_write(codec, CS4270_MODE, reg);
405 if (ret < 0) { 427 if (ret < 0) {