ALSA: firewire-digi00x: perform sequence replay for media clock recovery
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 31 May 2021 02:51:01 +0000 (11:51 +0900)
committerTakashi Iwai <tiwai@suse.de>
Tue, 1 Jun 2021 06:19:25 +0000 (08:19 +0200)
This commit takes ALSA firewire-digi00x driver to perform sequence replay
for media clock recovery.

All of models in Digidesign digi00x family don't transfer isochronous
packets till receiving isochronous packets. The on-the-fly mode is used
for the purpose. They don't interpret presentation time expressed in syt
field of received CIP, therefore the sequence of the number of data blocks
per packet is important for media clock recovery.

The sequence replay is tested with below models:

* Digidesign Digi 002
* Digidesign Digi 002 Rack
* Digidesign Digi 003
* Digidesign Digi 003 Rack

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210531025103.17880-5-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/digi00x/amdtp-dot.c
sound/firewire/digi00x/digi00x-stream.c

index 398c57a..59b86c8 100644 (file)
@@ -396,16 +396,13 @@ int amdtp_dot_init(struct amdtp_stream *s, struct fw_unit *unit,
                 enum amdtp_stream_direction dir)
 {
        amdtp_stream_process_ctx_payloads_t process_ctx_payloads;
-       unsigned int flags;
+       unsigned int flags = CIP_NONBLOCKING | CIP_UNAWARE_SYT;
 
        // Use different mode between incoming/outgoing.
-       if (dir == AMDTP_IN_STREAM) {
-               flags = CIP_NONBLOCKING;
+       if (dir == AMDTP_IN_STREAM)
                process_ctx_payloads = process_ir_ctx_payloads;
-       } else {
-               flags = CIP_BLOCKING;
+       else
                process_ctx_payloads = process_it_ctx_payloads;
-       }
 
        return amdtp_stream_init(s, unit, dir, flags, CIP_FMT_AM,
                                process_ctx_payloads, sizeof(struct amdtp_dot));
index 2019f65..a15f55b 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "digi00x.h"
 
-#define READY_TIMEOUT_MS       500
+#define READY_TIMEOUT_MS       200
 
 const unsigned int snd_dg00x_stream_rates[SND_DG00X_RATE_COUNT] = {
        [SND_DG00X_RATE_44100] = 44100,
@@ -375,7 +375,11 @@ int snd_dg00x_stream_start_duplex(struct snd_dg00x *dg00x)
                if (err < 0)
                        goto error;
 
-               err = amdtp_domain_start(&dg00x->domain, 0, false, false);
+               // NOTE: The device doesn't start packet transmission till receiving any packet.
+               // It ignores presentation time expressed by the value of syt field of CIP header
+               // in received packets. The sequence of the number of data blocks per packet is
+               // important for media clock recovery.
+               err = amdtp_domain_start(&dg00x->domain, 0, true, true);
                if (err < 0)
                        goto error;