linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <mripard@kernel.org>
To: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Sandy Huang" <hjc@rock-chips.com>,
	"Heiko Stübner" <heiko@sntech.de>, "Chen-Yu Tsai" <wens@csie.org>,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	"Samuel Holland" <samuel@sholland.org>
Cc: "Hans Verkuil" <hverkuil@xs4all.nl>,
	"Sebastian Wick" <sebastian.wick@redhat.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	dri-devel@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev,
	"Maxime Ripard" <mripard@kernel.org>,
	"Dave Stevenson" <dave.stevenson@raspberrypi.com>
Subject: [PATCH v10 18/27] drm/connector: hdmi: Add RGB Quantization Range to the connector state
Date: Thu, 21 Mar 2024 16:29:14 +0100	[thread overview]
Message-ID: <20240321-kms-hdmi-connector-state-v10-18-e6c178361898@kernel.org> (raw)
In-Reply-To: <20240321-kms-hdmi-connector-state-v10-0-e6c178361898@kernel.org>

HDMI controller drivers will need to figure out the RGB range they need
to configure based on a mode and property values. Let's expose that in
the HDMI connector state so drivers can just use that value.

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
 drivers/gpu/drm/drm_atomic.c              |  1 +
 drivers/gpu/drm/drm_atomic_state_helper.c | 29 +++++++++++++++++++++++++++++
 include/drm/drm_connector.h               |  6 ++++++
 3 files changed, 36 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 3e57d98d8418..ec6c6beda5c9 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1145,10 +1145,11 @@ static void drm_atomic_connector_print_state(struct drm_printer *p,
 
 	if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
 	    connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) {
 		drm_printf(p, "\tbroadcast_rgb=%s\n",
 			   drm_hdmi_connector_get_broadcast_rgb_name(state->hdmi.broadcast_rgb));
+		drm_printf(p, "\tis_full_range=%c\n", state->hdmi.is_full_range ? 'y' : 'n');
 		drm_printf(p, "\toutput_bpc=%u\n", state->hdmi.output_bpc);
 		drm_printf(p, "\toutput_format=%s\n",
 			   drm_hdmi_connector_get_output_format_name(state->hdmi.output_format));
 		drm_printf(p, "\ttmds_char_rate=%llu\n", state->hdmi.tmds_char_rate);
 	}
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index 2ad3cfafde27..8d436fdc5c91 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -662,10 +662,37 @@ connector_state_get_mode(const struct drm_connector_state *conn_state)
 		return NULL;
 
 	return &crtc_state->mode;
 }
 
+static bool hdmi_is_full_range(const struct drm_connector *connector,
+			       const struct drm_connector_state *conn_state)
+{
+	const struct drm_display_info *display = &connector->display_info;
+	const struct drm_display_mode *mode =
+		connector_state_get_mode(conn_state);
+
+	/*
+	 * The Broadcast RGB property only applies to RGB format, and
+	 * i915 just assumes limited range for YCbCr output, so let's
+	 * just do the same.
+	 */
+	if (conn_state->hdmi.output_format != HDMI_COLORSPACE_RGB)
+		return false;
+
+	if (conn_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_FULL)
+		return true;
+
+	if (conn_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED)
+		return false;
+
+	if (!display->is_hdmi)
+		return true;
+
+	return drm_default_rgb_quant_range(mode) == HDMI_QUANTIZATION_RANGE_FULL ? true : false;
+}
+
 static bool
 sink_supports_format_bpc(const struct drm_connector *connector,
 			 const struct drm_display_info *info,
 			 const struct drm_display_mode *mode,
 			 unsigned int format, unsigned int bpc)
@@ -920,10 +947,12 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,
 		drm_atomic_get_new_connector_state(state, connector);
 	const struct drm_display_mode *mode =
 		connector_state_get_mode(new_conn_state);
 	int ret;
 
+	new_conn_state->hdmi.is_full_range = hdmi_is_full_range(connector, new_conn_state);
+
 	ret = hdmi_compute_config(connector, new_conn_state, mode);
 	if (ret)
 		return ret;
 
 	if (old_conn_state->hdmi.broadcast_rgb != new_conn_state->hdmi.broadcast_rgb ||
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index bb6b6a36ade3..3eaf4d54364d 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1068,10 +1068,16 @@ struct drm_connector_state {
 		 * @broadcast_rgb: Connector property to pass the
 		 * Broadcast RGB selection value.
 		 */
 		enum drm_hdmi_broadcast_rgb broadcast_rgb;
 
+		/**
+		 * @is_full_range: Is the output supposed to use a full
+		 * RGB Quantization Range or not?
+		 */
+		bool is_full_range;
+
 		/**
 		 * @output_bpc: Bits per color channel to output.
 		 */
 		unsigned int output_bpc;
 

-- 
2.44.0


  parent reply	other threads:[~2024-03-21 15:30 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-21 15:28 [PATCH v10 00/27] drm/connector: Create HDMI Connector infrastructure Maxime Ripard
2024-03-21 15:28 ` [PATCH v10 01/27] drm/connector: Introduce an HDMI connector initialization function Maxime Ripard
2024-03-21 15:28 ` [PATCH v10 02/27] drm/tests: connector: Add tests for drmm_connector_hdmi_init Maxime Ripard
2024-03-21 15:28 ` [PATCH v10 03/27] drm/connector: hdmi: Create an HDMI sub-state Maxime Ripard
2024-03-21 22:32   ` [v10,03/27] " Sui Jingfeng
2024-03-21 15:29 ` [PATCH v10 04/27] drm/connector: hdmi: Add output BPC to the connector state Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 05/27] drm/tests: Add output bpc tests Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 06/27] drm/connector: hdmi: Add support for output format Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 07/27] drm/tests: Add output formats tests Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 08/27] drm/connector: hdmi: Add HDMI compute clock helper Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 09/27] drm/tests: Add HDMI TDMS character rate tests Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 10/27] drm/connector: hdmi: Calculate TMDS character rate Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 11/27] drm/tests: Add TDMS character rate connector state tests Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 12/27] drm/connector: hdmi: Add custom hook to filter TMDS character rate Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 13/27] drm/tests: Add HDMI connector rate filter hook tests Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 14/27] drm/connector: hdmi: Compute bpc and format automatically Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 15/27] drm/tests: Add HDMI connector bpc and format tests Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 16/27] drm/connector: hdmi: Add Broadcast RGB property Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 17/27] drm/tests: Add tests for " Maxime Ripard
2024-03-21 15:29 ` Maxime Ripard [this message]
2024-03-21 15:29 ` [PATCH v10 19/27] drm/tests: Add RGB Quantization tests Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 20/27] drm/connector: hdmi: Add Infoframes generation Maxime Ripard
2024-03-21 21:53   ` [v10,20/27] " Sui Jingfeng
2024-03-22  9:22     ` Jani Nikula
2024-03-22 10:57       ` Maxime Ripard
2024-03-22 11:46         ` Jani Nikula
2024-03-22 11:28       ` Sui Jingfeng
2024-03-22 10:31     ` Maxime Ripard
2024-03-22 11:13       ` Sui Jingfeng
2024-03-22 12:31         ` Maxime Ripard
2024-03-22 14:30           ` Sui Jingfeng
2024-03-21 15:29 ` [PATCH v10 21/27] drm/tests: Add infoframes test Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 22/27] drm/connector: hdmi: Create Infoframe DebugFS entries Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 23/27] drm/vc4: hdmi: Switch to HDMI connector Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 24/27] drm/vc4: tests: Remove vc4_dummy_plane structure Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 25/27] drm/vc4: tests: Convert to plane creation helper Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 26/27] drm/rockchip: inno_hdmi: Switch to HDMI connector Maxime Ripard
2024-03-21 15:29 ` [PATCH v10 27/27] drm/sun4i: hdmi: " Maxime Ripard

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=20240321-kms-hdmi-connector-state-v10-18-e6c178361898@kernel.org \
    --to=mripard@kernel.org \
    --cc=airlied@gmail.com \
    --cc=corbet@lwn.net \
    --cc=daniel@ffwll.ch \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=samuel@sholland.org \
    --cc=sebastian.wick@redhat.com \
    --cc=tzimmermann@suse.de \
    --cc=ville.syrjala@linux.intel.com \
    --cc=wens@csie.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).