Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit 694dab8e authored by Ahmed Harhash's avatar Ahmed Harhash
Browse files

[Fix] Replace floating-point operations with fixed-point arithmetic in aw8695 and cam_ois drivers

- Updated `aw8695.c` to replace floating-point multiplication with fixed-point arithmetic:
  - Changed `f0_pre_low` and `f0_pre_high` calculations to use integer math.
  - Adjusted conditional checks to work with the new fixed-point representation.

- Updated `cam_ois_core.c` to use integer arithmetic for `c` and `d` calculations:
  - Replaced floating-point operations with scaled integer calculations.
  - Used `long long` casting to handle large intermediate values.
parent fd4e5603
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -2496,9 +2496,9 @@ static int aw8695_haptic_init(struct aw8695 *aw8695)
    pr_info("%s pre_f0 = %d \n", __func__,aw8695->info.f0_pre);;
    pr_info("%s aw8695_f0_cal = %d \n", __func__,aw8695_f0_cal);

    f0_pre_low = aw8695->info.f0_pre*0.93;
    f0_pre_high = aw8695->info.f0_pre * 1.07;
       if(aw8695_f0_cal > (aw8695->info.f0_pre * 1.07) || aw8695_f0_cal < (aw8695->info.f0_pre*0.93)){ //dtsi 里定义的校准偏差值 7%
    f0_pre_low = (aw8695->info.f0_pre * 93) / 100;
    f0_pre_high = (aw8695->info.f0_pre * 107) / 100;
       if (aw8695_f0_cal > f0_pre_high || aw8695_f0_cal < f0_pre_low) { //dtsi 里定义的校准偏差值 7%
         mutex_lock(&aw8695->lock);
         aw8695_haptic_f0_calibration(aw8695); //调用 1 次振动对 f0 值完成重新检测及校准
         mutex_unlock(&aw8695->lock);
+2 −2
Original line number Diff line number Diff line
@@ -445,8 +445,8 @@ static int cam_ois_gyro_calibration(struct cam_ois_ctrl_t *o_ctrl)

	if (decrease_gain_X == 0 && decrease_gain_Y == 0)
	{
		c= (int)((gyro_gain_init[0]*1000 - default_gain_X*8192)/1000);
		d= (int)((gyro_gain_init[1]*1000 - default_gain_Y*8192)/1000);
		c = (int)((gyro_gain_init[0] * 1000LL - (long long)default_gain_X * 8192) / 1000);
		d = (int)((gyro_gain_init[1] * 1000LL - (long long)default_gain_Y * 8192) / 1000);

		if (c<=11264 && c>=5939 && d<=11060 && d>=6144)//0.725-1.375,0.75-1.35
		{