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

Commit aec99ac9 authored by Sudheer Papothi's avatar Sudheer Papothi
Browse files

ASoC: wsa881x: Fix equilibrium temperature calculation on wsa881x



wsa881x has built-in temperature sensor for accurate temperature
measurement. Fix equilibrium temperature calculation on
wsa881x codec.

Change-Id: I1c6fb4ee59e2b5ce2d12d1043fd0bf4430a438e8
Signed-off-by: default avatarSudheer Papothi <spapothi@codeaurora.org>
parent 377d2dff
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ static void calculate_temp(long *temp_val, int dmeas,
		*temp_val = TEMP_INVALID;
		return;
	}
	*temp_val = t1 + ((dmeas - d1)/(d2 - d1)) * (t2 - t1);
	*temp_val = t1 + (((dmeas - d1) * (t2 - t1))/(d2 - d1));
}

static int wsa881x_get_temp(struct thermal_zone_device *thermal,
@@ -95,12 +95,14 @@ static int wsa881x_get_temp(struct thermal_zone_device *thermal,
	dmeas = ((dmeas_cur_msb << 0x8) | dmeas_cur_lsb) >> 0x6;
	pr_debug("%s: dmeas: %d\n", __func__, dmeas);
	calculate_temp(&temp_val, dmeas, codec, pdata->dig_base);
	*temp = temp_val;
	if (temp_val <= LOW_TEMP_THRESHOLD ||
			temp_val >= HIGH_TEMP_THRESHOLD) {
		pr_err("%s: T0: %ld is out of range [%d, %d]\n", __func__,
			temp_val, LOW_TEMP_THRESHOLD, HIGH_TEMP_THRESHOLD);
		ret = -EAGAIN;
		goto rel;
	}
	*temp = temp_val;
	pr_debug("%s: t0 measured: %ld\n", __func__, temp_val);
rel:
	ret = pdata->wsa_resource_acquire(codec, false);