diff mbox

[3/9] drm/i915: Check pixel clock when setting mode for LVDS

Message ID 1435923357-3821-4-git-send-email-mika.kahola@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kahola July 3, 2015, 11:35 a.m. UTC
It is possible the we request to have a mode that has
higher pixel clock than our HW can support. This patch
checks if requested pixel clock is lower than the one
supported by the HW. The requested mode is discarded
if we cannot support the requested pixel clock.

This patch applies to LVDS.

Signed-off-by: Mika Kahola <mika.kahola@intel.com>
---
 drivers/gpu/drm/i915/intel_lvds.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Chris Wilson July 3, 2015, 12:35 p.m. UTC | #1
On Fri, Jul 03, 2015 at 02:35:51PM +0300, Mika Kahola wrote:
> It is possible the we request to have a mode that has
> higher pixel clock than our HW can support. This patch
> checks if requested pixel clock is lower than the one
> supported by the HW. The requested mode is discarded
> if we cannot support the requested pixel clock.
> 
> This patch applies to LVDS.
> 
> Signed-off-by: Mika Kahola <mika.kahola@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_lvds.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
> index ea85547..3280413 100644
> --- a/drivers/gpu/drm/i915/intel_lvds.c
> +++ b/drivers/gpu/drm/i915/intel_lvds.c
> @@ -262,13 +262,31 @@ static void intel_disable_lvds(struct intel_encoder *encoder)
>  	POSTING_READ(lvds_encoder->reg);
>  }
>  
> +static int
> +intel_lvds_max_pixclk(struct drm_connector *connector)
> +{
> +	struct drm_i915_private *dev_priv = to_i915(connector->dev);
> +
> +	if (IS_CHERRYVIEW(connector->dev))
> +		return  DIV_ROUND_UP(dev_priv->max_cdclk_freq * 100, 95);
> +	else if (IS_VALLEYVIEW(connector->dev))
> +		return  DIV_ROUND_UP(dev_priv->max_cdclk_freq * 100, 90);
> +	else
> +		return dev_priv->max_cdclk_freq;
> +}
> +
>  static enum drm_mode_status
>  intel_lvds_mode_valid(struct drm_connector *connector,
>  		      struct drm_display_mode *mode)
>  {
>  	struct intel_connector *intel_connector = to_intel_connector(connector);
>  	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
> +	int max_pixclk;
> +
> +	max_pixclk = intel_lvds_max_pixclk(connector);
>  
> +	if (mode->clock > max_pixclk)
> +		return MODE_PANEL;

return MODE_CLOCK_HIGH;
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index ea85547..3280413 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -262,13 +262,31 @@  static void intel_disable_lvds(struct intel_encoder *encoder)
 	POSTING_READ(lvds_encoder->reg);
 }
 
+static int
+intel_lvds_max_pixclk(struct drm_connector *connector)
+{
+	struct drm_i915_private *dev_priv = to_i915(connector->dev);
+
+	if (IS_CHERRYVIEW(connector->dev))
+		return  DIV_ROUND_UP(dev_priv->max_cdclk_freq * 100, 95);
+	else if (IS_VALLEYVIEW(connector->dev))
+		return  DIV_ROUND_UP(dev_priv->max_cdclk_freq * 100, 90);
+	else
+		return dev_priv->max_cdclk_freq;
+}
+
 static enum drm_mode_status
 intel_lvds_mode_valid(struct drm_connector *connector,
 		      struct drm_display_mode *mode)
 {
 	struct intel_connector *intel_connector = to_intel_connector(connector);
 	struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
+	int max_pixclk;
+
+	max_pixclk = intel_lvds_max_pixclk(connector);
 
+	if (mode->clock > max_pixclk)
+		return MODE_PANEL;
 	if (mode->hdisplay > fixed_mode->hdisplay)
 		return MODE_PANEL;
 	if (mode->vdisplay > fixed_mode->vdisplay)