[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230920-kms-hdmi-connector-state-v2-4-17932daddd7d@kernel.org>
Date: Wed, 20 Sep 2023 16:35:19 +0200
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>, Emma Anholt <emma@...olt.net>,
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>, 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>
Subject: [PATCH RFC v2 04/37] drm/connector: hdmi: Add helper to get the
RGB range
HDMI controller drivers will need to figure out the RGB range they need
to configure based on a given atomic state.
Let's provide a helper to provide that information.
Signed-off-by: Maxime Ripard <mripard@...nel.org>
---
drivers/gpu/drm/drm_atomic_state_helper.c | 39 +++++++++++++++++++++++++++++++
include/drm/drm_atomic_state_helper.h | 5 ++++
2 files changed, 44 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index 4b24ebb7e3e8..0f7e5ba555b8 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -31,6 +31,7 @@
#include <drm/drm_connector.h>
#include <drm/drm_crtc.h>
#include <drm/drm_device.h>
+#include <drm/drm_edid.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_plane.h>
#include <drm/drm_print.h>
@@ -621,6 +622,15 @@ int drm_atomic_helper_connector_tv_check(struct drm_connector *connector,
}
EXPORT_SYMBOL(drm_atomic_helper_connector_tv_check);
+static const struct drm_display_mode *
+connector_state_get_adjusted_mode(const struct drm_connector_state *state)
+{
+ struct drm_crtc *crtc = state->crtc;
+ struct drm_crtc_state *crtc_state = crtc->state;
+
+ return &crtc_state->adjusted_mode;
+}
+
/**
* drm_atomic_helper_connector_hdmi_check() - Helper to check HDMI connector atomic state
* @connector: DRM Connector
@@ -656,6 +666,35 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector,
}
EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_check);
+/**
+ * drm_atomic_helper_connector_hdmi_is_full_range() - Checks whether a state uses Full-Range RGB
+ * @connector: the HDMI connector this state refers to
+ * @state: the HDMI connector state to check
+ *
+ * RETURNS:
+ * True if @state requires a Full range RGB output, False otherwise
+ */
+bool
+drm_atomic_helper_connector_hdmi_is_full_range(const struct drm_connector *connector,
+ const struct drm_connector_state *state)
+{
+ const struct drm_display_mode *mode =
+ connector_state_get_adjusted_mode(state);
+ const struct drm_display_info *display = &connector->display_info;
+
+ 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);
+}
+EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_is_full_range);
+
/**
* __drm_atomic_helper_connector_duplicate_state - copy atomic connector state
* @connector: connector object
diff --git a/include/drm/drm_atomic_state_helper.h b/include/drm/drm_atomic_state_helper.h
index d59d2b3aef9a..c6d941b9e846 100644
--- a/include/drm/drm_atomic_state_helper.h
+++ b/include/drm/drm_atomic_state_helper.h
@@ -88,6 +88,11 @@ void
__drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state);
void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
struct drm_connector_state *state);
+
+bool
+drm_atomic_helper_connector_hdmi_is_full_range(const struct drm_connector *connector,
+ const struct drm_connector_state *state);
+
void __drm_atomic_helper_private_obj_duplicate_state(struct drm_private_obj *obj,
struct drm_private_state *state);
--
2.41.0
Powered by blists - more mailing lists