summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2019-02-22 20:02:18 +0000
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2023-10-30 13:32:11 +0000
commit8506ba07a3351148c1e76e9e273b257124a0a2db (patch)
treeeb5b9d976aaad983023cd4d2fab7eecdf79347e1
parentffc253263a1375a65fa6c9f62a893e9767fbebfa (diff)
ASoC: hdmi-codec: add support for bclk_ratio
Some HDMI codecs need to know the relationship between the I2S bit clock and the I2S word clock in order to correctly generate the CTS value for audio clock recovery on the sink. Add support for this, but there are currently no callers of snd_soc_dai_set_bclk_ratio(), we provide a default implementation that uses the sample width to derive the ratio from the 8-bit aligned sample size. This reflects the derivation that is in TDA998x, which we are going to convert to use this new support. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
-rw-r--r--include/sound/hdmi-codec.h7
-rw-r--r--sound/soc/codecs/hdmi-codec.c14
2 files changed, 21 insertions, 0 deletions
diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
index 9b162ac1e08e..32c6fd09b74a 100644
--- a/include/sound/hdmi-codec.h
+++ b/include/sound/hdmi-codec.h
@@ -64,6 +64,13 @@ struct hdmi_codec_ops {
int (*audio_startup)(struct device *dev, void *data);
/*
+ * Set the bit clock ratio, as needed for some HDMI bridges.
+ * Optional.
+ */
+ int (*set_bclk_ratio)(struct device *dev, void *data,
+ unsigned int bclk_ratio);
+
+ /*
* Configures HDMI-encoder for audio stream.
* Having either prepare or hw_params is mandatory.
*/
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index 09eef6042aad..0620447b7c8e 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -620,6 +620,19 @@ static int hdmi_codec_prepare(struct snd_pcm_substream *substream,
cf, &hp);
}
+static int hdmi_codec_set_bclk_ratio(struct snd_soc_dai *dai,
+ unsigned int ratio)
+{
+ struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
+ int ret = -EOPNOTSUPP;
+
+ if (hcp->hcd.ops->set_bclk_ratio)
+ ret = hcp->hcd.ops->set_bclk_ratio(dai->dev->parent,
+ hcp->hcd.data, ratio);
+
+ return ret;
+}
+
static int hdmi_codec_i2s_set_fmt(struct snd_soc_dai *dai,
unsigned int fmt)
{
@@ -912,6 +925,7 @@ static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = {
.shutdown = hdmi_codec_shutdown,
.hw_params = hdmi_codec_hw_params,
.prepare = hdmi_codec_prepare,
+ .set_bclk_ratio = hdmi_codec_set_bclk_ratio,
.set_fmt = hdmi_codec_i2s_set_fmt,
.mute_stream = hdmi_codec_mute,
.pcm_new = hdmi_codec_pcm_new,