Skip to content

Commit c38d8cf

Browse files
takaswietiwai
authored andcommitted
ALSA: firewire-lib: code refactoring for cache position in sequence replay
When sequence replay is enabled for media clock recovery, current implementation refers to cache of sequence descriptors in tx packets, then fulfil sequence descriptors for rx packets. The initialization for rx packets is done before starting packet streaming, while it can be postponed till the cache has enough entries for the replay. This commit refactors for the purpose as well as minor code change for renaming of structure member. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20230107023214.29132-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent cccddec commit c38d8cf

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

sound/firewire/amdtp-stream.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -546,16 +546,16 @@ static void pool_replayed_seq(struct amdtp_stream *s, struct seq_desc *descs, un
546546
struct amdtp_stream *target = s->ctx_data.rx.replay_target;
547547
const struct seq_desc *cache = target->ctx_data.tx.cache.descs;
548548
const unsigned int cache_size = target->ctx_data.tx.cache.size;
549-
unsigned int cache_head = s->ctx_data.rx.cache_head;
549+
unsigned int cache_pos = s->ctx_data.rx.cache_pos;
550550
int i;
551551

552552
for (i = 0; i < count; ++i) {
553-
descs[pos] = cache[cache_head];
554-
cache_head = (cache_head + 1) % cache_size;
553+
descs[pos] = cache[cache_pos];
554+
cache_pos = (cache_pos + 1) % cache_size;
555555
pos = (pos + 1) % size;
556556
}
557557

558-
s->ctx_data.rx.cache_head = cache_head;
558+
s->ctx_data.rx.cache_pos = cache_pos;
559559
}
560560

561561
static void pool_seq_descs(struct amdtp_stream *s, struct seq_desc *descs, unsigned int size,
@@ -573,8 +573,8 @@ static void pool_seq_descs(struct amdtp_stream *s, struct seq_desc *descs, unsig
573573
} else {
574574
struct amdtp_stream *tx = s->ctx_data.rx.replay_target;
575575
const unsigned int cache_size = tx->ctx_data.tx.cache.size;
576-
const unsigned int cache_head = s->ctx_data.rx.cache_head;
577-
unsigned int cached_cycles = calculate_cached_cycle_count(tx, cache_head);
576+
const unsigned int cache_pos = s->ctx_data.rx.cache_pos;
577+
unsigned int cached_cycles = calculate_cached_cycle_count(tx, cache_pos);
578578

579579
if (cached_cycles > count && cached_cycles > cache_size / 2)
580580
pool_seq_descs = pool_replayed_seq;
@@ -1181,6 +1181,9 @@ static void process_rx_packets_intermediately(struct fw_iso_context *context, u3
11811181
s->ready_processing = true;
11821182
wake_up(&s->ready_wait);
11831183

1184+
if (d->replay.enable)
1185+
s->ctx_data.rx.cache_pos = 0;
1186+
11841187
process_rx_packets(context, tstamp, header_length, ctx_header, private_data);
11851188
if (amdtp_streaming_error(s))
11861189
return;
@@ -1909,7 +1912,6 @@ static int make_association(struct amdtp_domain *d)
19091912
}
19101913

19111914
rx->ctx_data.rx.replay_target = tx;
1912-
rx->ctx_data.rx.cache_head = 0;
19131915

19141916
++dst_index;
19151917
}

sound/firewire/amdtp-stream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ struct amdtp_stream {
167167
unsigned int last_syt_offset;
168168

169169
struct amdtp_stream *replay_target;
170-
unsigned int cache_head;
170+
unsigned int cache_pos;
171171
} rx;
172172
} ctx_data;
173173

0 commit comments

Comments
 (0)