Skip to content

Commit

Permalink
ALSA: firewire-lib: add cache for packet sequence to AMDTP domain str…
Browse files Browse the repository at this point in the history
…ucture

For future extension, storage is required to store packet sequence in
incoming AMDTP stream to recover media clock for outgoing AMDTP stream.

This commit adds the storage to AMDTP domain for this purpose. The
packet sequence is represented by 'struct seq_desc' which has two
members; syt_offset and the number of data blocks. The size of storage
is decided according to the size of packet queue.

Signed-off-by: Takashi Sakamoto <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
takaswie authored and tiwai committed May 8, 2020
1 parent 274fc35 commit 25babf2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
15 changes: 14 additions & 1 deletion sound/firewire/amdtp-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,8 @@ int amdtp_domain_init(struct amdtp_domain *d)

d->events_per_period = 0;

d->seq_descs = NULL;

return 0;
}
EXPORT_SYMBOL_GPL(amdtp_domain_init);
Expand Down Expand Up @@ -1370,12 +1372,18 @@ int amdtp_domain_start(struct amdtp_domain *d, unsigned int ir_delay_cycle)
queue_size = DIV_ROUND_UP(CYCLES_PER_SECOND * events_per_buffer,
amdtp_rate_table[d->irq_target->sfc]);

d->seq_descs = kcalloc(queue_size, sizeof(*d->seq_descs), GFP_KERNEL);
if (!d->seq_descs)
return -ENOMEM;
d->seq_size = queue_size;
d->seq_tail = 0;

if (ir_delay_cycle > 0) {
struct fw_card *fw_card = fw_parent_device(s->unit)->card;

err = get_current_cycle_time(fw_card, &cycle);
if (err < 0)
return err;
goto error;

// No need to care overflow in cycle field because of enough
// width.
Expand Down Expand Up @@ -1431,6 +1439,8 @@ int amdtp_domain_start(struct amdtp_domain *d, unsigned int ir_delay_cycle)
error:
list_for_each_entry(s, &d->streams, list)
amdtp_stream_stop(s);
kfree(d->seq_descs);
d->seq_descs = NULL;
return err;
}
EXPORT_SYMBOL_GPL(amdtp_domain_start);
Expand All @@ -1455,5 +1465,8 @@ void amdtp_domain_stop(struct amdtp_domain *d)

d->events_per_period = 0;
d->irq_target = NULL;

kfree(d->seq_descs);
d->seq_descs = NULL;
}
EXPORT_SYMBOL_GPL(amdtp_domain_stop);
9 changes: 9 additions & 0 deletions sound/firewire/amdtp-stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,22 @@ static inline bool amdtp_stream_wait_callback(struct amdtp_stream *s,
msecs_to_jiffies(timeout)) > 0;
}

struct seq_desc {
unsigned int syt_offset;
unsigned int data_blocks;
};

struct amdtp_domain {
struct list_head streams;

unsigned int events_per_period;
unsigned int events_per_buffer;

struct amdtp_stream *irq_target;

struct seq_desc *seq_descs;
unsigned int seq_size;
unsigned int seq_tail;
};

int amdtp_domain_init(struct amdtp_domain *d);
Expand Down

0 comments on commit 25babf2

Please sign in to comment.