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

Commit eb70f96d authored by Surendar karka's avatar Surendar karka
Browse files

ASoC: msm: qdsp6v2: Add support to set volume in ASM loopback



Allow to set volume in ASM for the loopback driver. Without the
get() function the corresponding volume mixer control is
failing to set volume.

CRs-Fixed: 1034862
Change-Id: I621dd9de3a8d4a0f4102227989e1dd17638c20ea
Signed-off-by: default avatarSurendar karka <sukark@codeaurora.org>
parent 9e4b3ba4
Loading
Loading
Loading
Loading
+44 −3
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ struct msm_pcm_loopback {
	int capture_start;
	int session_id;
	struct audio_client *audio_client;
	int volume;
	uint32_t volume;
};

struct fe_dai_session_map {
@@ -150,7 +150,8 @@ static int msm_pcm_loopback_probe(struct snd_soc_platform *platform)

	return 0;
}
static int pcm_loopback_set_volume(struct msm_pcm_loopback *prtd, int volume)
static int pcm_loopback_set_volume(struct msm_pcm_loopback *prtd,
				   uint32_t volume)
{
	int rc = -EINVAL;

@@ -459,10 +460,49 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol,
	int rc = 0;
	struct snd_pcm_volume *vol = kcontrol->private_data;
	struct snd_pcm_substream *substream = vol->pcm->streams[0].substream;
	struct msm_pcm_loopback *prtd = substream->runtime->private_data;
	struct msm_pcm_loopback *prtd;
	int volume = ucontrol->value.integer.value[0];

	pr_debug("%s: volume : 0x%x\n", __func__, volume);
	if ((!substream) || (!substream->runtime)) {
		pr_err("%s substream or runtime not found\n", __func__);
		rc = -ENODEV;
		goto exit;
	}
	prtd = substream->runtime->private_data;
	if (!prtd) {
		rc = -ENODEV;
		goto exit;
	}
	rc = pcm_loopback_set_volume(prtd, volume);

exit:
	return rc;
}

static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_value *ucontrol)
{
	int rc = 0;
	struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol);
	struct snd_pcm_substream *substream =
		vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
	struct msm_pcm_loopback *prtd;

	pr_debug("%s\n", __func__);
	if ((!substream) || (!substream->runtime)) {
		pr_err("%s substream or runtime not found\n", __func__);
		rc = -ENODEV;
		goto exit;
	}
	prtd = substream->runtime->private_data;
	if (!prtd) {
		rc = -ENODEV;
		goto exit;
	}
	ucontrol->value.integer.value[0] = prtd->volume;

exit:
	return rc;
}

@@ -482,6 +522,7 @@ static int msm_pcm_add_controls(struct snd_soc_pcm_runtime *rtd)
		return ret;
	kctl = volume_info->kctl;
	kctl->put = msm_pcm_volume_ctl_put;
	kctl->get = msm_pcm_volume_ctl_get;
	kctl->tlv.p = loopback_rx_vol_gain;
	return 0;
}