Commit b18f0cfa authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: firewire-lib: use 8 byte packet header for IT context to separate CIP header from CIP payload

In Linux firewire subsystem, for IT context, some quadlets of isochronous
packet payload can be indicated as a part of packet header to queue to
the context.

This commit uses the packet header to split CIP headers from CIP
payload. As a result, regardless of CIP or non-CIP, context payload
includes data blocks only.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 6007bf54
...@@ -62,6 +62,9 @@ ...@@ -62,6 +62,9 @@
#define IR_CTX_HEADER_SIZE_NO_CIP 8 #define IR_CTX_HEADER_SIZE_NO_CIP 8
#define HEADER_TSTAMP_MASK 0x0000ffff #define HEADER_TSTAMP_MASK 0x0000ffff
#define IT_PKT_HEADER_SIZE_CIP 8 // For 2 CIP header.
#define IT_PKT_HEADER_SIZE_NO_CIP 0 // Nothing.
static void pcm_period_tasklet(unsigned long data); static void pcm_period_tasklet(unsigned long data);
/** /**
...@@ -452,13 +455,10 @@ static int queue_packet(struct amdtp_stream *s, struct fw_iso_packet *params) ...@@ -452,13 +455,10 @@ static int queue_packet(struct amdtp_stream *s, struct fw_iso_packet *params)
} }
static inline int queue_out_packet(struct amdtp_stream *s, static inline int queue_out_packet(struct amdtp_stream *s,
struct fw_iso_packet *params, struct fw_iso_packet *params)
unsigned int payload_length)
{ {
// No header for this packet. params->skip =
params->header_length = 0; !!(params->header_length == 0 && params->payload_length == 0);
params->payload_length = payload_length;
params->skip = !!(payload_length == 0);
return queue_packet(s, params); return queue_packet(s, params);
} }
...@@ -491,41 +491,41 @@ static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle, ...@@ -491,41 +491,41 @@ static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle,
{ {
unsigned int syt; unsigned int syt;
unsigned int data_blocks; unsigned int data_blocks;
unsigned int payload_length;
__be32 *cip_header; __be32 *cip_header;
unsigned int pcm_frames; unsigned int pcm_frames;
struct snd_pcm_substream *pcm; struct snd_pcm_substream *pcm;
struct fw_iso_packet params = {0}; struct {
struct fw_iso_packet params;
__be32 header[IT_PKT_HEADER_SIZE_CIP / sizeof(__be32)];
} template = { {0}, {0} };
syt = calculate_syt(s, cycle); syt = calculate_syt(s, cycle);
data_blocks = calculate_data_blocks(s, syt); data_blocks = calculate_data_blocks(s, syt);
payload_length = data_blocks * sizeof(__be32) * s->data_block_quadlets;
if (!(s->flags & CIP_NO_HEADER)) {
cip_header = buffer;
buffer += 2;
payload_length += 2 * sizeof(__be32);
} else {
cip_header = NULL;
}
pcm_frames = s->process_data_blocks(s, buffer, data_blocks, &syt); pcm_frames = s->process_data_blocks(s, buffer, data_blocks, &syt);
if (s->flags & CIP_DBC_IS_END_EVENT) if (s->flags & CIP_DBC_IS_END_EVENT)
s->data_block_counter = s->data_block_counter =
(s->data_block_counter + data_blocks) & 0xff; (s->data_block_counter + data_blocks) & 0xff;
if (cip_header) if (!(s->flags & CIP_NO_HEADER)) {
cip_header = (__be32 *)template.params.header;
generate_cip_header(s, cip_header, syt); generate_cip_header(s, cip_header, syt);
template.params.header_length = 2 * sizeof(__be32);
} else {
cip_header = NULL;
}
if (!(s->flags & CIP_DBC_IS_END_EVENT)) if (!(s->flags & CIP_DBC_IS_END_EVENT))
s->data_block_counter = s->data_block_counter =
(s->data_block_counter + data_blocks) & 0xff; (s->data_block_counter + data_blocks) & 0xff;
trace_amdtp_packet(s, cycle, cip_header, payload_length, data_blocks, template.params.payload_length =
index); data_blocks * sizeof(__be32) * s->data_block_quadlets;
trace_amdtp_packet(s, cycle, cip_header, template.params.payload_length,
data_blocks, index);
if (queue_out_packet(s, &params, payload_length) < 0) if (queue_out_packet(s, &template.params) < 0)
return -EIO; return -EIO;
pcm = READ_ONCE(s->pcm); pcm = READ_ONCE(s->pcm);
...@@ -878,14 +878,18 @@ int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed) ...@@ -878,14 +878,18 @@ int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed)
ctx_header_size = IR_CTX_HEADER_SIZE_CIP; ctx_header_size = IR_CTX_HEADER_SIZE_CIP;
else else
ctx_header_size = IR_CTX_HEADER_SIZE_NO_CIP; ctx_header_size = IR_CTX_HEADER_SIZE_NO_CIP;
max_ctx_payload_size = amdtp_stream_get_max_payload(s) -
ctx_header_size;
} else { } else {
dir = DMA_TO_DEVICE; dir = DMA_TO_DEVICE;
type = FW_ISO_CONTEXT_TRANSMIT; type = FW_ISO_CONTEXT_TRANSMIT;
ctx_header_size = 0; // No effect for IT context. ctx_header_size = 0; // No effect for IT context.
}
max_ctx_payload_size = amdtp_stream_get_max_payload(s) - max_ctx_payload_size = amdtp_stream_get_max_payload(s);
ctx_header_size; if (!(s->flags & CIP_NO_HEADER))
max_ctx_payload_size -= IT_PKT_HEADER_SIZE_CIP;
}
err = iso_packets_buffer_init(&s->buffer, s->unit, QUEUE_LENGTH, err = iso_packets_buffer_init(&s->buffer, s->unit, QUEUE_LENGTH,
max_ctx_payload_size, dir); max_ctx_payload_size, dir);
...@@ -918,10 +922,13 @@ int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed) ...@@ -918,10 +922,13 @@ int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed)
s->packet_index = 0; s->packet_index = 0;
do { do {
struct fw_iso_packet params; struct fw_iso_packet params;
if (s->direction == AMDTP_IN_STREAM) if (s->direction == AMDTP_IN_STREAM) {
err = queue_in_packet(s, &params); err = queue_in_packet(s, &params);
else } else {
err = queue_out_packet(s, &params, 0); params.header_length = 0;
params.payload_length = 0;
err = queue_out_packet(s, &params);
}
if (err < 0) if (err < 0)
goto err_context; goto err_context;
} while (s->packet_index > 0); } while (s->packet_index > 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment