[PATCH v2 01/13] drm/connector: Add helper to check if a mode requires scrambling
Maxime Ripard
maxime at cerno.tech
Thu Nov 18 10:38:02 UTC 2021
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.
Signed-off-by: Maxime Ripard <maxime at cerno.tech>
---
include/drm/drm_modes.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index 29ba4adf0c53..3bbf98ae59ae 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -424,6 +424,26 @@ 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
+ * @bpc: Pixels bit depth
+ *
+ * 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,
+ unsigned char bpc)
+{
+ unsigned long long clock = mode->crtc_clock * bpc;
+ do_div(clock, 8);
+
+ return mode->clock > 340000;
+}
+
struct drm_connector;
struct drm_cmdline_mode;
--
2.33.1
More information about the dri-devel
mailing list