1*2b27bdccSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 27605eb5bSStephen Warren /* 37605eb5bSStephen Warren * tegra_pcm.c - Tegra PCM driver 47605eb5bSStephen Warren * 57605eb5bSStephen Warren * Author: Stephen Warren <swarren@nvidia.com> 6518de86bSStephen Warren * Copyright (C) 2010,2012 - NVIDIA, Inc. 77605eb5bSStephen Warren * 87605eb5bSStephen Warren * Based on code copyright/by: 97605eb5bSStephen Warren * 107605eb5bSStephen Warren * Copyright (c) 2009-2010, NVIDIA Corporation. 117605eb5bSStephen Warren * Scott Peterson <speterson@nvidia.com> 127605eb5bSStephen Warren * Vijay Mali <vmali@nvidia.com> 137605eb5bSStephen Warren * 147605eb5bSStephen Warren * Copyright (C) 2010 Google, Inc. 157605eb5bSStephen Warren * Iliyan Malchev <malchev@google.com> 167605eb5bSStephen Warren */ 177605eb5bSStephen Warren 187613c508SStephen Warren #include <linux/module.h> 197605eb5bSStephen Warren #include <sound/core.h> 207605eb5bSStephen Warren #include <sound/pcm.h> 217605eb5bSStephen Warren #include <sound/pcm_params.h> 227605eb5bSStephen Warren #include <sound/soc.h> 23df79f55dSLaxman Dewangan #include <sound/dmaengine_pcm.h> 247605eb5bSStephen Warren 257605eb5bSStephen Warren #include "tegra_pcm.h" 267605eb5bSStephen Warren 277605eb5bSStephen Warren static const struct snd_pcm_hardware tegra_pcm_hardware = { 287605eb5bSStephen Warren .info = SNDRV_PCM_INFO_MMAP | 297605eb5bSStephen Warren SNDRV_PCM_INFO_MMAP_VALID | 307605eb5bSStephen Warren SNDRV_PCM_INFO_INTERLEAVED, 317605eb5bSStephen Warren .period_bytes_min = 1024, 327605eb5bSStephen Warren .period_bytes_max = PAGE_SIZE, 337605eb5bSStephen Warren .periods_min = 2, 347605eb5bSStephen Warren .periods_max = 8, 357605eb5bSStephen Warren .buffer_bytes_max = PAGE_SIZE * 8, 367605eb5bSStephen Warren .fifo_size = 4, 377605eb5bSStephen Warren }; 387605eb5bSStephen Warren 3911a8576aSLars-Peter Clausen static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = { 4011a8576aSLars-Peter Clausen .pcm_hardware = &tegra_pcm_hardware, 4111a8576aSLars-Peter Clausen .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, 4211a8576aSLars-Peter Clausen .prealloc_buffer_size = PAGE_SIZE * 8, 437605eb5bSStephen Warren }; 447605eb5bSStephen Warren 454652a0d0SBill Pemberton int tegra_pcm_platform_register(struct device *dev) 467605eb5bSStephen Warren { 475608bd3eSStephen Warren return snd_dmaengine_pcm_register(dev, &tegra_dmaengine_pcm_config, 0); 487605eb5bSStephen Warren } 49518de86bSStephen Warren EXPORT_SYMBOL_GPL(tegra_pcm_platform_register); 507605eb5bSStephen Warren 515608bd3eSStephen Warren int tegra_pcm_platform_register_with_chan_names(struct device *dev, 525608bd3eSStephen Warren struct snd_dmaengine_pcm_config *config, 535608bd3eSStephen Warren char *txdmachan, char *rxdmachan) 545608bd3eSStephen Warren { 555608bd3eSStephen Warren *config = tegra_dmaengine_pcm_config; 565608bd3eSStephen Warren config->dma_dev = dev->parent; 575608bd3eSStephen Warren config->chan_names[0] = txdmachan; 585608bd3eSStephen Warren config->chan_names[1] = rxdmachan; 595608bd3eSStephen Warren 605608bd3eSStephen Warren return snd_dmaengine_pcm_register(dev, config, 0); 615608bd3eSStephen Warren } 625608bd3eSStephen Warren EXPORT_SYMBOL_GPL(tegra_pcm_platform_register_with_chan_names); 635608bd3eSStephen Warren 644652a0d0SBill Pemberton void tegra_pcm_platform_unregister(struct device *dev) 657605eb5bSStephen Warren { 6611a8576aSLars-Peter Clausen return snd_dmaengine_pcm_unregister(dev); 677605eb5bSStephen Warren } 68518de86bSStephen Warren EXPORT_SYMBOL_GPL(tegra_pcm_platform_unregister); 697605eb5bSStephen Warren 707605eb5bSStephen Warren MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); 717605eb5bSStephen Warren MODULE_DESCRIPTION("Tegra PCM ASoC driver"); 727605eb5bSStephen Warren MODULE_LICENSE("GPL"); 73