[alsa-devel] [PATCH] use set_channel_map api to reorder channels for AD1938 and AD1836

Mark Brown broonie at opensource.wolfsonmicro.com
Mon Sep 14 12:24:30 CEST 2009


On Mon, Sep 14, 2009 at 02:13:07PM +0800, Barry Song wrote:

> +	unsigned int channel_map[8] = {0, 4, 1, 5, 2, 6, 3, 7};

As a coding style thing it would be better to use [] here and let the
arrray size be figured out by the compiler and also...

> +	/* set cpu DAI channel mapping */
> +	ret = snd_soc_dai_set_channel_map(cpu_dai, 8, channel_map,
> +			8, channel_map);

...use ARRAY_SIZE() here.

> +	if ((tx_num > MAX_TDM_SLOTS) || (rx_num > MAX_TDM_SLOTS))
> +		return -EINVAL;
> +
> +	for (i = 0; i < tx_num; i++)
> +		bf5xx_tdm.tx_map[i] = tx_slot[i];

It'd be good if the function also recorded the number of slots that were
mapped to provide some error checking in case someone tries to use more
channels than were mapped.

> +#define MAX_TDM_SLOTS 8

This define needs to be namespaced - it's visible outside the driver and
is very likely to collide with something a CODEC driver wants to set up.


More information about the Alsa-devel mailing list