Commit d2c104a3 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: firewire-lib: pass packet descriptor to data block processing layer

This commit changes signature of callback function to call data block
processing layer with packet descriptor. At present, the layer is called
per packet.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 0f5cfcb2
...@@ -336,44 +336,46 @@ static void read_midi_messages(struct amdtp_stream *s, __be32 *buffer, ...@@ -336,44 +336,46 @@ static void read_midi_messages(struct amdtp_stream *s, __be32 *buffer,
} }
static unsigned int process_rx_data_blocks(struct amdtp_stream *s, static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
__be32 *buffer, unsigned int data_blocks, const struct pkt_desc *desc,
unsigned int data_block_counter) struct snd_pcm_substream *pcm)
{ {
struct amdtp_am824 *p = s->protocol; struct amdtp_am824 *p = s->protocol;
struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
unsigned int pcm_frames; unsigned int pcm_frames;
if (pcm) { if (pcm) {
write_pcm_s32(s, pcm, buffer, data_blocks); write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
pcm_frames = data_blocks * p->frame_multiplier; pcm_frames = desc->data_blocks * p->frame_multiplier;
} else { } else {
write_pcm_silence(s, buffer, data_blocks); write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
pcm_frames = 0; pcm_frames = 0;
} }
if (p->midi_ports) if (p->midi_ports) {
write_midi_messages(s, buffer, data_blocks, data_block_counter); write_midi_messages(s, desc->ctx_payload, desc->data_blocks,
desc->data_block_counter);
}
return pcm_frames; return pcm_frames;
} }
static unsigned int process_tx_data_blocks(struct amdtp_stream *s, static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
__be32 *buffer, unsigned int data_blocks, const struct pkt_desc *desc,
unsigned int data_block_counter) struct snd_pcm_substream *pcm)
{ {
struct amdtp_am824 *p = s->protocol; struct amdtp_am824 *p = s->protocol;
struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
unsigned int pcm_frames; unsigned int pcm_frames;
if (pcm) { if (pcm) {
read_pcm_s32(s, pcm, buffer, data_blocks); read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
pcm_frames = data_blocks * p->frame_multiplier; pcm_frames = desc->data_blocks * p->frame_multiplier;
} else { } else {
pcm_frames = 0; pcm_frames = 0;
} }
if (p->midi_ports) if (p->midi_ports) {
read_midi_messages(s, buffer, data_blocks, data_block_counter); read_midi_messages(s, desc->ctx_payload, desc->data_blocks,
desc->data_block_counter);
}
return pcm_frames; return pcm_frames;
} }
......
...@@ -768,13 +768,11 @@ static void process_ctx_payloads(struct amdtp_stream *s, ...@@ -768,13 +768,11 @@ static void process_ctx_payloads(struct amdtp_stream *s,
for (i = 0; i < packets; ++i) { for (i = 0; i < packets; ++i) {
const struct pkt_desc *desc = descs + i; const struct pkt_desc *desc = descs + i;
struct snd_pcm_substream *pcm; struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
unsigned int pcm_frames; unsigned int pcm_frames;
pcm_frames = s->process_data_blocks(s, desc->ctx_payload, pcm_frames = s->process_data_blocks(s, desc, pcm);
desc->data_blocks, desc->data_block_counter);
pcm = READ_ONCE(s->pcm);
if (pcm && pcm_frames > 0) if (pcm && pcm_frames > 0)
update_pcm_pointers(s, pcm, pcm_frames); update_pcm_pointers(s, pcm, pcm_frames);
} }
......
...@@ -105,9 +105,8 @@ struct pkt_desc { ...@@ -105,9 +105,8 @@ struct pkt_desc {
struct amdtp_stream; struct amdtp_stream;
typedef unsigned int (*amdtp_stream_process_data_blocks_t)( typedef unsigned int (*amdtp_stream_process_data_blocks_t)(
struct amdtp_stream *s, struct amdtp_stream *s,
__be32 *buffer, const struct pkt_desc *desc,
unsigned int data_blocks, struct snd_pcm_substream *pcm);
unsigned int data_block_counter);
struct amdtp_stream { struct amdtp_stream {
struct fw_unit *unit; struct fw_unit *unit;
enum cip_flags flags; enum cip_flags flags;
......
...@@ -330,42 +330,39 @@ void amdtp_dot_midi_trigger(struct amdtp_stream *s, unsigned int port, ...@@ -330,42 +330,39 @@ void amdtp_dot_midi_trigger(struct amdtp_stream *s, unsigned int port,
} }
static unsigned int process_tx_data_blocks(struct amdtp_stream *s, static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
__be32 *buffer, unsigned int data_blocks, const struct pkt_desc *desc,
unsigned int data_block_counter) struct snd_pcm_substream *pcm)
{ {
struct snd_pcm_substream *pcm;
unsigned int pcm_frames; unsigned int pcm_frames;
pcm = READ_ONCE(s->pcm);
if (pcm) { if (pcm) {
read_pcm_s32(s, pcm, buffer, data_blocks); read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
pcm_frames = data_blocks; pcm_frames = desc->data_blocks;
} else { } else {
pcm_frames = 0; pcm_frames = 0;
} }
read_midi_messages(s, buffer, data_blocks); read_midi_messages(s, desc->ctx_payload, desc->data_blocks);
return pcm_frames; return pcm_frames;
} }
static unsigned int process_rx_data_blocks(struct amdtp_stream *s, static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
__be32 *buffer, unsigned int data_blocks, const struct pkt_desc *desc,
unsigned int data_block_counter) struct snd_pcm_substream *pcm)
{ {
struct snd_pcm_substream *pcm;
unsigned int pcm_frames; unsigned int pcm_frames;
pcm = READ_ONCE(s->pcm);
if (pcm) { if (pcm) {
write_pcm_s32(s, pcm, buffer, data_blocks); write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
pcm_frames = data_blocks; pcm_frames = desc->data_blocks;
} else { } else {
write_pcm_silence(s, buffer, data_blocks); write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
pcm_frames = 0; pcm_frames = 0;
} }
write_midi_messages(s, buffer, data_blocks, data_block_counter); write_midi_messages(s, desc->ctx_payload, desc->data_blocks,
desc->data_block_counter);
return pcm_frames; return pcm_frames;
} }
......
...@@ -103,17 +103,18 @@ int amdtp_ff_add_pcm_hw_constraints(struct amdtp_stream *s, ...@@ -103,17 +103,18 @@ int amdtp_ff_add_pcm_hw_constraints(struct amdtp_stream *s,
} }
static unsigned int process_rx_data_blocks(struct amdtp_stream *s, static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
__be32 *buffer, unsigned int data_blocks, const struct pkt_desc *desc,
unsigned int data_block_counter) struct snd_pcm_substream *pcm)
{ {
struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
unsigned int pcm_frames; unsigned int pcm_frames;
if (pcm) { if (pcm) {
write_pcm_s32(s, pcm, (__le32 *)buffer, data_blocks); write_pcm_s32(s, pcm, (__le32 *)desc->ctx_payload,
pcm_frames = data_blocks; desc->data_blocks);
pcm_frames = desc->data_blocks;
} else { } else {
write_pcm_silence(s, (__le32 *)buffer, data_blocks); write_pcm_silence(s, (__le32 *)desc->ctx_payload,
desc->data_blocks);
pcm_frames = 0; pcm_frames = 0;
} }
...@@ -121,15 +122,15 @@ static unsigned int process_rx_data_blocks(struct amdtp_stream *s, ...@@ -121,15 +122,15 @@ static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
} }
static unsigned int process_tx_data_blocks(struct amdtp_stream *s, static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
__be32 *buffer, unsigned int data_blocks, const struct pkt_desc *desc,
unsigned int data_block_counter) struct snd_pcm_substream *pcm)
{ {
struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
unsigned int pcm_frames; unsigned int pcm_frames;
if (pcm) { if (pcm) {
read_pcm_s32(s, pcm, (__le32 *)buffer, data_blocks); read_pcm_s32(s, pcm, (__le32 *)desc->ctx_payload,
pcm_frames = data_blocks; desc->data_blocks);
pcm_frames = desc->data_blocks;
} else { } else {
pcm_frames = 0; pcm_frames = 0;
} }
......
...@@ -299,23 +299,27 @@ static void __maybe_unused copy_message(u64 *frames, __be32 *buffer, ...@@ -299,23 +299,27 @@ static void __maybe_unused copy_message(u64 *frames, __be32 *buffer,
} }
static unsigned int process_tx_data_blocks(struct amdtp_stream *s, static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
__be32 *buffer, unsigned int data_blocks, const struct pkt_desc *desc,
unsigned int data_block_counter) struct snd_pcm_substream *pcm)
{ {
struct amdtp_motu *p = s->protocol; struct amdtp_motu *p = s->protocol;
struct snd_pcm_substream *pcm; unsigned int pcm_frames;
trace_data_block_sph(s, data_blocks, buffer); trace_data_block_sph(s, desc->data_blocks, desc->ctx_payload);
trace_data_block_message(s, data_blocks, buffer); trace_data_block_message(s, desc->data_blocks, desc->ctx_payload);
if (p->midi_ports) if (p->midi_ports)
read_midi_messages(s, buffer, data_blocks); read_midi_messages(s, desc->ctx_payload, desc->data_blocks);
pcm = READ_ONCE(s->pcm); if (pcm) {
if (data_blocks > 0 && pcm) read_pcm_s32(s, pcm->runtime, desc->ctx_payload,
read_pcm_s32(s, pcm->runtime, buffer, data_blocks); desc->data_blocks);
pcm_frames = desc->data_blocks;
} else {
pcm_frames = 0;
}
return data_blocks; return pcm_frames;
} }
static inline void compute_next_elapse_from_start(struct amdtp_motu *p) static inline void compute_next_elapse_from_start(struct amdtp_motu *p)
...@@ -361,29 +365,32 @@ static void write_sph(struct amdtp_stream *s, __be32 *buffer, ...@@ -361,29 +365,32 @@ static void write_sph(struct amdtp_stream *s, __be32 *buffer,
} }
static unsigned int process_rx_data_blocks(struct amdtp_stream *s, static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
__be32 *buffer, unsigned int data_blocks, const struct pkt_desc *desc,
unsigned int data_block_counter) struct snd_pcm_substream *pcm)
{ {
struct amdtp_motu *p = (struct amdtp_motu *)s->protocol; struct amdtp_motu *p = (struct amdtp_motu *)s->protocol;
struct snd_pcm_substream *pcm; unsigned int pcm_frames;
/* TODO: how to interact control messages between userspace? */ /* TODO: how to interact control messages between userspace? */
if (p->midi_ports) if (p->midi_ports)
write_midi_messages(s, buffer, data_blocks); write_midi_messages(s, desc->ctx_payload, desc->data_blocks);
pcm = READ_ONCE(s->pcm); if (pcm) {
if (pcm) write_pcm_s32(s, pcm->runtime, desc->ctx_payload,
write_pcm_s32(s, pcm->runtime, buffer, data_blocks); desc->data_blocks);
else pcm_frames = desc->data_blocks;
write_pcm_silence(s, buffer, data_blocks); } else {
write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
pcm_frames = 0;
}
write_sph(s, buffer, data_blocks); write_sph(s, desc->ctx_payload, desc->data_blocks);
trace_data_block_sph(s, data_blocks, buffer); trace_data_block_sph(s, desc->data_blocks, desc->ctx_payload);
trace_data_block_message(s, data_blocks, buffer); trace_data_block_message(s, desc->data_blocks, desc->ctx_payload);
return data_blocks; return pcm_frames;
} }
int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit, int amdtp_motu_init(struct amdtp_stream *s, struct fw_unit *unit,
......
...@@ -166,33 +166,38 @@ static void read_status_messages(struct amdtp_stream *s, ...@@ -166,33 +166,38 @@ static void read_status_messages(struct amdtp_stream *s,
} }
static unsigned int process_tx_data_blocks(struct amdtp_stream *s, static unsigned int process_tx_data_blocks(struct amdtp_stream *s,
__be32 *buffer, unsigned int data_blocks, const struct pkt_desc *desc,
unsigned int data_block_counter) struct snd_pcm_substream *pcm)
{ {
struct snd_pcm_substream *pcm; unsigned int pcm_frames;
pcm = READ_ONCE(s->pcm); if (pcm) {
if (data_blocks > 0 && pcm) read_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
read_pcm_s32(s, pcm, buffer, data_blocks); pcm_frames = desc->data_blocks;
} else {
pcm_frames = 0;
}
read_status_messages(s, buffer, data_blocks); read_status_messages(s, desc->ctx_payload, desc->data_blocks);
return data_blocks; return pcm_frames;
} }
static unsigned int process_rx_data_blocks(struct amdtp_stream *s, static unsigned int process_rx_data_blocks(struct amdtp_stream *s,
__be32 *buffer, unsigned int data_blocks, const struct pkt_desc *desc,
unsigned int data_block_counter) struct snd_pcm_substream *pcm)
{ {
struct snd_pcm_substream *pcm; unsigned int pcm_frames;
pcm = READ_ONCE(s->pcm); if (pcm) {
if (pcm) write_pcm_s32(s, pcm, desc->ctx_payload, desc->data_blocks);
write_pcm_s32(s, pcm, buffer, data_blocks); pcm_frames = desc->data_blocks;
else } else {
write_pcm_silence(s, buffer, data_blocks); write_pcm_silence(s, desc->ctx_payload, desc->data_blocks);
pcm_frames = 0;
}
return data_blocks; return pcm_frames;
} }
int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit, int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment