Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __SOUND_CS5535AUDIO_H
0003 #define __SOUND_CS5535AUDIO_H
0004 
0005 #define cs_writel(cs5535au, reg, val)   outl(val, (cs5535au)->port + reg)
0006 #define cs_writeb(cs5535au, reg, val)   outb(val, (cs5535au)->port + reg)
0007 #define cs_readl(cs5535au, reg)     inl((cs5535au)->port + reg)
0008 #define cs_readw(cs5535au, reg)     inw((cs5535au)->port + reg)
0009 #define cs_readb(cs5535au, reg)     inb((cs5535au)->port + reg)
0010 
0011 #define CS5535AUDIO_MAX_DESCRIPTORS 128
0012 
0013 /* acc_codec bar0 reg addrs */
0014 #define ACC_GPIO_STATUS         0x00
0015 #define ACC_CODEC_STATUS        0x08
0016 #define ACC_CODEC_CNTL          0x0C
0017 #define ACC_IRQ_STATUS          0x12
0018 #define ACC_BM0_CMD         0x20
0019 #define ACC_BM1_CMD         0x28
0020 #define ACC_BM0_PRD         0x24
0021 #define ACC_BM1_PRD         0x2C
0022 #define ACC_BM0_STATUS          0x21
0023 #define ACC_BM1_STATUS          0x29
0024 #define ACC_BM0_PNTR            0x60
0025 #define ACC_BM1_PNTR            0x64
0026 
0027 /* acc_codec bar0 reg bits */
0028 /* ACC_IRQ_STATUS */
0029 #define IRQ_STS             0
0030 #define WU_IRQ_STS          1
0031 #define BM0_IRQ_STS             2
0032 #define BM1_IRQ_STS             3
0033 /* ACC_BMX_STATUS */
0034 #define EOP             (1<<0)
0035 #define BM_EOP_ERR          (1<<1)
0036 /* ACC_BMX_CTL */
0037 #define BM_CTL_EN           0x01
0038 #define BM_CTL_PAUSE            0x03
0039 #define BM_CTL_DIS          0x00
0040 #define BM_CTL_BYTE_ORD_LE      0x00
0041 #define BM_CTL_BYTE_ORD_BE      0x04
0042 /* cs5535 specific ac97 codec register defines */
0043 #define CMD_MASK            0xFF00FFFF
0044 #define CMD_NEW             0x00010000
0045 #define STS_NEW             0x00020000
0046 #define PRM_RDY_STS         0x00800000
0047 #define ACC_CODEC_CNTL_WR_CMD       (~0x80000000)
0048 #define ACC_CODEC_CNTL_RD_CMD       0x80000000
0049 #define ACC_CODEC_CNTL_LNK_SHUTDOWN 0x00040000
0050 #define ACC_CODEC_CNTL_LNK_WRM_RST  0x00020000
0051 #define PRD_JMP             0x2000
0052 #define PRD_EOP             0x4000
0053 #define PRD_EOT             0x8000
0054 
0055 enum { CS5535AUDIO_DMA_PLAYBACK, CS5535AUDIO_DMA_CAPTURE, NUM_CS5535AUDIO_DMAS };
0056 
0057 struct cs5535audio;
0058 
0059 struct cs5535audio_dma_ops {
0060     int type;
0061     void (*enable_dma)(struct cs5535audio *cs5535au);
0062     void (*disable_dma)(struct cs5535audio *cs5535au);
0063     void (*pause_dma)(struct cs5535audio *cs5535au);
0064     void (*setup_prd)(struct cs5535audio *cs5535au, u32 prd_addr);
0065     u32 (*read_prd)(struct cs5535audio *cs5535au);
0066     u32 (*read_dma_pntr)(struct cs5535audio *cs5535au);
0067 };
0068 
0069 struct cs5535audio_dma_desc {
0070     __le32 addr;
0071     __le16 size;
0072     __le16 ctlreserved;
0073 };
0074 
0075 struct cs5535audio_dma {
0076     const struct cs5535audio_dma_ops *ops;
0077     struct snd_dma_buffer desc_buf;
0078     struct snd_pcm_substream *substream;
0079     unsigned int buf_addr, buf_bytes;
0080     unsigned int period_bytes, periods;
0081     u32 saved_prd;
0082     int pcm_open_flag;
0083 };
0084 
0085 struct cs5535audio {
0086     struct snd_card *card;
0087     struct snd_ac97 *ac97;
0088     struct snd_pcm *pcm;
0089     int irq;
0090     struct pci_dev *pci;
0091     unsigned long port;
0092     spinlock_t reg_lock;
0093     struct snd_pcm_substream *playback_substream;
0094     struct snd_pcm_substream *capture_substream;
0095     struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS];
0096 };
0097 
0098 extern const struct dev_pm_ops snd_cs5535audio_pm;
0099 
0100 #ifdef CONFIG_OLPC
0101 void olpc_prequirks(struct snd_card *card,
0102             struct snd_ac97_template *ac97);
0103 int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97);
0104 void olpc_quirks_cleanup(void);
0105 void olpc_analog_input(struct snd_ac97 *ac97, int on);
0106 void olpc_mic_bias(struct snd_ac97 *ac97, int on);
0107 
0108 static inline void olpc_capture_open(struct snd_ac97 *ac97)
0109 {
0110     /* default to Analog Input off */
0111     olpc_analog_input(ac97, 0);
0112     /* enable MIC Bias for recording */
0113     olpc_mic_bias(ac97, 1);
0114 }
0115 
0116 static inline void olpc_capture_close(struct snd_ac97 *ac97)
0117 {
0118     /* disable Analog Input */
0119     olpc_analog_input(ac97, 0);
0120     /* disable the MIC Bias (so the recording LED turns off) */
0121     olpc_mic_bias(ac97, 0);
0122 }
0123 #else
0124 static inline void olpc_prequirks(struct snd_card *card,
0125         struct snd_ac97_template *ac97) { }
0126 static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
0127 {
0128     return 0;
0129 }
0130 static inline void olpc_quirks_cleanup(void) { }
0131 static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { }
0132 static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { }
0133 static inline void olpc_capture_open(struct snd_ac97 *ac97) { }
0134 static inline void olpc_capture_close(struct snd_ac97 *ac97) { }
0135 #endif
0136 
0137 int snd_cs5535audio_pcm(struct cs5535audio *cs5535audio);
0138 
0139 #endif /* __SOUND_CS5535AUDIO_H */
0140