All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: alsa-devel@alsa-project.org
Cc: Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>,
	Alexander Stein <alexander.stein@ew.tq-group.com>
Subject: [PATCH 1/1] bat: Fix buffer time configuration
Date: Thu, 10 Apr 2025 13:01:19 +0200	[thread overview]
Message-ID: <20250410110120.1997264-1-alexander.stein@ew.tq-group.com> (raw)

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 <alexander.stein@ew.tq-group.com>
---
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(-)

diff --git a/bat/alsa.c b/bat/alsa.c
index 67489c4..457e79a 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.43.0


             reply	other threads:[~2025-04-10 11:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 11:01 Alexander Stein [this message]
2025-05-16  8:41 ` [PATCH 1/1] bat: Fix buffer time configuration Alexander Stein
2025-05-16  9:17   ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250410110120.1997264-1-alexander.stein@ew.tq-group.com \
    --to=alexander.stein@ew.tq-group.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.