From patchwork Wed Feb 1 12:44:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sharma, Shashank" X-Patchwork-Id: 9549575 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 B28AD60424 for ; Wed, 1 Feb 2017 12:33:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4F3D2842B for ; Wed, 1 Feb 2017 12:33:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99F9628434; Wed, 1 Feb 2017 12:33:49 +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=unavailable 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 E89952842B for ; Wed, 1 Feb 2017 12:33:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C93DF6E7BD; Wed, 1 Feb 2017 12:33:34 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id D28036E7B9; Wed, 1 Feb 2017 12:33:32 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2017 04:33:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,320,1477983600"; d="scan'208";a="815799213" Received: from shashanks-desktop.iind.intel.com ([10.223.26.24]) by FMSMGA003.fm.intel.com with ESMTP; 01 Feb 2017 04:33:30 -0800 From: Shashank Sharma To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, ville.syrjala@linux.intel.com Date: Wed, 1 Feb 2017 18:14:39 +0530 Message-Id: <1485953081-7630-5-git-send-email-shashank.sharma@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485953081-7630-1-git-send-email-shashank.sharma@intel.com> References: <1485953081-7630-1-git-send-email-shashank.sharma@intel.com> Cc: jose.abreu@synopsys.com, =daniel.vetter@intel.com, thierry.reding@gmail.com Subject: [Intel-gfx] [PATCH 4/6] drm: scrambling support in drm layer X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP HDMI 2.0 spec mandates scrambling for modes with pixel clock higher than 340Mhz. This patch adds few new functions in drm layer for core drivers to enable/disable scrambling. This patch adds: - A function to detect scrambling support parsing HF-VSDB - A function to check scrambling status runtime using SCDC read. - Two functions to enable/disable scrambling using SCDC read/write. - Few new bools to reflect scrambling support and status. Signed-off-by: Shashank Sharma --- drivers/gpu/drm/drm_edid.c | 131 +++++++++++++++++++++++++++++++++++++++++++- include/drm/drm_connector.h | 24 ++++++++ include/drm/drm_edid.h | 6 +- 3 files changed, 159 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 37902e5..f0d940a 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -37,6 +37,7 @@ #include #include #include +#include #define version_greater(edid, maj, min) \ (((edid)->version > (maj)) || \ @@ -3814,6 +3815,132 @@ static void drm_detect_hdmi_scdc(struct drm_connector *connector, } } +static void drm_detect_hdmi_scrambling(struct drm_connector *connector, + const u8 *hf_vsdb) +{ + struct drm_display_info *display = &connector->display_info; + struct drm_hdmi_info *hdmi = &display->hdmi_info; + + /* + * All HDMI 2.0 monitors must support scrambling at rates > 340M. + * And as per the spec, three factors confirm this: + * * Availability of a HF-VSDB block in EDID (check) + * * Non zero Max_TMDS_Char_Rate filed in HF-VSDB + * * SCDC support available + * Lets check it out. + */ + + if (hf_vsdb[5]) { + display->max_tmds_clock = hf_vsdb[5] * 5000; + DRM_DEBUG_KMS("HF-VSDB: max TMDS clock %d kHz\n", + display->max_tmds_clock); + + if (hdmi->scdc_supported) { + hdmi->scr_info.supported = true; + + /* Few sinks support scrambling for cloks < 340M */ + if ((hf_vsdb[6] & 0x8)) + hdmi->scr_info.low_clocks = true; + } + } +} + +/** + * drm_check_scrambling_status - what is status of scrambling? + * @adapter: i2c adapter for SCDC channel + * + * Read the scrambler status over SCDC channel, and check the + * scrambling status. + * + * Return: True if the scrambling is enabled, false otherwise. + */ + +bool drm_check_scrambling_status(struct i2c_adapter *adapter) +{ + u8 status; + + if (drm_scdc_readb(adapter, SCDC_SCRAMBLER_STATUS, &status) < 0) { + DRM_ERROR("Failed to read scrambling status\n"); + return false; + } + + status &= SCDC_SCRAMBLING_STATUS; + return status != 0; +} + +/** + * drm_enable_scrambling - enable scrambling + * @connector: target drm_connector + * @adapter: i2c adapter for SCDC channel + * @force: enable scrambling, even if its already enabled + * + * Write the TMDS config over SCDC channel, and enable scrambling + * Return: True if scrambling is successfully enabled, false otherwise. + */ + +bool drm_enable_scrambling(struct drm_connector *connector, + struct i2c_adapter *adapter, bool force) +{ + u8 config; + struct drm_hdmi_info *hdmi_info = &connector->display_info.hdmi_info; + + if (hdmi_info->scr_info.status && !force) { + DRM_DEBUG_KMS("Scrambling already enabled\n"); + return true; + } + + if (drm_scdc_readb(adapter, SCDC_TMDS_CONFIG, &config) < 0) { + DRM_ERROR("Failed to read tmds config\n"); + return false; + } + + config |= SCDC_SCRAMBLING_ENABLE; + + if (drm_scdc_writeb(adapter, SCDC_TMDS_CONFIG, config) < 0) { + DRM_ERROR("Failed to enable scrambling, write error\n"); + return false; + } + + hdmi_info->scr_info.status = drm_check_scrambling_status(adapter); + return hdmi_info->scr_info.status; +} + +/** + * drm_disable_scrambling - disable scrambling + * @connector: target drm_connector + * @adapter: i2c adapter for SCDC channel + * @force: disable scrambling, even if its already disabled + * + * Write the TMDS config over SCDC channel, and disable scrambling + * Return: True if scrambling is successfully disabled, false otherwise. + */ +bool drm_disable_scrambling(struct drm_connector *connector, + struct i2c_adapter *adapter, bool force) +{ + u8 config; + struct drm_hdmi_info *hdmi_info = &connector->display_info.hdmi_info; + + if (!hdmi_info->scr_info.status && !force) { + DRM_DEBUG_KMS("Scrambling already disabled\n"); + return true; + } + + if (drm_scdc_readb(adapter, SCDC_TMDS_CONFIG, &config) < 0) { + DRM_ERROR("Failed to read tmds config\n"); + return false; + } + + config &= ~SCDC_SCRAMBLING_ENABLE; + + if (drm_scdc_writeb(adapter, SCDC_TMDS_CONFIG, config) < 0) { + DRM_ERROR("Failed to enable scrambling, write error\n"); + return false; + } + + hdmi_info->scr_info.status = drm_check_scrambling_status(adapter); + return !hdmi_info->scr_info.status; +} + static void drm_parse_hdmi_deep_color_info(struct drm_connector *connector, const u8 *hdmi) { @@ -3928,8 +4055,10 @@ static void drm_parse_cea_ext(struct drm_connector *connector, if (cea_db_is_hdmi_vsdb(db)) drm_parse_hdmi_vsdb_video(connector, db); - if (cea_db_is_hdmi_forum_vsdb(db)) + if (cea_db_is_hdmi_forum_vsdb(db)) { drm_detect_hdmi_scdc(connector, db); + drm_detect_hdmi_scrambling(connector, db); + } } } diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 2435598..b9735bd 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -90,6 +90,26 @@ enum subpixel_order { }; + +/** + * struct scrambling: sink's scrambling support. + */ +struct scrambling { + /** + * @supported: scrambling supported for rates > 340Mhz. + */ + bool supported; + /** + * @low_clocks: scrambling supported for rates <= 340Mhz. + */ + bool low_clocks; + /** + * @status: scrambling enabled/disabled ? + */ + bool status; +}; + + /** * struct drm_hdmi_info - runtime data about the connected sink * @@ -108,6 +128,10 @@ struct drm_hdmi_info { * @scdc_rr: sink is capable of generating scdc read request. */ bool scdc_rr; + /** + * scr_info: sink's scrambling support and capabilities. + */ + struct scrambling scr_info; }; /** diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 43fb0ac..d24c974 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -462,5 +462,9 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name, struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, int hsize, int vsize, int fresh, bool rb); - +bool drm_enable_scrambling(struct drm_connector *connector, + struct i2c_adapter *adapter, bool force); +bool drm_disable_scrambling(struct drm_connector *connector, + struct i2c_adapter *adapter, bool force); +bool drm_check_scrambling_status(struct i2c_adapter *adapter); #endif /* __DRM_EDID_H__ */