From: Maxime Ripard <maxime@cerno.tech>
To: Daniel Vetter <daniel.vetter@intel.com>,
David Airlie <airlied@linux.ie>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
Maxime Ripard <maxime@cerno.tech>
Cc: Dom Cobley <dom@raspberrypi.com>,
Tim Gover <tim.gover@raspberrypi.com>,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
dri-devel@lists.freedesktop.org,
Jonathan Hunter <jonathanh@nvidia.com>,
Thierry Reding <thierry.reding@gmail.com>,
Emma Anholt <emma@anholt.net>,
linux-tegra@vger.kernel.org, Phil Elwell <phil@raspberrypi.com>
Subject: [PATCH 02/13] drm/connector: Add helper to check if a mode requires scrambling
Date: Tue, 2 Nov 2021 15:59:33 +0100 [thread overview]
Message-ID: <20211102145944.259181-3-maxime@cerno.tech> (raw)
In-Reply-To: <20211102145944.259181-1-maxime@cerno.tech>
Most drivers supporting the HDMI scrambling seem to have the HDMI 1.4
maximum frequency open-coded, and a function to test whether a display
mode is above that threshold to control whether or not scrambling should
be enabled.
Let's create a common define and helper for drivers to reuse.
Cc: Emma Anholt <emma@anholt.net>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-tegra@vger.kernel.org
Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
drivers/gpu/drm/tegra/sor.c | 4 ++--
drivers/gpu/drm/vc4/vc4_hdmi.c | 21 +++++++++------------
include/drm/drm_modes.h | 15 +++++++++++++++
3 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
index 99a2d627bfeb..390bd04b0d22 100644
--- a/drivers/gpu/drm/tegra/sor.c
+++ b/drivers/gpu/drm/tegra/sor.c
@@ -2192,11 +2192,11 @@ static void tegra_sor_hdmi_scdc_work(struct work_struct *work)
static void tegra_sor_hdmi_scdc_start(struct tegra_sor *sor)
{
struct drm_scdc *scdc = &sor->output.connector.display_info.hdmi.scdc;
- struct drm_display_mode *mode;
+ const struct drm_display_mode *mode;
mode = &sor->output.encoder.crtc->state->adjusted_mode;
- if (mode->clock >= DRM_HDMI_14_MAX_TMDS_CLK_KHZ && scdc->supported) {
+ if (drm_mode_hdmi_requires_scrambling(mode) && scdc->supported) {
schedule_delayed_work(&sor->scdc, msecs_to_jiffies(5000));
tegra_sor_hdmi_scdc_enable(sor);
sor->scdc_enabled = true;
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index fc7247cc1022..fa76ae2c94e4 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -99,11 +99,6 @@
#define HDMI_14_MAX_TMDS_CLK (DRM_HDMI_14_MAX_TMDS_CLK_KHZ * 1000)
-static bool vc4_hdmi_mode_needs_scrambling(const struct drm_display_mode *mode)
-{
- return mode->clock > DRM_HDMI_14_MAX_TMDS_CLK_KHZ;
-}
-
static int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused)
{
struct drm_info_node *node = (struct drm_info_node *)m->private;
@@ -260,10 +255,10 @@ static int vc4_hdmi_connector_get_modes(struct drm_connector *connector)
if (vc4_hdmi->disable_4kp60) {
struct drm_device *drm = connector->dev;
- struct drm_display_mode *mode;
+ const struct drm_display_mode *mode;
list_for_each_entry(mode, &connector->probed_modes, head) {
- if (vc4_hdmi_mode_needs_scrambling(mode)) {
+ if (drm_mode_hdmi_requires_scrambling(mode)) {
drm_warn_once(drm, "The core clock cannot reach frequencies high enough to support 4k @ 60Hz.");
drm_warn_once(drm, "Please change your config.txt file to add hdmi_enable_4kp60.");
}
@@ -574,7 +569,7 @@ static void vc4_hdmi_set_infoframes(struct drm_encoder *encoder)
}
static bool vc4_hdmi_supports_scrambling(struct drm_encoder *encoder,
- struct drm_display_mode *mode)
+ const struct drm_display_mode *mode)
{
struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
@@ -597,7 +592,7 @@ static bool vc4_hdmi_supports_scrambling(struct drm_encoder *encoder,
static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder)
{
struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
- struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode;
+ const struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode;
unsigned long flags;
lockdep_assert_held(&vc4_hdmi->mutex);
@@ -605,7 +600,7 @@ static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder)
if (!vc4_hdmi_supports_scrambling(encoder, mode))
return;
- if (!vc4_hdmi_mode_needs_scrambling(mode))
+ if (!drm_mode_hdmi_requires_scrambling(mode))
return;
drm_scdc_set_high_tmds_clock_ratio(vc4_hdmi->ddc, true);
@@ -1283,7 +1278,8 @@ static int vc4_hdmi_encoder_atomic_check(struct drm_encoder *encoder,
if (pixel_rate > vc4_hdmi->variant->max_pixel_clock)
return -EINVAL;
- if (vc4_hdmi->disable_4kp60 && (pixel_rate > HDMI_14_MAX_TMDS_CLK))
+ if (vc4_hdmi->disable_4kp60 &&
+ drm_mode_hdmi_requires_scrambling(mode))
return -EINVAL;
vc4_state->pixel_rate = pixel_rate;
@@ -1305,7 +1301,8 @@ vc4_hdmi_encoder_mode_valid(struct drm_encoder *encoder,
if ((mode->clock * 1000) > vc4_hdmi->variant->max_pixel_clock)
return MODE_CLOCK_HIGH;
- if (vc4_hdmi->disable_4kp60 && vc4_hdmi_mode_needs_scrambling(mode))
+ if (vc4_hdmi->disable_4kp60 &&
+ drm_mode_hdmi_requires_scrambling(mode))
return MODE_CLOCK_HIGH;
return MODE_OK;
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index 29ba4adf0c53..d22816d55836 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -424,6 +424,21 @@ static inline bool drm_mode_is_stereo(const struct drm_display_mode *mode)
return mode->flags & DRM_MODE_FLAG_3D_MASK;
}
+/**
+ * drm_mode_hdmi_requires_scrambling - Checks if a mode requires HDMI Scrambling
+ * @mode: DRM display mode
+ *
+ * Checks if a given display mode requires the scrambling to be enabled.
+ *
+ * Returns:
+ * A boolean stating whether it's required or not.
+ */
+static inline bool
+drm_mode_hdmi_requires_scrambling(const struct drm_display_mode *mode)
+{
+ return mode->clock > DRM_HDMI_14_MAX_TMDS_CLK_KHZ;
+}
+
struct drm_connector;
struct drm_cmdline_mode;
--
2.32.0
next prev parent reply other threads:[~2021-11-02 15:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-02 14:59 [PATCH 00/13] drm: Add generic helpers for HDMI scrambling Maxime Ripard
2021-11-02 14:59 ` [PATCH 01/13] drm/connector: Add define for HDMI 1.4 Maximum Pixel Rate Maxime Ripard
2021-11-02 17:50 ` Alex Deucher
2021-11-03 9:08 ` Neil Armstrong
2021-11-03 11:02 ` Ville Syrjälä
2021-11-03 18:05 ` Ville Syrjälä
2021-11-04 8:48 ` Maxime Ripard
2021-11-04 15:41 ` Ville Syrjälä
2021-11-08 14:59 ` Maxime Ripard
2021-11-02 14:59 ` Maxime Ripard [this message]
2021-11-04 15:37 ` [PATCH 02/13] drm/connector: Add helper to check if a mode requires scrambling Ville Syrjälä
2021-11-05 18:02 ` Daniel Vetter
2021-11-05 18:14 ` Ville Syrjälä
2021-11-08 15:58 ` Maxime Ripard
2021-11-08 16:03 ` Daniel Vetter
2021-11-08 17:55 ` Ville Syrjälä
2021-11-15 12:15 ` Maxime Ripard
2021-11-17 10:01 ` Maxime Ripard
2021-11-02 14:59 ` [PATCH 03/13] drm/atomic: Add HDMI scrambler state helper Maxime Ripard
2021-11-02 14:59 ` [PATCH 04/13] drm/atomic: Add HDMI reset link helper Maxime Ripard
2021-11-02 14:59 ` [PATCH 05/13] drm/scdc: Document hotplug gotchas Maxime Ripard
2021-11-02 14:59 ` [PATCH 06/13] drm/vc4: hdmi: Remove unused argument in vc4_hdmi_supports_scrambling Maxime Ripard
2021-11-02 14:59 ` [PATCH 07/13] drm/vc4: hdmi: Remove mutex in detect Maxime Ripard
2021-11-02 14:59 ` [PATCH 08/13] drm/vc4: hdmi: Remove HDMI flag from encoder Maxime Ripard
2021-11-02 14:59 ` [PATCH 09/13] drm/vc4: hdmi: Simplify the hotplug handling Maxime Ripard
2021-11-02 14:59 ` [PATCH 10/13] drm/vc4: hdmi: Simplify the connector state retrieval Maxime Ripard
2021-11-02 14:59 ` [PATCH 11/13] drm/vc4: hdmi: Switch to detect_ctx Maxime Ripard
2021-11-02 14:59 ` [PATCH 12/13] drm/vc4: hdmi: Leverage new SCDC atomic_check Maxime Ripard
2021-11-02 14:59 ` [PATCH 13/13] drm/vc4: hdmi: Reset link on hotplug 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=20211102145944.259181-3-maxime@cerno.tech \
--to=maxime@cerno.tech \
--cc=airlied@linux.ie \
--cc=daniel.vetter@intel.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=dom@raspberrypi.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emma@anholt.net \
--cc=jonathanh@nvidia.com \
--cc=linux-tegra@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=phil@raspberrypi.com \
--cc=thierry.reding@gmail.com \
--cc=tim.gover@raspberrypi.com \
--cc=tzimmermann@suse.de \
/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).