Skip to content

Commit f91c9d7

Browse files
takaswietiwai
authored andcommitted
ALSA: firewire-lib: cache maximum length of payload to reduce function calls
During packet streaming, maximum length of payload for isochronous packet is invariable, therefore no need to recalculate. Current ALSA IEC 61883-1/6 engine calls a function to calculate it 8,000 or more times per second for incoming packet processing. This commit adds a member to have maximum length of payload into 'struct amdtp_stream', to reduces the function calls. At first callback from isochronous context, the length is calculated and stored for later processing. Signed-off-by: Takashi Sakamoto <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 12ee402 commit f91c9d7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

sound/firewire/amdtp-stream.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,7 @@ static inline int queue_out_packet(struct amdtp_stream *s,
412412

413413
static inline int queue_in_packet(struct amdtp_stream *s)
414414
{
415-
return queue_packet(s, IN_PACKET_HEADER_SIZE,
416-
amdtp_stream_get_max_payload(s));
415+
return queue_packet(s, IN_PACKET_HEADER_SIZE, s->max_payload_length);
417416
}
418417

419418
static int handle_out_packet(struct amdtp_stream *s,
@@ -713,12 +712,12 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,
713712
cycle = decrement_cycle_count(cycle, packets);
714713

715714
/* For buffer-over-run prevention. */
716-
max_payload_length = amdtp_stream_get_max_payload(s);
715+
max_payload_length = s->max_payload_length;
717716

718717
for (i = 0; i < packets; i++) {
719718
cycle = increment_cycle_count(cycle, 1);
720719

721-
/* The number of quadlets in this packet */
720+
/* The number of bytes in this packet */
722721
payload_length =
723722
(be32_to_cpu(headers[i]) >> ISO_DATA_LENGTH_SHIFT);
724723
if (payload_length > max_payload_length) {
@@ -751,6 +750,8 @@ static void amdtp_stream_first_callback(struct fw_iso_context *context,
751750
u32 cycle;
752751
unsigned int packets;
753752

753+
s->max_payload_length = amdtp_stream_get_max_payload(s);
754+
754755
/*
755756
* For in-stream, first packet has come.
756757
* For out-stream, prepared to transmit first packet

sound/firewire/amdtp-stream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ struct amdtp_stream {
110110
int (*handle_packet)(struct amdtp_stream *s,
111111
unsigned int payload_quadlets, unsigned int cycle,
112112
unsigned int index);
113+
unsigned int max_payload_length;
113114

114115
/* For CIP headers. */
115116
unsigned int source_node_id_field;

0 commit comments

Comments
 (0)