aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2017-03-31 09:06:06 -0400
committerTakashi Iwai <tiwai@suse.de>2017-04-05 15:31:38 -0400
commitff0fb5aaa8799701aa01bd1f2cdaf93ce98bbe60 (patch)
tree5de15a0f52736e5ef572ae7d9b671c6bd20b8b31
parentd3fc7aac11dc54f97f4f28c60a489a555529fa1c (diff)
ALSA: firewire-lib: use the same prototype for functions to handle packet
Audio and music units of RME Fireface series use its own protocol for isochronous packets to transfer data. This protocol requires ALSA IEC 61883-1/6 engine to have alternative functions. This commit is a preparation for the protocol. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/firewire/amdtp-stream-trace.h6
-rw-r--r--sound/firewire/amdtp-stream.c31
2 files changed, 19 insertions, 18 deletions
diff --git a/sound/firewire/amdtp-stream-trace.h b/sound/firewire/amdtp-stream-trace.h
index 9c04faf206b2..850b36e27d0d 100644
--- a/sound/firewire/amdtp-stream-trace.h
+++ b/sound/firewire/amdtp-stream-trace.h
@@ -14,8 +14,8 @@
14#include <linux/tracepoint.h> 14#include <linux/tracepoint.h>
15 15
16TRACE_EVENT(in_packet, 16TRACE_EVENT(in_packet,
17 TP_PROTO(const struct amdtp_stream *s, u32 cycles, u32 cip_header[2], unsigned int payload_quadlets, unsigned int index), 17 TP_PROTO(const struct amdtp_stream *s, u32 cycles, u32 cip_header[2], unsigned int payload_length, unsigned int index),
18 TP_ARGS(s, cycles, cip_header, payload_quadlets, index), 18 TP_ARGS(s, cycles, cip_header, payload_length, index),
19 TP_STRUCT__entry( 19 TP_STRUCT__entry(
20 __field(unsigned int, second) 20 __field(unsigned int, second)
21 __field(unsigned int, cycle) 21 __field(unsigned int, cycle)
@@ -37,7 +37,7 @@ TRACE_EVENT(in_packet,
37 __entry->dest = fw_parent_device(s->unit)->card->node_id; 37 __entry->dest = fw_parent_device(s->unit)->card->node_id;
38 __entry->cip_header0 = cip_header[0]; 38 __entry->cip_header0 = cip_header[0];
39 __entry->cip_header1 = cip_header[1]; 39 __entry->cip_header1 = cip_header[1];
40 __entry->payload_quadlets = payload_quadlets; 40 __entry->payload_quadlets = payload_length / 4;
41 __entry->packet_index = s->packet_index; 41 __entry->packet_index = s->packet_index;
42 __entry->irq = !!in_interrupt(); 42 __entry->irq = !!in_interrupt();
43 __entry->index = index; 43 __entry->index = index;
diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c
index 112ad039ed25..646e8e390773 100644
--- a/sound/firewire/amdtp-stream.c
+++ b/sound/firewire/amdtp-stream.c
@@ -411,13 +411,13 @@ static inline int queue_in_packet(struct amdtp_stream *s)
411 amdtp_stream_get_max_payload(s)); 411 amdtp_stream_get_max_payload(s));
412} 412}
413 413
414static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle, 414static int handle_out_packet(struct amdtp_stream *s,
415 unsigned int payload_length, unsigned int cycle,
415 unsigned int index) 416 unsigned int index)
416{ 417{
417 __be32 *buffer; 418 __be32 *buffer;
418 unsigned int syt; 419 unsigned int syt;
419 unsigned int data_blocks; 420 unsigned int data_blocks;
420 unsigned int payload_length;
421 unsigned int pcm_frames; 421 unsigned int pcm_frames;
422 struct snd_pcm_substream *pcm; 422 struct snd_pcm_substream *pcm;
423 423
@@ -458,7 +458,7 @@ static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle,
458} 458}
459 459
460static int handle_in_packet(struct amdtp_stream *s, 460static int handle_in_packet(struct amdtp_stream *s,
461 unsigned int payload_quadlets, unsigned int cycle, 461 unsigned int payload_length, unsigned int cycle,
462 unsigned int index) 462 unsigned int index)
463{ 463{
464 __be32 *buffer; 464 __be32 *buffer;
@@ -474,7 +474,7 @@ static int handle_in_packet(struct amdtp_stream *s,
474 cip_header[0] = be32_to_cpu(buffer[0]); 474 cip_header[0] = be32_to_cpu(buffer[0]);
475 cip_header[1] = be32_to_cpu(buffer[1]); 475 cip_header[1] = be32_to_cpu(buffer[1]);
476 476
477 trace_in_packet(s, cycle, cip_header, payload_quadlets, index); 477 trace_in_packet(s, cycle, cip_header, payload_length, index);
478 478
479 /* 479 /*
480 * This module supports 'Two-quadlet CIP header with SYT field'. 480 * This module supports 'Two-quadlet CIP header with SYT field'.
@@ -505,7 +505,7 @@ static int handle_in_packet(struct amdtp_stream *s,
505 505
506 /* Calculate data blocks */ 506 /* Calculate data blocks */
507 fdf = (cip_header[1] & CIP_FDF_MASK) >> CIP_FDF_SHIFT; 507 fdf = (cip_header[1] & CIP_FDF_MASK) >> CIP_FDF_SHIFT;
508 if (payload_quadlets < 3 || 508 if (payload_length < 12 ||
509 (fmt == CIP_FMT_AM && fdf == AMDTP_FDF_NO_DATA)) { 509 (fmt == CIP_FMT_AM && fdf == AMDTP_FDF_NO_DATA)) {
510 data_blocks = 0; 510 data_blocks = 0;
511 } else { 511 } else {
@@ -521,7 +521,8 @@ static int handle_in_packet(struct amdtp_stream *s,
521 if (s->flags & CIP_WRONG_DBS) 521 if (s->flags & CIP_WRONG_DBS)
522 data_block_quadlets = s->data_block_quadlets; 522 data_block_quadlets = s->data_block_quadlets;
523 523
524 data_blocks = (payload_quadlets - 2) / data_block_quadlets; 524 data_blocks = (payload_length / 4 - 2) /
525 data_block_quadlets;
525 } 526 }
526 527
527 /* Check data block counter continuity */ 528 /* Check data block counter continuity */
@@ -615,7 +616,7 @@ static void out_stream_callback(struct fw_iso_context *context, u32 tstamp,
615 616
616 for (i = 0; i < packets; ++i) { 617 for (i = 0; i < packets; ++i) {
617 cycle = increment_cycle_count(cycle, 1); 618 cycle = increment_cycle_count(cycle, 1);
618 if (handle_out_packet(s, cycle, i) < 0) { 619 if (handle_out_packet(s, 0, cycle, i) < 0) {
619 s->packet_index = -1; 620 s->packet_index = -1;
620 amdtp_stream_pcm_abort(s); 621 amdtp_stream_pcm_abort(s);
621 return; 622 return;
@@ -631,7 +632,7 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,
631{ 632{
632 struct amdtp_stream *s = private_data; 633 struct amdtp_stream *s = private_data;
633 unsigned int i, packets; 634 unsigned int i, packets;
634 unsigned int payload_quadlets, max_payload_quadlets; 635 unsigned int payload_length, max_payload_length;
635 __be32 *headers = header; 636 __be32 *headers = header;
636 u32 cycle; 637 u32 cycle;
637 638
@@ -647,22 +648,22 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,
647 cycle = decrement_cycle_count(cycle, packets); 648 cycle = decrement_cycle_count(cycle, packets);
648 649
649 /* For buffer-over-run prevention. */ 650 /* For buffer-over-run prevention. */
650 max_payload_quadlets = amdtp_stream_get_max_payload(s) / 4; 651 max_payload_length = amdtp_stream_get_max_payload(s);
651 652
652 for (i = 0; i < packets; i++) { 653 for (i = 0; i < packets; i++) {
653 cycle = increment_cycle_count(cycle, 1); 654 cycle = increment_cycle_count(cycle, 1);
654 655
655 /* The number of quadlets in this packet */ 656 /* The number of quadlets in this packet */
656 payload_quadlets = 657 payload_length =
657 (be32_to_cpu(headers[i]) >> ISO_DATA_LENGTH_SHIFT) / 4; 658 (be32_to_cpu(headers[i]) >> ISO_DATA_LENGTH_SHIFT);
658 if (payload_quadlets > max_payload_quadlets) { 659 if (payload_length > max_payload_length) {
659 dev_err(&s->unit->device, 660 dev_err(&s->unit->device,
660 "Detect jumbo payload: %02x %02x\n", 661 "Detect jumbo payload: %04x %04x\n",
661 payload_quadlets, max_payload_quadlets); 662 payload_length, max_payload_length);
662 break; 663 break;
663 } 664 }
664 665
665 if (handle_in_packet(s, payload_quadlets, cycle, i) < 0) 666 if (handle_in_packet(s, payload_length, cycle, i) < 0)
666 break; 667 break;
667 } 668 }
668 669