diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2017-04-11 07:33:18 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-04-12 09:34:21 -0400 |
commit | f91c9d7610a2fe306273a83e2fd5351bceb85d28 (patch) | |
tree | 83e477ea0a5ccdaa6f6e57e5ccbd83882c7a2d45 | |
parent | 12ee4022f67f8854061b46e5c0a7ad6258ab66c2 (diff) |
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 <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/firewire/amdtp-stream.c | 9 | ||||
-rw-r--r-- | sound/firewire/amdtp-stream.h | 1 |
2 files changed, 6 insertions, 4 deletions
diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index f6af8e64c2cd..9e6f54f8c45d 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c | |||
@@ -412,8 +412,7 @@ static inline int queue_out_packet(struct amdtp_stream *s, | |||
412 | 412 | ||
413 | static inline int queue_in_packet(struct amdtp_stream *s) | 413 | static inline int queue_in_packet(struct amdtp_stream *s) |
414 | { | 414 | { |
415 | return queue_packet(s, IN_PACKET_HEADER_SIZE, | 415 | return queue_packet(s, IN_PACKET_HEADER_SIZE, s->max_payload_length); |
416 | amdtp_stream_get_max_payload(s)); | ||
417 | } | 416 | } |
418 | 417 | ||
419 | static int handle_out_packet(struct amdtp_stream *s, | 418 | 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 | cycle = decrement_cycle_count(cycle, packets); | 712 | cycle = decrement_cycle_count(cycle, packets); |
714 | 713 | ||
715 | /* For buffer-over-run prevention. */ | 714 | /* For buffer-over-run prevention. */ |
716 | max_payload_length = amdtp_stream_get_max_payload(s); | 715 | max_payload_length = s->max_payload_length; |
717 | 716 | ||
718 | for (i = 0; i < packets; i++) { | 717 | for (i = 0; i < packets; i++) { |
719 | cycle = increment_cycle_count(cycle, 1); | 718 | cycle = increment_cycle_count(cycle, 1); |
720 | 719 | ||
721 | /* The number of quadlets in this packet */ | 720 | /* The number of bytes in this packet */ |
722 | payload_length = | 721 | payload_length = |
723 | (be32_to_cpu(headers[i]) >> ISO_DATA_LENGTH_SHIFT); | 722 | (be32_to_cpu(headers[i]) >> ISO_DATA_LENGTH_SHIFT); |
724 | if (payload_length > max_payload_length) { | 723 | if (payload_length > max_payload_length) { |
@@ -751,6 +750,8 @@ static void amdtp_stream_first_callback(struct fw_iso_context *context, | |||
751 | u32 cycle; | 750 | u32 cycle; |
752 | unsigned int packets; | 751 | unsigned int packets; |
753 | 752 | ||
753 | s->max_payload_length = amdtp_stream_get_max_payload(s); | ||
754 | |||
754 | /* | 755 | /* |
755 | * For in-stream, first packet has come. | 756 | * For in-stream, first packet has come. |
756 | * For out-stream, prepared to transmit first packet | 757 | * For out-stream, prepared to transmit first packet |
diff --git a/sound/firewire/amdtp-stream.h b/sound/firewire/amdtp-stream.h index 2bd4de4c7bb7..7e8831722821 100644 --- a/sound/firewire/amdtp-stream.h +++ b/sound/firewire/amdtp-stream.h | |||
@@ -110,6 +110,7 @@ struct amdtp_stream { | |||
110 | int (*handle_packet)(struct amdtp_stream *s, | 110 | int (*handle_packet)(struct amdtp_stream *s, |
111 | unsigned int payload_quadlets, unsigned int cycle, | 111 | unsigned int payload_quadlets, unsigned int cycle, |
112 | unsigned int index); | 112 | unsigned int index); |
113 | unsigned int max_payload_length; | ||
113 | 114 | ||
114 | /* For CIP headers. */ | 115 | /* For CIP headers. */ |
115 | unsigned int source_node_id_field; | 116 | unsigned int source_node_id_field; |