All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jose Abreu <Jose.Abreu@synopsys.com>
To: dri-devel@lists.freedesktop.org
Cc: Jose Abreu <Jose.Abreu@synopsys.com>,
	Carlos Palminha <CARLOS.PALMINHA@synopsys.com>
Subject: [RFC 5/5] drm: Do not expose HDMI 2.0+ modes to userspace/drivers unless asked to
Date: Wed, 22 Mar 2017 17:36:01 +0000	[thread overview]
Message-ID: <56cd65c7299ab0b8667fa020c146bdce17eb86a3.1490203284.git.joabreu@synopsys.com> (raw)
In-Reply-To: <cover.1490203284.git.joabreu@synopsys.com>
In-Reply-To: <cover.1490203284.git.joabreu@synopsys.com>

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@synopsys.com>
Cc: Carlos Palminha <palminha@synopsys.com>
Cc: dri-devel@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


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2017-03-22 17:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 17:35 [RFC 0/5] HDMI 2.0+ video modes handling in DRM core Jose Abreu
2017-03-22 17:35 ` [RFC 1/5] drm: Add HDMI 2.0+ features exposing knob Jose Abreu
2017-03-23  7:22   ` Daniel Vetter
2017-03-23 10:44     ` Jose Abreu
2017-03-23 11:00       ` Daniel Vetter
2017-03-27 13:47         ` Jose Abreu
2017-03-28  6:17           ` Daniel Vetter
2017-03-22 17:35 ` [RFC 2/5] drm: uapi: Add HDMI 2.0 aspect ratio flags and HDMI 2.0+ mode flag Jose Abreu
2017-03-23 15:16   ` Ville Syrjälä
2017-03-23 18:54     ` Jose Abreu
2017-03-23 19:00       ` Ville Syrjälä
2017-03-23 19:09         ` Jose Abreu
2017-03-22 17:35 ` [RFC 3/5] drm: edid: Add HDMI 2.0 CEA video modes Jose Abreu
2017-03-23  8:11   ` Andrzej Hajda
2017-03-23 11:04     ` Jose Abreu
2017-03-23 11:17       ` Andrzej Hajda
2017-03-23 11:35         ` Jose Abreu
2017-03-23 14:50           ` Andrzej Hajda
2017-03-23 11:07     ` Sharma, Shashank
2017-03-23 15:26       ` Sharma, Shashank
2017-03-22 17:36 ` [RFC 4/5] drm: connector: Add hdmi2_allowed flag Jose Abreu
2017-03-22 17:36 ` Jose Abreu [this message]
2017-03-23  7:25   ` [RFC 5/5] drm: Do not expose HDMI 2.0+ modes to userspace/drivers unless asked to Daniel Vetter
2017-03-23 11:02     ` Jose Abreu
2017-03-22 18:13 ` [RFC 0/5] HDMI 2.0+ video modes handling in DRM core Jose Abreu
2017-03-22 18:57   ` Sharma, Shashank
2017-03-23 10:37     ` Jose Abreu
2017-03-23 10:56       ` Sharma, Shashank

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=56cd65c7299ab0b8667fa020c146bdce17eb86a3.1490203284.git.joabreu@synopsys.com \
    --to=jose.abreu@synopsys.com \
    --cc=CARLOS.PALMINHA@synopsys.com \
    --cc=dri-devel@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.