cs46xx_lib.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
  3. * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  4. *
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. */
  21. #ifndef __CS46XX_LIB_H__
  22. #define __CS46XX_LIB_H__
  23. /*
  24. * constants
  25. */
  26. #define CS46XX_BA0_SIZE 0x1000
  27. #define CS46XX_BA1_DATA0_SIZE 0x3000
  28. #define CS46XX_BA1_DATA1_SIZE 0x3800
  29. #define CS46XX_BA1_PRG_SIZE 0x7000
  30. #define CS46XX_BA1_REG_SIZE 0x0100
  31. #ifdef CONFIG_SND_CS46XX_NEW_DSP
  32. #define CS46XX_MIN_PERIOD_SIZE 64
  33. #define CS46XX_MAX_PERIOD_SIZE 1024*1024
  34. #else
  35. #define CS46XX_MIN_PERIOD_SIZE 2048
  36. #define CS46XX_MAX_PERIOD_SIZE 2048
  37. #endif
  38. #define CS46XX_FRAGS 2
  39. /* #define CS46XX_BUFFER_SIZE CS46XX_MAX_PERIOD_SIZE * CS46XX_FRAGS */
  40. #define SCB_NO_PARENT 0
  41. #define SCB_ON_PARENT_NEXT_SCB 1
  42. #define SCB_ON_PARENT_SUBLIST_SCB 2
  43. /* 3*1024 parameter, 3.5*1024 sample, 2*3.5*1024 code */
  44. #define BA1_DWORD_SIZE (13 * 1024 + 512)
  45. #define BA1_MEMORY_COUNT 3
  46. /*
  47. * common I/O routines
  48. */
  49. static inline void snd_cs46xx_poke(struct snd_cs46xx *chip, unsigned long reg, unsigned int val)
  50. {
  51. unsigned int bank = reg >> 16;
  52. unsigned int offset = reg & 0xffff;
  53. /*
  54. if (bank == 0)
  55. printk(KERN_DEBUG "snd_cs46xx_poke: %04X - %08X\n",
  56. reg >> 2,val);
  57. */
  58. writel(val, chip->region.idx[bank+1].remap_addr + offset);
  59. }
  60. static inline unsigned int snd_cs46xx_peek(struct snd_cs46xx *chip, unsigned long reg)
  61. {
  62. unsigned int bank = reg >> 16;
  63. unsigned int offset = reg & 0xffff;
  64. return readl(chip->region.idx[bank+1].remap_addr + offset);
  65. }
  66. static inline void snd_cs46xx_pokeBA0(struct snd_cs46xx *chip, unsigned long offset, unsigned int val)
  67. {
  68. writel(val, chip->region.name.ba0.remap_addr + offset);
  69. }
  70. static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned long offset)
  71. {
  72. return readl(chip->region.name.ba0.remap_addr + offset);
  73. }
  74. struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip);
  75. void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip);
  76. int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module);
  77. #ifdef CONFIG_PM_SLEEP
  78. int cs46xx_dsp_resume(struct snd_cs46xx * chip);
  79. #endif
  80. struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,
  81. int symbol_type);
  82. #ifdef CONFIG_SND_PROC_FS
  83. int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip);
  84. int cs46xx_dsp_proc_done (struct snd_cs46xx *chip);
  85. #else
  86. #define cs46xx_dsp_proc_init(card, chip)
  87. #define cs46xx_dsp_proc_done(chip)
  88. #endif
  89. int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip);
  90. int snd_cs46xx_download (struct snd_cs46xx *chip, u32 *src, unsigned long offset,
  91. unsigned long len);
  92. int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip, unsigned long offset, unsigned long len);
  93. int cs46xx_dsp_enable_spdif_out (struct snd_cs46xx *chip);
  94. int cs46xx_dsp_enable_spdif_hw (struct snd_cs46xx *chip);
  95. int cs46xx_dsp_disable_spdif_out (struct snd_cs46xx *chip);
  96. int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip);
  97. int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip);
  98. int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip);
  99. int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip);
  100. int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip);
  101. int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip);
  102. int cs46xx_poke_via_dsp (struct snd_cs46xx *chip, u32 address, u32 data);
  103. struct dsp_scb_descriptor * cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name,
  104. u32 * scb_data, u32 dest);
  105. #ifdef CONFIG_SND_PROC_FS
  106. void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb);
  107. void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip,
  108. struct dsp_scb_descriptor * scb);
  109. #else
  110. #define cs46xx_dsp_proc_free_scb_desc(scb)
  111. #define cs46xx_dsp_proc_register_scb_desc(chip, scb)
  112. #endif
  113. struct dsp_scb_descriptor * cs46xx_dsp_create_timing_master_scb (struct snd_cs46xx *chip);
  114. struct dsp_scb_descriptor *
  115. cs46xx_dsp_create_codec_out_scb(struct snd_cs46xx * chip,
  116. char * codec_name, u16 channel_disp, u16 fifo_addr,
  117. u16 child_scb_addr, u32 dest,
  118. struct dsp_scb_descriptor * parent_scb,
  119. int scb_child_type);
  120. struct dsp_scb_descriptor *
  121. cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name,
  122. u16 channel_disp, u16 fifo_addr,
  123. u16 sample_buffer_addr, u32 dest,
  124. struct dsp_scb_descriptor * parent_scb,
  125. int scb_child_type);
  126. void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip,
  127. struct dsp_scb_descriptor * scb);
  128. struct dsp_scb_descriptor *
  129. cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name,
  130. u16 channel_disp, u16 fifo_addr,
  131. u16 sample_buffer_addr, u32 dest,
  132. struct dsp_scb_descriptor * parent_scb,
  133. int scb_child_type);
  134. struct dsp_scb_descriptor *
  135. cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
  136. int sample_rate, u16 src_buffer_addr,
  137. u16 src_delay_buffer_addr, u32 dest,
  138. struct dsp_scb_descriptor * parent_scb,
  139. int scb_child_type, int pass_through);
  140. struct dsp_scb_descriptor *
  141. cs46xx_dsp_create_mix_only_scb(struct snd_cs46xx * chip, char * scb_name,
  142. u16 mix_buffer_addr, u32 dest,
  143. struct dsp_scb_descriptor * parent_scb,
  144. int scb_child_type);
  145. struct dsp_scb_descriptor *
  146. cs46xx_dsp_create_vari_decimate_scb(struct snd_cs46xx * chip, char * scb_name,
  147. u16 vari_buffer_addr0, u16 vari_buffer_addr1, u32 dest,
  148. struct dsp_scb_descriptor * parent_scb,
  149. int scb_child_type);
  150. struct dsp_scb_descriptor *
  151. cs46xx_dsp_create_asynch_fg_rx_scb(struct snd_cs46xx * chip, char * scb_name,
  152. u32 dest, u16 hfg_scb_address, u16 asynch_buffer_address,
  153. struct dsp_scb_descriptor * parent_scb,
  154. int scb_child_type);
  155. struct dsp_scb_descriptor *
  156. cs46xx_dsp_create_spio_write_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest,
  157. struct dsp_scb_descriptor * parent_scb,
  158. int scb_child_type);
  159. struct dsp_scb_descriptor *
  160. cs46xx_dsp_create_mix_to_ostream_scb(struct snd_cs46xx * chip, char * scb_name,
  161. u16 mix_buffer_addr, u16 writeback_spb, u32 dest,
  162. struct dsp_scb_descriptor * parent_scb,
  163. int scb_child_type);
  164. struct dsp_scb_descriptor *
  165. cs46xx_dsp_create_magic_snoop_scb(struct snd_cs46xx * chip, char * scb_name,
  166. u32 dest, u16 snoop_buffer_address,
  167. struct dsp_scb_descriptor * snoop_scb,
  168. struct dsp_scb_descriptor * parent_scb,
  169. int scb_child_type);
  170. struct dsp_pcm_channel_descriptor *
  171. cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, u32 sample_rate,
  172. void * private_data, u32 hw_dma_addr,
  173. int pcm_channel_id);
  174. void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
  175. struct dsp_pcm_channel_descriptor * pcm_channel);
  176. int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip,
  177. struct dsp_pcm_channel_descriptor * pcm_channel);
  178. int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip,
  179. struct dsp_pcm_channel_descriptor * pcm_channel);
  180. struct dsp_scb_descriptor *
  181. cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * source,
  182. u16 addr, char * scb_name);
  183. int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
  184. int cs46xx_src_link(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
  185. int cs46xx_iec958_pre_open (struct snd_cs46xx *chip);
  186. int cs46xx_iec958_post_close (struct snd_cs46xx *chip);
  187. int cs46xx_dsp_pcm_channel_set_period (struct snd_cs46xx * chip,
  188. struct dsp_pcm_channel_descriptor * pcm_channel,
  189. int period_size);
  190. int cs46xx_dsp_pcm_ostream_set_period (struct snd_cs46xx * chip, int period_size);
  191. int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right);
  192. int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right);
  193. #endif /* __CS46XX_LIB_H__ */