aboutsummaryrefslogtreecommitdiffstats
path: root/sound/firewire
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2015-05-22 10:00:53 -0400
committerTakashi Iwai <tiwai@suse.de>2015-05-23 03:13:20 -0400
commita4103bd7fdd59548580bdbc8e995ef9621ef670e (patch)
tree5721ec50125f4e1c2d7848b983a2fc328324752b /sound/firewire
parent6fc6b9ce41c6e6ee123f0da5d3bfd7b628be2bd0 (diff)
ALSA: firewire-lib: set streaming error outside of packetization
In previous commit, error handling for incoming packet processing is outside of packetization. This is nice for reading the codes. This commit applies this idea for outgoing packet processing, too. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire')
-rw-r--r--sound/firewire/amdtp.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
index c69c3ab90acc..c26dda7f41e6 100644
--- a/sound/firewire/amdtp.c
+++ b/sound/firewire/amdtp.c
@@ -647,16 +647,13 @@ static inline int queue_in_packet(struct amdtp_stream *s)
647 amdtp_stream_get_max_payload(s), false); 647 amdtp_stream_get_max_payload(s), false);
648} 648}
649 649
650static void handle_out_packet(struct amdtp_stream *s, unsigned int data_blocks, 650static int handle_out_packet(struct amdtp_stream *s, unsigned int data_blocks,
651 unsigned int syt) 651 unsigned int syt)
652{ 652{
653 __be32 *buffer; 653 __be32 *buffer;
654 unsigned int payload_length; 654 unsigned int payload_length;
655 struct snd_pcm_substream *pcm; 655 struct snd_pcm_substream *pcm;
656 656
657 if (s->packet_index < 0)
658 return;
659
660 buffer = s->buffer.packets[s->packet_index].buffer; 657 buffer = s->buffer.packets[s->packet_index].buffer;
661 buffer[0] = cpu_to_be32(ACCESS_ONCE(s->source_node_id_field) | 658 buffer[0] = cpu_to_be32(ACCESS_ONCE(s->source_node_id_field) |
662 (s->data_block_quadlets << AMDTP_DBS_SHIFT) | 659 (s->data_block_quadlets << AMDTP_DBS_SHIFT) |
@@ -676,14 +673,14 @@ static void handle_out_packet(struct amdtp_stream *s, unsigned int data_blocks,
676 s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff; 673 s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff;
677 674
678 payload_length = 8 + data_blocks * 4 * s->data_block_quadlets; 675 payload_length = 8 + data_blocks * 4 * s->data_block_quadlets;
679 if (queue_out_packet(s, payload_length, false) < 0) { 676 if (queue_out_packet(s, payload_length, false) < 0)
680 s->packet_index = -1; 677 return -EIO;
681 amdtp_stream_pcm_abort(s);
682 return;
683 }
684 678
685 if (pcm) 679 if (pcm)
686 update_pcm_pointers(s, pcm, data_blocks); 680 update_pcm_pointers(s, pcm, data_blocks);
681
682 /* No need to return the number of handled data blocks. */
683 return 0;
687} 684}
688 685
689static int handle_in_packet(struct amdtp_stream *s, 686static int handle_in_packet(struct amdtp_stream *s,
@@ -795,6 +792,9 @@ static void out_stream_callback(struct fw_iso_context *context, u32 cycle,
795 unsigned int i, syt, packets = header_length / 4; 792 unsigned int i, syt, packets = header_length / 4;
796 unsigned int data_blocks; 793 unsigned int data_blocks;
797 794
795 if (s->packet_index < 0)
796 return;
797
798 /* 798 /*
799 * Compute the cycle of the last queued packet. 799 * Compute the cycle of the last queued packet.
800 * (We need only the four lowest bits for the SYT, so we can ignore 800 * (We need only the four lowest bits for the SYT, so we can ignore
@@ -806,8 +806,13 @@ static void out_stream_callback(struct fw_iso_context *context, u32 cycle,
806 syt = calculate_syt(s, ++cycle); 806 syt = calculate_syt(s, ++cycle);
807 data_blocks = calculate_data_blocks(s, syt); 807 data_blocks = calculate_data_blocks(s, syt);
808 808
809 handle_out_packet(s, data_blocks, syt); 809 if (handle_out_packet(s, data_blocks, syt) < 0) {
810 s->packet_index = -1;
811 amdtp_stream_pcm_abort(s);
812 return;
813 }
810 } 814 }
815
811 fw_iso_context_queue_flush(s->context); 816 fw_iso_context_queue_flush(s->context);
812} 817}
813 818
@@ -821,6 +826,9 @@ static void in_stream_callback(struct fw_iso_context *context, u32 cycle,
821 unsigned int data_blocks; 826 unsigned int data_blocks;
822 __be32 *buffer, *headers = header; 827 __be32 *buffer, *headers = header;
823 828
829 if (s->packet_index < 0)
830 return;
831
824 /* The number of packets in buffer */ 832 /* The number of packets in buffer */
825 packets = header_length / IN_PACKET_HEADER_SIZE; 833 packets = header_length / IN_PACKET_HEADER_SIZE;
826 834
@@ -828,9 +836,6 @@ static void in_stream_callback(struct fw_iso_context *context, u32 cycle,
828 max_payload_quadlets = amdtp_stream_get_max_payload(s) / 4; 836 max_payload_quadlets = amdtp_stream_get_max_payload(s) / 4;
829 837
830 for (p = 0; p < packets; p++) { 838 for (p = 0; p < packets; p++) {
831 if (s->packet_index < 0)
832 break;
833
834 buffer = s->buffer.packets[s->packet_index].buffer; 839 buffer = s->buffer.packets[s->packet_index].buffer;
835 840
836 /* The number of quadlets in this packet */ 841 /* The number of quadlets in this packet */
@@ -853,7 +858,11 @@ static void in_stream_callback(struct fw_iso_context *context, u32 cycle,
853 /* Process sync slave stream */ 858 /* Process sync slave stream */
854 if (s->sync_slave && s->sync_slave->callbacked) { 859 if (s->sync_slave && s->sync_slave->callbacked) {
855 syt = be32_to_cpu(buffer[1]) & CIP_SYT_MASK; 860 syt = be32_to_cpu(buffer[1]) & CIP_SYT_MASK;
856 handle_out_packet(s->sync_slave, data_blocks, syt); 861 if (handle_out_packet(s->sync_slave,
862 data_blocks, syt) < 0) {
863 s->packet_index = -1;
864 break;
865 }
857 } 866 }
858 } 867 }
859 868