Skip to content

Commit a457f54

Browse files
committed
drm/i915: Clean up .get_aux_clock_divider() functions
Now that the mess with AUX clock divder rounding is sorted out and we have both cdclk and rawclk cached in dev_priv, we can clean up the .get_aux_clock_divider() functions a bit. The main thing here is just calling ilk_get_aux_clock_divider() from hsw_get_aux_clock_divider() except for the LPT:H special case. We could go further and call g4x_get_aux_clock_divider() from ilk_get_aux_clock_divider() for the PCH ports, but I'm sure Jani would object, so leave that be. While at it repeat the comment where the AUX clock comes from in ilk_get_aux_clock_divider(). Signed-off-by: Ville Syrjälä <[email protected]> Reviewed-by: Jani Nikula <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 35d38d1 commit a457f54

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

drivers/gpu/drm/i915/intel_dp.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -676,22 +676,29 @@ static uint32_t g4x_get_aux_clock_divider(struct intel_dp *intel_dp, int index)
676676
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
677677
struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev);
678678

679+
if (index)
680+
return 0;
681+
679682
/*
680683
* The clock divider is based off the hrawclk, and would like to run at
681-
* 2MHz. So, take the hrawclk value and divide by 2 and use that
684+
* 2MHz. So, take the hrawclk value and divide by 2000 and use that
682685
*/
683-
return index ? 0 : DIV_ROUND_CLOSEST(dev_priv->rawclk_freq, 2000);
686+
return DIV_ROUND_CLOSEST(dev_priv->rawclk_freq, 2000);
684687
}
685688

686689
static uint32_t ilk_get_aux_clock_divider(struct intel_dp *intel_dp, int index)
687690
{
688691
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
689-
struct drm_device *dev = intel_dig_port->base.base.dev;
690-
struct drm_i915_private *dev_priv = dev->dev_private;
692+
struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev);
691693

692694
if (index)
693695
return 0;
694696

697+
/*
698+
* The clock divider is based off the cdclk or PCH rawclk, and would
699+
* like to run at 2MHz. So, take the cdclk or PCH rawclk value and
700+
* divide by 2000 and use that
701+
*/
695702
if (intel_dig_port->port == PORT_A)
696703
return DIV_ROUND_CLOSEST(dev_priv->cdclk_freq, 2000);
697704
else
@@ -701,23 +708,18 @@ static uint32_t ilk_get_aux_clock_divider(struct intel_dp *intel_dp, int index)
701708
static uint32_t hsw_get_aux_clock_divider(struct intel_dp *intel_dp, int index)
702709
{
703710
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
704-
struct drm_device *dev = intel_dig_port->base.base.dev;
705-
struct drm_i915_private *dev_priv = dev->dev_private;
711+
struct drm_i915_private *dev_priv = to_i915(intel_dig_port->base.base.dev);
706712

707-
if (intel_dig_port->port == PORT_A) {
708-
if (index)
709-
return 0;
710-
return DIV_ROUND_CLOSEST(dev_priv->cdclk_freq, 2000);
711-
} else if (HAS_PCH_LPT_H(dev_priv)) {
713+
if (intel_dig_port->port != PORT_A && HAS_PCH_LPT_H(dev_priv)) {
712714
/* Workaround for non-ULT HSW */
713715
switch (index) {
714716
case 0: return 63;
715717
case 1: return 72;
716718
default: return 0;
717719
}
718-
} else {
719-
return index ? 0 : DIV_ROUND_CLOSEST(dev_priv->rawclk_freq, 2000);
720720
}
721+
722+
return ilk_get_aux_clock_divider(intel_dp, index);
721723
}
722724

723725
static uint32_t skl_get_aux_clock_divider(struct intel_dp *intel_dp, int index)

0 commit comments

Comments
 (0)