Commit 8070d265 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: firewire-lib: add flag to unaware of syt in CIP header

Many devices are unaware of syt field in rx CIP for playback timing.

This commit adds a flag to cancel processing syt field. Actually,
syt calculation is required to decide the number of events per rx packet.
The flag put 0xffff to CIP header of rx packet. On the other hand,
The value of syt field in CIP header of tx packet is unavailable. The
sequence of packet descriptor for tx packet includes 0 for the offset
of syt field to avoid computation.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210522013303.49596-2-o-takashi@sakamocchi.jpSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 344f0f82
...@@ -113,9 +113,6 @@ int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit, ...@@ -113,9 +113,6 @@ int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit,
s->fmt = fmt; s->fmt = fmt;
s->process_ctx_payloads = process_ctx_payloads; s->process_ctx_payloads = process_ctx_payloads;
if (dir == AMDTP_OUT_STREAM)
s->ctx_data.rx.syt_override = -1;
return 0; return 0;
} }
EXPORT_SYMBOL(amdtp_stream_init); EXPORT_SYMBOL(amdtp_stream_init);
...@@ -638,6 +635,7 @@ static int check_cip_header(struct amdtp_stream *s, const __be32 *buf, ...@@ -638,6 +635,7 @@ static int check_cip_header(struct amdtp_stream *s, const __be32 *buf,
*data_block_counter = dbc; *data_block_counter = dbc;
if (!(s->flags & CIP_UNAWARE_SYT))
*syt = cip_header[1] & CIP_SYT_MASK; *syt = cip_header[1] & CIP_SYT_MASK;
return 0; return 0;
...@@ -836,22 +834,23 @@ static void generate_pkt_descs(struct amdtp_stream *s, struct pkt_desc *descs, ...@@ -836,22 +834,23 @@ static void generate_pkt_descs(struct amdtp_stream *s, struct pkt_desc *descs,
{ {
unsigned int dbc = s->data_block_counter; unsigned int dbc = s->data_block_counter;
unsigned int seq_index = s->ctx_data.rx.seq_index; unsigned int seq_index = s->ctx_data.rx.seq_index;
bool aware_syt = !(s->flags & CIP_UNAWARE_SYT);
int i; int i;
for (i = 0; i < packets; ++i) { for (i = 0; i < packets; ++i) {
struct pkt_desc *desc = descs + i; struct pkt_desc *desc = descs + i;
unsigned int index = (s->packet_index + i) % s->queue_size; unsigned int index = (s->packet_index + i) % s->queue_size;
const struct seq_desc *seq = seq_descs + seq_index; const struct seq_desc *seq = seq_descs + seq_index;
unsigned int syt;
desc->cycle = compute_ohci_it_cycle(*ctx_header, s->queue_size); desc->cycle = compute_ohci_it_cycle(*ctx_header, s->queue_size);
syt = seq->syt_offset; if (aware_syt && seq->syt_offset != CIP_SYT_NO_INFO) {
if (syt != CIP_SYT_NO_INFO) { desc->syt = compute_syt(seq->syt_offset, desc->cycle,
syt = compute_syt(syt, desc->cycle,
s->ctx_data.rx.transfer_delay); s->ctx_data.rx.transfer_delay);
} else {
desc->syt = CIP_SYT_NO_INFO;
} }
desc->syt = syt;
desc->data_blocks = seq->data_blocks; desc->data_blocks = seq->data_blocks;
if (s->flags & CIP_DBC_IS_END_EVENT) if (s->flags & CIP_DBC_IS_END_EVENT)
...@@ -924,21 +923,15 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ ...@@ -924,21 +923,15 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_
for (i = 0; i < packets; ++i) { for (i = 0; i < packets; ++i) {
const struct pkt_desc *desc = s->pkt_descs + i; const struct pkt_desc *desc = s->pkt_descs + i;
unsigned int syt;
struct { struct {
struct fw_iso_packet params; struct fw_iso_packet params;
__be32 header[CIP_HEADER_QUADLETS]; __be32 header[CIP_HEADER_QUADLETS];
} template = { {0}, {0} }; } template = { {0}, {0} };
bool sched_irq = false; bool sched_irq = false;
if (s->ctx_data.rx.syt_override < 0)
syt = desc->syt;
else
syt = s->ctx_data.rx.syt_override;
build_it_pkt_header(s, desc->cycle, &template.params, pkt_header_length, build_it_pkt_header(s, desc->cycle, &template.params, pkt_header_length,
desc->data_blocks, desc->data_block_counter, desc->data_blocks, desc->data_block_counter,
syt, i); desc->syt, i);
if (s == s->domain->irq_target) { if (s == s->domain->irq_target) {
event_count += desc->data_blocks; event_count += desc->data_blocks;
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
* @CIP_NO_HEADERS: a lack of headers in packets * @CIP_NO_HEADERS: a lack of headers in packets
* @CIP_UNALIGHED_DBC: Only for in-stream. The value of dbc is not alighed to * @CIP_UNALIGHED_DBC: Only for in-stream. The value of dbc is not alighed to
* the value of current SYT_INTERVAL; e.g. initial value is not zero. * the value of current SYT_INTERVAL; e.g. initial value is not zero.
* @CIP_UNAWARE_SYT: For outgoing packet, the value in SYT field of CIP is 0xffff.
* For incoming packet, the value in SYT field of CIP is not handled.
*/ */
enum cip_flags { enum cip_flags {
CIP_NONBLOCKING = 0x00, CIP_NONBLOCKING = 0x00,
...@@ -48,6 +50,7 @@ enum cip_flags { ...@@ -48,6 +50,7 @@ enum cip_flags {
CIP_HEADER_WITHOUT_EOH = 0x80, CIP_HEADER_WITHOUT_EOH = 0x80,
CIP_NO_HEADER = 0x100, CIP_NO_HEADER = 0x100,
CIP_UNALIGHED_DBC = 0x200, CIP_UNALIGHED_DBC = 0x200,
CIP_UNAWARE_SYT = 0x400,
}; };
/** /**
...@@ -143,7 +146,6 @@ struct amdtp_stream { ...@@ -143,7 +146,6 @@ struct amdtp_stream {
// To generate CIP header. // To generate CIP header.
unsigned int fdf; unsigned int fdf;
int syt_override;
// To generate constant hardware IRQ. // To generate constant hardware IRQ.
unsigned int event_count; unsigned int event_count;
......
...@@ -441,7 +441,7 @@ int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit, ...@@ -441,7 +441,7 @@ int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
{ {
amdtp_stream_process_ctx_payloads_t process_ctx_payloads; amdtp_stream_process_ctx_payloads_t process_ctx_payloads;
int fmt = CIP_FMT_MOTU; int fmt = CIP_FMT_MOTU;
int flags = CIP_BLOCKING; unsigned int flags = CIP_BLOCKING | CIP_UNAWARE_SYT;
int err; int err;
if (dir == AMDTP_IN_STREAM) { if (dir == AMDTP_IN_STREAM) {
...@@ -479,8 +479,6 @@ int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit, ...@@ -479,8 +479,6 @@ int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
if (dir == AMDTP_OUT_STREAM) { if (dir == AMDTP_OUT_STREAM) {
// Use fixed value for FDF field. // Use fixed value for FDF field.
s->ctx_data.rx.fdf = MOTU_FDF_AM824; s->ctx_data.rx.fdf = MOTU_FDF_AM824;
// Not used.
s->ctx_data.rx.syt_override = 0xffff;
} }
return 0; return 0;
......
...@@ -228,6 +228,7 @@ int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit, ...@@ -228,6 +228,7 @@ 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_ctx_payloads_t process_ctx_payloads; amdtp_stream_process_ctx_payloads_t process_ctx_payloads;
unsigned int flags = CIP_NONBLOCKING | CIP_SKIP_DBC_ZERO_CHECK | CIP_UNAWARE_SYT;
struct amdtp_tscm *p; struct amdtp_tscm *p;
unsigned int fmt; unsigned int fmt;
int err; int err;
...@@ -240,8 +241,7 @@ int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit, ...@@ -240,8 +241,7 @@ int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit,
process_ctx_payloads = process_it_ctx_payloads; process_ctx_payloads = process_it_ctx_payloads;
} }
err = amdtp_stream_init(s, unit, dir, err = amdtp_stream_init(s, unit, dir, flags, fmt,
CIP_NONBLOCKING | CIP_SKIP_DBC_ZERO_CHECK, fmt,
process_ctx_payloads, sizeof(struct amdtp_tscm)); process_ctx_payloads, sizeof(struct amdtp_tscm));
if (err < 0) if (err < 0)
return 0; return 0;
...@@ -249,8 +249,6 @@ int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit, ...@@ -249,8 +249,6 @@ int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit,
if (dir == AMDTP_OUT_STREAM) { if (dir == AMDTP_OUT_STREAM) {
// Use fixed value for FDF field. // Use fixed value for FDF field.
s->ctx_data.rx.fdf = 0x00; s->ctx_data.rx.fdf = 0x00;
// Not used.
s->ctx_data.rx.syt_override = 0x0000;
} }
/* This protocol uses fixed number of data channels for PCM samples. */ /* This protocol uses fixed number of data channels for PCM samples. */
......
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