cthardware.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
  4. *
  5. * @File cthardware.h
  6. *
  7. * @Brief
  8. * This file contains the definition of hardware access methord.
  9. *
  10. * @Author Liu Chun
  11. * @Date May 13 2008
  12. */
  13. #ifndef CTHARDWARE_H
  14. #define CTHARDWARE_H
  15. #include <linux/types.h>
  16. #include <linux/pci.h>
  17. #include <sound/core.h>
  18. enum CHIPTYP {
  19. ATC20K1,
  20. ATC20K2,
  21. ATCNONE
  22. };
  23. enum CTCARDS {
  24. /* 20k1 models */
  25. CTSB046X,
  26. CT20K1_MODEL_FIRST = CTSB046X,
  27. CTSB055X,
  28. CTSB073X,
  29. CTUAA,
  30. CT20K1_UNKNOWN,
  31. /* 20k2 models */
  32. CTSB0760,
  33. CT20K2_MODEL_FIRST = CTSB0760,
  34. CTHENDRIX,
  35. CTSB0880,
  36. CTSB1270,
  37. CT20K2_UNKNOWN,
  38. NUM_CTCARDS /* This should always be the last */
  39. };
  40. /* Type of input source for ADC */
  41. enum ADCSRC{
  42. ADC_MICIN,
  43. ADC_LINEIN,
  44. ADC_VIDEO,
  45. ADC_AUX,
  46. ADC_NONE /* Switch to digital input */
  47. };
  48. struct card_conf {
  49. /* device virtual mem page table page physical addr
  50. * (supporting one page table page now) */
  51. unsigned long vm_pgt_phys;
  52. unsigned int rsr; /* reference sample rate in Hzs*/
  53. unsigned int msr; /* master sample rate in rsrs */
  54. };
  55. struct capabilities {
  56. unsigned int digit_io_switch:1;
  57. unsigned int dedicated_mic:1;
  58. unsigned int output_switch:1;
  59. unsigned int mic_source_switch:1;
  60. };
  61. struct hw {
  62. int (*card_init)(struct hw *hw, struct card_conf *info);
  63. int (*card_stop)(struct hw *hw);
  64. int (*pll_init)(struct hw *hw, unsigned int rsr);
  65. #ifdef CONFIG_PM_SLEEP
  66. int (*suspend)(struct hw *hw);
  67. int (*resume)(struct hw *hw, struct card_conf *info);
  68. #endif
  69. int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source);
  70. int (*select_adc_source)(struct hw *hw, enum ADCSRC source);
  71. struct capabilities (*capabilities)(struct hw *hw);
  72. int (*output_switch_get)(struct hw *hw);
  73. int (*output_switch_put)(struct hw *hw, int position);
  74. int (*mic_source_switch_get)(struct hw *hw);
  75. int (*mic_source_switch_put)(struct hw *hw, int position);
  76. /* SRC operations */
  77. int (*src_rsc_get_ctrl_blk)(void **rblk);
  78. int (*src_rsc_put_ctrl_blk)(void *blk);
  79. int (*src_set_state)(void *blk, unsigned int state);
  80. int (*src_set_bm)(void *blk, unsigned int bm);
  81. int (*src_set_rsr)(void *blk, unsigned int rsr);
  82. int (*src_set_sf)(void *blk, unsigned int sf);
  83. int (*src_set_wr)(void *blk, unsigned int wr);
  84. int (*src_set_pm)(void *blk, unsigned int pm);
  85. int (*src_set_rom)(void *blk, unsigned int rom);
  86. int (*src_set_vo)(void *blk, unsigned int vo);
  87. int (*src_set_st)(void *blk, unsigned int st);
  88. int (*src_set_ie)(void *blk, unsigned int ie);
  89. int (*src_set_ilsz)(void *blk, unsigned int ilsz);
  90. int (*src_set_bp)(void *blk, unsigned int bp);
  91. int (*src_set_cisz)(void *blk, unsigned int cisz);
  92. int (*src_set_ca)(void *blk, unsigned int ca);
  93. int (*src_set_sa)(void *blk, unsigned int sa);
  94. int (*src_set_la)(void *blk, unsigned int la);
  95. int (*src_set_pitch)(void *blk, unsigned int pitch);
  96. int (*src_set_clear_zbufs)(void *blk, unsigned int clear);
  97. int (*src_set_dirty)(void *blk, unsigned int flags);
  98. int (*src_set_dirty_all)(void *blk);
  99. int (*src_commit_write)(struct hw *hw, unsigned int idx, void *blk);
  100. int (*src_get_ca)(struct hw *hw, unsigned int idx, void *blk);
  101. unsigned int (*src_get_dirty)(void *blk);
  102. unsigned int (*src_dirty_conj_mask)(void);
  103. int (*src_mgr_get_ctrl_blk)(void **rblk);
  104. int (*src_mgr_put_ctrl_blk)(void *blk);
  105. /* syncly enable src @idx */
  106. int (*src_mgr_enbs_src)(void *blk, unsigned int idx);
  107. /* enable src @idx */
  108. int (*src_mgr_enb_src)(void *blk, unsigned int idx);
  109. /* disable src @idx */
  110. int (*src_mgr_dsb_src)(void *blk, unsigned int idx);
  111. int (*src_mgr_commit_write)(struct hw *hw, void *blk);
  112. /* SRC Input Mapper operations */
  113. int (*srcimp_mgr_get_ctrl_blk)(void **rblk);
  114. int (*srcimp_mgr_put_ctrl_blk)(void *blk);
  115. int (*srcimp_mgr_set_imaparc)(void *blk, unsigned int slot);
  116. int (*srcimp_mgr_set_imapuser)(void *blk, unsigned int user);
  117. int (*srcimp_mgr_set_imapnxt)(void *blk, unsigned int next);
  118. int (*srcimp_mgr_set_imapaddr)(void *blk, unsigned int addr);
  119. int (*srcimp_mgr_commit_write)(struct hw *hw, void *blk);
  120. /* AMIXER operations */
  121. int (*amixer_rsc_get_ctrl_blk)(void **rblk);
  122. int (*amixer_rsc_put_ctrl_blk)(void *blk);
  123. int (*amixer_mgr_get_ctrl_blk)(void **rblk);
  124. int (*amixer_mgr_put_ctrl_blk)(void *blk);
  125. int (*amixer_set_mode)(void *blk, unsigned int mode);
  126. int (*amixer_set_iv)(void *blk, unsigned int iv);
  127. int (*amixer_set_x)(void *blk, unsigned int x);
  128. int (*amixer_set_y)(void *blk, unsigned int y);
  129. int (*amixer_set_sadr)(void *blk, unsigned int sadr);
  130. int (*amixer_set_se)(void *blk, unsigned int se);
  131. int (*amixer_set_dirty)(void *blk, unsigned int flags);
  132. int (*amixer_set_dirty_all)(void *blk);
  133. int (*amixer_commit_write)(struct hw *hw, unsigned int idx, void *blk);
  134. int (*amixer_get_y)(void *blk);
  135. unsigned int (*amixer_get_dirty)(void *blk);
  136. /* DAIO operations */
  137. int (*dai_get_ctrl_blk)(void **rblk);
  138. int (*dai_put_ctrl_blk)(void *blk);
  139. int (*dai_srt_set_srco)(void *blk, unsigned int src);
  140. int (*dai_srt_set_srcm)(void *blk, unsigned int src);
  141. int (*dai_srt_set_rsr)(void *blk, unsigned int rsr);
  142. int (*dai_srt_set_drat)(void *blk, unsigned int drat);
  143. int (*dai_srt_set_ec)(void *blk, unsigned int ec);
  144. int (*dai_srt_set_et)(void *blk, unsigned int et);
  145. int (*dai_commit_write)(struct hw *hw, unsigned int idx, void *blk);
  146. int (*dao_get_ctrl_blk)(void **rblk);
  147. int (*dao_put_ctrl_blk)(void *blk);
  148. int (*dao_set_spos)(void *blk, unsigned int spos);
  149. int (*dao_commit_write)(struct hw *hw, unsigned int idx, void *blk);
  150. int (*dao_get_spos)(void *blk, unsigned int *spos);
  151. int (*daio_mgr_get_ctrl_blk)(struct hw *hw, void **rblk);
  152. int (*daio_mgr_put_ctrl_blk)(void *blk);
  153. int (*daio_mgr_enb_dai)(void *blk, unsigned int idx);
  154. int (*daio_mgr_dsb_dai)(void *blk, unsigned int idx);
  155. int (*daio_mgr_enb_dao)(void *blk, unsigned int idx);
  156. int (*daio_mgr_dsb_dao)(void *blk, unsigned int idx);
  157. int (*daio_mgr_dao_init)(void *blk, unsigned int idx,
  158. unsigned int conf);
  159. int (*daio_mgr_set_imaparc)(void *blk, unsigned int slot);
  160. int (*daio_mgr_set_imapnxt)(void *blk, unsigned int next);
  161. int (*daio_mgr_set_imapaddr)(void *blk, unsigned int addr);
  162. int (*daio_mgr_commit_write)(struct hw *hw, void *blk);
  163. int (*set_timer_irq)(struct hw *hw, int enable);
  164. int (*set_timer_tick)(struct hw *hw, unsigned int tick);
  165. unsigned int (*get_wc)(struct hw *hw);
  166. void (*irq_callback)(void *data, unsigned int bit);
  167. void *irq_callback_data;
  168. struct pci_dev *pci; /* the pci kernel structure of this card */
  169. struct snd_card *card; /* pointer to this card */
  170. int irq;
  171. unsigned long io_base;
  172. void __iomem *mem_base;
  173. enum CHIPTYP chip_type;
  174. enum CTCARDS model;
  175. };
  176. int create_hw_obj(struct pci_dev *pci, enum CHIPTYP chip_type,
  177. enum CTCARDS model, struct hw **rhw);
  178. int destroy_hw_obj(struct hw *hw);
  179. unsigned int get_field(unsigned int data, unsigned int field);
  180. void set_field(unsigned int *data, unsigned int field, unsigned int value);
  181. /* IRQ bits */
  182. #define PLL_INT (1 << 10) /* PLL input-clock out-of-range */
  183. #define FI_INT (1 << 9) /* forced interrupt */
  184. #define IT_INT (1 << 8) /* timer interrupt */
  185. #define PCI_INT (1 << 7) /* PCI bus error pending */
  186. #define URT_INT (1 << 6) /* UART Tx/Rx */
  187. #define GPI_INT (1 << 5) /* GPI pin */
  188. #define MIX_INT (1 << 4) /* mixer parameter segment FIFO channels */
  189. #define DAI_INT (1 << 3) /* DAI (SR-tracker or SPDIF-receiver) */
  190. #define TP_INT (1 << 2) /* transport priority queue */
  191. #define DSP_INT (1 << 1) /* DSP */
  192. #define SRC_INT (1 << 0) /* SRC channels */
  193. #endif /* CTHARDWARE_H */