]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
drm/i915: Extract broadwell_calc_cdclk()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 11 May 2016 19:44:41 +0000 (22:44 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 13 May 2016 18:28:09 +0000 (21:28 +0300)
Try to reduce the amount of duplicated cdclk magic numbers by
moving the max_pixclk->cdclk conversion into a helper.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1462995892-32416-3-git-send-email-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/intel_display.c

index 5bc7300db654a7c2509fe1c63622915108993cef..f6adea8116de351173eca4ff5572b8c9e957d3a9 100644 (file)
@@ -9675,6 +9675,18 @@ static void broadwell_set_cdclk(struct drm_device *dev, int cdclk)
             cdclk, dev_priv->cdclk_freq);
 }
 
+static int broadwell_calc_cdclk(int max_pixclk)
+{
+       if (max_pixclk > 540000)
+               return 675000;
+       else if (max_pixclk > 450000)
+               return 540000;
+       else if (max_pixclk > 337500)
+               return 450000;
+       else
+               return 337500;
+}
+
 static int broadwell_modeset_calc_cdclk(struct drm_atomic_state *state)
 {
        struct drm_i915_private *dev_priv = to_i915(state->dev);
@@ -9686,14 +9698,7 @@ static int broadwell_modeset_calc_cdclk(struct drm_atomic_state *state)
         * FIXME should also account for plane ratio
         * once 64bpp pixel formats are supported.
         */
-       if (max_pixclk > 540000)
-               cdclk = 675000;
-       else if (max_pixclk > 450000)
-               cdclk = 540000;
-       else if (max_pixclk > 337500)
-               cdclk = 450000;
-       else
-               cdclk = 337500;
+       cdclk = broadwell_calc_cdclk(max_pixclk);
 
        if (cdclk > dev_priv->max_cdclk_freq) {
                DRM_DEBUG_KMS("requested cdclk (%d kHz) exceeds max (%d kHz)\n",
@@ -9703,7 +9708,7 @@ static int broadwell_modeset_calc_cdclk(struct drm_atomic_state *state)
 
        intel_state->cdclk = intel_state->dev_cdclk = cdclk;
        if (!intel_state->active_crtcs)
-               intel_state->dev_cdclk = 337500;
+               intel_state->dev_cdclk = broadwell_calc_cdclk(0);
 
        return 0;
 }