From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: tiwai@suse.de
Cc: alsa-devel@alsa-project.org, clemens@ladisch.de
Subject: [PATCH 8/9] ALSA: firewire-motu: fix register handling for 828
Date: Wed, 23 Jun 2021 16:59:40 +0900 [thread overview]
Message-ID: <20210623075941.72562-9-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20210623075941.72562-1-o-takashi@sakamocchi.jp>
After further investigation, I find out some mistakes for 828 about its
register. This commit fixes it.
Fixes: d13d6b284d8b ("ALSA: firewire-motu: add support for MOTU 828")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
sound/firewire/motu/motu-protocol-v1.c | 53 +++++++++++++++++---------
1 file changed, 35 insertions(+), 18 deletions(-)
diff --git a/sound/firewire/motu/motu-protocol-v1.c b/sound/firewire/motu/motu-protocol-v1.c
index 65209e617e10..3b766615a9ee 100644
--- a/sound/firewire/motu/motu-protocol-v1.c
+++ b/sound/firewire/motu/motu-protocol-v1.c
@@ -19,7 +19,7 @@
// 0x00004000: mode of optical output interface.
// 0x00004000: for S/PDIF signal.
// 0x00000000: disabled or for ADAT signal.
-// 0x00003f40: monitor input mode.
+// 0x00003f00: monitor input mode.
// 0x00000800: analog-1/2
// 0x00001a00: analog-3/4
// 0x00002c00: analog-5/6
@@ -32,26 +32,32 @@
// 0x00002d00: analog-6
// 0x00003600: analog-7
// 0x00003f00: analog-8
-// 0x00000040: disabled
+// 0x00000080: enable stream input.
+// 0x00000040: disable monitor input.
+// 0x00000008: enable main out.
// 0x00000004: rate of sampling clock.
// 0x00000004: 48.0 kHz
// 0x00000000: 44.1 kHz
// 0x00000023: source of sampling clock.
+// 0x00000003: source packet header (SPH)
// 0x00000002: S/PDIF on optical/coaxial interface.
// 0x00000021: ADAT on optical interface
// 0x00000001: ADAT on Dsub 9pin
-// 0x00000000: internal or SMPTE
+// 0x00000000: internal
#define CLK_828_STATUS_OFFSET 0x0b00
#define CLK_828_STATUS_MASK 0x0000ffff
#define CLK_828_STATUS_FLAG_OPT_IN_IFACE_IS_SPDIF 0x00008000
#define CLK_828_STATUS_FLAG_OPT_OUT_IFACE_IS_SPDIF 0x00004000
#define CLK_828_STATUS_FLAG_FETCH_PCM_FRAMES 0x00000080
-#define CLK_828_STATUS_FLAG_SRC_IS_NOT_FROM_ADAT_DSUB 0x00000020
-#define CLK_828_STATUS_FLAG_OUTPUT_MUTE 0x00000008
+#define CLK_828_STATUS_FLAG_ENABLE_OUTPUT 0x00000008
#define CLK_828_STATUS_FLAG_RATE_48000 0x00000004
-#define CLK_828_STATUS_FLAG_SRC_SPDIF_ON_OPT_OR_COAX 0x00000002
-#define CLK_828_STATUS_FLAG_SRC_ADAT_ON_OPT_OR_DSUB 0x00000001
+#define CLK_828_STATUS_MASK_SRC 0x00000023
+#define CLK_828_STATUS_FLAG_SRC_ADAT_ON_OPT 0x00000021
+#define CLK_828_STATUS_FLAG_SRC_SPH 0x00000003
+#define CLK_828_STATUS_FLAG_SRC_SPDIF 0x00000002
+#define CLK_828_STATUS_FLAG_SRC_ADAT_ON_DSUB 0x00000001
+#define CLK_828_STATUS_FLAG_SRC_INTERNAL 0x00000000
// Status register for MOTU 896 (0x'ffff'f000'0b14).
//
@@ -249,18 +255,29 @@ static int get_clock_source_828(struct snd_motu *motu, enum snd_motu_clock_sourc
return err;
data = be32_to_cpu(reg) & CLK_828_STATUS_MASK;
- if (data & CLK_828_STATUS_FLAG_SRC_ADAT_ON_OPT_OR_DSUB) {
- if (data & CLK_828_STATUS_FLAG_SRC_IS_NOT_FROM_ADAT_DSUB)
- *src = SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT;
- else
- *src = SND_MOTU_CLOCK_SOURCE_ADAT_ON_DSUB;
- } else if (data & CLK_828_STATUS_FLAG_SRC_SPDIF_ON_OPT_OR_COAX) {
+ switch (data & CLK_828_STATUS_MASK_SRC) {
+ case CLK_828_STATUS_FLAG_SRC_ADAT_ON_OPT:
+ *src = SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT;
+ break;
+ case CLK_828_STATUS_FLAG_SRC_SPH:
+ *src = SND_MOTU_CLOCK_SOURCE_SPH;
+ break;
+ case CLK_828_STATUS_FLAG_SRC_SPDIF:
+ {
if (data & CLK_828_STATUS_FLAG_OPT_IN_IFACE_IS_SPDIF)
- *src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT;
- else
*src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX;
- } else {
+ else
+ *src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT;
+ break;
+ }
+ case CLK_828_STATUS_FLAG_SRC_ADAT_ON_DSUB:
+ *src = SND_MOTU_CLOCK_SOURCE_ADAT_ON_DSUB;
+ break;
+ case CLK_828_STATUS_FLAG_SRC_INTERNAL:
*src = SND_MOTU_CLOCK_SOURCE_INTERNAL;
+ break;
+ default:
+ return -ENXIO;
}
return 0;
@@ -321,13 +338,13 @@ static int switch_fetching_mode_828(struct snd_motu *motu, bool enable)
return err;
data = be32_to_cpu(reg) & CLK_828_STATUS_MASK;
- data &= ~(CLK_828_STATUS_FLAG_FETCH_PCM_FRAMES | CLK_828_STATUS_FLAG_OUTPUT_MUTE);
+ data &= ~(CLK_828_STATUS_FLAG_FETCH_PCM_FRAMES | CLK_828_STATUS_FLAG_ENABLE_OUTPUT);
if (enable) {
// This transaction should be initiated after the device receives batch of packets
// since the device voluntarily mutes outputs. As a workaround, yield processor over
// 100 msec.
msleep(100);
- data |= CLK_828_STATUS_FLAG_FETCH_PCM_FRAMES | CLK_828_STATUS_FLAG_OUTPUT_MUTE;
+ data |= CLK_828_STATUS_FLAG_FETCH_PCM_FRAMES | CLK_828_STATUS_FLAG_ENABLE_OUTPUT;
}
reg = cpu_to_be32(data);
--
2.30.2
next prev parent reply other threads:[~2021-06-23 8:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 7:59 [PATCH 0/9] ALSA: firewire-motu: misc fixes and code refactoring Takashi Sakamoto
2021-06-23 7:59 ` [PATCH 1/9] ALSA: firewire-motu: fix detection for S/PDIF source on optical interface in v2 protocol Takashi Sakamoto
2021-06-23 7:59 ` [PATCH 2/9] ALSA: firewire-motu: code refactoring for detection of clock source " Takashi Sakamoto
2021-06-23 7:59 ` [PATCH 3/9] ALSA: firewire-motu: add support for AES/EBU " Takashi Sakamoto
2021-06-23 7:59 ` [PATCH 4/9] ALSA: firewire-motu: use macro instead of magic number for " Takashi Sakamoto
2021-06-23 7:59 ` [PATCH 5/9] ALSA: firewire-motu: code refactoring for packet format detection " Takashi Sakamoto
2021-06-23 7:59 ` [PATCH 6/9] ALSA: firewire-motu: code refactoring for source detection of sampling clock in v3 protocol Takashi Sakamoto
2021-06-23 7:59 ` [PATCH 7/9] ALSA: firewire-motu: use macro instead of magic number for clock source " Takashi Sakamoto
2021-06-23 7:59 ` Takashi Sakamoto [this message]
2021-06-23 7:59 ` [PATCH 9/9] ALSA: firewire-motu: fix register handling for 896 Takashi Sakamoto
2021-06-23 8:54 ` [PATCH 0/9] ALSA: firewire-motu: misc fixes and code refactoring 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=20210623075941.72562-9-o-takashi@sakamocchi.jp \
--to=o-takashi@sakamocchi.jp \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).