~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/ux500/ux500_pcm.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright (C) ST-Ericsson SA 2012
  4  *
  5  * Author: Ola Lilja <ola.o.lilja@stericsson.com>,
  6  *         Roger Nilsson <roger.xr.nilsson@stericsson.com>
  7  *         for ST-Ericsson.
  8  */
  9 
 10 #include <asm/page.h>
 11 
 12 #include <linux/module.h>
 13 #include <linux/dma-mapping.h>
 14 #include <linux/dmaengine.h>
 15 #include <linux/slab.h>
 16 
 17 #include <sound/pcm.h>
 18 #include <sound/pcm_params.h>
 19 #include <sound/soc.h>
 20 #include <sound/dmaengine_pcm.h>
 21 
 22 #include "ux500_msp_i2s.h"
 23 #include "ux500_pcm.h"
 24 
 25 #define UX500_PLATFORM_PERIODS_BYTES_MIN        128
 26 #define UX500_PLATFORM_PERIODS_BYTES_MAX        (64 * PAGE_SIZE)
 27 #define UX500_PLATFORM_PERIODS_MIN              2
 28 #define UX500_PLATFORM_PERIODS_MAX              48
 29 #define UX500_PLATFORM_BUFFER_BYTES_MAX         (2048 * PAGE_SIZE)
 30 
 31 static int ux500_pcm_prepare_slave_config(struct snd_pcm_substream *substream,
 32                 struct snd_pcm_hw_params *params,
 33                 struct dma_slave_config *slave_config)
 34 {
 35         struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
 36         struct snd_dmaengine_dai_dma_data *snd_dma_params;
 37         dma_addr_t dma_addr;
 38         int ret;
 39 
 40         snd_dma_params = snd_soc_dai_get_dma_data(snd_soc_rtd_to_cpu(rtd, 0), substream);
 41         dma_addr = snd_dma_params->addr;
 42 
 43         ret = snd_hwparams_to_dma_slave_config(substream, params, slave_config);
 44         if (ret)
 45                 return ret;
 46 
 47         slave_config->dst_maxburst = 4;
 48         slave_config->src_maxburst = 4;
 49 
 50         slave_config->src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
 51         slave_config->dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
 52 
 53         if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
 54                 slave_config->dst_addr = dma_addr;
 55         else
 56                 slave_config->src_addr = dma_addr;
 57 
 58         return 0;
 59 }
 60 
 61 static const struct snd_dmaengine_pcm_config ux500_dmaengine_of_pcm_config = {
 62         .prepare_slave_config = ux500_pcm_prepare_slave_config,
 63 };
 64 
 65 int ux500_pcm_register_platform(struct platform_device *pdev)
 66 {
 67         int ret;
 68 
 69         ret = snd_dmaengine_pcm_register(&pdev->dev,
 70                                          &ux500_dmaengine_of_pcm_config, 0);
 71         if (ret < 0) {
 72                 dev_err(&pdev->dev,
 73                         "%s: ERROR: Failed to register platform '%s' (%d)!\n",
 74                         __func__, pdev->name, ret);
 75                 return ret;
 76         }
 77 
 78         return 0;
 79 }
 80 EXPORT_SYMBOL_GPL(ux500_pcm_register_platform);
 81 
 82 int ux500_pcm_unregister_platform(struct platform_device *pdev)
 83 {
 84         snd_dmaengine_pcm_unregister(&pdev->dev);
 85         return 0;
 86 }
 87 EXPORT_SYMBOL_GPL(ux500_pcm_unregister_platform);
 88 
 89 MODULE_AUTHOR("Ola Lilja");
 90 MODULE_AUTHOR("Roger Nilsson");
 91 MODULE_DESCRIPTION("ASoC UX500 driver");
 92 MODULE_LICENSE("GPL v2");
 93 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php