summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorZidan Wang <zidan.wang@freescale.com>2015-04-30 22:03:24 +0800
committerNitin Garg <nitin.garg@freescale.com>2015-09-17 09:22:51 -0500
commitfdb98ce909853126be804e4fed4488d2e1f3f5c1 (patch)
treee191f589016ecc478ad2b454325b2d07227f800f /sound
parente5dbe12ff53ce19f2cf63baf73619dc9d4d1e589 (diff)
MLK-10796 ASoC: imx-wm8960: add constraint list for codec master mode
add constraint list for codec master mode. Signed-off-by: Zidan Wang <zidan.wang@freescale.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/fsl/imx-wm8960.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/sound/soc/fsl/imx-wm8960.c b/sound/soc/fsl/imx-wm8960.c
index 51994900a9f8..9bdddbcae693 100644
--- a/sound/soc/fsl/imx-wm8960.c
+++ b/sound/soc/fsl/imx-wm8960.c
@@ -156,7 +156,7 @@ static int imx_wm8960_gpio_init(struct snd_soc_card *card)
imx_hp_set_gpio.gpio = priv->hp_set_gpio;
imx_hp_set_gpio.jack_status_check = hp_set_status_check;
- ret = snd_soc_jack_new(codec, "Headpset Jack",
+ ret = snd_soc_jack_new(codec, "Headset Jack",
SND_JACK_HEADSET, &imx_hp_set);
if (ret)
return ret;
@@ -297,6 +297,12 @@ static int imx_hifi_hw_params(struct snd_pcm_substream *substream,
}
if (!data->is_codec_master) {
+ ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 0, 2, params_width(params));
+ if (ret) {
+ dev_err(dev, "failed to set cpu dai tdm slot: %d\n", ret);
+ return ret;
+ }
+
ret = snd_soc_dai_set_sysclk(cpu_dai, 0, 0, SND_SOC_CLOCK_OUT);
if (ret) {
dev_err(dev, "failed to set cpu sysclk: %d\n", ret);
@@ -317,7 +323,7 @@ static int imx_hifi_hw_params(struct snd_pcm_substream *substream,
if (ret < 0)
dev_dbg(dev, "fail to set codec clock frequency.\n");
else
- data->clk_frequency = DEFAULT_MCLK_FREQ;
+ data->clk_frequency = clk_get_rate(data->codec_clk);
}
/* Use MCLK to provide sysclk directly*/
@@ -385,6 +391,20 @@ static int imx_hifi_hw_free(struct snd_pcm_substream *substream)
return 0;
}
+static u32 imx_wm8960_rates[] = {
+ 8000, 16000, 32000, 48000, 64000, 96000
+};
+static struct snd_pcm_hw_constraint_list imx_wm8960_rate_constraints = {
+ .count = ARRAY_SIZE(imx_wm8960_rates),
+ .list = imx_wm8960_rates,
+};
+
+static u32 imx_wm8960_formats[] = {16, 32};
+static struct snd_pcm_hw_constraint_list imx_wm8960_format_constraints = {
+ .count = ARRAY_SIZE(imx_wm8960_formats),
+ .list = imx_wm8960_formats,
+};
+
static int imx_hifi_startup(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -403,6 +423,18 @@ static int imx_hifi_startup(struct snd_pcm_substream *substream)
return -EBUSY;
}
+ if (!data->is_codec_master) {
+ ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
+ SNDRV_PCM_HW_PARAM_RATE, &imx_wm8960_rate_constraints);
+ if (ret)
+ return ret;
+
+ ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
+ SNDRV_PCM_HW_PARAM_SAMPLE_BITS, &imx_wm8960_format_constraints);
+ if (ret)
+ return ret;
+ }
+
return ret;
}