cs46xx_lib.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
  3. * Copyright (c) by Jaroslav Kysela <perex@suse.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 1
  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(cs46xx_t *chip, unsigned long reg, unsigned int val)
  50. {
  51. unsigned int bank = reg >> 16;
  52. unsigned int offset = reg & 0xffff;
  53. /*if (bank == 0) printk("snd_cs46xx_poke: %04X - %08X\n",reg >> 2,val); */
  54. writel(val, chip->region.idx[bank+1].remap_addr + offset);
  55. }
  56. static inline unsigned int snd_cs46xx_peek(cs46xx_t *chip, unsigned long reg)
  57. {
  58. unsigned int bank = reg >> 16;
  59. unsigned int offset = reg & 0xffff;
  60. return readl(chip->region.idx[bank+1].remap_addr + offset);
  61. }
  62. static inline void snd_cs46xx_pokeBA0(cs46xx_t *chip, unsigned long offset, unsigned int val)
  63. {
  64. writel(val, chip->region.name.ba0.remap_addr + offset);
  65. }
  66. static inline unsigned int snd_cs46xx_peekBA0(cs46xx_t *chip, unsigned long offset)
  67. {
  68. return readl(chip->region.name.ba0.remap_addr + offset);
  69. }
  70. dsp_spos_instance_t * cs46xx_dsp_spos_create (cs46xx_t * chip);
  71. void cs46xx_dsp_spos_destroy (cs46xx_t * chip);
  72. int cs46xx_dsp_load_module (cs46xx_t * chip,dsp_module_desc_t * module);
  73. symbol_entry_t * cs46xx_dsp_lookup_symbol (cs46xx_t * chip,char * symbol_name,int symbol_type);
  74. int cs46xx_dsp_proc_init (snd_card_t * card, cs46xx_t *chip);
  75. int cs46xx_dsp_proc_done (cs46xx_t *chip);
  76. int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip);
  77. int snd_cs46xx_download (cs46xx_t *chip,u32 *src,unsigned long offset,
  78. unsigned long len);
  79. int snd_cs46xx_clear_BA1(cs46xx_t *chip,unsigned long offset,unsigned long len);
  80. int cs46xx_dsp_enable_spdif_out (cs46xx_t *chip);
  81. int cs46xx_dsp_enable_spdif_hw (cs46xx_t *chip);
  82. int cs46xx_dsp_disable_spdif_out (cs46xx_t *chip);
  83. int cs46xx_dsp_enable_spdif_in (cs46xx_t *chip);
  84. int cs46xx_dsp_disable_spdif_in (cs46xx_t *chip);
  85. int cs46xx_dsp_enable_pcm_capture (cs46xx_t *chip);
  86. int cs46xx_dsp_disable_pcm_capture (cs46xx_t *chip);
  87. int cs46xx_dsp_enable_adc_capture (cs46xx_t *chip);
  88. int cs46xx_dsp_disable_adc_capture (cs46xx_t *chip);
  89. int cs46xx_poke_via_dsp (cs46xx_t *chip,u32 address,u32 data);
  90. dsp_scb_descriptor_t * cs46xx_dsp_create_scb (cs46xx_t *chip,char * name, u32 * scb_data,u32 dest);
  91. void cs46xx_dsp_proc_free_scb_desc (dsp_scb_descriptor_t * scb);
  92. void cs46xx_dsp_proc_register_scb_desc (cs46xx_t *chip,dsp_scb_descriptor_t * scb);
  93. dsp_scb_descriptor_t * cs46xx_dsp_create_timing_master_scb (cs46xx_t *chip);
  94. dsp_scb_descriptor_t * cs46xx_dsp_create_codec_out_scb(cs46xx_t * chip,char * codec_name,
  95. u16 channel_disp,u16 fifo_addr,
  96. u16 child_scb_addr,
  97. u32 dest,
  98. dsp_scb_descriptor_t * parent_scb,
  99. int scb_child_type);
  100. dsp_scb_descriptor_t * cs46xx_dsp_create_codec_in_scb(cs46xx_t * chip,char * codec_name,
  101. u16 channel_disp,u16 fifo_addr,
  102. u16 sample_buffer_addr,
  103. u32 dest,
  104. dsp_scb_descriptor_t * parent_scb,
  105. int scb_child_type);
  106. void cs46xx_dsp_remove_scb (cs46xx_t *chip,dsp_scb_descriptor_t * scb);
  107. dsp_scb_descriptor_t * cs46xx_dsp_create_codec_in_scb(cs46xx_t * chip,char * codec_name,
  108. u16 channel_disp,u16 fifo_addr,
  109. u16 sample_buffer_addr,
  110. u32 dest,dsp_scb_descriptor_t * parent_scb,
  111. int scb_child_type);
  112. dsp_scb_descriptor_t * cs46xx_dsp_create_src_task_scb(cs46xx_t * chip,char * scb_name,
  113. int sample_rate,
  114. u16 src_buffer_addr,
  115. u16 src_delay_buffer_addr,u32 dest,
  116. dsp_scb_descriptor_t * parent_scb,
  117. int scb_child_type,
  118. int pass_through);
  119. dsp_scb_descriptor_t * cs46xx_dsp_create_mix_only_scb(cs46xx_t * chip,char * scb_name,
  120. u16 mix_buffer_addr,u32 dest,
  121. dsp_scb_descriptor_t * parent_scb,
  122. int scb_child_type);
  123. dsp_scb_descriptor_t * cs46xx_dsp_create_vari_decimate_scb(cs46xx_t * chip,char * scb_name,
  124. u16 vari_buffer_addr0,
  125. u16 vari_buffer_addr1,
  126. u32 dest,
  127. dsp_scb_descriptor_t * parent_scb,
  128. int scb_child_type);
  129. dsp_scb_descriptor_t * cs46xx_dsp_create_asynch_fg_rx_scb(cs46xx_t * chip,char * scb_name,u32 dest,
  130. u16 hfg_scb_address,
  131. u16 asynch_buffer_address,
  132. dsp_scb_descriptor_t * parent_scb,
  133. int scb_child_type);
  134. dsp_scb_descriptor_t * cs46xx_dsp_create_spio_write_scb(cs46xx_t * chip,char * scb_name,u32 dest,
  135. dsp_scb_descriptor_t * parent_scb,
  136. int scb_child_type);
  137. dsp_scb_descriptor_t * cs46xx_dsp_create_mix_to_ostream_scb(cs46xx_t * chip,char * scb_name,
  138. u16 mix_buffer_addr,u16 writeback_spb,u32 dest,
  139. dsp_scb_descriptor_t * parent_scb,
  140. int scb_child_type);
  141. dsp_scb_descriptor_t * cs46xx_dsp_create_magic_snoop_scb(cs46xx_t * chip,char * scb_name,u32 dest,
  142. u16 snoop_buffer_address,
  143. dsp_scb_descriptor_t * snoop_scb,
  144. dsp_scb_descriptor_t * parent_scb,
  145. int scb_child_type);
  146. pcm_channel_descriptor_t * cs46xx_dsp_create_pcm_channel (cs46xx_t * chip,u32 sample_rate, void * private_data, u32 hw_dma_addr,
  147. int pcm_channel_id);
  148. void cs46xx_dsp_destroy_pcm_channel (cs46xx_t * chip,
  149. pcm_channel_descriptor_t * pcm_channel);
  150. int cs46xx_dsp_pcm_unlink (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channel);
  151. int cs46xx_dsp_pcm_link (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channel);
  152. dsp_scb_descriptor_t * cs46xx_add_record_source (cs46xx_t *chip,dsp_scb_descriptor_t * source,
  153. u16 addr,char * scb_name);
  154. int cs46xx_src_unlink(cs46xx_t *chip,dsp_scb_descriptor_t * src);
  155. int cs46xx_src_link(cs46xx_t *chip,dsp_scb_descriptor_t * src);
  156. int cs46xx_iec958_pre_open (cs46xx_t *chip);
  157. int cs46xx_iec958_post_close (cs46xx_t *chip);
  158. int cs46xx_dsp_pcm_channel_set_period (cs46xx_t * chip,
  159. pcm_channel_descriptor_t * pcm_channel,
  160. int period_size);
  161. int cs46xx_dsp_pcm_ostream_set_period (cs46xx_t * chip,
  162. int period_size);
  163. int cs46xx_dsp_set_dac_volume (cs46xx_t * chip,u16 left,u16 right);
  164. int cs46xx_dsp_set_iec958_volume (cs46xx_t * chip,u16 left,u16 right);
  165. #endif /* __CS46XX_LIB_H__ */