[alsa-devel] [PATCH 11/39] firewire-lib: Add support for channel mapping

Clemens Ladisch clemens at ladisch.de
Sun Mar 9 22:20:42 CET 2014


Takashi Sakamoto wrote:
> Some devices arrange the position of PCM/MIDI data channel in AMDTP packet.
> This commit allows drivers to set channel mapping.
>
> To be simple, the mapping table is an array with fixed length. Then the number
> of channels for PCM is restricted by 64 channels.

> +++ b/sound/firewire/amdtp.c
> @@ -351,22 +358,20 @@ static void amdtp_write_s32(struct amdtp_stream *s,
>  			    __be32 *buffer, unsigned int frames)
>  {
>  	struct snd_pcm_runtime *runtime = pcm->runtime;
> -	unsigned int channels, remaining_frames, frame_step, i, c;
> +	unsigned int remaining_frames, i, c;
>  	const u32 *src;
>
> -	channels = s->pcm_channels;

This change is not necessary.  I used a separate local variable
deliberately to allow the compiler to recognize that it cannot be
aliased with the buffer contents.

> @@ -403,29 +406,29 @@ static void amdtp_write_s32_dualwire(struct amdtp_stream *s,
>  	for (i = 0; i < frames; ++i) {
>  		for (c = 0; c < channels; ++c) {
> +			buffer[s->pcm_positions[c] * 2] =
> +					cpu_to_be32((*src >> 8) | 0x40000000);
>  			src++;
>  		}
> +		buffer += 1;
>  		for (c = 0; c < channels; ++c) {
> +			buffer[s->pcm_positions[c] * 2] =
> +					cpu_to_be32((*src >> 8) | 0x40000000);
>  			src++;
>  		}
> +		buffer += s->data_block_quadlets - 1;
> +		if (--remaining_frames == 0)
> +			src = (void *)runtime->dma_area;
>  	}

AFAICS the dual-wire format could be handled easier by setting pcm_positions[]
in the dice driver.


Regards,
Clemens


More information about the Alsa-devel mailing list