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>
s->ctx_data.rx.cache_head = cache_head;
}
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 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);
void (*pool_seq_descs)(struct amdtp_stream *s, struct seq_desc *descs, unsigned int size,
unsigned int pos, unsigned int count);
}
pool_seq_descs(s, descs, size, pos, 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,
}
static void update_pcm_pointers(struct amdtp_stream *s,
return syt & CIP_SYT_MASK;
}
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 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;
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;
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);
desc->cycle = compute_ohci_it_cycle(*ctx_header, s->queue_size);
desc->ctx_payload = s->buffer.packets[index].buffer;
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;
++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)
}
static inline void cancel_stream(struct amdtp_stream *s)
// Calculate the number of packets in buffer and check XRUN.
packets = header_length / sizeof(*ctx_header);
// 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);
process_ctx_payloads(s, s->pkt_descs, packets);
}
s->ctx_data.rx.seq.size = queue_size;
s->ctx_data.rx.seq.pos = 0;
}
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;
entry = &initial_state[s->sfc];
s->ctx_data.rx.data_block_state = entry->data_block;
struct seq_desc *descs;
unsigned int size;
unsigned int pos;
struct seq_desc *descs;
unsigned int size;
unsigned int pos;
} seq;
unsigned int data_block_state;
} seq;
unsigned int data_block_state;