Re: [Intel-gfx] [PATCH 4/6] drm: scrambling support in drm layer
Thanks for the review, Dhinakaran. Regards Shashank On 2/2/2017 1:23 AM, Pandiyan, Dhinakaran wrote: On Wed, 2017-02-01 at 18:14 +0530, Shashank Sharma wrote: 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 = >display_info; + struct drm_hdmi_info *hdmi = >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; Comment explaining or quoting where the 5000 comes from? Sure, can be done. + 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, ) < 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 = >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, ) < 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 = >display_info.hdmi_info; + + if (!hdmi_info->scr_info.status &&
Re: [Intel-gfx] [PATCH 4/6] drm: scrambling support in drm layer
On Wed, 2017-02-01 at 18:14 +0530, Shashank Sharma wrote: > 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 = >display_info; > + struct drm_hdmi_info *hdmi = >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; Comment explaining or quoting where the 5000 comes from? > + 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, ) < 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 = >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, ) < 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 = >display_info.hdmi_info; > + > + if