[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240222-kms-hdmi-connector-state-v7-23-8f4af575fce2@kernel.org>
Date: Thu, 22 Feb 2024 19:14:09 +0100
From: Maxime Ripard <mripard@...nel.org>
To: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Thomas Zimmermann <tzimmermann@...e.de>, David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>, Jonathan Corbet <corbet@....net>,
Sandy Huang <hjc@...k-chips.com>,
Heiko Stübner <heiko@...ech.de>,
Chen-Yu Tsai <wens@...e.org>, Jernej Skrabec <jernej.skrabec@...il.com>,
Samuel Holland <samuel@...lland.org>
Cc: Hans Verkuil <hverkuil@...all.nl>,
Sebastian Wick <sebastian.wick@...hat.com>,
Ville Syrjälä <ville.syrjala@...ux.intel.com>,
dri-devel@...ts.freedesktop.org, linux-arm-kernel@...ts.infradead.org,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org, linux-rockchip@...ts.infradead.org,
linux-sunxi@...ts.linux.dev, Maxime Ripard <mripard@...nel.org>,
Dave Stevenson <dave.stevenson@...pberrypi.com>
Subject: [PATCH v7 23/36] drm/connector: hdmi: Add RGB Quantization Range
to the connector state
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@...pberrypi.com>
Signed-off-by: Maxime Ripard <mripard@...nel.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
@@ -1147,6 +1147,7 @@ static void drm_atomic_connector_print_state(struct drm_printer *p,
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));
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index 0e8fb653965a..e66272c0d006 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -664,6 +664,33 @@ connector_state_get_mode(const struct drm_connector_state *conn_state)
return &crtc_state->mode;
}
+static bool hdmi_is_full_range(const struct drm_connector *connector,
+ const struct drm_connector_state *state)
+{
+ const struct drm_display_info *display = &connector->display_info;
+ const struct drm_display_mode *mode =
+ connector_state_get_mode(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 (state->hdmi.output_format != HDMI_COLORSPACE_RGB)
+ return false;
+
+ if (state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_FULL)
+ return true;
+
+ if (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,
@@ -910,6 +937,8 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,
connector_state_get_mode(new_state);
int ret;
+ new_state->hdmi.is_full_range = hdmi_is_full_range(connector, new_state);
+
ret = hdmi_compute_config(connector, new_state, mode);
if (ret)
return ret;
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
@@ -1070,6 +1070,12 @@ struct drm_connector_state {
*/
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.
*/
--
2.43.2
Powered by blists - more mailing lists