aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2016-05-09 08:12:45 -0400
committerTakashi Iwai <tiwai@suse.de>2016-05-09 09:18:25 -0400
commitf90e2dedf7f47ff4f2f757188a0360fbf526a81e (patch)
treea4a83f85eb8c9e14edab2716579afc86796d52df
parent73fc7f080105b16d9f189c82d0092f22107cc67b (diff)
ALSA: firewire-lib: compute the value of second field in cycle count for IR context
In callback function of isochronous context, modules can queue packets to indicated isochronous cycles. Although the cycle to queue a packet is deterministic by calculation, this module doesn't implement the calculation because it's useless for processing. In future, the cycle count is going to be printed with the other parameters for debugging. This commit is the preparation. The cycle count is computed by cycle unit, and correctly arranged to corresponding packets. The calculated count is used in later commit. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/firewire/amdtp-stream.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c
index 46f1167bf69f..4d86da0355ba 100644
--- a/sound/firewire/amdtp-stream.c
+++ b/sound/firewire/amdtp-stream.c
@@ -566,6 +566,13 @@ static inline u32 increment_cycle_count(u32 cycle, unsigned int addend)
566 return cycle; 566 return cycle;
567} 567}
568 568
569static inline u32 decrement_cycle_count(u32 cycle, unsigned int subtrahend)
570{
571 if (cycle < subtrahend)
572 cycle += 8 * CYCLES_PER_SECOND;
573 return cycle - subtrahend;
574}
575
569static void out_stream_callback(struct fw_iso_context *context, u32 tstamp, 576static void out_stream_callback(struct fw_iso_context *context, u32 tstamp,
570 size_t header_length, void *header, 577 size_t header_length, void *header,
571 void *private_data) 578 void *private_data)
@@ -607,6 +614,7 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,
607 unsigned int payload_quadlets, max_payload_quadlets; 614 unsigned int payload_quadlets, max_payload_quadlets;
608 unsigned int data_blocks; 615 unsigned int data_blocks;
609 __be32 *buffer, *headers = header; 616 __be32 *buffer, *headers = header;
617 u32 cycle;
610 618
611 if (s->packet_index < 0) 619 if (s->packet_index < 0)
612 return; 620 return;
@@ -614,10 +622,16 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,
614 /* The number of packets in buffer */ 622 /* The number of packets in buffer */
615 packets = header_length / IN_PACKET_HEADER_SIZE; 623 packets = header_length / IN_PACKET_HEADER_SIZE;
616 624
625 cycle = compute_cycle_count(tstamp);
626
627 /* Align to actual cycle count for the last packet. */
628 cycle = decrement_cycle_count(cycle, packets);
629
617 /* For buffer-over-run prevention. */ 630 /* For buffer-over-run prevention. */
618 max_payload_quadlets = amdtp_stream_get_max_payload(s) / 4; 631 max_payload_quadlets = amdtp_stream_get_max_payload(s) / 4;
619 632
620 for (p = 0; p < packets; p++) { 633 for (p = 0; p < packets; p++) {
634 cycle = increment_cycle_count(cycle, 1);
621 buffer = s->buffer.packets[s->packet_index].buffer; 635 buffer = s->buffer.packets[s->packet_index].buffer;
622 636
623 /* The number of quadlets in this packet */ 637 /* The number of quadlets in this packet */