aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Jackson <Andrew.Jackson@arm.com>2014-08-29 15:54:53 +0100
committerAndrey Konovalov <andrey.konovalov@linaro.org>2015-10-16 19:11:42 +0300
commit5a16cd5b910d0220666032216475b5208cfd471d (patch)
tree7b189f66193c40e729bc519690369218706c84c0
parentcc13325ef2bf87623ac4bbca7a4c74fb32a38a67 (diff)
drm: i2c: tda998x: Select appropriate sound clock rate
The average CTS value is based upon the (pixel) clock rate. Signed-off-by: Andrew Jackson <Andrew.Jackson@arm.com> Signed-off-by: Jon Medhurst <tixy@linaro.org>
-rw-r--r--drivers/gpu/drm/i2c/tda998x_codec.c1
-rw-r--r--drivers/gpu/drm/i2c/tda998x_drv.c24
2 files changed, 21 insertions, 4 deletions
diff --git a/drivers/gpu/drm/i2c/tda998x_codec.c b/drivers/gpu/drm/i2c/tda998x_codec.c
index 4f1d7590e267..c84d2b58f42d 100644
--- a/drivers/gpu/drm/i2c/tda998x_codec.c
+++ b/drivers/gpu/drm/i2c/tda998x_codec.c
@@ -117,6 +117,7 @@ static int tda_hw_params(struct snd_pcm_substream *substream,
tda998x_audio_start(priv, 0);
return 0;
}
+ priv->params.audio_sample_rate = params_rate(params);
priv->params.audio_format = dai->id;
priv->audio_sample_format = params_format(params);
priv->params.audio_cfg =
diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index a943d490b6b2..831e3d7f5abc 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -652,7 +652,7 @@ tda998x_configure_audio(struct tda998x_priv *priv,
struct drm_display_mode *mode, struct tda998x_encoder_params *p)
{
uint8_t buf[6], clksel_aip, clksel_fs, cts_n, adiv, aclk;
- uint32_t n;
+ uint32_t n, cts;
/* Enable audio ports */
reg_write(priv, REG_ENA_AP, p->audio_cfg);
@@ -723,9 +723,25 @@ tda998x_configure_audio(struct tda998x_priv *priv,
n = 128 * p->audio_sample_rate / 1000;
/* Write the CTS and N values */
- buf[0] = 0x44;
- buf[1] = 0x42;
- buf[2] = 0x01;
+ if ((n > 0) && (mode->clock > 0)) {
+ /*
+ * The average CTS value is calculated as:
+ *
+ * fTMDS * n / (128 * fs)
+ *
+ * which equates to:
+ *
+ * fTMDS / 1000
+ *
+ * for non-coherent clocks.
+ */
+ cts = mode->clock;
+ } else {
+ cts = 82500;
+ }
+ buf[0] = cts;
+ buf[1] = cts >> 8;
+ buf[2] = cts >> 16;
buf[3] = n;
buf[4] = n >> 8;
buf[5] = n >> 16;