ASoC: rt5514-spi: Convert to the common vmalloc memalloc
authorTakashi Iwai <tiwai@suse.de>
Fri, 8 Nov 2019 09:46:35 +0000 (10:46 +0100)
committerTakashi Iwai <tiwai@suse.de>
Sat, 9 Nov 2019 17:02:52 +0000 (18:02 +0100)
The recent change (*) in the ALSA memalloc core allows us to drop the
special vmalloc-specific allocation and page handling.  This patch
coverts to the common code.
(*) 1fe7f397cfe2: ALSA: memalloc: Add vmalloc buffer allocation
                  support
    7e8edae39fd1: ALSA: pcm: Handle special page mapping in the
                  default mmap handler

Since it requires the specific buffer type (SNDRV_DMA_TYPE_VMALLOC),
it's set in the pcm_new ops now.

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20191108094641.20086-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/soc/codecs/rt5514-spi.c

index 57ff5aee452deaf440d2bddceb07175f362ee728..f1b7b947ecbdb98afaf9ba63b8867fdfa2af4985 100644 (file)
@@ -219,8 +219,7 @@ static int rt5514_spi_hw_params(struct snd_soc_component *component,
        u8 buf[8];
 
        mutex_lock(&rt5514_dsp->dma_lock);
-       ret = snd_pcm_lib_alloc_vmalloc_buffer(substream,
-                       params_buffer_bytes(hw_params));
+       ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
        rt5514_dsp->substream = substream;
        rt5514_dsp->dma_offset = 0;
 
@@ -246,7 +245,7 @@ static int rt5514_spi_hw_free(struct snd_soc_component *component,
 
        cancel_delayed_work_sync(&rt5514_dsp->copy_work);
 
-       return snd_pcm_lib_free_vmalloc_buffer(substream);
+       return snd_pcm_lib_free_pages(substream);
 }
 
 static snd_pcm_uframes_t rt5514_spi_pcm_pointer(
@@ -260,12 +259,6 @@ static snd_pcm_uframes_t rt5514_spi_pcm_pointer(
        return bytes_to_frames(runtime, rt5514_dsp->dma_offset);
 }
 
-static struct page *rt5514_spi_pcm_page(struct snd_soc_component *component,
-                                       struct snd_pcm_substream *substream,
-                                       unsigned long offset)
-{
-       return snd_pcm_lib_get_vmalloc_page(substream, offset);
-}
 
 static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
 {
@@ -298,6 +291,14 @@ static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
        return 0;
 }
 
+static int rt5514_spi_pcm_new(struct snd_soc_component *component,
+                             struct snd_soc_pcm_runtime *rtd)
+{
+       snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_VMALLOC,
+                                             NULL, 0, 0);
+       return 0;
+}
+
 static const struct snd_soc_component_driver rt5514_spi_component = {
        .name           = DRV_NAME,
        .probe          = rt5514_spi_pcm_probe,
@@ -305,7 +306,7 @@ static const struct snd_soc_component_driver rt5514_spi_component = {
        .hw_params      = rt5514_spi_hw_params,
        .hw_free        = rt5514_spi_hw_free,
        .pointer        = rt5514_spi_pcm_pointer,
-       .page           = rt5514_spi_pcm_page,
+       .pcm_construct  = rt5514_spi_pcm_new,
 };
 
 /**