[Intel-gfx] [PATCH] drm/i915/cnl: Simplify dco_fraction calculation.
Ville Syrjälä
ville.syrjala at linux.intel.com
Wed Nov 15 11:09:31 UTC 2017
On Tue, Nov 14, 2017 at 03:51:26PM -0800, Rodrigo Vivi wrote:
> I confess I never fully understood that previous calculation,
> so this is not a "fix". But let's simplify this math
> so poor brains like mine can read and make some sense of
> it in the future.
>
> v2: Don't follow the spec since that gives invalid
> values and it is also confusing. This Ville's
> version is much simpler.
>
> Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
> Cc: Mika Kahola <mika.kahola at intel.com>
> Cc: Manasi Navare <manasi.d.navare at intel.com>
> Cc: James Ausmus <james.ausmus at intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
> ---
> drivers/gpu/drm/i915/intel_dpll_mgr.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_dpll_mgr.c b/drivers/gpu/drm/i915/intel_dpll_mgr.c
> index 361b7102b602..f9651accecc9 100644
> --- a/drivers/gpu/drm/i915/intel_dpll_mgr.c
> +++ b/drivers/gpu/drm/i915/intel_dpll_mgr.c
> @@ -2153,6 +2153,8 @@ static void cnl_wrpll_params_populate(struct skl_wrpll_params *params,
> u32 dco_freq, u32 ref_freq,
> int pdiv, int qdiv, int kdiv)
> {
> + u64 dco;
> +
> switch (kdiv) {
> case 1:
> params->kdiv = 1;
> @@ -2189,9 +2191,10 @@ static void cnl_wrpll_params_populate(struct skl_wrpll_params *params,
> params->qdiv_ratio = qdiv;
> params->qdiv_mode = (qdiv == 1) ? 0 : 1;
>
> - params->dco_integer = div_u64(dco_freq, ref_freq);
> - params->dco_fraction = div_u64((div_u64((uint64_t)dco_freq<<15, (uint64_t)ref_freq) -
> - ((uint64_t)params->dco_integer<<15)) * 0x8000, 0x8000);
> + dco = dco_freq;
> + dco = div_u64(dco << 15, ref_freq);
A bit wasteful putting the result into a u64. The cast I had in my
earlier proposal should do.
> + params->dco_integer = dco >> 15;
> + params->dco_fraction = dco & 0x7fff;
> }
>
> static bool
> --
> 2.13.6
--
Ville Syrjälä
Intel OTC
More information about the Intel-gfx
mailing list