ASoC: mediatek: Use managed buffer allocation
authorTakashi Iwai <tiwai@suse.de>
Wed, 11 Dec 2019 17:20:18 +0000 (18:20 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 12 Dec 2019 15:41:13 +0000 (15:41 +0000)
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, as well as the superfluous
snd_pcm_lib_preallocate_free_for_all() call.  As of the result,
hw_free and pcm_destruct ops became empty and got removed.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20191211172019.23206-1-tiwai@suse.de
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/mediatek/common/mtk-afe-fe-dai.c
sound/soc/mediatek/common/mtk-afe-platform-driver.c
sound/soc/mediatek/common/mtk-afe-platform-driver.h
sound/soc/mediatek/mt6797/mt6797-afe-pcm.c
sound/soc/mediatek/mt8183/mt8183-afe-pcm.c

index e761cb66be5db8c6fc6593cd81681975b5071af8..8f314e15ce733d314021840519716f2a8766197e 100644 (file)
@@ -129,10 +129,6 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream,
        unsigned int rate = params_rate(params);
        snd_pcm_format_t format = params_format(params);
 
-       ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
-       if (ret < 0)
-               return ret;
-
        if (afe->request_dram_resource)
                afe->request_dram_resource(afe->dev);
 
@@ -193,7 +189,7 @@ int mtk_afe_fe_hw_free(struct snd_pcm_substream *substream,
        if (afe->release_dram_resource)
                afe->release_dram_resource(afe->dev);
 
-       return snd_pcm_lib_free_pages(substream);
+       return 0;
 }
 EXPORT_SYMBOL_GPL(mtk_afe_fe_hw_free);
 
index 86c09165fae1cc5bd9f47d0175f63209a3c7ba31..44dfef71390573c8e28d5fa8da34160ab0b7622b 100644 (file)
@@ -120,24 +120,16 @@ int mtk_afe_pcm_new(struct snd_soc_component *component,
        struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
 
        size = afe->mtk_afe_hardware->buffer_bytes_max;
-       snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
-                                             afe->dev, size, size);
+       snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
+                                      afe->dev, size, size);
        return 0;
 }
 EXPORT_SYMBOL_GPL(mtk_afe_pcm_new);
 
-void mtk_afe_pcm_free(struct snd_soc_component *component,
-                     struct snd_pcm *pcm)
-{
-       snd_pcm_lib_preallocate_free_for_all(pcm);
-}
-EXPORT_SYMBOL_GPL(mtk_afe_pcm_free);
-
 const struct snd_soc_component_driver mtk_afe_pcm_platform = {
        .name           = AFE_PCM_NAME,
        .pointer        = mtk_afe_pcm_pointer,
        .pcm_construct  = mtk_afe_pcm_new,
-       .pcm_destruct   = mtk_afe_pcm_free,
 };
 EXPORT_SYMBOL_GPL(mtk_afe_pcm_platform);
 
index e550d11568c36c26397e7d39f7ef9071166178b1..fcc923b88f124f3c89e77d5ab3d60f86221635dc 100644 (file)
@@ -21,8 +21,6 @@ snd_pcm_uframes_t mtk_afe_pcm_pointer(struct snd_soc_component *component,
                                      struct snd_pcm_substream *substream);
 int mtk_afe_pcm_new(struct snd_soc_component *component,
                    struct snd_soc_pcm_runtime *rtd);
-void mtk_afe_pcm_free(struct snd_soc_component *component,
-                     struct snd_pcm *pcm);
 
 int mtk_afe_combine_sub_dai(struct mtk_base_afe *afe);
 int mtk_afe_add_sub_dai_control(struct snd_soc_component *component);
index cd7c5fabc605014b2b4e90782bd5c13060998183..378bfc16ef52b0708ee09051443e7e61d87eff93 100644 (file)
@@ -714,7 +714,6 @@ static const struct snd_soc_component_driver mt6797_afe_component = {
        .probe          = mt6797_afe_component_probe,
        .pointer        = mtk_afe_pcm_pointer,
        .pcm_construct  = mtk_afe_pcm_new,
-       .pcm_destruct   = mtk_afe_pcm_free,
 };
 
 static int mt6797_dai_memif_register(struct mtk_base_afe *afe)
index f6a0fadeb3cccb6a14ad54ed8a06abef76476697..6e2270bbb10e5874556ae8e316a829985f306eca 100644 (file)
@@ -1052,7 +1052,6 @@ static const struct snd_soc_component_driver mt8183_afe_component = {
        .probe          = mt8183_afe_component_probe,
        .pointer        = mtk_afe_pcm_pointer,
        .pcm_construct  = mtk_afe_pcm_new,
-       .pcm_destruct   = mtk_afe_pcm_free,
 };
 
 static int mt8183_dai_memif_register(struct mtk_base_afe *afe)