dsp: remove float operations in excursion calculation
Avoid float operation during excursion calculation since that impacts CPU performance. Maintain the same precision for 2 digit as per requirement for final value to print in sys/class node. Change-Id: I34d0f2e7b9eca499206ee9d30acf0d9121b0442e Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
This commit is contained in:
1 parent
e039f16fa4
commit
366670efa7
1 file changed
+8
-7
+8
-7
@@ -15,8 +15,9 @@
|
||||
#define SPK_PARAMS "spk_params"
|
||||
#define CLASS_NAME "cal_data"
|
||||
#define BUF_SZ 20
|
||||
#define Q27 (1<<27)
|
||||
#define Q22 (1<<22)
|
||||
#define Q13 (1<<13)
|
||||
#define Q7 (1<<7)
|
||||
|
||||
struct afe_spk_ctl {
|
||||
struct class *p_class;
|
||||
@@ -88,11 +89,11 @@ static ssize_t sp_max_excursion_l_show(struct device *dev,
|
||||
{
|
||||
ssize_t ret = 0;
|
||||
int32_t ex_val_frac;
|
||||
float ex_val;
|
||||
int32_t ex_q27 = this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_1];
|
||||
|
||||
ex_val = (ex_q27 * 1.0)/Q27;
|
||||
ex_val_frac = ex_val * 100;
|
||||
ex_val_frac = ex_q27/Q13;
|
||||
ex_val_frac = (ex_val_frac * 10000)/(Q7 * Q7);
|
||||
ex_val_frac /= 100;
|
||||
ret = snprintf(buf, BUF_SZ, "%d.%02d\n", 0, ex_val_frac);
|
||||
this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_1] = 0;
|
||||
return ret;
|
||||
@@ -105,11 +106,11 @@ static ssize_t sp_max_excursion_r_show(struct device *dev,
|
||||
{
|
||||
ssize_t ret = 0;
|
||||
int32_t ex_val_frac;
|
||||
float ex_val;
|
||||
int32_t ex_q27 = this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_2];
|
||||
|
||||
ex_val = (ex_q27 * 1.0)/Q27;
|
||||
ex_val_frac = ex_val * 100;
|
||||
ex_val_frac = ex_q27/Q13;
|
||||
ex_val_frac = (ex_val_frac * 10000)/(Q7 * Q7);
|
||||
ex_val_frac /= 100;
|
||||
ret = snprintf(buf, BUF_SZ, "%d.%02d\n", 0, ex_val_frac);
|
||||
this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_2] = 0;
|
||||
return ret;
|
||||
|
||||
Reference in new issue
Block a user