ALSA: firewire-lib: process payload of isoc context according to packet descriptors

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>
This commit is contained in:
Takashi Sakamoto 2019-07-22 12:37:09 +09:00 committed by Takashi Iwai
parent 4731c672c9
commit 9a738ad1b1
7 changed files with 212 additions and 148 deletions

View 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, static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
const struct pkt_desc *desc, const struct pkt_desc *descs,
struct snd_pcm_substream *pcm) unsigned int packets,
struct snd_pcm_substream *pcm)
{ {
struct amdtp_am824 *p = s->protocol; struct amdtp_am824 *p = s->protocol;
unsigned int pcm_frames = 0; unsigned int pcm_frames = 0;
int i;
if (pcm) { for (i = 0; i < packets; ++i) {
write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks, const struct pkt_desc *desc = descs + i;
pcm_frames); __be32 *buf = desc->ctx_payload;
pcm_frames = desc->data_blocks * p->frame_multiplier; unsigned int data_blocks = desc->data_blocks;
} else {
write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
}
if (p->midi_ports) { if (pcm) {
write_midi_messages(s, desc->ctx_payload, desc->data_blocks, write_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
desc->data_block_counter); 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; return pcm_frames;
} }
static unsigned int process_tx_data_blocks(struct amdtp_stream *s, static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
const struct pkt_desc *desc, const struct pkt_desc *descs,
struct snd_pcm_substream *pcm) unsigned int packets,
struct snd_pcm_substream *pcm)
{ {
struct amdtp_am824 *p = s->protocol; struct amdtp_am824 *p = s->protocol;
unsigned int pcm_frames = 0; unsigned int pcm_frames = 0;
int i;
if (pcm) { for (i = 0; i < packets; ++i) {
read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks, const struct pkt_desc *desc = descs + i;
pcm_frames); __be32 *buf = desc->ctx_payload;
pcm_frames = desc->data_blocks * p->frame_multiplier; unsigned int data_blocks = desc->data_blocks;
}
if (p->midi_ports) { if (pcm) {
read_midi_messages(s, desc->ctx_payload, desc->data_blocks, read_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
desc->data_block_counter); pcm_frames += data_blocks * p->frame_multiplier;
}
if (p->midi_ports) {
read_midi_messages(s, buf, data_blocks,
desc->data_block_counter);
}
} }
return pcm_frames; 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, int amdtp_am824_init(struct amdtp_stream *s, struct fw_unit *unit,
enum amdtp_stream_direction dir, enum cip_flags flags) 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) if (dir == AMDTP_IN_STREAM)
process_data_blocks = process_tx_data_blocks; process_ctx_payloads = process_ir_ctx_payloads;
else 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, return amdtp_stream_init(s, unit, dir, flags, CIP_FMT_AM,
process_data_blocks, process_ctx_payloads, sizeof(struct amdtp_am824));
sizeof(struct amdtp_am824));
} }
EXPORT_SYMBOL_GPL(amdtp_am824_init); EXPORT_SYMBOL_GPL(amdtp_am824_init);

View File

@ -74,16 +74,16 @@ static void pcm_period_tasklet(unsigned long data);
* @dir: the direction of stream * @dir: the direction of stream
* @flags: the packet transmission method to use * @flags: the packet transmission method to use
* @fmt: the value of fmt field in CIP header * @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 * @protocol_size: the size to allocate newly for protocol
*/ */
int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit, int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit,
enum amdtp_stream_direction dir, enum cip_flags flags, enum amdtp_stream_direction dir, enum cip_flags flags,
unsigned int fmt, 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) unsigned int protocol_size)
{ {
if (process_data_blocks == NULL) if (process_ctx_payloads == NULL)
return -EINVAL; return -EINVAL;
s->protocol = kzalloc(protocol_size, GFP_KERNEL); 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->callbacked = false;
s->fmt = fmt; s->fmt = fmt;
s->process_data_blocks = process_data_blocks; s->process_ctx_payloads = process_ctx_payloads;
if (dir == AMDTP_OUT_STREAM) if (dir == AMDTP_OUT_STREAM)
s->ctx_data.rx.syt_override = -1; 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, const struct pkt_desc *descs,
unsigned int packets) unsigned int packets)
{ {
int i; struct snd_pcm_substream *pcm;
unsigned int pcm_frames;
for (i = 0; i < packets; ++i) { pcm = READ_ONCE(s->pcm);
const struct pkt_desc *desc = descs + i; pcm_frames = s->process_ctx_payloads(s, descs, packets, pcm);
struct snd_pcm_substream *pcm = READ_ONCE(s->pcm); if (pcm)
unsigned int pcm_frames; update_pcm_pointers(s, pcm, pcm_frames);
pcm_frames = s->process_data_blocks(s, desc, pcm);
if (pcm && pcm_frames > 0)
update_pcm_pointers(s, pcm, pcm_frames);
}
} }
static void out_stream_callback(struct fw_iso_context *context, u32 tstamp, static void out_stream_callback(struct fw_iso_context *context, u32 tstamp,

View File

@ -103,9 +103,10 @@ struct pkt_desc {
}; };
struct amdtp_stream; 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, struct amdtp_stream *s,
const struct pkt_desc *desc, const struct pkt_desc *desc,
unsigned int packets,
struct snd_pcm_substream *pcm); struct snd_pcm_substream *pcm);
struct amdtp_stream { struct amdtp_stream {
struct fw_unit *unit; struct fw_unit *unit;
@ -168,13 +169,13 @@ struct amdtp_stream {
/* For backends to process data blocks. */ /* For backends to process data blocks. */
void *protocol; 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, int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit,
enum amdtp_stream_direction dir, enum cip_flags flags, enum amdtp_stream_direction dir, enum cip_flags flags,
unsigned int fmt, 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); unsigned int protocol_size);
void amdtp_stream_destroy(struct amdtp_stream *s); void amdtp_stream_destroy(struct amdtp_stream *s);

View File

@ -341,60 +341,74 @@ void amdtp_dot_midi_trigger(struct amdtp_stream *s, unsigned int port,
WRITE_ONCE(p->midi[port], midi); WRITE_ONCE(p->midi[port], midi);
} }
static unsigned int process_tx_data_blocks(struct amdtp_stream *s, static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
const struct pkt_desc *desc, const struct pkt_desc *descs,
struct snd_pcm_substream *pcm) unsigned int packets,
struct snd_pcm_substream *pcm)
{ {
unsigned int pcm_frames = 0; unsigned int pcm_frames = 0;
int i;
if (pcm) { for (i = 0; i < packets; ++i) {
read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks, const struct pkt_desc *desc = descs + i;
pcm_frames); __be32 *buf = desc->ctx_payload;
pcm_frames = desc->data_blocks; unsigned int data_blocks = 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);
} }
read_midi_messages(s, desc->ctx_payload, desc->data_blocks);
return pcm_frames; return pcm_frames;
} }
static unsigned int process_rx_data_blocks(struct amdtp_stream *s, static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
const struct pkt_desc *desc, const struct pkt_desc *descs,
struct snd_pcm_substream *pcm) unsigned int packets,
struct snd_pcm_substream *pcm)
{ {
unsigned int pcm_frames = 0; unsigned int pcm_frames = 0;
int i;
if (pcm) { for (i = 0; i < packets; ++i) {
write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks, const struct pkt_desc *desc = descs + i;
pcm_frames); __be32 *buf = desc->ctx_payload;
pcm_frames = desc->data_blocks; unsigned int data_blocks = desc->data_blocks;
} else {
write_pcm_silence(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);
}
write_midi_messages(s, buf, data_blocks,
desc->data_block_counter);
} }
write_midi_messages(s, desc->ctx_payload, desc->data_blocks,
desc->data_block_counter);
return pcm_frames; return pcm_frames;
} }
int amdtp_dot_init(struct amdtp_stream *s, struct fw_unit *unit, int amdtp_dot_init(struct amdtp_stream *s, struct fw_unit *unit,
enum amdtp_stream_direction dir) 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; enum cip_flags flags;
/* Use different mode between incoming/outgoing. */ // Use different mode between incoming/outgoing.
if (dir == AMDTP_IN_STREAM) { if (dir == AMDTP_IN_STREAM) {
flags = CIP_NONBLOCKING; flags = CIP_NONBLOCKING;
process_data_blocks = process_tx_data_blocks; process_ctx_payloads = process_ir_ctx_payloads;
} else { } else {
flags = CIP_BLOCKING; 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, 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) void amdtp_dot_reset(struct amdtp_stream *s)

View 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); return amdtp_stream_add_pcm_hw_constraints(s, runtime);
} }
static unsigned int process_rx_data_blocks(struct amdtp_stream *s, static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
const struct pkt_desc *desc, const struct pkt_desc *descs,
unsigned int packets,
struct snd_pcm_substream *pcm) struct snd_pcm_substream *pcm)
{ {
unsigned int pcm_frames = 0; unsigned int pcm_frames = 0;
int i;
if (pcm) { for (i = 0; i < packets; ++i) {
write_pcm_s32(s, pcm, (__le32 *)desc->ctx_payload, const struct pkt_desc *desc = descs + i;
desc->data_blocks, pcm_frames); __le32 *buf = (__le32 *)desc->ctx_payload;
pcm_frames = desc->data_blocks; unsigned int data_blocks = desc->data_blocks;
} else {
write_pcm_silence(s, (__le32 *)desc->ctx_payload, if (pcm) {
desc->data_blocks); 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; return pcm_frames;
} }
static unsigned int process_tx_data_blocks(struct amdtp_stream *s, static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
const struct pkt_desc *desc, const struct pkt_desc *descs,
struct snd_pcm_substream *pcm) unsigned int packets,
struct snd_pcm_substream *pcm)
{ {
unsigned int pcm_frames = 0; unsigned int pcm_frames = 0;
int i;
if (pcm) { for (i = 0; i < packets; ++i) {
read_pcm_s32(s, pcm, (__le32 *)desc->ctx_payload, const struct pkt_desc *desc = descs + i;
desc->data_blocks, pcm_frames); __le32 *buf = (__le32 *)desc->ctx_payload;
pcm_frames = desc->data_blocks; 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; 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, int amdtp_ff_init(struct amdtp_stream *s, struct fw_unit *unit,
enum amdtp_stream_direction dir) 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) if (dir == AMDTP_IN_STREAM)
process_data_blocks = process_tx_data_blocks; process_ctx_payloads = process_ir_ctx_payloads;
else 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, 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));
} }

View 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, static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
const struct pkt_desc *desc, const struct pkt_desc *descs,
struct snd_pcm_substream *pcm) unsigned int packets,
struct snd_pcm_substream *pcm)
{ {
struct amdtp_motu *p = s->protocol; struct amdtp_motu *p = s->protocol;
unsigned int pcm_frames = 0; unsigned int pcm_frames = 0;
int i;
trace_data_block_sph(s, desc->data_blocks, desc->ctx_payload); for (i = 0; i < packets; ++i) {
trace_data_block_message(s, desc->data_blocks, desc->ctx_payload); const struct pkt_desc *desc = descs + i;
__be32 *buf = desc->ctx_payload;
unsigned int data_blocks = desc->data_blocks;
if (p->midi_ports) trace_data_block_sph(s, data_blocks, buf);
read_midi_messages(s, desc->ctx_payload, desc->data_blocks); trace_data_block_message(s, data_blocks, buf);
if (pcm) { if (p->midi_ports)
read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks, read_midi_messages(s, buf, 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; return pcm_frames;
@ -374,31 +381,38 @@ static void write_sph(struct amdtp_stream *s, __be32 *buffer,
} }
} }
static unsigned int process_rx_data_blocks(struct amdtp_stream *s, static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
const struct pkt_desc *desc, const struct pkt_desc *descs,
struct snd_pcm_substream *pcm) unsigned int packets,
struct snd_pcm_substream *pcm)
{ {
struct amdtp_motu *p = s->protocol; struct amdtp_motu *p = s->protocol;
unsigned int pcm_frames = 0; 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) // TODO: how to interact control messages between userspace?
write_midi_messages(s, desc->ctx_payload, desc->data_blocks);
if (pcm) { if (p->midi_ports)
write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks, write_midi_messages(s, buf, data_blocks);
pcm_frames);
pcm_frames = desc->data_blocks; if (pcm) {
} else { write_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
write_pcm_silence(s, desc->ctx_payload, desc->data_blocks); pcm_frames += data_blocks;
} else {
write_pcm_silence(s, buf, data_blocks);
}
write_sph(s, buf, data_blocks);
trace_data_block_sph(s, data_blocks, buf);
trace_data_block_message(s, data_blocks, buf);
} }
write_sph(s, desc->ctx_payload, 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);
return pcm_frames; return pcm_frames;
} }
@ -406,13 +420,13 @@ int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
enum amdtp_stream_direction dir, enum amdtp_stream_direction dir,
const struct snd_motu_protocol *const protocol) 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 fmt = CIP_FMT_MOTU;
int flags = CIP_BLOCKING; int flags = CIP_BLOCKING;
int err; int err;
if (dir == AMDTP_IN_STREAM) { 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 * 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; CIP_SKIP_DBC_ZERO_CHECK;
} }
} else { } else {
process_data_blocks = process_rx_data_blocks; process_ctx_payloads = process_it_ctx_payloads;
flags |= CIP_DBC_IS_END_EVENT; 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)); sizeof(struct amdtp_motu));
if (err < 0) if (err < 0)
return err; return err;

View 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, static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
const struct pkt_desc *desc, const struct pkt_desc *descs,
struct snd_pcm_substream *pcm) unsigned int packets,
struct snd_pcm_substream *pcm)
{ {
unsigned int pcm_frames = 0; unsigned int pcm_frames = 0;
int i;
if (pcm) { for (i = 0; i < packets; ++i) {
read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks, const struct pkt_desc *desc = descs + i;
pcm_frames); __be32 *buf = desc->ctx_payload;
pcm_frames += desc->data_blocks; unsigned int data_blocks = 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);
} }
read_status_messages(s, desc->ctx_payload, desc->data_blocks);
return pcm_frames; return pcm_frames;
} }
static unsigned int process_rx_data_blocks(struct amdtp_stream *s, static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
const struct pkt_desc *desc, const struct pkt_desc *descs,
struct snd_pcm_substream *pcm) unsigned int packets,
struct snd_pcm_substream *pcm)
{ {
unsigned int pcm_frames = 0; unsigned int pcm_frames = 0;
int i;
if (pcm) { for (i = 0; i < packets; ++i) {
write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks, const struct pkt_desc *desc = descs + i;
pcm_frames); __be32 *buf = desc->ctx_payload;
pcm_frames += desc->data_blocks; unsigned int data_blocks = desc->data_blocks;
} else {
write_pcm_silence(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);
}
} }
return pcm_frames; 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, int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit,
enum amdtp_stream_direction dir, unsigned int pcm_channels) 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; struct amdtp_tscm *p;
unsigned int fmt; unsigned int fmt;
int err; int err;
if (dir == AMDTP_IN_STREAM) { if (dir == AMDTP_IN_STREAM) {
fmt = AMDTP_FMT_TSCM_TX; fmt = AMDTP_FMT_TSCM_TX;
process_data_blocks = process_tx_data_blocks; process_ctx_payloads = process_ir_ctx_payloads;
} else { } else {
fmt = AMDTP_FMT_TSCM_RX; 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, err = amdtp_stream_init(s, unit, dir,
CIP_NONBLOCKING | CIP_SKIP_DBC_ZERO_CHECK, fmt, CIP_NONBLOCKING | CIP_SKIP_DBC_ZERO_CHECK, fmt,
process_data_blocks, sizeof(struct amdtp_tscm)); process_ctx_payloads, sizeof(struct amdtp_tscm));
if (err < 0) if (err < 0)
return 0; return 0;