Re: [RFC/PATCH] Stop Apple i2s DMA gracefully

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At Sun, 29 Oct 2006 15:19:40 +1100,
Paul Mackerras wrote:
> 
> This fixes the problem of getting extra bytes inserted at the
> beginning of a recording when using the Apple i2s interface and DBDMA
> controller.  It turns out that we can't just abort the DMA; we have to
> let it stop at the end of a command, and then wait for the S7 bit to
> be set before turning off the DBDMA controller.  Doing that for
> playback doesn't seem to be necessary, but doesn't hurt either.
> 
> We use the technique used by the Darwin driver: make each transfer
> command branch to a stop command if the S0 status bit is set.  Thus we
> can ask the DMA controller to stop at the end of the current command
> by setting S0.
> 
> The interrupt routine now looks at and clears the status word of the
> DBDMA command ring.  This is necessary so it can know when the DBDMA
> controller has seen that S0 is set, and so when it should look for the
> DBDMA controller being stopped and S7 being set.  This also ended up
> simplifying the calculation in i2sbus_pcm_pointer.

Thanks, the patch looks good, just very minor issues.

> --- a/sound/aoa/soundbus/i2sbus/i2sbus-pcm.c
> +++ b/sound/aoa/soundbus/i2sbus/i2sbus-pcm.c
> @@ -245,18 +245,66 @@ static int i2sbus_pcm_close(struct i2sbu
>  	return err;
>  }
>  
> +static void i2sbus_wait_for_stop(struct i2sbus_dev *i2sdev,
> +				 struct pcm_info *pi)
> +{
> +	unsigned long flags;
> +	struct completion done;
> +	long timeout;
> +
> +	spin_lock_irqsave(&i2sdev->low_lock, flags);

We need no irqsave/irqrestore but here since the function is supposed
to be called always in schedulable situation.  spin_lock_irq() should
be enough.

>  static int i2sbus_hw_params(struct snd_pcm_substream *substream,
>  			    struct snd_pcm_hw_params *params)
>  {
>  	return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
>  }
>  
> -static int i2sbus_hw_free(struct snd_pcm_substream *substream)
> +static inline int i2sbus_hw_free(struct snd_pcm_substream *substream, int in)

Any reason to put extra inline here?  It's no time-critical funciton,
so let compiler do optimization.

BTW, shoud this go to 2.6.19 although the fix isn't so trivial, or
could wait for the next?


Takashi

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux