mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 14:42:24 +00:00
ASoC: qcom: qdsp6: Use managed buffer allocation
This patch simplifies the buffer pre-allocation code of qcom qdsp6 driver with the standard managed buffer helper. It uses the newly introduced fixed-size buffer allocation helper. Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Cc: Banajit Goswami <bgoswami@codeaurora.org> Acked-by: Mark Brown <broonie@kernel.org> Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20210802072815.13551-15-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
15a52cdcb0
commit
8c505b773d
@ -429,8 +429,6 @@ static int q6asm_dai_open(struct snd_soc_component *component,
|
||||
else
|
||||
prtd->phys = substream->dma_buffer.addr | (pdata->sid << 32);
|
||||
|
||||
snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -470,18 +468,6 @@ static snd_pcm_uframes_t q6asm_dai_pointer(struct snd_soc_component *component,
|
||||
return bytes_to_frames(runtime, (prtd->pcm_irq_pos));
|
||||
}
|
||||
|
||||
static int q6asm_dai_mmap(struct snd_soc_component *component,
|
||||
struct snd_pcm_substream *substream,
|
||||
struct vm_area_struct *vma)
|
||||
{
|
||||
struct snd_pcm_runtime *runtime = substream->runtime;
|
||||
struct device *dev = component->dev;
|
||||
|
||||
return dma_mmap_coherent(dev, vma,
|
||||
runtime->dma_area, runtime->dma_addr,
|
||||
runtime->dma_bytes);
|
||||
}
|
||||
|
||||
static int q6asm_dai_hw_params(struct snd_soc_component *component,
|
||||
struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params)
|
||||
@ -1185,52 +1171,11 @@ static const struct snd_compress_ops q6asm_dai_compress_ops = {
|
||||
static int q6asm_dai_pcm_new(struct snd_soc_component *component,
|
||||
struct snd_soc_pcm_runtime *rtd)
|
||||
{
|
||||
struct snd_pcm_substream *psubstream, *csubstream;
|
||||
struct snd_pcm *pcm = rtd->pcm;
|
||||
struct device *dev;
|
||||
int size, ret;
|
||||
size_t size = q6asm_dai_hardware_playback.buffer_bytes_max;
|
||||
|
||||
dev = component->dev;
|
||||
size = q6asm_dai_hardware_playback.buffer_bytes_max;
|
||||
psubstream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
|
||||
if (psubstream) {
|
||||
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size,
|
||||
&psubstream->dma_buffer);
|
||||
if (ret) {
|
||||
dev_err(dev, "Cannot allocate buffer(s)\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
csubstream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
|
||||
if (csubstream) {
|
||||
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size,
|
||||
&csubstream->dma_buffer);
|
||||
if (ret) {
|
||||
dev_err(dev, "Cannot allocate buffer(s)\n");
|
||||
if (psubstream)
|
||||
snd_dma_free_pages(&psubstream->dma_buffer);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void q6asm_dai_pcm_free(struct snd_soc_component *component,
|
||||
struct snd_pcm *pcm)
|
||||
{
|
||||
struct snd_pcm_substream *substream;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(pcm->streams); i++) {
|
||||
substream = pcm->streams[i].substream;
|
||||
if (substream) {
|
||||
snd_dma_free_pages(&substream->dma_buffer);
|
||||
substream->dma_buffer.area = NULL;
|
||||
substream->dma_buffer.addr = 0;
|
||||
}
|
||||
}
|
||||
return snd_pcm_set_fixed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
|
||||
component->dev, size);
|
||||
}
|
||||
|
||||
static const struct snd_soc_dapm_widget q6asm_dapm_widgets[] = {
|
||||
@ -1260,9 +1205,7 @@ static const struct snd_soc_component_driver q6asm_fe_dai_component = {
|
||||
.prepare = q6asm_dai_prepare,
|
||||
.trigger = q6asm_dai_trigger,
|
||||
.pointer = q6asm_dai_pointer,
|
||||
.mmap = q6asm_dai_mmap,
|
||||
.pcm_construct = q6asm_dai_pcm_new,
|
||||
.pcm_destruct = q6asm_dai_pcm_free,
|
||||
.compress_ops = &q6asm_dai_compress_ops,
|
||||
.dapm_widgets = q6asm_dapm_widgets,
|
||||
.num_dapm_widgets = ARRAY_SIZE(q6asm_dapm_widgets),
|
||||
|
Loading…
Reference in New Issue
Block a user