summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2025-05-20 19:08:00 +0200
committerFrancesco Dolcini <francesco.dolcini@toradex.com>2025-05-23 09:18:07 +0000
commit90f3705633a690b3fb406170ca6bb01b2cef1908 (patch)
tree633645923e3325ce54cdf1e6002c76081a66f6eb
parentaa1cf6a6706baafc64690ed8348acd77029148ed (diff)
alsa-utils: alsa-bat: fix buffer time configuration
On some hardware some sample rates lead to a configuration error when not forcing 'valid' buffer/period settings. Affected is e.g. toradex-smarc-imx95 when using 44100 samples/s. | root@toradex-smarc-imx95-12593551:~# alsabat -D hw:0,0 -r 44100 -c 2 -f S16_LE | alsa-utils version 1.2.11 | | Entering playback thread (ALSA). | Set parameter to device error: buffer time: 500000 hw:0,0: Invalid argument(-22) | Exit playback thread fail: -22 Backport the relevant fix. Related-to: ELB-6452 Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> (cherry picked from commit 4295f1cdfeedf9b90439befcecea5a5e4fb128b7)
-rw-r--r--recipes-multimedia/alsa-utils/alsa-utils/0001-bat-Fix-buffer-time-configuration.patch56
-rw-r--r--recipes-multimedia/alsa-utils/alsa-utils_%.bbappend4
2 files changed, 60 insertions, 0 deletions
diff --git a/recipes-multimedia/alsa-utils/alsa-utils/0001-bat-Fix-buffer-time-configuration.patch b/recipes-multimedia/alsa-utils/alsa-utils/0001-bat-Fix-buffer-time-configuration.patch
new file mode 100644
index 00000000..774b51ff
--- /dev/null
+++ b/recipes-multimedia/alsa-utils/alsa-utils/0001-bat-Fix-buffer-time-configuration.patch
@@ -0,0 +1,56 @@
+From bbd106d104ec3995964e89cb54a9a5a67fc7591d Mon Sep 17 00:00:00 2001
+From: Alexander Stein <alexander.stein@ew.tq-group.com>
+Date: Thu, 10 Apr 2025 13:01:19 +0200
+Subject: [PATCH] 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)
+
+Upstream-Status: Backport [bbd106d104ec3995964e89cb54a9a5a67fc7591d]
+Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+---
+ bat/alsa.c | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/bat/alsa.c b/bat/alsa.c
+index 67489c4214fb..457e79a2b293 100644
+--- a/bat/alsa.c
++++ b/bat/alsa.c
+@@ -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;
+ }
+--
+2.42.0
+
diff --git a/recipes-multimedia/alsa-utils/alsa-utils_%.bbappend b/recipes-multimedia/alsa-utils/alsa-utils_%.bbappend
index e9808075..3e3a012c 100644
--- a/recipes-multimedia/alsa-utils/alsa-utils_%.bbappend
+++ b/recipes-multimedia/alsa-utils/alsa-utils_%.bbappend
@@ -1 +1,5 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
+
+SRC_URI:append = " file://0001-bat-Fix-buffer-time-configuration.patch"
+
PACKAGECONFIG:append = " bat"