pcm: dmix: Add option to allow alignment of slave pointers

These changes are required due to the kernel
commit 07b7acb51d283d8469696c906b91f1882696a4d4
("ASoC: rsnd: update pointer more accurate")

Issue is that snd_pcm_wait() goes back to waiting because the hw_ptr
is not period aligned. Therefore snd_pcm_wait() will block for a longer
time as required.

With these rcar driver changes the exact position of the dma is returned.
During snd_pcm_start they read hw_ptr as reference, and this hw_ptr
is now not period aligned, and is a little ahead over the period while it
is read. Therefore when the avail is calculated during snd_pcm_wait(),
it is missing the avail_min by a few frames.

An additional option hw_ptr_alignment is provided to dmix configuration,
to allow the user to configure the slave application and hw pointer
alignment at startup

[ Slight indentation and parentheses removals by tiwai ]

Signed-off-by: Laxmi Devi <Laxmi.Devi@in.bosch.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Laxmi Devi 2018-11-13 08:43:00 +01:00 committed by Takashi Iwai
parent 178fe66bc8
commit 6b058fda9d
3 changed files with 76 additions and 8 deletions

View file

@ -1877,6 +1877,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
rec->max_periods = 0;
rec->var_periodsize = 0;
rec->direct_memory_access = 1;
rec->hw_ptr_alignment = SND_PCM_HW_PTR_ALIGNMENT_AUTO;
/* read defaults */
if (snd_config_search(root, "defaults.pcm.dmix_max_periods", &n) >= 0) {
@ -1918,6 +1919,28 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
rec->ipc_perm = perm;
continue;
}
if (strcmp(id, "hw_ptr_alignment") == 0) {
const char *str;
err = snd_config_get_string(n, &str);
if (err < 0) {
SNDERR("Invalid type for %s", id);
return -EINVAL;
}
if (strcmp(str, "no") == 0)
rec->hw_ptr_alignment = SND_PCM_HW_PTR_ALIGNMENT_NO;
else if (strcmp(str, "roundup") == 0)
rec->hw_ptr_alignment = SND_PCM_HW_PTR_ALIGNMENT_ROUNDUP;
else if (strcmp(str, "rounddown") == 0)
rec->hw_ptr_alignment = SND_PCM_HW_PTR_ALIGNMENT_ROUNDDOWN;
else if (strcmp(str, "auto") == 0)
rec->hw_ptr_alignment = SND_PCM_HW_PTR_ALIGNMENT_AUTO;
else {
SNDERR("The field hw_ptr_alignment is invalid : %s", str);
return -EINVAL;
}
continue;
}
if (strcmp(id, "ipc_gid") == 0) {
char *group;
char *endp;