diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2023-01-07 05:32:12 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2023-01-08 17:00:09 +0300 |
commit | f2bdee856f20e21416130c392a3ec527079a1226 (patch) | |
tree | 50b1ddd725cd8317b0d93b1ddc90c276bae7363e /sound/firewire | |
parent | 119c446a484a646a5762ff11ecff53c337f0e236 (diff) | |
download | linux-f2bdee856f20e21416130c392a3ec527079a1226.tar.xz |
ALSA: firewire-lib: code refactoring for pool position in rx packets
When scheduling transmission of rx packets, current implementation
fulfils packet descriptors after pooling sequence descriptors. It is for
packet queueing. Besides the implementations do not necessarily have
good readability.
This commit refactors them by adding function local variables and
function arguments.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230107023214.29132-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire')
-rw-r--r-- | sound/firewire/amdtp-stream.c | 33 | ||||
-rw-r--r-- | sound/firewire/amdtp-stream.h | 1 |
2 files changed, 14 insertions, 20 deletions
diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 881e30c049fc..172addba7aab 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -558,12 +558,10 @@ static void pool_replayed_seq(struct amdtp_stream *s, struct seq_desc *descs, un s->ctx_data.rx.cache_head = cache_head; } -static void pool_seq_descs(struct amdtp_stream *s, unsigned int count) +static void pool_seq_descs(struct amdtp_stream *s, struct seq_desc *descs, unsigned int size, + unsigned int pos, unsigned int count) { struct amdtp_domain *d = s->domain; - struct seq_desc *descs = s->ctx_data.rx.seq.descs; - const unsigned int size = s->ctx_data.rx.seq.size; - unsigned int pos = s->ctx_data.rx.seq.pos; void (*pool_seq_descs)(struct amdtp_stream *s, struct seq_desc *descs, unsigned int size, unsigned int pos, unsigned int count); @@ -586,8 +584,6 @@ static void pool_seq_descs(struct amdtp_stream *s, unsigned int count) } pool_seq_descs(s, descs, size, pos, count); - - s->ctx_data.rx.seq.pos = (pos + count) % size; } static void update_pcm_pointers(struct amdtp_stream *s, @@ -979,20 +975,22 @@ static unsigned int compute_syt(unsigned int syt_offset, unsigned int cycle, return syt & CIP_SYT_MASK; } -static void generate_pkt_descs(struct amdtp_stream *s, const __be32 *ctx_header, unsigned int packets) +static void generate_rx_packet_descs(struct amdtp_stream *s, struct pkt_desc *descs, + const __be32 *ctx_header, unsigned int packet_count) { - struct pkt_desc *descs = s->pkt_descs; - const struct seq_desc *seq_descs = s->ctx_data.rx.seq.descs; - const unsigned int seq_size = s->ctx_data.rx.seq.size; + struct seq_desc *seq_descs = s->ctx_data.rx.seq.descs; + unsigned int seq_size = s->ctx_data.rx.seq.size; + unsigned int seq_pos = s->ctx_data.rx.seq.pos; unsigned int dbc = s->data_block_counter; - unsigned int seq_head = s->ctx_data.rx.seq.head; bool aware_syt = !(s->flags & CIP_UNAWARE_SYT); int i; - for (i = 0; i < packets; ++i) { + pool_seq_descs(s, seq_descs, seq_size, seq_pos, packet_count); + + for (i = 0; i < packet_count; ++i) { struct pkt_desc *desc = descs + i; unsigned int index = (s->packet_index + i) % s->queue_size; - const struct seq_desc *seq = seq_descs + seq_head; + const struct seq_desc *seq = seq_descs + seq_pos; desc->cycle = compute_ohci_it_cycle(*ctx_header, s->queue_size); @@ -1013,13 +1011,13 @@ static void generate_pkt_descs(struct amdtp_stream *s, const __be32 *ctx_header, desc->ctx_payload = s->buffer.packets[index].buffer; - seq_head = (seq_head + 1) % seq_size; + seq_pos = (seq_pos + 1) % seq_size; ++ctx_header; } s->data_block_counter = dbc; - s->ctx_data.rx.seq.head = seq_head; + s->ctx_data.rx.seq.pos = seq_pos; } static inline void cancel_stream(struct amdtp_stream *s) @@ -1062,9 +1060,7 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ // Calculate the number of packets in buffer and check XRUN. packets = header_length / sizeof(*ctx_header); - pool_seq_descs(s, packets); - - generate_pkt_descs(s, ctx_header, packets); + generate_rx_packet_descs(s, s->pkt_descs, ctx_header, packets); process_ctx_payloads(s, s->pkt_descs, packets); @@ -1644,7 +1640,6 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, } s->ctx_data.rx.seq.size = queue_size; s->ctx_data.rx.seq.pos = 0; - s->ctx_data.rx.seq.head = 0; entry = &initial_state[s->sfc]; s->ctx_data.rx.data_block_state = entry->data_block; diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index baab63d31ddd..dbe6d4bcbb8a 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h @@ -160,7 +160,6 @@ struct amdtp_stream { struct seq_desc *descs; unsigned int size; unsigned int pos; - unsigned int head; } seq; unsigned int data_block_state; |