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

Commit 71309e08 authored by Kenneth Westfield's avatar Kenneth Westfield
Browse files

ASoC: msm: qdsp6v2: update path_delay in delay ops



Update the path_delay in audio_client to the
current value from ASM_SESSION_GET_PATH_DELAY_V2.
The path_delay is then converted to frames and
stored in the runtime.

Change-Id: I184ad9ac53e7e2cbbaa1c0e7f5bfa78543137e8b
Signed-off-by: default avatarKenneth Westfield <kwestfie@codeaurora.org>
parent 210cbc1a
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -1199,9 +1199,37 @@ static int msm_asoc_pcm_new(struct snd_soc_pcm_runtime *rtd)
	return ret;
}

static snd_pcm_sframes_t msm_pcm_delay_blk(struct snd_pcm_substream *substream,
		struct snd_soc_dai *dai)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct msm_audio *prtd = runtime->private_data;
	struct audio_client *ac = prtd->audio_client;
	snd_pcm_sframes_t frames;
	int ret;

	ret = q6asm_get_path_delay(prtd->audio_client);
	if (ret) {
		pr_err("%s: get_path_delay failed, ret=%d\n", __func__, ret);
		return 0;
	}

	/* convert microseconds to frames */
	frames = ac->path_delay / 1000 * runtime->rate / 1000;

	/* also convert the remainder from the initial division */
	frames += ac->path_delay % 1000 * runtime->rate / 1000000;

	/* overcompensate for the loss of precision (empirical) */
	frames += 2;

	return frames;
}

static struct snd_soc_platform_driver msm_soc_platform = {
	.ops		= &msm_pcm_ops,
	.pcm_new	= msm_asoc_pcm_new,
	.delay_blk      = msm_pcm_delay_blk,
};

static int msm_pcm_probe(struct platform_device *pdev)