ALSA: firewire-motu: fix detection for S/PDIF source on optical interface in v2 protocol
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 23 Jun 2021 07:59:33 +0000 (16:59 +0900)
committerTakashi Iwai <tiwai@suse.de>
Wed, 23 Jun 2021 08:17:23 +0000 (10:17 +0200)
The devices in protocol version 2 has a register with flag for IEC 60958
signal detection as source of sampling clock without discrimination
between coaxial and optical interfaces. On the other hand, current
implementation of driver manage to interpret type of signal on optical
interface instead.

This commit fixes the detection of optical/coaxial interface for S/PDIF
signal.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210623075941.72562-2-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/motu/motu-protocol-v2.c

index 784073a..f0a0eca 100644 (file)
@@ -86,24 +86,23 @@ static int detect_clock_source_optical_model(struct snd_motu *motu, u32 data,
                *src = SND_MOTU_CLOCK_SOURCE_INTERNAL;
                break;
        case 1:
+               *src = SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT;
+               break;
+       case 2:
        {
                __be32 reg;
 
                // To check the configuration of optical interface.
-               int err = snd_motu_transaction_read(motu, V2_IN_OUT_CONF_OFFSET,
-                                                   &reg, sizeof(reg));
+               int err = snd_motu_transaction_read(motu, V2_IN_OUT_CONF_OFFSET, &reg, sizeof(reg));
                if (err < 0)
                        return err;
 
-               if (be32_to_cpu(reg) & 0x00000200)
+               if (((data & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT) == V2_OPT_IFACE_MODE_SPDIF)
                        *src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT;
                else
-                       *src = SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT;
+                       *src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX;
                break;
        }
-       case 2:
-               *src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX;
-               break;
        case 3:
                *src = SND_MOTU_CLOCK_SOURCE_SPH;
                break;