Commit b916449c authored by Srinivas Kandagatla's avatar Srinivas Kandagatla Committed by Mark Brown

ASoC: qdsp6: q6afe-dai: use q6afe_dai_prepare() for MI2S

Use common q6afe_dai_prepare() for MI2S dais, this will remove
some code duplication. Also make the if statement to switch to
make the code look neater.
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent dea1ffbe
...@@ -144,7 +144,7 @@ static void q6afe_dai_shutdown(struct snd_pcm_substream *substream, ...@@ -144,7 +144,7 @@ static void q6afe_dai_shutdown(struct snd_pcm_substream *substream,
} }
static int q6afe_mi2s_prepare(struct snd_pcm_substream *substream, static int q6afe_dai_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev); struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
...@@ -159,45 +159,28 @@ static int q6afe_mi2s_prepare(struct snd_pcm_substream *substream, ...@@ -159,45 +159,28 @@ static int q6afe_mi2s_prepare(struct snd_pcm_substream *substream,
} }
} }
switch (dai->id) {
case HDMI_RX:
q6afe_hdmi_port_prepare(dai_data->port[dai->id],
&dai_data->port_config[dai->id].hdmi);
break;
case SLIMBUS_0_RX ... SLIMBUS_6_TX:
q6afe_slim_port_prepare(dai_data->port[dai->id],
&dai_data->port_config[dai->id].slim);
break;
case PRIMARY_MI2S_RX ... QUATERNARY_MI2S_TX:
rc = q6afe_i2s_port_prepare(dai_data->port[dai->id], rc = q6afe_i2s_port_prepare(dai_data->port[dai->id],
&dai_data->port_config[dai->id].i2s_cfg); &dai_data->port_config[dai->id].i2s_cfg);
if (rc < 0) { if (rc < 0) {
dev_err(dai->dev, "fail to prepare AFE port %x\n", dai->id); dev_err(dai->dev, "fail to prepare AFE port %x\n",
return rc; dai->id);
}
rc = q6afe_port_start(dai_data->port[dai->id]);
if (rc < 0) {
dev_err(dai->dev, "fail to start AFE port %x\n", dai->id);
return rc;
}
dai_data->is_port_started[dai->id] = true;
return 0;
}
static int q6afe_dai_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct q6afe_dai_data *dai_data = dev_get_drvdata(dai->dev);
int rc;
if (dai_data->is_port_started[dai->id]) {
/* stop the port and restart with new port config */
rc = q6afe_port_stop(dai_data->port[dai->id]);
if (rc < 0) {
dev_err(dai->dev, "fail to close AFE port (%d)\n", rc);
return rc; return rc;
} }
break;
default:
return -EINVAL;
} }
if (dai->id == HDMI_RX)
q6afe_hdmi_port_prepare(dai_data->port[dai->id],
&dai_data->port_config[dai->id].hdmi);
else if (dai->id >= SLIMBUS_0_RX && dai->id <= SLIMBUS_6_TX)
q6afe_slim_port_prepare(dai_data->port[dai->id],
&dai_data->port_config[dai->id].slim);
rc = q6afe_port_start(dai_data->port[dai->id]); rc = q6afe_port_start(dai_data->port[dai->id]);
if (rc < 0) { if (rc < 0) {
dev_err(dai->dev, "fail to start AFE port %x\n", dai->id); dev_err(dai->dev, "fail to start AFE port %x\n", dai->id);
...@@ -289,7 +272,7 @@ static struct snd_soc_dai_ops q6hdmi_ops = { ...@@ -289,7 +272,7 @@ static struct snd_soc_dai_ops q6hdmi_ops = {
}; };
static struct snd_soc_dai_ops q6i2s_ops = { static struct snd_soc_dai_ops q6i2s_ops = {
.prepare = q6afe_mi2s_prepare, .prepare = q6afe_dai_prepare,
.hw_params = q6i2s_hw_params, .hw_params = q6i2s_hw_params,
.set_fmt = q6i2s_set_fmt, .set_fmt = q6i2s_set_fmt,
.shutdown = q6afe_dai_shutdown, .shutdown = q6afe_dai_shutdown,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment