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
Subject: [alsa-devel] [PATCH 3/6] ALSA: firewire-motu: detect SPH source of sampling clock
Date: Wed, 30 Oct 2019 17:06:41 +0900	[thread overview]
Message-ID: <20191030080644.1704-4-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20191030080644.1704-1-o-takashi@sakamocchi.jp>

In MOTU FireWire series, devices have a mode to generate sampling clock
from a sequence of source packet header (SPH) included in each data block
of received packet. This mode is used for several purposes such as mode
for SMPTE time code, sync to the other sound cards and so on.

This commit adds support for the SPH mode.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/motu/motu-pcm.c         | 3 ++-
 sound/firewire/motu/motu-proc.c        | 1 +
 sound/firewire/motu/motu-protocol-v2.c | 3 +++
 sound/firewire/motu/motu-protocol-v3.c | 2 ++
 sound/firewire/motu/motu.h             | 1 +
 5 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/sound/firewire/motu/motu-pcm.c b/sound/firewire/motu/motu-pcm.c
index 55d3d6661731..490408b49157 100644
--- a/sound/firewire/motu/motu-pcm.c
+++ b/sound/firewire/motu/motu-pcm.c
@@ -159,7 +159,8 @@ static int pcm_open(struct snd_pcm_substream *substream)
 	// When source of clock is not internal or any stream is reserved for
 	// transmission of PCM frames, the available sampling rate is limited
 	// at current one.
-	if (src != SND_MOTU_CLOCK_SOURCE_INTERNAL ||
+	if ((src != SND_MOTU_CLOCK_SOURCE_INTERNAL &&
+	     src != SND_MOTU_CLOCK_SOURCE_SPH) ||
 	    (motu->substreams_counter > 0 && d->events_per_period > 0)) {
 		unsigned int frames_per_period = d->events_per_period;
 		unsigned int frames_per_buffer = d->events_per_buffer;
diff --git a/sound/firewire/motu/motu-proc.c b/sound/firewire/motu/motu-proc.c
index 4e5767c0c8d7..b47ba818343f 100644
--- a/sound/firewire/motu/motu-proc.c
+++ b/sound/firewire/motu/motu-proc.c
@@ -19,6 +19,7 @@ static const char *const clock_names[] = {
 	[SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX] = "S/PCIF on coaxial interface",
 	[SND_MOTU_CLOCK_SOURCE_AESEBU_ON_XLR] = "AESEBU on XLR interface",
 	[SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC] = "Word clock on BNC interface",
+	[SND_MOTU_CLOCK_SOURCE_SPH] = "Source packet header",
 	[SND_MOTU_CLOCK_SOURCE_UNKNOWN] = "Unknown",
 };
 
diff --git a/sound/firewire/motu/motu-protocol-v2.c b/sound/firewire/motu/motu-protocol-v2.c
index a42f77fc3858..2757e5b42b9b 100644
--- a/sound/firewire/motu/motu-protocol-v2.c
+++ b/sound/firewire/motu/motu-protocol-v2.c
@@ -114,6 +114,9 @@ static int v2_get_clock_source(struct snd_motu *motu,
 	case 2:
 		*src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX;
 		break;
+	case 3:
+		*src = SND_MOTU_CLOCK_SOURCE_SPH;
+		break;
 	case 4:
 		*src = SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC;
 		break;
diff --git a/sound/firewire/motu/motu-protocol-v3.c b/sound/firewire/motu/motu-protocol-v3.c
index ba5794c724be..d1545e2b5caa 100644
--- a/sound/firewire/motu/motu-protocol-v3.c
+++ b/sound/firewire/motu/motu-protocol-v3.c
@@ -104,6 +104,8 @@ static int v3_get_clock_source(struct snd_motu *motu,
 		*src = SND_MOTU_CLOCK_SOURCE_INTERNAL;
 	} else if (val == 0x01) {
 		*src = SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC;
+	} else if (val == 0x02) {
+		*src = SND_MOTU_CLOCK_SOURCE_SPH;
 	} else if (val == 0x10) {
 		*src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX;
 	} else if (val == 0x18 || val == 0x19) {
diff --git a/sound/firewire/motu/motu.h b/sound/firewire/motu/motu.h
index 08e3d568221d..bd782ee4e763 100644
--- a/sound/firewire/motu/motu.h
+++ b/sound/firewire/motu/motu.h
@@ -104,6 +104,7 @@ enum snd_motu_clock_source {
 	SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX,
 	SND_MOTU_CLOCK_SOURCE_AESEBU_ON_XLR,
 	SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC,
+	SND_MOTU_CLOCK_SOURCE_SPH,
 	SND_MOTU_CLOCK_SOURCE_UNKNOWN,
 };
 
-- 
2.20.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  parent reply	other threads:[~2019-10-30  8:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30  8:06 [alsa-devel] [PATCH 0/6] ALSA: firewire-motu: add support for MOTU UltraLite and source packet header clock mode Takashi Sakamoto
2019-10-30  8:06 ` [alsa-devel] [PATCH 1/6] ALSA: firewire-motu: fix wrong spelling for macro Takashi Sakamoto
2019-10-30  8:06 ` [alsa-devel] [PATCH 2/6] ALSA: firewire-motu: print for unknown source of sampling clock Takashi Sakamoto
2019-10-30  8:06 ` Takashi Sakamoto [this message]
2019-10-30  8:06 ` [alsa-devel] [PATCH 4/6] ALSA: firewire-motu: minor code refactoring for protocol version 2 Takashi Sakamoto
2019-10-30  8:06 ` [alsa-devel] [PATCH 5/6] ALSA: firewire-motu: code refactoring to handle model specific switch for protocol v2 Takashi Sakamoto
2019-10-30  8:06 ` [alsa-devel] [PATCH 6/6] ALSA: firewire-motu: add support for MOTU UltraLite Takashi Sakamoto
2019-10-30 10:03 ` [alsa-devel] [PATCH 0/6] ALSA: firewire-motu: add support for MOTU UltraLite and source packet header clock mode 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=20191030080644.1704-4-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 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.