ALSA: firewire-lib: process payload of isoc context according to packet descriptors
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 22 Jul 2019 03:37:09 +0000 (12:37 +0900)
committerTakashi Iwai <tiwai@suse.de>
Mon, 22 Jul 2019 14:05:11 +0000 (16:05 +0200)
This commit changes each of data block processing layer so that it
receives list of packet descriptor.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/amdtp-am824.c
sound/firewire/amdtp-stream.c
sound/firewire/amdtp-stream.h
sound/firewire/digi00x/amdtp-dot.c
sound/firewire/fireface/amdtp-ff.c
sound/firewire/motu/amdtp-motu.c
sound/firewire/tascam/amdtp-tascam.c

index 5d2952a1a9b2ba04b875b10a23509a9c0d97a392..67d735e9a6a4c2564d12613b25c2078d66c446bd 100644 (file)
@@ -345,45 +345,59 @@ static void read_midi_messages(struct amdtp_stream *s, __be32 *buffer,
        }
 }
 
-static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
-                                          const struct pkt_desc *desc,
-                                          struct snd_pcm_substream *pcm)
+static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
+                                           const struct pkt_desc *descs,
+                                           unsigned int packets,
+                                           struct snd_pcm_substream *pcm)
 {
        struct amdtp_am824 *p = s->protocol;
        unsigned int pcm_frames = 0;
+       int i;
 
-       if (pcm) {
-               write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks,
-                             pcm_frames);
-               pcm_frames = desc->data_blocks * p->frame_multiplier;
-       } else {
-               write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
-       }
+       for (i = 0; i < packets; ++i) {
+               const struct pkt_desc *desc = descs + i;
+               __be32 *buf = desc->ctx_payload;
+               unsigned int data_blocks = desc->data_blocks;
 
-       if (p->midi_ports) {
-               write_midi_messages(s, desc->ctx_payload, desc->data_blocks,
-                                   desc->data_block_counter);
+               if (pcm) {
+                       write_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
+                       pcm_frames += data_blocks * p->frame_multiplier;
+               } else {
+                       write_pcm_silence(s, buf, data_blocks);
+               }
+
+               if (p->midi_ports) {
+                       write_midi_messages(s, buf, data_blocks,
+                                           desc->data_block_counter);
+               }
        }
 
        return pcm_frames;
 }
 
-static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
-                                          const struct pkt_desc *desc,
-                                          struct snd_pcm_substream *pcm)
+static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
+                                           const struct pkt_desc *descs,
+                                           unsigned int packets,
+                                           struct snd_pcm_substream *pcm)
 {
        struct amdtp_am824 *p = s->protocol;
        unsigned int pcm_frames = 0;
+       int i;
 
-       if (pcm) {
-               read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks,
-                            pcm_frames);
-               pcm_frames = desc->data_blocks * p->frame_multiplier;
-       }
+       for (i = 0; i < packets; ++i) {
+               const struct pkt_desc *desc = descs + i;
+               __be32 *buf = desc->ctx_payload;
+               unsigned int data_blocks = desc->data_blocks;
+
+               if (pcm) {
+                       read_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
+                       pcm_frames += data_blocks * p->frame_multiplier;
+               }
 
-       if (p->midi_ports) {
-               read_midi_messages(s, desc->ctx_payload, desc->data_blocks,
-                                  desc->data_block_counter);
+               if (p->midi_ports) {
+                       read_midi_messages(s, buf, data_blocks,
+                                          desc->data_block_counter);
+               }
        }
 
        return pcm_frames;
@@ -400,15 +414,14 @@ static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
 int amdtp_am824_init(struct amdtp_stream *s, struct fw_unit *unit,
                     enum amdtp_stream_direction dir, enum cip_flags flags)
 {
-       amdtp_stream_process_data_blocks_t process_data_blocks;
+       amdtp_stream_process_ctx_payloads_t process_ctx_payloads;
 
        if (dir == AMDTP_IN_STREAM)
-               process_data_blocks = process_tx_data_blocks;
+               process_ctx_payloads = process_ir_ctx_payloads;
        else
-               process_data_blocks = process_rx_data_blocks;
+               process_ctx_payloads = process_it_ctx_payloads;
 
        return amdtp_stream_init(s, unit, dir, flags, CIP_FMT_AM,
-                                process_data_blocks,
-                                sizeof(struct amdtp_am824));
+                       process_ctx_payloads, sizeof(struct amdtp_am824));
 }
 EXPORT_SYMBOL_GPL(amdtp_am824_init);
index db2feb68105ca25125d7c65b4333ee83d401ba96..369e75e33120e02c21c109bb1ce693eb10092d7b 100644 (file)
@@ -74,16 +74,16 @@ static void pcm_period_tasklet(unsigned long data);
  * @dir: the direction of stream
  * @flags: the packet transmission method to use
  * @fmt: the value of fmt field in CIP header
- * @process_data_blocks: callback handler to process data blocks
+ * @process_ctx_payloads: callback handler to process payloads of isoc context
  * @protocol_size: the size to allocate newly for protocol
  */
 int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit,
                      enum amdtp_stream_direction dir, enum cip_flags flags,
                      unsigned int fmt,
-                     amdtp_stream_process_data_blocks_t process_data_blocks,
+                     amdtp_stream_process_ctx_payloads_t process_ctx_payloads,
                      unsigned int protocol_size)
 {
-       if (process_data_blocks == NULL)
+       if (process_ctx_payloads == NULL)
                return -EINVAL;
 
        s->protocol = kzalloc(protocol_size, GFP_KERNEL);
@@ -102,7 +102,7 @@ int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit,
        s->callbacked = false;
 
        s->fmt = fmt;
-       s->process_data_blocks = process_data_blocks;
+       s->process_ctx_payloads = process_ctx_payloads;
 
        if (dir == AMDTP_OUT_STREAM)
                s->ctx_data.rx.syt_override = -1;
@@ -764,18 +764,13 @@ static void process_ctx_payloads(struct amdtp_stream *s,
                                 const struct pkt_desc *descs,
                                 unsigned int packets)
 {
-       int i;
-
-       for (i = 0; i < packets; ++i) {
-               const struct pkt_desc *desc = descs + i;
-               struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
-               unsigned int pcm_frames;
-
-               pcm_frames = s->process_data_blocks(s, desc, pcm);
+       struct snd_pcm_substream *pcm;
+       unsigned int pcm_frames;
 
-               if (pcm && pcm_frames > 0)
-                       update_pcm_pointers(s, pcm, pcm_frames);
-       }
+       pcm = READ_ONCE(s->pcm);
+       pcm_frames = s->process_ctx_payloads(s, descs, packets, pcm);
+       if (pcm)
+               update_pcm_pointers(s, pcm, pcm_frames);
 }
 
 static void out_stream_callback(struct fw_iso_context *context, u32 tstamp,
index 0e5b85100a04ad3ba70716cd6d873f0f7dbf8dfa..50041fa884d9b10d5c73355a9cce2b680d64ba85 100644 (file)
@@ -103,9 +103,10 @@ struct pkt_desc {
 };
 
 struct amdtp_stream;
-typedef unsigned int (*amdtp_stream_process_data_blocks_t)(
+typedef unsigned int (*amdtp_stream_process_ctx_payloads_t)(
                                                struct amdtp_stream *s,
                                                const struct pkt_desc *desc,
+                                               unsigned int packets,
                                                struct snd_pcm_substream *pcm);
 struct amdtp_stream {
        struct fw_unit *unit;
@@ -168,13 +169,13 @@ struct amdtp_stream {
 
        /* For backends to process data blocks. */
        void *protocol;
-       amdtp_stream_process_data_blocks_t process_data_blocks;
+       amdtp_stream_process_ctx_payloads_t process_ctx_payloads;
 };
 
 int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit,
                      enum amdtp_stream_direction dir, enum cip_flags flags,
                      unsigned int fmt,
-                     amdtp_stream_process_data_blocks_t process_data_blocks,
+                     amdtp_stream_process_ctx_payloads_t process_ctx_payloads,
                      unsigned int protocol_size);
 void amdtp_stream_destroy(struct amdtp_stream *s);
 
index cef5caf9723680c90d3f41b573191d90ac4d3397..d613642a2ce352f8ef741c45fa4dcb98e0418ed8 100644 (file)
@@ -341,39 +341,53 @@ void amdtp_dot_midi_trigger(struct amdtp_stream *s, unsigned int port,
                WRITE_ONCE(p->midi[port], midi);
 }
 
-static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
-                                          const struct pkt_desc *desc,
-                                          struct snd_pcm_substream *pcm)
+static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
+                                           const struct pkt_desc *descs,
+                                           unsigned int packets,
+                                           struct snd_pcm_substream *pcm)
 {
        unsigned int pcm_frames = 0;
+       int i;
 
-       if (pcm) {
-               read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks,
-                            pcm_frames);
-               pcm_frames = desc->data_blocks;
-       }
+       for (i = 0; i < packets; ++i) {
+               const struct pkt_desc *desc = descs + i;
+               __be32 *buf = desc->ctx_payload;
+               unsigned int data_blocks = desc->data_blocks;
 
-       read_midi_messages(s, desc->ctx_payload, desc->data_blocks);
+               if (pcm) {
+                       read_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
+                       pcm_frames += data_blocks;
+               }
+
+               read_midi_messages(s, buf, data_blocks);
+       }
 
        return pcm_frames;
 }
 
-static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
-                                          const struct pkt_desc *desc,
-                                          struct snd_pcm_substream *pcm)
+static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
+                                           const struct pkt_desc *descs,
+                                           unsigned int packets,
+                                           struct snd_pcm_substream *pcm)
 {
        unsigned int pcm_frames = 0;
+       int i;
 
-       if (pcm) {
-               write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks,
-                             pcm_frames);
-               pcm_frames = desc->data_blocks;
-       } else {
-               write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
-       }
+       for (i = 0; i < packets; ++i) {
+               const struct pkt_desc *desc = descs + i;
+               __be32 *buf = desc->ctx_payload;
+               unsigned int data_blocks = desc->data_blocks;
 
-       write_midi_messages(s, desc->ctx_payload, desc->data_blocks,
-                           desc->data_block_counter);
+               if (pcm) {
+                       write_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
+                       pcm_frames += data_blocks;
+               } else {
+                       write_pcm_silence(s, buf, data_blocks);
+               }
+
+               write_midi_messages(s, buf, data_blocks,
+                                   desc->data_block_counter);
+       }
 
        return pcm_frames;
 }
@@ -381,20 +395,20 @@ static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
 int amdtp_dot_init(struct amdtp_stream *s, struct fw_unit *unit,
                 enum amdtp_stream_direction dir)
 {
-       amdtp_stream_process_data_blocks_t process_data_blocks;
+       amdtp_stream_process_ctx_payloads_t process_ctx_payloads;
        enum cip_flags flags;
 
-       /* Use different mode between incoming/outgoing. */
+       // Use different mode between incoming/outgoing.
        if (dir == AMDTP_IN_STREAM) {
                flags = CIP_NONBLOCKING;
-               process_data_blocks = process_tx_data_blocks;
+               process_ctx_payloads = process_ir_ctx_payloads;
        } else {
                flags = CIP_BLOCKING;
-               process_data_blocks = process_rx_data_blocks;
+               process_ctx_payloads = process_it_ctx_payloads;
        }
 
        return amdtp_stream_init(s, unit, dir, flags, CIP_FMT_AM,
-                                process_data_blocks, sizeof(struct amdtp_dot));
+                               process_ctx_payloads, sizeof(struct amdtp_dot));
 }
 
 void amdtp_dot_reset(struct amdtp_stream *s)
index cb2073cf146bcbaf1209e9ec1c9b9850b40a3ce3..119c0076b17a371b46eb7e20a26c7cccc334f0a8 100644 (file)
@@ -112,34 +112,47 @@ int amdtp_ff_add_pcm_hw_constraints(struct amdtp_stream *s,
        return amdtp_stream_add_pcm_hw_constraints(s, runtime);
 }
 
-static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
-                                          const struct pkt_desc *desc,
+static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
+                                          const struct pkt_desc *descs,
+                                          unsigned int packets,
                                           struct snd_pcm_substream *pcm)
 {
        unsigned int pcm_frames = 0;
-
-       if (pcm) {
-               write_pcm_s32(s, pcm, (__le32 *)desc->ctx_payload,
-                             desc->data_blocks, pcm_frames);
-               pcm_frames = desc->data_blocks;
-       } else {
-               write_pcm_silence(s, (__le32 *)desc->ctx_payload,
-                                 desc->data_blocks);
+       int i;
+
+       for (i = 0; i < packets; ++i) {
+               const struct pkt_desc *desc = descs + i;
+               __le32 *buf = (__le32 *)desc->ctx_payload;
+               unsigned int data_blocks = desc->data_blocks;
+
+               if (pcm) {
+                       write_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
+                       pcm_frames += data_blocks;
+               } else {
+                       write_pcm_silence(s, buf, data_blocks);
+               }
        }
 
        return pcm_frames;
 }
 
-static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
-                                          const struct pkt_desc *desc,
-                                          struct snd_pcm_substream *pcm)
+static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
+                                           const struct pkt_desc *descs,
+                                           unsigned int packets,
+                                           struct snd_pcm_substream *pcm)
 {
        unsigned int pcm_frames = 0;
+       int i;
 
-       if (pcm) {
-               read_pcm_s32(s, pcm, (__le32 *)desc->ctx_payload,
-                            desc->data_blocks, pcm_frames);
-               pcm_frames = desc->data_blocks;
+       for (i = 0; i < packets; ++i) {
+               const struct pkt_desc *desc = descs + i;
+               __le32 *buf = (__le32 *)desc->ctx_payload;
+               unsigned int data_blocks = desc->data_blocks;
+
+               if (pcm) {
+                       read_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
+                       pcm_frames += data_blocks;
+               }
        }
 
        return pcm_frames;
@@ -148,13 +161,13 @@ static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
 int amdtp_ff_init(struct amdtp_stream *s, struct fw_unit *unit,
                  enum amdtp_stream_direction dir)
 {
-       amdtp_stream_process_data_blocks_t process_data_blocks;
+       amdtp_stream_process_ctx_payloads_t process_ctx_payloads;
 
        if (dir == AMDTP_IN_STREAM)
-               process_data_blocks = process_tx_data_blocks;
+               process_ctx_payloads = process_ir_ctx_payloads;
        else
-               process_data_blocks = process_rx_data_blocks;
+               process_ctx_payloads = process_it_ctx_payloads;
 
        return amdtp_stream_init(s, unit, dir, CIP_NO_HEADER, 0,
-                                process_data_blocks, sizeof(struct amdtp_ff));
+                                process_ctx_payloads, sizeof(struct amdtp_ff));
 }
index 21c6bfdf47c0e5bc7fac8e47e5cafb3d0a85634d..05a6e218b0ad9e496c09c7ff8ce20bd1372f2bb9 100644 (file)
@@ -310,23 +310,30 @@ static void __maybe_unused copy_message(u64 *frames, __be32 *buffer,
        }
 }
 
-static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
-                                          const struct pkt_desc *desc,
-                                          struct snd_pcm_substream *pcm)
+static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
+                                           const struct pkt_desc *descs,
+                                           unsigned int packets,
+                                           struct snd_pcm_substream *pcm)
 {
        struct amdtp_motu *p = s->protocol;
        unsigned int pcm_frames = 0;
+       int i;
+
+       for (i = 0; i < packets; ++i) {
+               const struct pkt_desc *desc = descs + i;
+               __be32 *buf = desc->ctx_payload;
+               unsigned int data_blocks = desc->data_blocks;
 
-       trace_data_block_sph(s, desc->data_blocks, desc->ctx_payload);
-       trace_data_block_message(s, desc->data_blocks, desc->ctx_payload);
+               trace_data_block_sph(s, data_blocks, buf);
+               trace_data_block_message(s, data_blocks, buf);
 
-       if (p->midi_ports)
-               read_midi_messages(s, desc->ctx_payload, desc->data_blocks);
+               if (p->midi_ports)
+                       read_midi_messages(s, buf, data_blocks);
 
-       if (pcm) {
-               read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks,
-                            pcm_frames);
-               pcm_frames = desc->data_blocks;
+               if (pcm) {
+                       read_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
+                       pcm_frames += data_blocks;
+               }
        }
 
        return pcm_frames;
@@ -374,30 +381,37 @@ static void write_sph(struct amdtp_stream *s, __be32 *buffer,
        }
 }
 
-static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
-                                          const struct pkt_desc *desc,
-                                          struct snd_pcm_substream *pcm)
+static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
+                                           const struct pkt_desc *descs,
+                                           unsigned int packets,
+                                           struct snd_pcm_substream *pcm)
 {
        struct amdtp_motu *p = s->protocol;
        unsigned int pcm_frames = 0;
+       int i;
 
-       /* TODO: how to interact control messages between userspace? */
+       for (i = 0; i < packets; ++i) {
+               const struct pkt_desc *desc = descs + i;
+               __be32 *buf = desc->ctx_payload;
+               unsigned int data_blocks = desc->data_blocks;
 
-       if (p->midi_ports)
-               write_midi_messages(s, desc->ctx_payload, desc->data_blocks);
+               // TODO: how to interact control messages between userspace?
 
-       if (pcm) {
-               write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks,
-                             pcm_frames);
-               pcm_frames = desc->data_blocks;
-       } else {
-               write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
-       }
+               if (p->midi_ports)
+                       write_midi_messages(s, buf, data_blocks);
 
-       write_sph(s, desc->ctx_payload, desc->data_blocks);
+               if (pcm) {
+                       write_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
+                       pcm_frames += data_blocks;
+               } else {
+                       write_pcm_silence(s, buf, data_blocks);
+               }
 
-       trace_data_block_sph(s, desc->data_blocks, desc->ctx_payload);
-       trace_data_block_message(s, desc->data_blocks, desc->ctx_payload);
+               write_sph(s, buf, data_blocks);
+
+               trace_data_block_sph(s, data_blocks, buf);
+               trace_data_block_message(s, data_blocks, buf);
+       }
 
        return pcm_frames;
 }
@@ -406,13 +420,13 @@ int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
                    enum amdtp_stream_direction dir,
                    const struct snd_motu_protocol *const protocol)
 {
-       amdtp_stream_process_data_blocks_t process_data_blocks;
+       amdtp_stream_process_ctx_payloads_t process_ctx_payloads;
        int fmt = CIP_FMT_MOTU;
        int flags = CIP_BLOCKING;
        int err;
 
        if (dir == AMDTP_IN_STREAM) {
-               process_data_blocks = process_tx_data_blocks;
+               process_ctx_payloads = process_ir_ctx_payloads;
 
                /*
                 * Units of version 3 transmits packets with invalid CIP header
@@ -431,11 +445,11 @@ int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
                                 CIP_SKIP_DBC_ZERO_CHECK;
                }
        } else {
-               process_data_blocks = process_rx_data_blocks;
+               process_ctx_payloads = process_it_ctx_payloads;
                flags |= CIP_DBC_IS_END_EVENT;
        }
 
-       err = amdtp_stream_init(s, unit, dir, flags, fmt, process_data_blocks,
+       err = amdtp_stream_init(s, unit, dir, flags, fmt, process_ctx_payloads,
                                sizeof(struct amdtp_motu));
        if (err < 0)
                return err;
index 3c9abf422f24b915a099353525862687bb67c1f6..e80bb84c43f6780fc7006fd3930b2c546e80b2e3 100644 (file)
@@ -175,35 +175,49 @@ static void read_status_messages(struct amdtp_stream *s,
        }
 }
 
-static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
-                                          const struct pkt_desc *desc,
-                                          struct snd_pcm_substream *pcm)
+static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
+                                           const struct pkt_desc *descs,
+                                           unsigned int packets,
+                                           struct snd_pcm_substream *pcm)
 {
        unsigned int pcm_frames = 0;
+       int i;
 
-       if (pcm) {
-               read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks,
-                            pcm_frames);
-               pcm_frames += desc->data_blocks;
-       }
+       for (i = 0; i < packets; ++i) {
+               const struct pkt_desc *desc = descs + i;
+               __be32 *buf = desc->ctx_payload;
+               unsigned int data_blocks = desc->data_blocks;
 
-       read_status_messages(s, desc->ctx_payload, desc->data_blocks);
+               if (pcm) {
+                       read_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
+                       pcm_frames += data_blocks;
+               }
+
+               read_status_messages(s, buf, data_blocks);
+       }
 
        return pcm_frames;
 }
 
-static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
-                                          const struct pkt_desc *desc,
-                                          struct snd_pcm_substream *pcm)
+static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
+                                           const struct pkt_desc *descs,
+                                           unsigned int packets,
+                                           struct snd_pcm_substream *pcm)
 {
        unsigned int pcm_frames = 0;
+       int i;
 
-       if (pcm) {
-               write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks,
-                             pcm_frames);
-               pcm_frames += desc->data_blocks;
-       } else {
-               write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
+       for (i = 0; i < packets; ++i) {
+               const struct pkt_desc *desc = descs + i;
+               __be32 *buf = desc->ctx_payload;
+               unsigned int data_blocks = desc->data_blocks;
+
+               if (pcm) {
+                       write_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
+                       pcm_frames += data_blocks;
+               } else {
+                       write_pcm_silence(s, buf, data_blocks);
+               }
        }
 
        return pcm_frames;
@@ -212,22 +226,22 @@ static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
 int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit,
                    enum amdtp_stream_direction dir, unsigned int pcm_channels)
 {
-       amdtp_stream_process_data_blocks_t process_data_blocks;
+       amdtp_stream_process_ctx_payloads_t process_ctx_payloads;
        struct amdtp_tscm *p;
        unsigned int fmt;
        int err;
 
        if (dir == AMDTP_IN_STREAM) {
                fmt = AMDTP_FMT_TSCM_TX;
-               process_data_blocks = process_tx_data_blocks;
+               process_ctx_payloads = process_ir_ctx_payloads;
        } else {
                fmt = AMDTP_FMT_TSCM_RX;
-               process_data_blocks = process_rx_data_blocks;
+               process_ctx_payloads = process_it_ctx_payloads;
        }
 
        err = amdtp_stream_init(s, unit, dir,
-                               CIP_NONBLOCKING | CIP_SKIP_DBC_ZERO_CHECK, fmt,
-                               process_data_blocks, sizeof(struct amdtp_tscm));
+                       CIP_NONBLOCKING | CIP_SKIP_DBC_ZERO_CHECK, fmt,
+                       process_ctx_payloads, sizeof(struct amdtp_tscm));
        if (err < 0)
                return 0;