mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 13:41:51 +00:00
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>
This commit is contained in:
parent
cccddec49c
commit
c38d8cff9c
@ -546,16 +546,16 @@ static void pool_replayed_seq(struct amdtp_stream *s, struct seq_desc *descs, un
|
|||||||
struct amdtp_stream *target = s->ctx_data.rx.replay_target;
|
struct amdtp_stream *target = s->ctx_data.rx.replay_target;
|
||||||
const struct seq_desc *cache = target->ctx_data.tx.cache.descs;
|
const struct seq_desc *cache = target->ctx_data.tx.cache.descs;
|
||||||
const unsigned int cache_size = target->ctx_data.tx.cache.size;
|
const unsigned int cache_size = target->ctx_data.tx.cache.size;
|
||||||
unsigned int cache_head = s->ctx_data.rx.cache_head;
|
unsigned int cache_pos = s->ctx_data.rx.cache_pos;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
descs[pos] = cache[cache_head];
|
descs[pos] = cache[cache_pos];
|
||||||
cache_head = (cache_head + 1) % cache_size;
|
cache_pos = (cache_pos + 1) % cache_size;
|
||||||
pos = (pos + 1) % size;
|
pos = (pos + 1) % size;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->ctx_data.rx.cache_head = cache_head;
|
s->ctx_data.rx.cache_pos = cache_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pool_seq_descs(struct amdtp_stream *s, struct seq_desc *descs, unsigned int size,
|
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
|
|||||||
} else {
|
} else {
|
||||||
struct amdtp_stream *tx = s->ctx_data.rx.replay_target;
|
struct amdtp_stream *tx = s->ctx_data.rx.replay_target;
|
||||||
const unsigned int cache_size = tx->ctx_data.tx.cache.size;
|
const unsigned int cache_size = tx->ctx_data.tx.cache.size;
|
||||||
const unsigned int cache_head = s->ctx_data.rx.cache_head;
|
const unsigned int cache_pos = s->ctx_data.rx.cache_pos;
|
||||||
unsigned int cached_cycles = calculate_cached_cycle_count(tx, cache_head);
|
unsigned int cached_cycles = calculate_cached_cycle_count(tx, cache_pos);
|
||||||
|
|
||||||
if (cached_cycles > count && cached_cycles > cache_size / 2)
|
if (cached_cycles > count && cached_cycles > cache_size / 2)
|
||||||
pool_seq_descs = pool_replayed_seq;
|
pool_seq_descs = pool_replayed_seq;
|
||||||
@ -1181,6 +1181,9 @@ static void process_rx_packets_intermediately(struct fw_iso_context *context, u3
|
|||||||
s->ready_processing = true;
|
s->ready_processing = true;
|
||||||
wake_up(&s->ready_wait);
|
wake_up(&s->ready_wait);
|
||||||
|
|
||||||
|
if (d->replay.enable)
|
||||||
|
s->ctx_data.rx.cache_pos = 0;
|
||||||
|
|
||||||
process_rx_packets(context, tstamp, header_length, ctx_header, private_data);
|
process_rx_packets(context, tstamp, header_length, ctx_header, private_data);
|
||||||
if (amdtp_streaming_error(s))
|
if (amdtp_streaming_error(s))
|
||||||
return;
|
return;
|
||||||
@ -1909,7 +1912,6 @@ static int make_association(struct amdtp_domain *d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rx->ctx_data.rx.replay_target = tx;
|
rx->ctx_data.rx.replay_target = tx;
|
||||||
rx->ctx_data.rx.cache_head = 0;
|
|
||||||
|
|
||||||
++dst_index;
|
++dst_index;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ struct amdtp_stream {
|
|||||||
unsigned int last_syt_offset;
|
unsigned int last_syt_offset;
|
||||||
|
|
||||||
struct amdtp_stream *replay_target;
|
struct amdtp_stream *replay_target;
|
||||||
unsigned int cache_head;
|
unsigned int cache_pos;
|
||||||
} rx;
|
} rx;
|
||||||
} ctx_data;
|
} ctx_data;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user