cthardware.h 7.5 KB

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