bat: Fix buffer time configuration
PATCH 1/1 bat: Fix buffer time configuration
By swapping time configuration some hardware constraints can be supported. Fixes the error: Set parameter to device error: buffer time: 500000 hw:tqmtlv320aic32: Invalid argument(-22)
---
Our common 'alsabat -Dhw:tqmtlv320aic32 -f S16_LE -c 2 -r 44100 -F 997:500' failed ona i.MX95 based platform, while it worked flawlessly on others, e.g. i.MX8M Plus. Upon searching I stumbled across [1], which this patch is inspired/based on.
[1] https://github.com/arkq/bluez-alsa/pull/290/commits/da78b82ff77310093b4b4a914d31e69b8ebb49eb
--- bat/alsa.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
bat/alsa.c +9 -9
@@ -221,23 +221,23 @@ static int set_snd_pcm_params(struct bat *bat, struct pcm_container *sndpcm) period_time = buffer_time /DIV_BUFFERTIME ; -/* Set buffer time and period time */ - err =snd_pcm_hw_params_set_buffer_time_near (sndpcm->handle, - params, &buffer_time,0 ); +/* Set period time and buffer time */ + err =snd_pcm_hw_params_set_period_time_near (sndpcm->handle, + params, &period_time,0 );if (err <0 ) {fprintf (bat->err,_ ("Set parameter to device error: " )); -fprintf (bat->err,_ ("buffer time: %d %s: %s(%d)\n" ), - buffer_time, +fprintf (bat->err,_ ("period time: %d %s: %s(%d)\n" ), + period_time, device_name,snd_strerror (err), err);return err; } - err =snd_pcm_hw_params_set_period_time_near (sndpcm->handle, - params, &period_time,0 ); + err =snd_pcm_hw_params_set_buffer_time_near (sndpcm->handle, + params, &buffer_time,0 );if (err <0 ) {fprintf (bat->err,_ ("Set parameter to device error: " )); -fprintf (bat->err,_ ("period time: %d %s: %s(%d)\n" ), - period_time, +fprintf (bat->err,_ ("buffer time: %d %s: %s(%d)\n" ), + buffer_time, device_name,snd_strerror (err), err);return err; }
Signature · 1 line
2.43.0
Hi,
Am Donnerstag, 10. April 2025, 13:01:19 CEST schrieb Alexander Stein:
Quoted 5 lines
By swapping time configuration some hardware constraints can be supported. Fixes the error: Set parameter to device error: buffer time: 500000 hw:tqmtlv320aic32: Invalid argument(-22)
Signed-off-by Alexander Stein <[email protected]>
Any feedback here? Or should I create a PR on github instead?
Thanks and best regards
Alexander
Quoted 49 lines
---
Our common 'alsabat -Dhw:tqmtlv320aic32 -fS16_LE-c 2 -r 44100 -F 997:500' failed ona i.MX95 based platform, while it worked flawlessly on others, e.g. i.MX8M Plus. Upon searching I stumbled across [1], which this patch is inspired/based on.[1] https://github.com/arkq/bluez-alsa/pull/290/commits/da78b82ff77310093b4b4a914d31e69b8ebb49eb
--- bat/alsa.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)bat/alsa.c +9
-9@@ -221,23 +221,23 @@ static int set_snd_pcm_params(struct bat *bat, struct pcm_container *sndpcm) period_time = buffer_time /DIV_BUFFERTIME ; -/* Set buffer time and period time */ - err =snd_pcm_hw_params_set_buffer_time_near (sndpcm->handle, - params, &buffer_time,0 ); +/* Set period time and buffer time */ + err =snd_pcm_hw_params_set_period_time_near (sndpcm->handle, + params, &period_time,0 );if (err <0 ) {fprintf (bat->err,_ ("Set parameter to device error: " )); -fprintf (bat->err,_ ("buffer time: %d %s: %s(%d)\n" ), - buffer_time, +fprintf (bat->err,_ ("period time: %d %s: %s(%d)\n" ), + period_time, device_name,snd_strerror (err), err);return err; } - err =snd_pcm_hw_params_set_period_time_near (sndpcm->handle, - params, &period_time,0 ); + err =snd_pcm_hw_params_set_buffer_time_near (sndpcm->handle, + params, &buffer_time,0 );if (err <0 ) {fprintf (bat->err,_ ("Set parameter to device error: " )); -fprintf (bat->err,_ ("period time: %d %s: %s(%d)\n" ), - period_time, +fprintf (bat->err,_ ("buffer time: %d %s: %s(%d)\n" ), + buffer_time, device_name,snd_strerror (err), err);return err; }
Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/
Quoted 11 lines · Alexander Stein
Hi,
Am Donnerstag, 10. April 2025, 13:01:19 CEST schrieb Alexander Stein:
Quoted 5 lines
By swapping time configuration some hardware constraints can be supported. Fixes the error: Set parameter to device error: buffer time: 500000 hw:tqmtlv320aic32: Invalid argument(-22)
Signed-off-by Alexander Stein <[email protected]>Any feedback here? Or should I create a PR on github instead?
Sorry, it was just overlooked.
Now applied the patch. Thanks!
Takashi