Path: blob/master/sound/pci/cs5535audio/cs5535audio.h
10817 views
#ifndef __SOUND_CS5535AUDIO_H1#define __SOUND_CS5535AUDIO_H23#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)89#define CS5535AUDIO_MAX_DESCRIPTORS 1281011/* acc_codec bar0 reg addrs */12#define ACC_GPIO_STATUS 0x0013#define ACC_CODEC_STATUS 0x0814#define ACC_CODEC_CNTL 0x0C15#define ACC_IRQ_STATUS 0x1216#define ACC_BM0_CMD 0x2017#define ACC_BM1_CMD 0x2818#define ACC_BM0_PRD 0x2419#define ACC_BM1_PRD 0x2C20#define ACC_BM0_STATUS 0x2121#define ACC_BM1_STATUS 0x2922#define ACC_BM0_PNTR 0x6023#define ACC_BM1_PNTR 0x642425/* acc_codec bar0 reg bits */26/* ACC_IRQ_STATUS */27#define IRQ_STS 028#define WU_IRQ_STS 129#define BM0_IRQ_STS 230#define BM1_IRQ_STS 331/* ACC_BMX_STATUS */32#define EOP (1<<0)33#define BM_EOP_ERR (1<<1)34/* ACC_BMX_CTL */35#define BM_CTL_EN 0x0136#define BM_CTL_PAUSE 0x0337#define BM_CTL_DIS 0x0038#define BM_CTL_BYTE_ORD_LE 0x0039#define BM_CTL_BYTE_ORD_BE 0x0440/* cs5535 specific ac97 codec register defines */41#define CMD_MASK 0xFF00FFFF42#define CMD_NEW 0x0001000043#define STS_NEW 0x0002000044#define PRM_RDY_STS 0x0080000045#define ACC_CODEC_CNTL_WR_CMD (~0x80000000)46#define ACC_CODEC_CNTL_RD_CMD 0x8000000047#define ACC_CODEC_CNTL_LNK_SHUTDOWN 0x0004000048#define ACC_CODEC_CNTL_LNK_WRM_RST 0x0002000049#define PRD_JMP 0x200050#define PRD_EOP 0x400051#define PRD_EOT 0x80005253enum { CS5535AUDIO_DMA_PLAYBACK, CS5535AUDIO_DMA_CAPTURE, NUM_CS5535AUDIO_DMAS };5455struct cs5535audio;5657struct cs5535audio_dma_ops {58int type;59void (*enable_dma)(struct cs5535audio *cs5535au);60void (*disable_dma)(struct cs5535audio *cs5535au);61void (*pause_dma)(struct cs5535audio *cs5535au);62void (*setup_prd)(struct cs5535audio *cs5535au, u32 prd_addr);63u32 (*read_prd)(struct cs5535audio *cs5535au);64u32 (*read_dma_pntr)(struct cs5535audio *cs5535au);65};6667struct cs5535audio_dma_desc {68u32 addr;69u16 size;70u16 ctlreserved;71};7273struct cs5535audio_dma {74const struct cs5535audio_dma_ops *ops;75struct snd_dma_buffer desc_buf;76struct snd_pcm_substream *substream;77unsigned int buf_addr, buf_bytes;78unsigned int period_bytes, periods;79u32 saved_prd;80int pcm_open_flag;81};8283struct cs5535audio {84struct snd_card *card;85struct snd_ac97 *ac97;86struct snd_pcm *pcm;87int irq;88struct pci_dev *pci;89unsigned long port;90spinlock_t reg_lock;91struct snd_pcm_substream *playback_substream;92struct snd_pcm_substream *capture_substream;93struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS];94};9596#ifdef CONFIG_PM97int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state);98int snd_cs5535audio_resume(struct pci_dev *pci);99#endif100101#ifdef CONFIG_OLPC102void __devinit olpc_prequirks(struct snd_card *card,103struct snd_ac97_template *ac97);104int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97);105void __devexit olpc_quirks_cleanup(void);106void olpc_analog_input(struct snd_ac97 *ac97, int on);107void olpc_mic_bias(struct snd_ac97 *ac97, int on);108109static inline void olpc_capture_open(struct snd_ac97 *ac97)110{111/* default to Analog Input off */112olpc_analog_input(ac97, 0);113/* enable MIC Bias for recording */114olpc_mic_bias(ac97, 1);115}116117static inline void olpc_capture_close(struct snd_ac97 *ac97)118{119/* disable Analog Input */120olpc_analog_input(ac97, 0);121/* disable the MIC Bias (so the recording LED turns off) */122olpc_mic_bias(ac97, 0);123}124#else125static inline void olpc_prequirks(struct snd_card *card,126struct snd_ac97_template *ac97) { }127static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)128{129return 0;130}131static inline void olpc_quirks_cleanup(void) { }132static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { }133static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { }134static inline void olpc_capture_open(struct snd_ac97 *ac97) { }135static inline void olpc_capture_close(struct snd_ac97 *ac97) { }136#endif137138int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535audio);139140#endif /* __SOUND_CS5535AUDIO_H */141142143144