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

Commit 2d7c0096 authored by Ashish Jain's avatar Ashish Jain
Browse files

ASoC: msm: Configure correct gain on set Volume command



Output channel gain is product of per channel gain and master gain.
Hence if only per channel gain is set and master gain is set to 0
then no audio is heard at the output.
Ensure that if we change per channel gain then we set master gain
to unity and vice versa. This enables only one gain to be effective.

Change-Id: I4cc2990efbb3e86edcc3d4328761cb64ed8fa775
Signed-off-by: default avatarAshish Jain <ashishj@codeaurora.org>
parent d3904af2
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -177,8 +177,31 @@ static int msm_compr_set_volume(struct snd_compr_stream *cstream,
			pr_debug("%s: call q6asm_set_lrgain\n", __func__);
			rc = q6asm_set_lrgain(prtd->audio_client,
						volume_l, volume_r);
			if (rc < 0) {
				pr_err("%s: set lrgain command failed rc=%d\n",
				__func__, rc);
				return rc;
			}
			/*
			 * set master gain to unity so that only lr gain
			 * is effective
			 */
			rc = q6asm_set_volume(prtd->audio_client,
						COMPRESSED_LR_VOL_MAX_STEPS);
		} else {
			pr_debug("%s: call q6asm_set_volume\n", __func__);
			/*
			 * set left and right channel gain to unity so that
			 * only master gain is effective
			 */
			rc = q6asm_set_lrgain(prtd->audio_client,
						COMPRESSED_LR_VOL_MAX_STEPS,
						COMPRESSED_LR_VOL_MAX_STEPS);
			if (rc < 0) {
				pr_err("%s: set lrgain command failed rc=%d\n",
				__func__, rc);
				return rc;
			}
			rc = q6asm_set_volume(prtd->audio_client, volume_l);
		}
		if (rc < 0) {
@@ -647,10 +670,6 @@ static int msm_compr_configure_dsp(struct snd_compr_stream *cstream)
		return ret;
	}

	ret = msm_compr_set_volume(cstream, 0, 0);
	if (ret < 0)
		pr_err("%s : Set Volume failed : %d", __func__, ret);

	ret = q6asm_set_softvolume(ac, &softvol);
	if (ret < 0)
		pr_err("%s: Send SoftVolume Param failed ret=%d\n",