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

Commit 3b672c43 authored by Daniel Jacob Chittoor's avatar Daniel Jacob Chittoor
Browse files

ASoC: aw882xx: Don't use max amplifier gain for AW882XX_RECEIVER_MODE

In the case of Fairphone 4's stereo speaker setup, where one speaker
also serves as the earpiece module, the earpiece is treated as a mono
transmit source during standalone use, such as in VoIP calls. The
current issue lies in the amplifier applying maximum gains regardless of
whether it operates standalone or as part of a stereo setup which is not
ideal considering the usecase.

Controlling amplifier gains for a specific audio backend device via
mixer paths is not possible, as the property exported by the amplifier
gets overwritten by the kernelspace.

When the "handset" device is being used the amplifier switches the
working mode to "Rcv" as shown in [1], this patch checks whether the
current working mode is "Rcv" and limits the gain being set to max.

The more appropriate fix is adjusting digital RX volume or addressing
and tuning the volume curves for the HANDSET backend on ACDBs.

[1] https://github.com/WeAreFairphone/android_device_fairphone_FP4/blob/staging/lineage-19.1/audio/mixer_paths_lagoon_fp4.xml#L3428
parent 5e63c67c
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -349,18 +349,24 @@ static int aw882xx_fade_in_out(struct aw882xx *aw882xx, bool fade_in)
{
	int i = 0;
	uint32_t start_volume = 0;
	int target_offset = 0;

	/*volume up*/
	if (fade_in) {
		for (i = AW_FADE_OUT_TARGET_VOL; i >= (int32_t)aw882xx->db_offset;
		if (aw882xx->cfg_num != AW882XX_RECEIVER_MODE) {
		    target_offset = aw882xx->db_offset;
		} else {
		    target_offset = AW_EARPIECE_MAX_GAIN;
		}
		for (i = AW_FADE_OUT_TARGET_VOL; i >= (int32_t)target_offset;
						i -= aw882xx->fade_step) {
			if (i < (int32_t)aw882xx->fade_step)
				i = aw882xx->db_offset;
				i = target_offset;
			aw882xx_set_volume(aw882xx, i);
			usleep_range(1400, 1600);
		}
		if (i != (int32_t)aw882xx->db_offset)
			aw882xx_set_volume(aw882xx, aw882xx->db_offset);
		if (i != (int32_t)target_offset)
			aw882xx_set_volume(aw882xx, target_offset);
	} else {
		/*volume down*/
		aw882xx_get_volume(aw882xx, &start_volume);
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@

#define AW882XX_CFG_NAME_MAX			(64)
#define AW_FADE_OUT_TARGET_VOL			(90 * 2)
#define AW_EARPIECE_MAX_GAIN			(40)
#define AW882XX_VOLUME_STEP_DB			(6 * 2)