From patchwork Wed Mar 22 17:36:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jose Abreu X-Patchwork-Id: 9640205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2DF0A6020B for ; Wed, 22 Mar 2017 22:26:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21B0828459 for ; Wed, 22 Mar 2017 22:26:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14E8C28485; Wed, 22 Mar 2017 22:26:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6486628459 for ; Wed, 22 Mar 2017 22:26:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 06E816E9B4; Wed, 22 Mar 2017 22:26:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtprelay.synopsys.com (us01smtprelay-2.synopsys.com [198.182.47.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFB396E955 for ; Wed, 22 Mar 2017 17:36:29 +0000 (UTC) Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id AFCBD24E0C78 for ; Wed, 22 Mar 2017 10:36:29 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 9A65062B; Wed, 22 Mar 2017 10:36:29 -0700 (PDT) Received: from joabreu-VirtualBox.internal.synopsys.com (joabreu-e7440.internal.synopsys.com [10.107.19.97]) by mailhost.synopsys.com (Postfix) with ESMTP id A7F75618; Wed, 22 Mar 2017 10:36:28 -0700 (PDT) From: Jose Abreu To: dri-devel@lists.freedesktop.org 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 Message-Id: <56cd65c7299ab0b8667fa020c146bdce17eb86a3.1490203284.git.joabreu@synopsys.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-Mailman-Approved-At: Wed, 22 Mar 2017 22:26:38 +0000 Cc: Jose Abreu , Carlos Palminha X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Perform sanity checks so that HDMI 2.0+ modes are not exported to drivers or userspace unless asked to. Signed-off-by: Jose Abreu Cc: Carlos Palminha 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;