Skip to content

Commit

Permalink
ASoC: mxs-sgtl5000: Use static DAI format setup
Browse files Browse the repository at this point in the history
Set the dai_fmt field in the dai_link struct instead of manually calling
snd_soc_dai_fmt(). This makes the code cleaner and shorter.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Lars-Peter Clausen authored and Mark Brown committed Jan 6, 2015
1 parent 734890a commit bc6a5d6
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions sound/soc/mxs/mxs-sgtl5000.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static int mxs_sgtl5000_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
unsigned int rate = params_rate(params);
u32 dai_format, mclk;
u32 mclk;
int ret;

/* sgtl5000 does not support 512*rate when in 96000 fs */
Expand Down Expand Up @@ -65,44 +65,29 @@ static int mxs_sgtl5000_hw_params(struct snd_pcm_substream *substream,
return ret;
}

/* set codec to slave mode */
dai_format = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS;

/* set codec DAI configuration */
ret = snd_soc_dai_set_fmt(codec_dai, dai_format);
if (ret) {
dev_err(codec_dai->dev, "Failed to set dai format to %08x\n",
dai_format);
return ret;
}

/* set cpu DAI configuration */
ret = snd_soc_dai_set_fmt(cpu_dai, dai_format);
if (ret) {
dev_err(cpu_dai->dev, "Failed to set dai format to %08x\n",
dai_format);
return ret;
}

return 0;
}

static struct snd_soc_ops mxs_sgtl5000_hifi_ops = {
.hw_params = mxs_sgtl5000_hw_params,
};

#define MXS_SGTL5000_DAI_FMT (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | \
SND_SOC_DAIFMT_CBS_CFS)

static struct snd_soc_dai_link mxs_sgtl5000_dai[] = {
{
.name = "HiFi Tx",
.stream_name = "HiFi Playback",
.codec_dai_name = "sgtl5000",
.dai_fmt = MXS_SGTL5000_DAI_FMT,
.ops = &mxs_sgtl5000_hifi_ops,
.playback_only = true,
}, {
.name = "HiFi Rx",
.stream_name = "HiFi Capture",
.codec_dai_name = "sgtl5000",
.dai_fmt = MXS_SGTL5000_DAI_FMT,
.ops = &mxs_sgtl5000_hifi_ops,
.capture_only = true,
},
Expand Down

0 comments on commit bc6a5d6

Please sign in to comment.