Commit b54a0dfd authored by Philippe Longepe's avatar Philippe Longepe Committed by Rafael J. Wysocki

intel_pstate: Remove extra conversions in pid calculation

pid->setpoint and pid->deadband can be initialized in fixed point, so we
can avoid the int_tofp in pid_calc.
Signed-off-by: default avatarPhilippe Longepe <philippe.longepe@linux.intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent a5acbfbd
...@@ -198,8 +198,8 @@ static struct perf_limits *limits = &powersave_limits; ...@@ -198,8 +198,8 @@ static struct perf_limits *limits = &powersave_limits;
static inline void pid_reset(struct _pid *pid, int setpoint, int busy, static inline void pid_reset(struct _pid *pid, int setpoint, int busy,
int deadband, int integral) { int deadband, int integral) {
pid->setpoint = setpoint; pid->setpoint = int_tofp(setpoint);
pid->deadband = deadband; pid->deadband = int_tofp(deadband);
pid->integral = int_tofp(integral); pid->integral = int_tofp(integral);
pid->last_err = int_tofp(setpoint) - int_tofp(busy); pid->last_err = int_tofp(setpoint) - int_tofp(busy);
} }
...@@ -225,9 +225,9 @@ static signed int pid_calc(struct _pid *pid, int32_t busy) ...@@ -225,9 +225,9 @@ static signed int pid_calc(struct _pid *pid, int32_t busy)
int32_t pterm, dterm, fp_error; int32_t pterm, dterm, fp_error;
int32_t integral_limit; int32_t integral_limit;
fp_error = int_tofp(pid->setpoint) - busy; fp_error = pid->setpoint - busy;
if (abs(fp_error) <= int_tofp(pid->deadband)) if (abs(fp_error) <= pid->deadband)
return 0; return 0;
pterm = mul_fp(pid->p_gain, fp_error); pterm = mul_fp(pid->p_gain, fp_error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment