diff options
author | Nitin Pai <npai@nvidia.com> | 2012-11-21 16:17:15 +0530 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2013-09-14 12:43:31 -0700 |
commit | 3613fe97609c614507cbeb33d75bfac51fa5df6f (patch) | |
tree | 6883a850cba7c75ced9a6d933903df806a5aeb55 /sound | |
parent | 90e22dbdcacc935942c84ecf19b2609d2d7b1860 (diff) |
asoc: tegra: tdm: change buffer sizes.
Change the min-buffer-size according to min-channels.
Bug 1040171
Change-Id: Ief575c0a180c05521338d0d38fecb8907127b9fe
Reviewed-on: http://git-master/r/165340
(cherry picked from commit 93c738795b834290e71775206a8e94e58e4f223d)
Signed-off-by: Nitin Pai <npai@nvidia.com>
Change-Id: I8d49035c433cbbf0ed7e7a7df61b86fe1657dad3
Reviewed-on: http://git-master/r/166137
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Scott Peterson <speterson@nvidia.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/tegra/tegra_tdm_pcm.c | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/sound/soc/tegra/tegra_tdm_pcm.c b/sound/soc/tegra/tegra_tdm_pcm.c new file mode 100644 index 000000000000..8345ba04f943 --- /dev/null +++ b/sound/soc/tegra/tegra_tdm_pcm.c @@ -0,0 +1,160 @@ +/* + * tegra_tdm_pcm.c - Tegra TDM PCM driver + * + * Author: Nitin Pai <npai@nvidia.com> + * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. + * + * Based on code copyright/by: + * + * Copyright (c) 2009-2010, NVIDIA CORPORATION. All rights reserved. + * Scott Peterson <speterson@nvidia.com> + * Stephen Warren <swarren@nvidia.com> + * Vijay Mali <vmali@nvidia.com> + * + * Copyright (C) 2010 Google, Inc. + * Iliyan Malchev <malchev@google.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include <linux/module.h> +#include <linux/dma-mapping.h> +#include <linux/slab.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/soc.h> + +#include "tegra_pcm.h" + +#define DRV_NAME "tegra-tdm-pcm-audio" + +static const struct snd_pcm_hardware tegra_tdm_pcm_hardware = { + .info = SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | + SNDRV_PCM_INFO_RESUME | + SNDRV_PCM_INFO_INTERLEAVED, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .channels_min = 8, + .channels_max = 16, + .period_bytes_min = 8 * 1024, + .period_bytes_max = 16 * 1024, + .periods_min = 4, + .periods_max = 4, + .buffer_bytes_max = 16 * 4 * 1024, + .fifo_size = 4, +}; + +static int tegra_tdm_pcm_open(struct snd_pcm_substream *substream) +{ + return tegra_pcm_allocate(substream, + TEGRA_DMA_MODE_CONTINUOUS_DOUBLE, + &tegra_tdm_pcm_hardware); + +} + +static int tegra_tdm_pcm_close(struct snd_pcm_substream *substream) +{ + return tegra_pcm_close(substream); +} + +static int tegra_tdm_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + return tegra_pcm_hw_params(substream, params); +} + +static int tegra_tdm_pcm_hw_free(struct snd_pcm_substream *substream) +{ + return tegra_pcm_hw_free(substream); +} + +static int tegra_tdm_pcm_trigger(struct snd_pcm_substream *substream, int cmd) +{ + return tegra_pcm_trigger(substream, cmd); +} + +static int tegra_tdm_pcm_mmap(struct snd_pcm_substream *substream, + struct vm_area_struct *vma) +{ + return tegra_pcm_mmap(substream, vma); +} + +static struct snd_pcm_ops tegra_tdm_pcm_ops = { + .open = tegra_tdm_pcm_open, + .close = tegra_tdm_pcm_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = tegra_tdm_pcm_hw_params, + .hw_free = tegra_tdm_pcm_hw_free, + .trigger = tegra_tdm_pcm_trigger, + .pointer = tegra_pcm_pointer, + .mmap = tegra_tdm_pcm_mmap, +}; + +static int tegra_tdm_pcm_new(struct snd_soc_pcm_runtime *rtd) +{ + return tegra_pcm_dma_allocate(rtd , + tegra_tdm_pcm_hardware.buffer_bytes_max); +} + +static void tegra_tdm_pcm_free(struct snd_pcm *pcm) +{ + return tegra_pcm_free(pcm); +} + +struct snd_soc_platform_driver tegra_tdm_pcm_platform = { + .ops = &tegra_tdm_pcm_ops, + .pcm_new = tegra_tdm_pcm_new, + .pcm_free = tegra_tdm_pcm_free, +}; + +static int __devinit tegra_tdm_pcm_platform_probe(struct platform_device *pdev) +{ + return snd_soc_register_platform(&pdev->dev, &tegra_tdm_pcm_platform); +} + +static int __devexit tegra_tdm_pcm_platform_remove(struct platform_device *pdev) +{ + snd_soc_unregister_platform(&pdev->dev); + return 0; +} + +static struct platform_driver tegra_tdm_pcm_driver = { + .driver = { + .name = DRV_NAME, + .owner = THIS_MODULE, + }, + .probe = tegra_tdm_pcm_platform_probe, + .remove = __devexit_p(tegra_tdm_pcm_platform_remove), +}; + +static int __init snd_tegra_tdm_pcm_init(void) +{ + return platform_driver_register(&tegra_tdm_pcm_driver); +} +module_init(snd_tegra_tdm_pcm_init); + +static void __exit snd_tegra_tdm_pcm_exit(void) +{ + platform_driver_unregister(&tegra_tdm_pcm_driver); +} +module_exit(snd_tegra_tdm_pcm_exit); + +MODULE_AUTHOR("Nitin Pai <npai@nvidia.com>"); +MODULE_DESCRIPTION("Tegra PCM ASoC driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:" DRV_NAME); |