[Intel-gfx] [PATCH] drm/i915: Convert pxvid to extvid lookup table

Ville Syrjälä ville.syrjala at linux.intel.com
Fri Nov 28 15:55:11 CET 2014


On Thu, Nov 27, 2014 at 04:23:12PM +0200, Mika Kuoppala wrote:
> to a procedural to save space.
> 
> Signed-off-by: Mika Kuoppala <mika.kuoppala at intel.com>
> ---
>  drivers/gpu/drm/i915/intel_pm.c | 155 +++++-----------------------------------
>  1 file changed, 18 insertions(+), 137 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 9af0af4..78911e2 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -5681,146 +5681,27 @@ unsigned long i915_mch_val(struct drm_i915_private *dev_priv)
>  	return ((m * x) / 127) - b;
>  }
>  
> -static u16 pvid_to_extvid(struct drm_i915_private *dev_priv, u8 pxvid)
> +static int _pxvid_to_vd(u8 pxvid)
> +{
> +	if (pxvid == 0)
> +		return 0;
> +
> +	if (pxvid >= 8 && pxvid < 31)
> +		pxvid = 31;
> +
> +	return (pxvid + 2) * 125;
> +}

Seems simple enough as a function. I copy pasted the stuff into a small c
program and it confirmed that we get identical values from the old and
new code. So looks good.

Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>


> +
> +static u32 pvid_to_extvid(struct drm_i915_private *dev_priv, u8 pxvid)
>  {
>  	struct drm_device *dev = dev_priv->dev;
> -	static const struct v_table {
> -		u16 vd; /* in .1 mil */
> -		u16 vm; /* in .1 mil */
> -	} v_table[] = {
> -		{ 0, 0, },
> -		{ 375, 0, },
> -		{ 500, 0, },
> -		{ 625, 0, },
> -		{ 750, 0, },
> -		{ 875, 0, },
> -		{ 1000, 0, },
> -		{ 1125, 0, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4125, 3000, },
> -		{ 4250, 3125, },
> -		{ 4375, 3250, },
> -		{ 4500, 3375, },
> -		{ 4625, 3500, },
> -		{ 4750, 3625, },
> -		{ 4875, 3750, },
> -		{ 5000, 3875, },
> -		{ 5125, 4000, },
> -		{ 5250, 4125, },
> -		{ 5375, 4250, },
> -		{ 5500, 4375, },
> -		{ 5625, 4500, },
> -		{ 5750, 4625, },
> -		{ 5875, 4750, },
> -		{ 6000, 4875, },
> -		{ 6125, 5000, },
> -		{ 6250, 5125, },
> -		{ 6375, 5250, },
> -		{ 6500, 5375, },
> -		{ 6625, 5500, },
> -		{ 6750, 5625, },
> -		{ 6875, 5750, },
> -		{ 7000, 5875, },
> -		{ 7125, 6000, },
> -		{ 7250, 6125, },
> -		{ 7375, 6250, },
> -		{ 7500, 6375, },
> -		{ 7625, 6500, },
> -		{ 7750, 6625, },
> -		{ 7875, 6750, },
> -		{ 8000, 6875, },
> -		{ 8125, 7000, },
> -		{ 8250, 7125, },
> -		{ 8375, 7250, },
> -		{ 8500, 7375, },
> -		{ 8625, 7500, },
> -		{ 8750, 7625, },
> -		{ 8875, 7750, },
> -		{ 9000, 7875, },
> -		{ 9125, 8000, },
> -		{ 9250, 8125, },
> -		{ 9375, 8250, },
> -		{ 9500, 8375, },
> -		{ 9625, 8500, },
> -		{ 9750, 8625, },
> -		{ 9875, 8750, },
> -		{ 10000, 8875, },
> -		{ 10125, 9000, },
> -		{ 10250, 9125, },
> -		{ 10375, 9250, },
> -		{ 10500, 9375, },
> -		{ 10625, 9500, },
> -		{ 10750, 9625, },
> -		{ 10875, 9750, },
> -		{ 11000, 9875, },
> -		{ 11125, 10000, },
> -		{ 11250, 10125, },
> -		{ 11375, 10250, },
> -		{ 11500, 10375, },
> -		{ 11625, 10500, },
> -		{ 11750, 10625, },
> -		{ 11875, 10750, },
> -		{ 12000, 10875, },
> -		{ 12125, 11000, },
> -		{ 12250, 11125, },
> -		{ 12375, 11250, },
> -		{ 12500, 11375, },
> -		{ 12625, 11500, },
> -		{ 12750, 11625, },
> -		{ 12875, 11750, },
> -		{ 13000, 11875, },
> -		{ 13125, 12000, },
> -		{ 13250, 12125, },
> -		{ 13375, 12250, },
> -		{ 13500, 12375, },
> -		{ 13625, 12500, },
> -		{ 13750, 12625, },
> -		{ 13875, 12750, },
> -		{ 14000, 12875, },
> -		{ 14125, 13000, },
> -		{ 14250, 13125, },
> -		{ 14375, 13250, },
> -		{ 14500, 13375, },
> -		{ 14625, 13500, },
> -		{ 14750, 13625, },
> -		{ 14875, 13750, },
> -		{ 15000, 13875, },
> -		{ 15125, 14000, },
> -		{ 15250, 14125, },
> -		{ 15375, 14250, },
> -		{ 15500, 14375, },
> -		{ 15625, 14500, },
> -		{ 15750, 14625, },
> -		{ 15875, 14750, },
> -		{ 16000, 14875, },
> -		{ 16125, 15000, },
> -	};
> +	const int vd = _pxvid_to_vd(pxvid);
> +	const int vm = vd - 1125;
> +
>  	if (INTEL_INFO(dev)->is_mobile)
> -		return v_table[pxvid].vm;
> -	else
> -		return v_table[pxvid].vd;
> +		return vm > 0 ? vm : 0;
> +
> +	return vd;
>  }
>  
>  static void __i915_update_gfx_val(struct drm_i915_private *dev_priv)
> -- 
> 1.9.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC



More information about the Intel-gfx mailing list