Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 132822
b: refs/heads/master
c: 5b24744
h: refs/heads/master
v: v3
  • Loading branch information
Philipp Zabel authored and Mark Brown committed Feb 4, 2009
1 parent 8ea9887 commit fb68244
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 8 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: 111f6fbeb73fc350fe3a08c4ecd0ccdf3e13bef0
refs/heads/master: 5b2474425ed2a625b75dcd8d648701e473b7d764
68 changes: 61 additions & 7 deletions trunk/sound/soc/codecs/uda1380.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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 */
Expand All @@ -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*/
Expand All @@ -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,
},
},
};
Expand Down

0 comments on commit fb68244

Please sign in to comment.