cs5535audio.h 4.0 KB

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