Commit 0cac60c7 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai
Browse files

ALSA: firewire-lib: use circular linked list for context payload processing layer



The list of packet descriptor is passed to context payload processing
layer so that each driver can copy PCM frames, MIDI messages, and device
specific data between packet payload buffer and intermediate buffer for
user space application.

The list of packet descriptor was replaced by circular linked list in a
previous commit. This commit uses circular linked in context payload
processing layer as well.

Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230109021738.75543-3-o-takashi@sakamocchi.jp


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent cec371ff
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -347,16 +347,15 @@ static void read_midi_messages(struct amdtp_stream *s, __be32 *buffer,
}

static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
					    const struct pkt_desc *descs,
					    unsigned int packets,
					    const struct pkt_desc *desc,
					    unsigned int count,
					    struct snd_pcm_substream *pcm)
{
	struct amdtp_am824 *p = s->protocol;
	unsigned int pcm_frames = 0;
	int i;

	for (i = 0; i < packets; ++i) {
		const struct pkt_desc *desc = descs + i;
	for (i = 0; i < count; ++i) {
		__be32 *buf = desc->ctx_payload;
		unsigned int data_blocks = desc->data_blocks;

@@ -371,22 +370,23 @@ static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
			write_midi_messages(s, buf, data_blocks,
					    desc->data_block_counter);
		}

		desc = amdtp_stream_next_packet_desc(s, desc);
	}

	return pcm_frames;
}

static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
					    const struct pkt_desc *descs,
					    unsigned int packets,
					    const struct pkt_desc *desc,
					    unsigned int count,
					    struct snd_pcm_substream *pcm)
{
	struct amdtp_am824 *p = s->protocol;
	unsigned int pcm_frames = 0;
	int i;

	for (i = 0; i < packets; ++i) {
		const struct pkt_desc *desc = descs + i;
	for (i = 0; i < count; ++i) {
		__be32 *buf = desc->ctx_payload;
		unsigned int data_blocks = desc->data_blocks;

@@ -399,6 +399,8 @@ static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
			read_midi_messages(s, buf, data_blocks,
					   desc->data_block_counter);
		}

		desc = amdtp_stream_next_packet_desc(s, desc);
	}

	return pcm_frames;
+2 −2
Original line number Diff line number Diff line
@@ -1028,13 +1028,13 @@ static inline void cancel_stream(struct amdtp_stream *s)

static void process_ctx_payloads(struct amdtp_stream *s,
				 const struct pkt_desc *descs,
				 unsigned int packets)
				 unsigned int count)
{
	struct snd_pcm_substream *pcm;
	unsigned int pcm_frames;

	pcm = READ_ONCE(s->pcm);
	pcm_frames = s->process_ctx_payloads(s, descs, packets, pcm);
	pcm_frames = s->process_ctx_payloads(s, descs, count, pcm);
	if (pcm)
		update_pcm_pointers(s, pcm, pcm_frames);
}
+1 −1
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ struct amdtp_stream;
typedef unsigned int (*amdtp_stream_process_ctx_payloads_t)(
						struct amdtp_stream *s,
						const struct pkt_desc *desc,
						unsigned int packets,
						unsigned int count,
						struct snd_pcm_substream *pcm);

struct amdtp_domain;
+10 −8
Original line number Diff line number Diff line
@@ -342,15 +342,14 @@ void amdtp_dot_midi_trigger(struct amdtp_stream *s, unsigned int port,
}

static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
					    const struct pkt_desc *descs,
					    unsigned int packets,
					    const struct pkt_desc *desc,
					    unsigned int count,
					    struct snd_pcm_substream *pcm)
{
	unsigned int pcm_frames = 0;
	int i;

	for (i = 0; i < packets; ++i) {
		const struct pkt_desc *desc = descs + i;
	for (i = 0; i < count; ++i) {
		__be32 *buf = desc->ctx_payload;
		unsigned int data_blocks = desc->data_blocks;

@@ -360,21 +359,22 @@ static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
		}

		read_midi_messages(s, buf, data_blocks);

		desc = amdtp_stream_next_packet_desc(s, desc);
	}

	return pcm_frames;
}

static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
					    const struct pkt_desc *descs,
					    unsigned int packets,
					    const struct pkt_desc *desc,
					    unsigned int count,
					    struct snd_pcm_substream *pcm)
{
	unsigned int pcm_frames = 0;
	int i;

	for (i = 0; i < packets; ++i) {
		const struct pkt_desc *desc = descs + i;
	for (i = 0; i < count; ++i) {
		__be32 *buf = desc->ctx_payload;
		unsigned int data_blocks = desc->data_blocks;

@@ -387,6 +387,8 @@ static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,

		write_midi_messages(s, buf, data_blocks,
				    desc->data_block_counter);

		desc = amdtp_stream_next_packet_desc(s, desc);
	}

	return pcm_frames;
+10 −8
Original line number Diff line number Diff line
@@ -113,15 +113,14 @@ int amdtp_ff_add_pcm_hw_constraints(struct amdtp_stream *s,
}

static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
					   const struct pkt_desc *descs,
					   unsigned int packets,
					   const struct pkt_desc *desc,
					   unsigned int count,
					   struct snd_pcm_substream *pcm)
{
	unsigned int pcm_frames = 0;
	int i;

	for (i = 0; i < packets; ++i) {
		const struct pkt_desc *desc = descs + i;
	for (i = 0; i < count; ++i) {
		__le32 *buf = (__le32 *)desc->ctx_payload;
		unsigned int data_blocks = desc->data_blocks;

@@ -131,21 +130,22 @@ static unsigned int process_it_ctx_payloads(struct amdtp_stream *s,
		} else {
			write_pcm_silence(s, buf, data_blocks);
		}

		desc = amdtp_stream_next_packet_desc(s, desc);
	}

	return pcm_frames;
}

static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
					    const struct pkt_desc *descs,
					    unsigned int packets,
					    const struct pkt_desc *desc,
					    unsigned int count,
					    struct snd_pcm_substream *pcm)
{
	unsigned int pcm_frames = 0;
	int i;

	for (i = 0; i < packets; ++i) {
		const struct pkt_desc *desc = descs + i;
	for (i = 0; i < count; ++i) {
		__le32 *buf = (__le32 *)desc->ctx_payload;
		unsigned int data_blocks = desc->data_blocks;

@@ -153,6 +153,8 @@ static unsigned int process_ir_ctx_payloads(struct amdtp_stream *s,
			read_pcm_s32(s, pcm, buf, data_blocks, pcm_frames);
			pcm_frames += data_blocks;
		}

		desc = amdtp_stream_next_packet_desc(s, desc);
	}

	return pcm_frames;
Loading