1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * tegra_pcm.c - Tegra PCM driver 4 * 5 * Author: Stephen Warren <swarren@nvidia.com> 6 * Copyright (C) 2010,2012 - NVIDIA, Inc. 7 * 8 * Based on code copyright/by: 9 * 10 * Copyright (c) 2009-2010, NVIDIA Corporation. 11 * Scott Peterson <speterson@nvidia.com> 12 * Vijay Mali <vmali@nvidia.com> 13 * 14 * Copyright (C) 2010 Google, Inc. 15 * Iliyan Malchev <malchev@google.com> 16 */ 17 18 #include <linux/module.h> 19 #include <sound/core.h> 20 #include <sound/pcm.h> 21 #include <sound/pcm_params.h> 22 #include <sound/soc.h> 23 #include <sound/dmaengine_pcm.h> 24 25 #include "tegra_pcm.h" 26 27 static const struct snd_pcm_hardware tegra_pcm_hardware = { 28 .info = SNDRV_PCM_INFO_MMAP | 29 SNDRV_PCM_INFO_MMAP_VALID | 30 SNDRV_PCM_INFO_INTERLEAVED, 31 .period_bytes_min = 1024, 32 .period_bytes_max = PAGE_SIZE, 33 .periods_min = 2, 34 .periods_max = 8, 35 .buffer_bytes_max = PAGE_SIZE * 8, 36 .fifo_size = 4, 37 }; 38 39 static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = { 40 .pcm_hardware = &tegra_pcm_hardware, 41 .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, 42 .prealloc_buffer_size = PAGE_SIZE * 8, 43 }; 44 45 int tegra_pcm_platform_register(struct device *dev) 46 { 47 return snd_dmaengine_pcm_register(dev, &tegra_dmaengine_pcm_config, 0); 48 } 49 EXPORT_SYMBOL_GPL(tegra_pcm_platform_register); 50 51 int tegra_pcm_platform_register_with_chan_names(struct device *dev, 52 struct snd_dmaengine_pcm_config *config, 53 char *txdmachan, char *rxdmachan) 54 { 55 *config = tegra_dmaengine_pcm_config; 56 config->dma_dev = dev->parent; 57 config->chan_names[0] = txdmachan; 58 config->chan_names[1] = rxdmachan; 59 60 return snd_dmaengine_pcm_register(dev, config, 0); 61 } 62 EXPORT_SYMBOL_GPL(tegra_pcm_platform_register_with_chan_names); 63 64 void tegra_pcm_platform_unregister(struct device *dev) 65 { 66 return snd_dmaengine_pcm_unregister(dev); 67 } 68 EXPORT_SYMBOL_GPL(tegra_pcm_platform_unregister); 69 70 MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); 71 MODULE_DESCRIPTION("Tegra PCM ASoC driver"); 72 MODULE_LICENSE("GPL"); 73