All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: clemens@ladisch.de, tiwai@suse.de
Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sourceforge.net,
	stable@vger.kernel.org
Subject: [PATCH 1/6] ALSA: fireface: fix configuration error for nominal sampling transfer frequency
Date: Sun, 10 May 2020 16:42:56 +0900	[thread overview]
Message-ID: <20200510074301.116224-2-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20200510074301.116224-1-o-takashi@sakamocchi.jp>

128000 and 192000 are congruence modulo 32000, thus it's wrong to
distinguish them as multiple of 32000 and 48000 by modulo 32000 at
first.

Additionally, used condition statement to detect quadruple speed can
cause missing bit flag.

Furthermore, counter to ensure the configuration is wrong and it
causes false positive.

This commit fixes the above three bugs.

Cc: <stable@vger.kernel.org>
Fixes: 60aec494b389 ("ALSA: fireface: support allocate_resources operation in latter protocol")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/fireface/ff-protocol-latter.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sound/firewire/fireface/ff-protocol-latter.c b/sound/firewire/fireface/ff-protocol-latter.c
index 0e4c3a9ed5e4..76ae568489ef 100644
--- a/sound/firewire/fireface/ff-protocol-latter.c
+++ b/sound/firewire/fireface/ff-protocol-latter.c
@@ -107,18 +107,18 @@ static int latter_allocate_resources(struct snd_ff *ff, unsigned int rate)
 	int err;
 
 	// Set the number of data blocks transferred in a second.
-	if (rate % 32000 == 0)
-		code = 0x00;
+	if (rate % 48000 == 0)
+		code = 0x04;
 	else if (rate % 44100 == 0)
 		code = 0x02;
-	else if (rate % 48000 == 0)
-		code = 0x04;
+	else if (rate % 32000 == 0)
+		code = 0x00;
 	else
 		return -EINVAL;
 
 	if (rate >= 64000 && rate < 128000)
 		code |= 0x08;
-	else if (rate >= 128000 && rate < 192000)
+	else if (rate >= 128000)
 		code |= 0x10;
 
 	reg = cpu_to_le32(code);
@@ -140,7 +140,7 @@ static int latter_allocate_resources(struct snd_ff *ff, unsigned int rate)
 		if (curr_rate == rate)
 			break;
 	}
-	if (count == 10)
+	if (count > 10)
 		return -ETIMEDOUT;
 
 	for (i = 0; i < ARRAY_SIZE(amdtp_rate_table); ++i) {
-- 
2.25.1


  reply	other threads:[~2020-05-10  7:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-10  7:42 [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Sakamoto
2020-05-10  7:42 ` Takashi Sakamoto [this message]
2020-05-10  7:42 ` [PATCH 2/6] ALSA: fireface: start IR context immediately Takashi Sakamoto
2020-05-10  7:42 ` [PATCH 3/6] ALSA: fireface: code refactoring to add enumeration constants for model identification Takashi Sakamoto
2020-05-10  7:42 ` [PATCH 4/6] ALSA: fireface: code refactoring to decide name of sound card Takashi Sakamoto
2020-05-10  7:43 ` [PATCH 5/6] ALSA: fireface: add support for RME FireFace 802 Takashi Sakamoto
2020-05-10  7:43 ` [PATCH 6/6] ALSA: fireface: add support for RME Fireface UFX (untested) Takashi Sakamoto
2020-05-10 10:05 ` [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Iwai
2020-05-10 10:17   ` Takashi Sakamoto
2020-05-10 17:28     ` 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=20200510074301.116224-2-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=ffado-devel@lists.sourceforge.net \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.de \
    --subject='Re: [PATCH 1/6] ALSA: fireface: fix configuration error for nominal sampling transfer frequency' \
    /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

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.