cs46xx_lib.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * The driver for the Cirrus Logic's Sound Fusion CS46XX based soundcards
  4. * Copyright (c) by Jaroslav Kysela <[email protected]>
  5. */
  6. #ifndef __CS46XX_LIB_H__
  7. #define __CS46XX_LIB_H__
  8. /*
  9. * constants
  10. */
  11. #define CS46XX_BA0_SIZE 0x1000
  12. #define CS46XX_BA1_DATA0_SIZE 0x3000
  13. #define CS46XX_BA1_DATA1_SIZE 0x3800
  14. #define CS46XX_BA1_PRG_SIZE 0x7000
  15. #define CS46XX_BA1_REG_SIZE 0x0100
  16. #ifdef CONFIG_SND_CS46XX_NEW_DSP
  17. #define CS46XX_MIN_PERIOD_SIZE 64
  18. #define CS46XX_MAX_PERIOD_SIZE 1024*1024
  19. #else
  20. #define CS46XX_MIN_PERIOD_SIZE 2048
  21. #define CS46XX_MAX_PERIOD_SIZE 2048
  22. #endif
  23. #define CS46XX_FRAGS 2
  24. /* #define CS46XX_BUFFER_SIZE CS46XX_MAX_PERIOD_SIZE * CS46XX_FRAGS */
  25. #define SCB_NO_PARENT 0
  26. #define SCB_ON_PARENT_NEXT_SCB 1
  27. #define SCB_ON_PARENT_SUBLIST_SCB 2
  28. /* 3*1024 parameter, 3.5*1024 sample, 2*3.5*1024 code */
  29. #define BA1_DWORD_SIZE (13 * 1024 + 512)
  30. #define BA1_MEMORY_COUNT 3
  31. /*
  32. * common I/O routines
  33. */
  34. static inline void snd_cs46xx_poke(struct snd_cs46xx *chip, unsigned long reg, unsigned int val)
  35. {
  36. unsigned int bank = reg >> 16;
  37. unsigned int offset = reg & 0xffff;
  38. /*
  39. if (bank == 0)
  40. printk(KERN_DEBUG "snd_cs46xx_poke: %04X - %08X\n",
  41. reg >> 2,val);
  42. */
  43. writel(val, chip->region.idx[bank+1].remap_addr + offset);
  44. }
  45. static inline unsigned int snd_cs46xx_peek(struct snd_cs46xx *chip, unsigned long reg)
  46. {
  47. unsigned int bank = reg >> 16;
  48. unsigned int offset = reg & 0xffff;
  49. return readl(chip->region.idx[bank+1].remap_addr + offset);
  50. }
  51. static inline void snd_cs46xx_pokeBA0(struct snd_cs46xx *chip, unsigned long offset, unsigned int val)
  52. {
  53. writel(val, chip->region.name.ba0.remap_addr + offset);
  54. }
  55. static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned long offset)
  56. {
  57. return readl(chip->region.name.ba0.remap_addr + offset);
  58. }
  59. struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip);
  60. void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip);
  61. int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module);
  62. #ifdef CONFIG_PM_SLEEP
  63. int cs46xx_dsp_resume(struct snd_cs46xx * chip);
  64. #endif
  65. struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name,
  66. int symbol_type);
  67. #ifdef CONFIG_SND_PROC_FS
  68. int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip);
  69. int cs46xx_dsp_proc_done (struct snd_cs46xx *chip);
  70. #else
  71. #define cs46xx_dsp_proc_init(card, chip)
  72. #define cs46xx_dsp_proc_done(chip)
  73. #endif
  74. int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip);
  75. int snd_cs46xx_download (struct snd_cs46xx *chip, u32 *src, unsigned long offset,
  76. unsigned long len);
  77. int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip, unsigned long offset, unsigned long len);
  78. int cs46xx_dsp_enable_spdif_out (struct snd_cs46xx *chip);
  79. int cs46xx_dsp_enable_spdif_hw (struct snd_cs46xx *chip);
  80. int cs46xx_dsp_disable_spdif_out (struct snd_cs46xx *chip);
  81. int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip);
  82. int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip);
  83. int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip);
  84. int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip);
  85. int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip);
  86. int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip);
  87. int cs46xx_poke_via_dsp (struct snd_cs46xx *chip, u32 address, u32 data);
  88. struct dsp_scb_descriptor * cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name,
  89. u32 * scb_data, u32 dest);
  90. #ifdef CONFIG_SND_PROC_FS
  91. void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb);
  92. void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip,
  93. struct dsp_scb_descriptor * scb);
  94. #else
  95. #define cs46xx_dsp_proc_free_scb_desc(scb)
  96. #define cs46xx_dsp_proc_register_scb_desc(chip, scb)
  97. #endif
  98. struct dsp_scb_descriptor * cs46xx_dsp_create_timing_master_scb (struct snd_cs46xx *chip);
  99. struct dsp_scb_descriptor *
  100. cs46xx_dsp_create_codec_out_scb(struct snd_cs46xx * chip,
  101. char * codec_name, u16 channel_disp, u16 fifo_addr,
  102. u16 child_scb_addr, u32 dest,
  103. struct dsp_scb_descriptor * parent_scb,
  104. int scb_child_type);
  105. struct dsp_scb_descriptor *
  106. cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name,
  107. u16 channel_disp, u16 fifo_addr,
  108. u16 sample_buffer_addr, u32 dest,
  109. struct dsp_scb_descriptor * parent_scb,
  110. int scb_child_type);
  111. void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip,
  112. struct dsp_scb_descriptor * scb);
  113. struct dsp_scb_descriptor *
  114. cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name,
  115. u16 channel_disp, u16 fifo_addr,
  116. u16 sample_buffer_addr, u32 dest,
  117. struct dsp_scb_descriptor * parent_scb,
  118. int scb_child_type);
  119. struct dsp_scb_descriptor *
  120. cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
  121. int sample_rate, u16 src_buffer_addr,
  122. u16 src_delay_buffer_addr, u32 dest,
  123. struct dsp_scb_descriptor * parent_scb,
  124. int scb_child_type, int pass_through);
  125. struct dsp_scb_descriptor *
  126. cs46xx_dsp_create_mix_only_scb(struct snd_cs46xx * chip, char * scb_name,
  127. u16 mix_buffer_addr, u32 dest,
  128. struct dsp_scb_descriptor * parent_scb,
  129. int scb_child_type);
  130. struct dsp_scb_descriptor *
  131. cs46xx_dsp_create_vari_decimate_scb(struct snd_cs46xx * chip, char * scb_name,
  132. u16 vari_buffer_addr0, u16 vari_buffer_addr1, u32 dest,
  133. struct dsp_scb_descriptor * parent_scb,
  134. int scb_child_type);
  135. struct dsp_scb_descriptor *
  136. cs46xx_dsp_create_asynch_fg_rx_scb(struct snd_cs46xx * chip, char * scb_name,
  137. u32 dest, u16 hfg_scb_address, u16 asynch_buffer_address,
  138. struct dsp_scb_descriptor * parent_scb,
  139. int scb_child_type);
  140. struct dsp_scb_descriptor *
  141. cs46xx_dsp_create_spio_write_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest,
  142. struct dsp_scb_descriptor * parent_scb,
  143. int scb_child_type);
  144. struct dsp_scb_descriptor *
  145. cs46xx_dsp_create_mix_to_ostream_scb(struct snd_cs46xx * chip, char * scb_name,
  146. u16 mix_buffer_addr, u16 writeback_spb, u32 dest,
  147. struct dsp_scb_descriptor * parent_scb,
  148. int scb_child_type);
  149. struct dsp_scb_descriptor *
  150. cs46xx_dsp_create_magic_snoop_scb(struct snd_cs46xx * chip, char * scb_name,
  151. u32 dest, u16 snoop_buffer_address,
  152. struct dsp_scb_descriptor * snoop_scb,
  153. struct dsp_scb_descriptor * parent_scb,
  154. int scb_child_type);
  155. struct dsp_pcm_channel_descriptor *
  156. cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, u32 sample_rate,
  157. void * private_data, u32 hw_dma_addr,
  158. int pcm_channel_id);
  159. void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip,
  160. struct dsp_pcm_channel_descriptor * pcm_channel);
  161. int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip,
  162. struct dsp_pcm_channel_descriptor * pcm_channel);
  163. int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip,
  164. struct dsp_pcm_channel_descriptor * pcm_channel);
  165. struct dsp_scb_descriptor *
  166. cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * source,
  167. u16 addr, char * scb_name);
  168. int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
  169. int cs46xx_src_link(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src);
  170. int cs46xx_iec958_pre_open (struct snd_cs46xx *chip);
  171. int cs46xx_iec958_post_close (struct snd_cs46xx *chip);
  172. int cs46xx_dsp_pcm_channel_set_period (struct snd_cs46xx * chip,
  173. struct dsp_pcm_channel_descriptor * pcm_channel,
  174. int period_size);
  175. int cs46xx_dsp_pcm_ostream_set_period (struct snd_cs46xx * chip, int period_size);
  176. int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right);
  177. int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right);
  178. #endif /* __CS46XX_LIB_H__ */