Commit f91c9d76 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

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: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 12ee4022
...@@ -412,8 +412,7 @@ static inline int queue_out_packet(struct amdtp_stream *s, ...@@ -412,8 +412,7 @@ static inline int queue_out_packet(struct amdtp_stream *s,
static inline int queue_in_packet(struct amdtp_stream *s) static inline int queue_in_packet(struct amdtp_stream *s)
{ {
return queue_packet(s, IN_PACKET_HEADER_SIZE, return queue_packet(s, IN_PACKET_HEADER_SIZE, s->max_payload_length);
amdtp_stream_get_max_payload(s));
} }
static int handle_out_packet(struct amdtp_stream *s, 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, ...@@ -713,12 +712,12 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,
cycle = decrement_cycle_count(cycle, packets); cycle = decrement_cycle_count(cycle, packets);
/* For buffer-over-run prevention. */ /* For buffer-over-run prevention. */
max_payload_length = amdtp_stream_get_max_payload(s); max_payload_length = s->max_payload_length;
for (i = 0; i < packets; i++) { for (i = 0; i < packets; i++) {
cycle = increment_cycle_count(cycle, 1); cycle = increment_cycle_count(cycle, 1);
/* The number of quadlets in this packet */ /* The number of bytes in this packet */
payload_length = payload_length =
(be32_to_cpu(headers[i]) >> ISO_DATA_LENGTH_SHIFT); (be32_to_cpu(headers[i]) >> ISO_DATA_LENGTH_SHIFT);
if (payload_length > max_payload_length) { if (payload_length > max_payload_length) {
...@@ -751,6 +750,8 @@ static void amdtp_stream_first_callback(struct fw_iso_context *context, ...@@ -751,6 +750,8 @@ static void amdtp_stream_first_callback(struct fw_iso_context *context,
u32 cycle; u32 cycle;
unsigned int packets; unsigned int packets;
s->max_payload_length = amdtp_stream_get_max_payload(s);
/* /*
* For in-stream, first packet has come. * For in-stream, first packet has come.
* For out-stream, prepared to transmit first packet * For out-stream, prepared to transmit first packet
......
...@@ -110,6 +110,7 @@ struct amdtp_stream { ...@@ -110,6 +110,7 @@ struct amdtp_stream {
int (*handle_packet)(struct amdtp_stream *s, int (*handle_packet)(struct amdtp_stream *s,
unsigned int payload_quadlets, unsigned int cycle, unsigned int payload_quadlets, unsigned int cycle,
unsigned int index); unsigned int index);
unsigned int max_payload_length;
/* For CIP headers. */ /* For CIP headers. */
unsigned int source_node_id_field; unsigned int source_node_id_field;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment