Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 132866
b: refs/heads/master
c: 4eae080
h: refs/heads/master
v: v3
  • Loading branch information
Daniel Mack authored and Mark Brown committed Feb 28, 2009
1 parent 9153bb8 commit 3fdf5c7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c8efef1745d168b80c800e98cce48a59630dbbfc
refs/heads/master: 4eae080dda3a563160be2f642cfbda27ffc42178
24 changes: 23 additions & 1 deletion trunk/sound/soc/codecs/cs4270.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down Expand Up @@ -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:
Expand All @@ -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;
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3fdf5c7

Please sign in to comment.