All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk+kernel@armlinux.org.uk>
To: Sven Van Asbroeck <thesven73@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	Jyri Sarha <jsarha@ti.com>
Cc: David Airlie <airlied@linux.ie>, dri-devel@lists.freedesktop.org
Subject: [PATCH v2 12/13] drm/i2c: tda998x: improve correctness of quantisation range
Date: Thu, 13 Jun 2019 15:31:52 +0100	[thread overview]
Message-ID: <E1hbQlc-00080J-0B@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20190613142943.vhgiy6yvyjz6uqlp@shell.armlinux.org.uk>

CEA-861 says: "A Source shall not send a non-zero Q value that does
not correspond to the default RGB Quantization Range for the
transmitted Picture unless the Sink indicates support for the Q bit
in a Video Capabilities Data Block."

Make TDA998x compliant by using the helper to set the quantisation
range in the infoframe, and using the TDA998x's colour scaling to
appropriately adjust the RGB values sent to the monitor.

This ensures that monitors that do not support the Q bit are sent
RGB values that are within the expected range.  Monitors with
support for the Q bit will be sent full-range RGB.

Reviewed-by: Brian Starkey <brian.starkey@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index d4409aa5ed7a..2d69aef556a5 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -67,6 +67,7 @@ struct tda998x_priv {
 	bool is_on;
 	bool supports_infoframes;
 	bool sink_has_audio;
+	enum hdmi_quantization_range rgb_quant_range;
 	u8 vip_cntrl_0;
 	u8 vip_cntrl_1;
 	u8 vip_cntrl_2;
@@ -870,6 +871,8 @@ tda998x_write_avi(struct tda998x_priv *priv, const struct drm_display_mode *mode
 	drm_hdmi_avi_infoframe_from_display_mode(&frame.avi,
 						 &priv->connector, mode);
 	frame.avi.quantization_range = HDMI_QUANTIZATION_RANGE_FULL;
+	drm_hdmi_avi_infoframe_quant_range(&frame.avi, &priv->connector, mode,
+					   priv->rgb_quant_range);
 
 	tda998x_write_if(priv, DIP_IF_FLAGS_IF2, REG_IF2_HB0, &frame);
 }
@@ -1427,6 +1430,16 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
 	u8 reg, div, rep, sel_clk;
 
 	/*
+	 * Since we are "computer" like, our source invariably produces
+	 * full-range RGB.  If the monitor supports full-range, then use
+	 * it, otherwise reduce to limited-range.
+	 */
+	priv->rgb_quant_range =
+		priv->connector.display_info.rgb_quant_range_selectable ?
+		HDMI_QUANTIZATION_RANGE_FULL :
+		drm_default_rgb_quant_range(adjusted_mode);
+
+	/*
 	 * Internally TDA998x is using ITU-R BT.656 style sync but
 	 * we get VESA style sync. TDA998x is using a reference pixel
 	 * relative to ITU to sync to the input frame and for output
@@ -1541,10 +1554,25 @@ static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
 	reg_write(priv, REG_PLL_SERIAL_2, PLL_SERIAL_2_SRL_NOSC(div) |
 			PLL_SERIAL_2_SRL_PR(rep));
 
-	/* set color matrix bypass flag: */
-	reg_write(priv, REG_MAT_CONTRL, MAT_CONTRL_MAT_BP |
-				MAT_CONTRL_MAT_SC(1));
-	reg_set(priv, REG_FEAT_POWERDOWN, FEAT_POWERDOWN_CSC);
+	/* set color matrix according to output rgb quant range */
+	if (priv->rgb_quant_range == HDMI_QUANTIZATION_RANGE_LIMITED) {
+		static u8 tda998x_full_to_limited_range[] = {
+			MAT_CONTRL_MAT_SC(2),
+			0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+			0x03, 0x6f, 0x00, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x03, 0x6f, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00, 0x03, 0x6f,
+			0x00, 0x40, 0x00, 0x40, 0x00, 0x40
+		};
+		reg_clear(priv, REG_FEAT_POWERDOWN, FEAT_POWERDOWN_CSC);
+		reg_write_range(priv, REG_MAT_CONTRL,
+				tda998x_full_to_limited_range,
+				sizeof(tda998x_full_to_limited_range));
+	} else {
+		reg_write(priv, REG_MAT_CONTRL, MAT_CONTRL_MAT_BP |
+					MAT_CONTRL_MAT_SC(1));
+		reg_set(priv, REG_FEAT_POWERDOWN, FEAT_POWERDOWN_CSC);
+	}
 
 	/* set BIAS tmds value: */
 	reg_write(priv, REG_ANA_GENERAL, 0x09);
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-06-13 14:34 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-11 11:00 [PATCH 00/13] tda998x updates Russell King - ARM Linux admin
2019-06-11 11:01 ` [PATCH 01/13] drm/i2c: tda998x: introduce tda998x_audio_settings Russell King
2019-06-12 15:24   ` Sven Van Asbroeck
2019-06-13  9:52     ` Russell King - ARM Linux admin
2019-06-11 11:01 ` [PATCH 02/13] drm/i2c: tda998x: implement different I2S flavours Russell King
2019-06-11 11:01 ` [PATCH 03/13] drm/i2c: tda998x: improve programming of audio divisor Russell King
2019-06-12 15:25   ` Sven Van Asbroeck
2019-06-12 16:26     ` Russell King - ARM Linux admin
2019-06-11 11:01 ` [PATCH 04/13] drm/i2c: tda998x: derive CTS_N value from aclk sample rate ratio Russell King
2019-06-12 15:27   ` Sven Van Asbroeck
2019-06-12 16:28     ` Russell King - ARM Linux admin
2019-06-12 16:37       ` Sven Van Asbroeck
2019-06-12 16:42         ` Russell King - ARM Linux admin
2019-06-12 16:45           ` Sven Van Asbroeck
2019-06-11 11:01 ` [PATCH 05/13] drm/i2c: tda998x: store audio port enable in settings Russell King
2019-06-11 11:02 ` [PATCH 06/13] drm/i2c: tda998x: index audio port enable config by route type Russell King
2019-06-11 11:02 ` [PATCH 07/13] drm/i2c: tda998x: configure both fields of AIP_CLKSEL together Russell King
2019-06-11 11:02 ` [PATCH 08/13] drm/i2c: tda998x: move audio routing configuration Russell King
2019-06-12 15:36   ` Sven Van Asbroeck
2019-06-12 16:32     ` Russell King - ARM Linux admin
2019-06-11 11:02 ` [PATCH 09/13] drm/i2c: tda998x: clean up tda998x_configure_audio() Russell King
2019-06-12 15:37   ` Sven Van Asbroeck
2019-06-11 11:02 ` [PATCH 10/13] drm/i2c: tda998x: get rid of params in audio settings Russell King
2019-06-11 11:02 ` [PATCH 11/13] drm/i2c: tda998x: add support for pixel repeated modes Russell King
2019-06-11 11:02 ` [PATCH 12/13] drm/i2c: tda998x: add bridge timing information Russell King
2019-06-12 15:38   ` Sven Van Asbroeck
2019-06-13 10:01     ` Russell King - ARM Linux admin
2019-06-11 11:02 ` [PATCH 13/13] drm/i2c: tda998x: improve correctness of quantisation range Russell King
2019-06-12 15:40 ` [PATCH 00/13] tda998x updates Sven Van Asbroeck
2019-06-13 10:52   ` Russell King - ARM Linux admin
2019-06-13 14:29 ` [PATCH v2 " Russell King - ARM Linux admin
2019-06-13 14:30   ` [PATCH v2 01/13] drm/i2c: tda998x: introduce tda998x_audio_settings Russell King
2019-06-13 18:48     ` Sven Van Asbroeck
2019-06-13 20:36       ` Russell King - ARM Linux admin
2019-06-13 14:31   ` [PATCH v2 02/13] drm/i2c: tda998x: implement different I2S flavours Russell King
2019-06-13 14:31   ` [PATCH v2 03/13] drm/i2c: tda998x: improve programming of audio divisor Russell King
2019-06-13 14:31   ` [PATCH v2 04/13] drm/i2c: tda998x: derive CTS_N value from aclk sample rate ratio Russell King
2019-06-13 14:31   ` [PATCH v2 05/13] drm/i2c: tda998x: store audio port enable in settings Russell King
2019-06-13 14:31   ` [PATCH v2 06/13] drm/i2c: tda998x: index audio port enable config by route type Russell King
2019-06-13 14:31   ` [PATCH v2 07/13] drm/i2c: tda998x: configure both fields of AIP_CLKSEL together Russell King
2019-06-13 14:31   ` [PATCH v2 08/13] drm/i2c: tda998x: move audio routing configuration Russell King
2019-06-13 14:31   ` [PATCH v2 09/13] drm/i2c: tda998x: clean up tda998x_configure_audio() Russell King
2019-06-13 14:31   ` [PATCH v2 10/13] drm/i2c: tda998x: get rid of params in audio settings Russell King
2019-06-13 14:31   ` [PATCH v2 11/13] drm/i2c: tda998x: add support for pixel repeated modes Russell King
2019-06-13 14:31   ` Russell King [this message]
2019-06-13 14:31   ` [PATCH v2 13/13] drm/i2c: tda998x: add vendor specific infoframe support Russell King
2019-06-13 19:51   ` [PATCH v2 00/13] tda998x updates Sven Van Asbroeck
2019-06-13 20:56     ` Russell King - ARM Linux admin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1hbQlc-00080J-0B@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=airlied@linux.ie \
    --cc=broonie@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jsarha@ti.com \
    --cc=peter.ujfalusi@ti.com \
    --cc=thesven73@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.