cs5535audio.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef __SOUND_CS5535AUDIO_H
  2. #define __SOUND_CS5535AUDIO_H
  3. #define cs_writel(cs5535au, reg, val) outl(val, (cs5535au)->port + reg)
  4. #define cs_writeb(cs5535au, reg, val) outb(val, (cs5535au)->port + reg)
  5. #define cs_readl(cs5535au, reg) inl((cs5535au)->port + reg)
  6. #define cs_readw(cs5535au, reg) inw((cs5535au)->port + reg)
  7. #define cs_readb(cs5535au, reg) inb((cs5535au)->port + reg)
  8. #define CS5535AUDIO_MAX_DESCRIPTORS 128
  9. /* acc_codec bar0 reg addrs */
  10. #define ACC_GPIO_STATUS 0x00
  11. #define ACC_CODEC_STATUS 0x08
  12. #define ACC_CODEC_CNTL 0x0C
  13. #define ACC_IRQ_STATUS 0x12
  14. #define ACC_BM0_CMD 0x20
  15. #define ACC_BM1_CMD 0x28
  16. #define ACC_BM0_PRD 0x24
  17. #define ACC_BM1_PRD 0x2C
  18. #define ACC_BM0_STATUS 0x21
  19. #define ACC_BM1_STATUS 0x29
  20. #define ACC_BM0_PNTR 0x60
  21. #define ACC_BM1_PNTR 0x64
  22. /* acc_codec bar0 reg bits */
  23. /* ACC_IRQ_STATUS */
  24. #define IRQ_STS 0
  25. #define WU_IRQ_STS 1
  26. #define BM0_IRQ_STS 2
  27. #define BM1_IRQ_STS 3
  28. /* ACC_BMX_STATUS */
  29. #define EOP (1<<0)
  30. #define BM_EOP_ERR (1<<1)
  31. /* ACC_BMX_CTL */
  32. #define BM_CTL_EN 0x01
  33. #define BM_CTL_PAUSE 0x03
  34. #define BM_CTL_DIS 0x00
  35. #define BM_CTL_BYTE_ORD_LE 0x00
  36. #define BM_CTL_BYTE_ORD_BE 0x04
  37. /* cs5535 specific ac97 codec register defines */
  38. #define CMD_MASK 0xFF00FFFF
  39. #define CMD_NEW 0x00010000
  40. #define STS_NEW 0x00020000
  41. #define PRM_RDY_STS 0x00800000
  42. #define ACC_CODEC_CNTL_WR_CMD (~0x80000000)
  43. #define ACC_CODEC_CNTL_RD_CMD 0x80000000
  44. #define ACC_CODEC_CNTL_LNK_SHUTDOWN 0x00040000
  45. #define ACC_CODEC_CNTL_LNK_WRM_RST 0x00020000
  46. #define PRD_JMP 0x2000
  47. #define PRD_EOP 0x4000
  48. #define PRD_EOT 0x8000
  49. enum { CS5535AUDIO_DMA_PLAYBACK, CS5535AUDIO_DMA_CAPTURE, NUM_CS5535AUDIO_DMAS };
  50. struct cs5535audio;
  51. struct cs5535audio_dma_ops {
  52. int type;
  53. void (*enable_dma)(struct cs5535audio *cs5535au);
  54. void (*disable_dma)(struct cs5535audio *cs5535au);
  55. void (*pause_dma)(struct cs5535audio *cs5535au);
  56. void (*setup_prd)(struct cs5535audio *cs5535au, u32 prd_addr);
  57. u32 (*read_prd)(struct cs5535audio *cs5535au);
  58. u32 (*read_dma_pntr)(struct cs5535audio *cs5535au);
  59. };
  60. struct cs5535audio_dma_desc {
  61. __le32 addr;
  62. __le16 size;
  63. __le16 ctlreserved;
  64. };
  65. struct cs5535audio_dma {
  66. const struct cs5535audio_dma_ops *ops;
  67. struct snd_dma_buffer desc_buf;
  68. struct snd_pcm_substream *substream;
  69. unsigned int buf_addr, buf_bytes;
  70. unsigned int period_bytes, periods;
  71. u32 saved_prd;
  72. int pcm_open_flag;
  73. };
  74. struct cs5535audio {
  75. struct snd_card *card;
  76. struct snd_ac97 *ac97;
  77. struct snd_pcm *pcm;
  78. int irq;
  79. struct pci_dev *pci;
  80. unsigned long port;
  81. spinlock_t reg_lock;
  82. struct snd_pcm_substream *playback_substream;
  83. struct snd_pcm_substream *capture_substream;
  84. struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS];
  85. };
  86. extern const struct dev_pm_ops snd_cs5535audio_pm;
  87. #ifdef CONFIG_OLPC
  88. void olpc_prequirks(struct snd_card *card,
  89. struct snd_ac97_template *ac97);
  90. int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97);
  91. void olpc_quirks_cleanup(void);
  92. void olpc_analog_input(struct snd_ac97 *ac97, int on);
  93. void olpc_mic_bias(struct snd_ac97 *ac97, int on);
  94. static inline void olpc_capture_open(struct snd_ac97 *ac97)
  95. {
  96. /* default to Analog Input off */
  97. olpc_analog_input(ac97, 0);
  98. /* enable MIC Bias for recording */
  99. olpc_mic_bias(ac97, 1);
  100. }
  101. static inline void olpc_capture_close(struct snd_ac97 *ac97)
  102. {
  103. /* disable Analog Input */
  104. olpc_analog_input(ac97, 0);
  105. /* disable the MIC Bias (so the recording LED turns off) */
  106. olpc_mic_bias(ac97, 0);
  107. }
  108. #else
  109. static inline void olpc_prequirks(struct snd_card *card,
  110. struct snd_ac97_template *ac97) { }
  111. static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
  112. {
  113. return 0;
  114. }
  115. static inline void olpc_quirks_cleanup(void) { }
  116. static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { }
  117. static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { }
  118. static inline void olpc_capture_open(struct snd_ac97 *ac97) { }
  119. static inline void olpc_capture_close(struct snd_ac97 *ac97) { }
  120. #endif
  121. int snd_cs5535audio_pcm(struct cs5535audio *cs5535audio);
  122. #endif /* __SOUND_CS5535AUDIO_H */