ASoC: dmaengine_pcm: Make FLAG_NO_RESIDUE internal
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 27 Apr 2015 10:44:25 +0000 (12:44 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 27 Apr 2015 18:26:07 +0000 (19:26 +0100)
Whether residue can be reported or not is not a property of the audio
controller but of the DMA controller. The FLAG_NO_RESIDUE was initially
added when the DMAengine framework had no support for describing the residue
reporting capabilities of the controller. Support for this was added quite a
while ago and recently the DMAengine framework started to complain if a
driver does not describe its capabilities and a lot of patches have been
merged that add support for this where it was missing. So it should be safe
to assume that driver on actively used platforms properly implement the DMA
capabilities API.

This patch makes the FLAG_NO_RESIDUE internal and no longer allows audio
controller drivers to manually set the flag. If a DMA driver against
expectations does not support reporting its capabilities for now the generic
DMAengine PCM driver will now emit a warning and simply assume that residue
reporting is not supported. In the future this might be changed to aborting
with an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/dmaengine_pcm.h
sound/soc/atmel/atmel-pcm-dma.c
sound/soc/cirrus/ep93xx-pcm.c
sound/soc/fsl/fsl_sai.c
sound/soc/soc-generic-dmaengine-pcm.c
sound/soc/ux500/ux500_pcm.c

index eb73a3a39ec2fbb9a3b4aef39ff65e21af9d51b4..f86ef5ea9b0147c4f51d6f885d5566ef4c6a023b 100644 (file)
@@ -90,11 +90,6 @@ void snd_dmaengine_pcm_set_config_from_dai_data(
  * makes sense if SND_DMAENGINE_PCM_FLAG_COMPAT is set as well.
  */
 #define SND_DMAENGINE_PCM_FLAG_NO_DT BIT(1)
-/*
- * The platforms dmaengine driver does not support reporting the amount of
- * bytes that are still left to transfer.
- */
-#define SND_DMAENGINE_PCM_FLAG_NO_RESIDUE BIT(2)
 /*
  * The PCM is half duplex and the DMA channel is shared between capture and
  * playback.
index b6625c8c411b8a66a6d1cbaf807109f7ccc8ec71..dd57a9eac171dba4da718e9f09a4853c322c393f 100644 (file)
@@ -124,8 +124,7 @@ static const struct snd_dmaengine_pcm_config atmel_dmaengine_pcm_config = {
 
 int atmel_pcm_dma_platform_register(struct device *dev)
 {
-       return snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config,
-                       SND_DMAENGINE_PCM_FLAG_NO_RESIDUE);
+       return snd_dmaengine_pcm_register(dev, &atmel_dmaengine_pcm_config, 0);
 }
 EXPORT_SYMBOL(atmel_pcm_dma_platform_register);
 
index 5f664471d99ee480fd38bd723e65d8023462973c..67a73330db5e88e669c52f424dafa5045a0728d6 100644 (file)
@@ -60,7 +60,6 @@ int devm_ep93xx_pcm_platform_register(struct device *dev)
 {
        return devm_snd_dmaengine_pcm_register(dev,
                &ep93xx_dmaengine_pcm_config,
-               SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
                SND_DMAENGINE_PCM_FLAG_NO_DT |
                SND_DMAENGINE_PCM_FLAG_COMPAT);
 }
index ec79c3d5e65e28acb24b6be4190a1fe091252e7a..ee2671b805926bd520498233e3b8ed5b0cec6df7 100644 (file)
@@ -664,8 +664,7 @@ static int fsl_sai_probe(struct platform_device *pdev)
        if (sai->sai_on_imx)
                return imx_pcm_dma_init(pdev);
        else
-               return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL,
-                               SND_DMAENGINE_PCM_FLAG_NO_RESIDUE);
+               return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0);
 }
 
 static const struct of_device_id fsl_sai_ids[] = {
index c9917ca5de1a50285482da998fb03b305f81a5e0..6fd1906af3873aa90b351649c2d0b8afe7152e9d 100644 (file)
 
 #include <sound/dmaengine_pcm.h>
 
+/*
+ * The platforms dmaengine driver does not support reporting the amount of
+ * bytes that are still left to transfer.
+ */
+#define SND_DMAENGINE_PCM_FLAG_NO_RESIDUE BIT(31)
+
 struct dmaengine_pcm {
        struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1];
        const struct snd_dmaengine_pcm_config *config;
@@ -222,14 +228,18 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel(
        return snd_dmaengine_pcm_request_channel(fn, dma_data->filter_data);
 }
 
-static bool dmaengine_pcm_can_report_residue(struct dma_chan *chan)
+static bool dmaengine_pcm_can_report_residue(struct device *dev,
+       struct dma_chan *chan)
 {
        struct dma_slave_caps dma_caps;
        int ret;
 
        ret = dma_get_slave_caps(chan, &dma_caps);
-       if (ret != 0)
-               return true;
+       if (ret != 0) {
+               dev_warn(dev, "Failed to get DMA channel capabilities, falling back to period counting: %d\n",
+                        ret);
+               return false;
+       }
 
        if (dma_caps.residue_granularity == DMA_RESIDUE_GRANULARITY_DESCRIPTOR)
                return false;
@@ -289,14 +299,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
                if (ret)
                        return ret;
 
-               /*
-                * This will only return false if we know for sure that at least
-                * one channel does not support residue reporting. If the DMA
-                * driver does not implement the slave_caps API we rely having
-                * the NO_RESIDUE flag set manually in case residue reporting is
-                * not supported.
-                */
-               if (!dmaengine_pcm_can_report_residue(pcm->chan[i]))
+               if (!dmaengine_pcm_can_report_residue(dev, pcm->chan[i]))
                        pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE;
        }
 
index 51a66a87305ae0ad96b26206108f13bcec5a189f..f12c01dddc8dd5df6dd185a91016b4e38820856a 100644 (file)
@@ -147,7 +147,6 @@ int ux500_pcm_register_platform(struct platform_device *pdev)
                pcm_config = &ux500_dmaengine_pcm_config;
 
        ret = snd_dmaengine_pcm_register(&pdev->dev, pcm_config,
-                                        SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
                                         SND_DMAENGINE_PCM_FLAG_COMPAT);
        if (ret < 0) {
                dev_err(&pdev->dev,