ALSA: firewire-motu: detect SPH source of sampling clock
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 30 Oct 2019 08:06:41 +0000 (17:06 +0900)
committerTakashi Iwai <tiwai@suse.de>
Wed, 30 Oct 2019 09:57:54 +0000 (10:57 +0100)
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>
Link: https://lore.kernel.org/r/20191030080644.1704-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/motu/motu-pcm.c
sound/firewire/motu/motu-proc.c
sound/firewire/motu/motu-protocol-v2.c
sound/firewire/motu/motu-protocol-v3.c
sound/firewire/motu/motu.h

index 55d3d6661731e9ca05533fbcda728d471fedd459..490408b49157b4d7336db2ae84e7c8839e987c19 100644 (file)
@@ -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;
index 4e5767c0c8d768dab73f3547231957493c03b253..b47ba818343ff8233a6d4a88ca410be2b0fd1281 100644 (file)
@@ -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",
 };
 
index a42f77fc38580dae2fd9ede5e7862cf2fadb7ef4..2757e5b42b9b19c5eba8b5506d015d8f4c436824 100644 (file)
@@ -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;
index ba5794c724beb54c462a9755006adaf349fbb41a..d1545e2b5caaa7dc3b1d05abb63d86e9d1a3dca8 100644 (file)
@@ -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) {
index 08e3d568221d97a309ff8c16d64e84e076f5f7b1..bd782ee4e763bbc956848b7ef56807f5ecd2d833 100644 (file)
@@ -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,
 };