omap-alsa.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * arch/arm/plat-omap/include/mach/omap-alsa.h
  3. *
  4. * Alsa Driver for AIC23 and TSC2101 codecs on OMAP platform boards.
  5. *
  6. * Copyright (C) 2006 Mika Laitio <lamikr@cc.jyu.fi>
  7. *
  8. * Copyright (C) 2005 Instituto Nokia de Tecnologia - INdT - Manaus Brazil
  9. * Written by Daniel Petrini, David Cohen, Anderson Briglia
  10. * {daniel.petrini, david.cohen, anderson.briglia}@indt.org.br
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. *
  17. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  18. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  20. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  23. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  24. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *
  28. * You should have received a copy of the GNU General Public License along
  29. * with this program; if not, write to the Free Software Foundation, Inc.,
  30. * 675 Mass Ave, Cambridge, MA 02139, USA.
  31. *
  32. * History
  33. * -------
  34. *
  35. * 2005/07/25 INdT-10LE Kernel Team - Alsa driver for omap osk,
  36. * original version based in sa1100 driver
  37. * and omap oss driver.
  38. */
  39. #ifndef __OMAP_ALSA_H
  40. #define __OMAP_ALSA_H
  41. #include <mach/dma.h>
  42. #include <sound/core.h>
  43. #include <sound/pcm.h>
  44. #include <mach/mcbsp.h>
  45. #include <linux/platform_device.h>
  46. #define DMA_BUF_SIZE (1024 * 8)
  47. /*
  48. * Buffer management for alsa and dma
  49. */
  50. struct audio_stream {
  51. char *id; /* identification string */
  52. int stream_id; /* numeric identification */
  53. int dma_dev; /* dma number of that device */
  54. int *lch; /* Chain of channels this stream is linked to */
  55. char started; /* to store if the chain was started or not */
  56. int dma_q_head; /* DMA Channel Q Head */
  57. int dma_q_tail; /* DMA Channel Q Tail */
  58. char dma_q_count; /* DMA Channel Q Count */
  59. int active:1; /* we are using this stream for transfer now */
  60. int period; /* current transfer period */
  61. int periods; /* current count of periods registerd in the DMA engine */
  62. spinlock_t dma_lock; /* for locking in DMA operations */
  63. struct snd_pcm_substream *stream; /* the pcm stream */
  64. unsigned linked:1; /* dma channels linked */
  65. int offset; /* store start position of the last period in the alsa buffer */
  66. int (*hw_start)(void); /* interface to start HW interface, e.g. McBSP */
  67. int (*hw_stop)(void); /* interface to stop HW interface, e.g. McBSP */
  68. };
  69. /*
  70. * Alsa card structure for aic23
  71. */
  72. struct snd_card_omap_codec {
  73. struct snd_card *card;
  74. struct snd_pcm *pcm;
  75. long samplerate;
  76. struct audio_stream s[2]; /* playback & capture */
  77. };
  78. /* Codec specific information and function pointers.
  79. * Codec (omap-alsa-aic23.c and omap-alsa-tsc2101.c)
  80. * are responsible for defining the function pointers.
  81. */
  82. struct omap_alsa_codec_config {
  83. char *name;
  84. struct omap_mcbsp_reg_cfg *mcbsp_regs_alsa;
  85. struct snd_pcm_hw_constraint_list *hw_constraints_rates;
  86. struct snd_pcm_hardware *snd_omap_alsa_playback;
  87. struct snd_pcm_hardware *snd_omap_alsa_capture;
  88. void (*codec_configure_dev)(void);
  89. void (*codec_set_samplerate)(long);
  90. void (*codec_clock_setup)(void);
  91. int (*codec_clock_on)(void);
  92. int (*codec_clock_off)(void);
  93. int (*get_default_samplerate)(void);
  94. };
  95. /*********** Mixer function prototypes *************************/
  96. int snd_omap_mixer(struct snd_card_omap_codec *);
  97. void snd_omap_init_mixer(void);
  98. #ifdef CONFIG_PM
  99. void snd_omap_suspend_mixer(void);
  100. void snd_omap_resume_mixer(void);
  101. #endif
  102. int snd_omap_alsa_post_probe(struct platform_device *pdev, struct omap_alsa_codec_config *config);
  103. int snd_omap_alsa_remove(struct platform_device *pdev);
  104. #ifdef CONFIG_PM
  105. int snd_omap_alsa_suspend(struct platform_device *pdev, pm_message_t state);
  106. int snd_omap_alsa_resume(struct platform_device *pdev);
  107. #else
  108. #define snd_omap_alsa_suspend NULL
  109. #define snd_omap_alsa_resume NULL
  110. #endif
  111. void callback_omap_alsa_sound_dma(void *);
  112. #endif