tegra_pcm.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * tegra_pcm.c - Tegra PCM driver
  3. *
  4. * Author: Stephen Warren <swarren@nvidia.com>
  5. * Copyright (C) 2010,2012 - NVIDIA, Inc.
  6. *
  7. * Based on code copyright/by:
  8. *
  9. * Copyright (c) 2009-2010, NVIDIA Corporation.
  10. * Scott Peterson <speterson@nvidia.com>
  11. * Vijay Mali <vmali@nvidia.com>
  12. *
  13. * Copyright (C) 2010 Google, Inc.
  14. * Iliyan Malchev <malchev@google.com>
  15. *
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License
  18. * version 2 as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful, but
  21. * WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  23. * General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  28. * 02110-1301 USA
  29. *
  30. */
  31. #include <linux/module.h>
  32. #include <sound/core.h>
  33. #include <sound/pcm.h>
  34. #include <sound/pcm_params.h>
  35. #include <sound/soc.h>
  36. #include <sound/dmaengine_pcm.h>
  37. #include "tegra_pcm.h"
  38. static const struct snd_pcm_hardware tegra_pcm_hardware = {
  39. .info = SNDRV_PCM_INFO_MMAP |
  40. SNDRV_PCM_INFO_MMAP_VALID |
  41. SNDRV_PCM_INFO_INTERLEAVED,
  42. .period_bytes_min = 1024,
  43. .period_bytes_max = PAGE_SIZE,
  44. .periods_min = 2,
  45. .periods_max = 8,
  46. .buffer_bytes_max = PAGE_SIZE * 8,
  47. .fifo_size = 4,
  48. };
  49. static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = {
  50. .pcm_hardware = &tegra_pcm_hardware,
  51. .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
  52. .prealloc_buffer_size = PAGE_SIZE * 8,
  53. };
  54. int tegra_pcm_platform_register(struct device *dev)
  55. {
  56. return snd_dmaengine_pcm_register(dev, &tegra_dmaengine_pcm_config, 0);
  57. }
  58. EXPORT_SYMBOL_GPL(tegra_pcm_platform_register);
  59. int tegra_pcm_platform_register_with_chan_names(struct device *dev,
  60. struct snd_dmaengine_pcm_config *config,
  61. char *txdmachan, char *rxdmachan)
  62. {
  63. *config = tegra_dmaengine_pcm_config;
  64. config->dma_dev = dev->parent;
  65. config->chan_names[0] = txdmachan;
  66. config->chan_names[1] = rxdmachan;
  67. return snd_dmaengine_pcm_register(dev, config, 0);
  68. }
  69. EXPORT_SYMBOL_GPL(tegra_pcm_platform_register_with_chan_names);
  70. void tegra_pcm_platform_unregister(struct device *dev)
  71. {
  72. return snd_dmaengine_pcm_unregister(dev);
  73. }
  74. EXPORT_SYMBOL_GPL(tegra_pcm_platform_unregister);
  75. MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
  76. MODULE_DESCRIPTION("Tegra PCM ASoC driver");
  77. MODULE_LICENSE("GPL");