ASoC: SOF: Use managed buffer allocation
Clean up the drivers with the new managed buffer allocation API. The superfluous snd_pcm_lib_malloc_pages() and snd_pcm_lib_free_pages() calls are dropped. Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://lore.kernel.org/r/20191211172019.23206-2-tiwai@suse.de Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
bf523463d8
commit
57e960f002
@ -118,20 +118,8 @@ static int sof_pcm_hw_params(struct snd_soc_component *component,
|
|||||||
|
|
||||||
memset(&pcm, 0, sizeof(pcm));
|
memset(&pcm, 0, sizeof(pcm));
|
||||||
|
|
||||||
/* allocate audio buffer pages */
|
/* create compressed page table for audio firmware */
|
||||||
ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
|
if (runtime->buffer_changed) {
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(component->dev, "error: could not allocate %d bytes for PCM %d\n",
|
|
||||||
params_buffer_bytes(params), spcm->pcm.pcm_id);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
if (ret) {
|
|
||||||
/*
|
|
||||||
* ret == 1 means the buffer is changed
|
|
||||||
* create compressed page table for audio firmware
|
|
||||||
* ret == 0 means the buffer is not changed
|
|
||||||
* so no need to regenerate the page table
|
|
||||||
*/
|
|
||||||
ret = create_page_table(component, substream, runtime->dma_area,
|
ret = create_page_table(component, substream, runtime->dma_area,
|
||||||
runtime->dma_bytes);
|
runtime->dma_bytes);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -259,8 +247,6 @@ static int sof_pcm_hw_free(struct snd_soc_component *component,
|
|||||||
err = ret;
|
err = ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
snd_pcm_lib_free_pages(substream);
|
|
||||||
|
|
||||||
cancel_work_sync(&spcm->stream[substream->stream].period_elapsed_work);
|
cancel_work_sync(&spcm->stream[substream->stream].period_elapsed_work);
|
||||||
|
|
||||||
ret = snd_sof_pcm_platform_hw_free(sdev, substream);
|
ret = snd_sof_pcm_platform_hw_free(sdev, substream);
|
||||||
@ -596,10 +582,10 @@ static int sof_pcm_new(struct snd_soc_component *component,
|
|||||||
"spcm: allocate %s playback DMA buffer size 0x%x max 0x%x\n",
|
"spcm: allocate %s playback DMA buffer size 0x%x max 0x%x\n",
|
||||||
caps->name, caps->buffer_size_min, caps->buffer_size_max);
|
caps->name, caps->buffer_size_min, caps->buffer_size_max);
|
||||||
|
|
||||||
snd_pcm_lib_preallocate_pages(pcm->streams[stream].substream,
|
snd_pcm_set_managed_buffer(pcm->streams[stream].substream,
|
||||||
SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
|
SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
|
||||||
le32_to_cpu(caps->buffer_size_min),
|
le32_to_cpu(caps->buffer_size_min),
|
||||||
le32_to_cpu(caps->buffer_size_max));
|
le32_to_cpu(caps->buffer_size_max));
|
||||||
capture:
|
capture:
|
||||||
stream = SNDRV_PCM_STREAM_CAPTURE;
|
stream = SNDRV_PCM_STREAM_CAPTURE;
|
||||||
|
|
||||||
@ -614,10 +600,10 @@ capture:
|
|||||||
"spcm: allocate %s capture DMA buffer size 0x%x max 0x%x\n",
|
"spcm: allocate %s capture DMA buffer size 0x%x max 0x%x\n",
|
||||||
caps->name, caps->buffer_size_min, caps->buffer_size_max);
|
caps->name, caps->buffer_size_min, caps->buffer_size_max);
|
||||||
|
|
||||||
snd_pcm_lib_preallocate_pages(pcm->streams[stream].substream,
|
snd_pcm_set_managed_buffer(pcm->streams[stream].substream,
|
||||||
SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
|
SNDRV_DMA_TYPE_DEV_SG, sdev->dev,
|
||||||
le32_to_cpu(caps->buffer_size_min),
|
le32_to_cpu(caps->buffer_size_min),
|
||||||
le32_to_cpu(caps->buffer_size_max));
|
le32_to_cpu(caps->buffer_size_max));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user