Commit 99b4f439 authored by Yu-Hsuan Hsu's avatar Yu-Hsuan Hsu Committed by Mark Brown

ASoC: cros_ec_codec: Support setting bclk ratio

Support setting bclk ratio from machine drivers.
Signed-off-by: default avatarYu-Hsuan Hsu <yuhsuan@chromium.org>
Reviewed-by: default avatarTzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20200125162917.247485-1-yuhsuan@chromium.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent bb6d3fb3
...@@ -45,6 +45,9 @@ struct cros_ec_codec_priv { ...@@ -45,6 +45,9 @@ struct cros_ec_codec_priv {
/* DMIC */ /* DMIC */
atomic_t dmic_probed; atomic_t dmic_probed;
/* I2S_RX */
uint32_t i2s_rx_bclk_ratio;
/* WoV */ /* WoV */
bool wov_enabled; bool wov_enabled;
uint8_t *wov_audio_shm_p; uint8_t *wov_audio_shm_p;
...@@ -259,6 +262,7 @@ static int i2s_rx_hw_params(struct snd_pcm_substream *substream, ...@@ -259,6 +262,7 @@ static int i2s_rx_hw_params(struct snd_pcm_substream *substream,
snd_soc_component_get_drvdata(component); snd_soc_component_get_drvdata(component);
struct ec_param_ec_codec_i2s_rx p; struct ec_param_ec_codec_i2s_rx p;
enum ec_codec_i2s_rx_sample_depth depth; enum ec_codec_i2s_rx_sample_depth depth;
uint32_t bclk;
int ret; int ret;
if (params_rate(params) != 48000) if (params_rate(params) != 48000)
...@@ -284,15 +288,29 @@ static int i2s_rx_hw_params(struct snd_pcm_substream *substream, ...@@ -284,15 +288,29 @@ static int i2s_rx_hw_params(struct snd_pcm_substream *substream,
if (ret < 0) if (ret < 0)
return ret; return ret;
dev_dbg(component->dev, "set bclk to %u\n", if (priv->i2s_rx_bclk_ratio)
snd_soc_params_to_bclk(params)); bclk = params_rate(params) * priv->i2s_rx_bclk_ratio;
else
bclk = snd_soc_params_to_bclk(params);
dev_dbg(component->dev, "set bclk to %u\n", bclk);
p.cmd = EC_CODEC_I2S_RX_SET_BCLK; p.cmd = EC_CODEC_I2S_RX_SET_BCLK;
p.set_bclk_param.bclk = snd_soc_params_to_bclk(params); p.set_bclk_param.bclk = bclk;
return send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_I2S_RX, return send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_I2S_RX,
(uint8_t *)&p, sizeof(p), NULL, 0); (uint8_t *)&p, sizeof(p), NULL, 0);
} }
static int i2s_rx_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
{
struct snd_soc_component *component = dai->component;
struct cros_ec_codec_priv *priv =
snd_soc_component_get_drvdata(component);
priv->i2s_rx_bclk_ratio = ratio;
return 0;
}
static int i2s_rx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int i2s_rx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_component *component = dai->component; struct snd_soc_component *component = dai->component;
...@@ -340,6 +358,7 @@ static int i2s_rx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -340,6 +358,7 @@ static int i2s_rx_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
static const struct snd_soc_dai_ops i2s_rx_dai_ops = { static const struct snd_soc_dai_ops i2s_rx_dai_ops = {
.hw_params = i2s_rx_hw_params, .hw_params = i2s_rx_hw_params,
.set_fmt = i2s_rx_set_fmt, .set_fmt = i2s_rx_set_fmt,
.set_bclk_ratio = i2s_rx_set_bclk_ratio,
}; };
static int i2s_rx_event(struct snd_soc_dapm_widget *w, static int i2s_rx_event(struct snd_soc_dapm_widget *w,
......
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