[alsa-devel] [PATCH] ASoC: s3c24xx platform: Fix s3c2410_dma_started called at wrong time

Mark Brown broonie at opensource.wolfsonmicro.com
Mon Aug 24 12:17:33 CEST 2009

On Sun, Aug 23, 2009 at 07:37:13PM +0800, Shine Liu wrote:

> Yes, I understand what you exactly want. I was intend to register the
> callback function on I2S startup, but finally I found it is not possible
> because there are two callback functions for the DMA driver:
> s3c24xx_snd_txctrl() and s3c24xx_snd_rxctrl(), however, there's only one
> slot for the callback function. So I choose not to setup the callback

This is not a problem - just pass the substream into the callback and
you can check to see if it's a playback or record stream.  Kind of like
what you have here...

> However, there's another way to archive what you expect: combine the
> s3c24xx_snd_txctrl() and s3c24xx_snd_rxctrl() into one function. That
> would be like:

> struct s3c24xx_snd_ctrl_data {
> 	int event;	//start or stop
> 	int direction;	//playback or record
> };

> static void s3c24xx_snd_ctrl(struct s3c24xx_snd_ctrl_data* data)
> {
> 	if(data->direction == SNDRV_PCM_STREAM_PLAYBACK)
> 		s3c24xx_snd_txctrl(data->event);
> 	eles
> 		s3c24xx_snd_rxctrl(data->event);
> }

...but there's no need for the struct, just pass two arguments to the
function, the event and either the substream or the direction.  The
substream is probably easier since otherwise all the callers will need
to parse the direction.

More information about the Alsa-devel mailing list