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

Commit 491adb87 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

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

parents 83978dfb eb70f96d
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;
}