diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2019-02-22 20:02:18 +0000 |
---|---|---|
committer | Russell King <rmk+kernel@armlinux.org.uk> | 2020-08-04 17:42:04 +0100 |
commit | ca3c771ddad0d254ff9cd20c2868a59186840372 (patch) | |
tree | 802f46d8a97914776ed374499d66def6305883a0 | |
parent | bcf876870b95592b52519ed4aafcf9d95999bc9c (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.h | 7 | ||||
-rw-r--r-- | sound/soc/codecs/hdmi-codec.c | 14 |
2 files changed, 21 insertions, 0 deletions
diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index 83b17682e01c..5272aa17fe03 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -59,6 +59,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. * Mandatory */ diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index f005751da2cc..ec0468cae0f0 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -491,6 +491,19 @@ static int hdmi_codec_hw_params(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) { @@ -573,6 +586,7 @@ static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = { .startup = hdmi_codec_startup, .shutdown = hdmi_codec_shutdown, .hw_params = hdmi_codec_hw_params, + .set_bclk_ratio = hdmi_codec_set_bclk_ratio, .set_fmt = hdmi_codec_i2s_set_fmt, .digital_mute = hdmi_codec_digital_mute, }; |