forked from Minki/linux
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>
This commit is contained in:
parent
73fc7f0801
commit
f90e2dedf7
@ -566,6 +566,13 @@ static inline u32 increment_cycle_count(u32 cycle, unsigned int addend)
|
|||||||
return cycle;
|
return cycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline u32 decrement_cycle_count(u32 cycle, unsigned int subtrahend)
|
||||||
|
{
|
||||||
|
if (cycle < subtrahend)
|
||||||
|
cycle += 8 * CYCLES_PER_SECOND;
|
||||||
|
return cycle - subtrahend;
|
||||||
|
}
|
||||||
|
|
||||||
static void out_stream_callback(struct fw_iso_context *context, u32 tstamp,
|
static void out_stream_callback(struct fw_iso_context *context, u32 tstamp,
|
||||||
size_t header_length, void *header,
|
size_t header_length, void *header,
|
||||||
void *private_data)
|
void *private_data)
|
||||||
@ -607,6 +614,7 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,
|
|||||||
unsigned int payload_quadlets, max_payload_quadlets;
|
unsigned int payload_quadlets, max_payload_quadlets;
|
||||||
unsigned int data_blocks;
|
unsigned int data_blocks;
|
||||||
__be32 *buffer, *headers = header;
|
__be32 *buffer, *headers = header;
|
||||||
|
u32 cycle;
|
||||||
|
|
||||||
if (s->packet_index < 0)
|
if (s->packet_index < 0)
|
||||||
return;
|
return;
|
||||||
@ -614,10 +622,16 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp,
|
|||||||
/* The number of packets in buffer */
|
/* The number of packets in buffer */
|
||||||
packets = header_length / IN_PACKET_HEADER_SIZE;
|
packets = header_length / IN_PACKET_HEADER_SIZE;
|
||||||
|
|
||||||
|
cycle = compute_cycle_count(tstamp);
|
||||||
|
|
||||||
|
/* Align to actual cycle count for the last packet. */
|
||||||
|
cycle = decrement_cycle_count(cycle, packets);
|
||||||
|
|
||||||
/* For buffer-over-run prevention. */
|
/* For buffer-over-run prevention. */
|
||||||
max_payload_quadlets = amdtp_stream_get_max_payload(s) / 4;
|
max_payload_quadlets = amdtp_stream_get_max_payload(s) / 4;
|
||||||
|
|
||||||
for (p = 0; p < packets; p++) {
|
for (p = 0; p < packets; p++) {
|
||||||
|
cycle = increment_cycle_count(cycle, 1);
|
||||||
buffer = s->buffer.packets[s->packet_index].buffer;
|
buffer = s->buffer.packets[s->packet_index].buffer;
|
||||||
|
|
||||||
/* The number of quadlets in this packet */
|
/* The number of quadlets in this packet */
|
||||||
|
Loading…
Reference in New Issue
Block a user