[RFC 5/5] drm: Do not expose HDMI 2.0+ modes to userspace/drivers unless asked to

Jose Abreu Jose.Abreu at synopsys.com
Wed Mar 22 17:36:01 UTC 2017


Perform sanity checks so that HDMI 2.0+ modes are not exported to
drivers or userspace unless asked to.

Signed-off-by: Jose Abreu <joabreu at synopsys.com>
Cc: Carlos Palminha <palminha at synopsys.com>
Cc: dri-devel at lists.freedesktop.org
---
 drivers/gpu/drm/drm_connector.c    |  2 ++
 drivers/gpu/drm/drm_probe_helper.c |  9 ++++++++-
 include/drm/drm_modes.h            | 14 ++++++++++++++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 9f84761..430bb2b 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1200,6 +1200,8 @@ static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode,
 	 */
 	if (!file_priv->stereo_allowed && drm_mode_is_stereo(mode))
 		return false;
+	if (!file_priv->hdmi2_allowed && drm_mode_is_hdmi2(mode))
+		return false;
 
 	return true;
 }
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 85005d5..ddacb5d 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -77,6 +77,10 @@
 	    !(flags & DRM_MODE_FLAG_3D_MASK))
 		return MODE_NO_STEREO;
 
+	if ((mode->flags & DRM_MODE_FLAG_HDMI2) &&
+	    !(flags & DRM_MODE_FLAG_HDMI2))
+		return MODE_NO_HDMI2;
+
 	return MODE_OK;
 }
 
@@ -221,7 +225,8 @@ void drm_kms_helper_poll_enable(struct drm_device *dev)
  *    - drm_mode_validate_size() filters out modes larger than @maxX and @maxY
  *      (if specified)
  *    - drm_mode_validate_flag() checks the modes against basic connector
- *      capabilities (interlace_allowed,doublescan_allowed,stereo_allowed)
+ *      capabilities (interlace_allowed,doublescan_allowed,stereo_allowed,
+ *      hdmi2_allowed)
  *    - the optional &drm_connector_helper_funcs.mode_valid helper can perform
  *      driver and/or hardware specific checks
  *
@@ -336,6 +341,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
 		mode_flags |= DRM_MODE_FLAG_DBLSCAN;
 	if (connector->stereo_allowed)
 		mode_flags |= DRM_MODE_FLAG_3D_MASK;
+	if (connector->hdmi2_allowed)
+		mode_flags |= DRM_MODE_FLAG_HDMI2;
 
 	list_for_each_entry(mode, &connector->modes, head) {
 		if (mode->status == MODE_OK)
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index 6dd34280..83466ff 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -80,6 +80,7 @@
  * @MODE_ONE_SIZE: only one resolution is supported
  * @MODE_NO_REDUCED: monitor doesn't accept reduced blanking
  * @MODE_NO_STEREO: stereo modes not supported
+ * @MODE_NO_HDMI2: HDMI 2.0+ modes not supported
  * @MODE_STALE: mode has become stale
  * @MODE_BAD: unspecified reason
  * @MODE_ERROR: error condition
@@ -124,6 +125,7 @@ enum drm_mode_status {
 	MODE_ONE_SIZE,
 	MODE_NO_REDUCED,
 	MODE_NO_STEREO,
+	MODE_NO_HDMI2,
 	MODE_STALE = -3,
 	MODE_BAD = -2,
 	MODE_ERROR = -1
@@ -422,6 +424,18 @@ static inline bool drm_mode_is_stereo(const struct drm_display_mode *mode)
 	return mode->flags & DRM_MODE_FLAG_3D_MASK;
 }
 
+/**
+ * drm_mode_is_hdmi2 - check for HDMI 2.0+ mode flag
+ * @mode: drm_display_mode to check
+ *
+ * Returns:
+ * True if the mode is HDMI 2.0+ mode, false if not
+ */
+static inline bool drm_mode_is_hdmi2(const struct drm_display_mode *mode)
+{
+	return mode->flags & DRM_MODE_FLAG_HDMI2;
+}
+
 struct drm_connector;
 struct drm_cmdline_mode;
 
-- 
1.9.1




More information about the dri-devel mailing list