[PATCH 2/2] ASoC: Intel: KMB: Enable DMA transfer mode

Lars-Peter Clausen lars at metafoo.de
Tue Dec 15 10:41:02 CET 2020


On 12/15/20 6:33 AM, Michael Sit Wei Hong wrote:
> [...]
> +static inline void kmb_i2s_enable_dma(struct kmb_i2s_info *kmb_i2s, u32 stream)
> +{
> +	u32 dma_reg;
> +
> +	dma_reg = readl(kmb_i2s->i2s_base + I2S_DMACR);
> +	/* Enable DMA handshake for stream */
> +	if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> +		dma_reg |= I2S_DMAEN_TXBLOCK;
> +	else
> +		dma_reg |= I2S_DMAEN_RXBLOCK;
> +
> +	writel(dma_reg, kmb_i2s->i2s_base + I2S_DMACR);
> +}
> +
> +static inline void kmb_i2s_disable_dma(struct kmb_i2s_info *kmb_i2s, u32 stream)
> +{
> +	u32 dma_reg;
> +
> +	dma_reg = readl(kmb_i2s->i2s_base + I2S_DMACR);
> +	/* Disable DMA handshake for stream */
> +	if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
> +		dma_reg &= ~I2S_DMAEN_TXBLOCK;
> +		writel(1, kmb_i2s->i2s_base + I2S_RTXDMA);
> +	} else {
> +		dma_reg &= ~I2S_DMAEN_RXBLOCK;
> +		writel(1, kmb_i2s->i2s_base + I2S_RRXDMA);
> +	}
> +	writel(dma_reg, kmb_i2s->i2s_base + I2S_DMACR);

Does this need locking? I believe it is possible for the startup 
callback of the playback and capture stream to be called concurrently.

> +}
> +
>   static void kmb_i2s_start(struct kmb_i2s_info *kmb_i2s,
>   			  struct snd_pcm_substream *substream)
>   {
> @@ -356,7 +405,11 @@ static void kmb_i2s_start(struct kmb_i2s_info *kmb_i2s,
>   	else
>   		writel(1, kmb_i2s->i2s_base + IRER);
>   
> -	kmb_i2s_irq_trigger(kmb_i2s, substream->stream, config->chan_nr, true);
> +	if (kmb_i2s->use_pio)
> +		kmb_i2s_irq_trigger(kmb_i2s, substream->stream,
> +				    config->chan_nr, true);
> +	else
> +		kmb_i2s_enable_dma(kmb_i2s, substream->stream);
>   
>   	if (kmb_i2s->master)
>   		writel(1, kmb_i2s->i2s_base + CER);
[...]


More information about the Alsa-devel mailing list