Commit 2c4956bc authored by Jerome Brunet's avatar Jerome Brunet Committed by Mark Brown

ASoC: meson: g12a-tohdmitx: override codec2codec params

So far, forwarding the hw_params of the input to output relied on the
.hw_params() callback of the cpu side of the codec2codec link to be called
first. This is a bit weak.

Instead, override the stream params of the codec2codec to link to set it up
correctly.
Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20190729080139.32068-1-jbrunet@baylibre.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 096769ea
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define CTRL0_SPDIF_CLK_SEL BIT(0) #define CTRL0_SPDIF_CLK_SEL BIT(0)
struct g12a_tohdmitx_input { struct g12a_tohdmitx_input {
struct snd_pcm_hw_params params; struct snd_soc_pcm_stream params;
unsigned int fmt; unsigned int fmt;
}; };
...@@ -225,26 +225,17 @@ static int g12a_tohdmitx_input_hw_params(struct snd_pcm_substream *substream, ...@@ -225,26 +225,17 @@ static int g12a_tohdmitx_input_hw_params(struct snd_pcm_substream *substream,
{ {
struct g12a_tohdmitx_input *data = dai->playback_dma_data; struct g12a_tohdmitx_input *data = dai->playback_dma_data;
/* Save the stream params for the downstream link */ data->params.rates = snd_pcm_rate_to_rate_bit(params_rate(params));
memcpy(&data->params, params, sizeof(*params)); data->params.rate_min = params_rate(params);
data->params.rate_max = params_rate(params);
data->params.formats = 1 << params_format(params);
data->params.channels_min = params_channels(params);
data->params.channels_max = params_channels(params);
data->params.sig_bits = dai->driver->playback.sig_bits;
return 0; return 0;
} }
static int g12a_tohdmitx_output_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct g12a_tohdmitx_input *in_data =
g12a_tohdmitx_get_input_data(dai->capture_widget);
if (!in_data)
return -ENODEV;
memcpy(params, &in_data->params, sizeof(*params));
return 0;
}
static int g12a_tohdmitx_input_set_fmt(struct snd_soc_dai *dai, static int g12a_tohdmitx_input_set_fmt(struct snd_soc_dai *dai,
unsigned int fmt) unsigned int fmt)
...@@ -266,6 +257,14 @@ static int g12a_tohdmitx_output_startup(struct snd_pcm_substream *substream, ...@@ -266,6 +257,14 @@ static int g12a_tohdmitx_output_startup(struct snd_pcm_substream *substream,
if (!in_data) if (!in_data)
return -ENODEV; return -ENODEV;
if (WARN_ON(!rtd->dai_link->params)) {
dev_warn(dai->dev, "codec2codec link expected\n");
return -EINVAL;
}
/* Replace link params with the input params */
rtd->dai_link->params = &in_data->params;
if (!in_data->fmt) if (!in_data->fmt)
return 0; return 0;
...@@ -278,7 +277,6 @@ static const struct snd_soc_dai_ops g12a_tohdmitx_input_ops = { ...@@ -278,7 +277,6 @@ static const struct snd_soc_dai_ops g12a_tohdmitx_input_ops = {
}; };
static const struct snd_soc_dai_ops g12a_tohdmitx_output_ops = { static const struct snd_soc_dai_ops g12a_tohdmitx_output_ops = {
.hw_params = g12a_tohdmitx_output_hw_params,
.startup = g12a_tohdmitx_output_startup, .startup = g12a_tohdmitx_output_startup,
}; };
......
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