2005-11-17 10:12:23 +01:00
|
|
|
#ifndef __SOUND_CS5535AUDIO_H
|
|
|
|
#define __SOUND_CS5535AUDIO_H
|
|
|
|
|
2005-11-17 10:15:37 +01:00
|
|
|
#define cs_writel(cs5535au, reg, val) outl(val, (cs5535au)->port + reg)
|
|
|
|
#define cs_writeb(cs5535au, reg, val) outb(val, (cs5535au)->port + reg)
|
|
|
|
#define cs_readl(cs5535au, reg) inl((cs5535au)->port + reg)
|
|
|
|
#define cs_readw(cs5535au, reg) inw((cs5535au)->port + reg)
|
|
|
|
#define cs_readb(cs5535au, reg) inb((cs5535au)->port + reg)
|
2005-11-17 10:12:23 +01:00
|
|
|
|
|
|
|
#define CS5535AUDIO_MAX_DESCRIPTORS 128
|
|
|
|
|
|
|
|
/* acc_codec bar0 reg addrs */
|
|
|
|
#define ACC_GPIO_STATUS 0x00
|
|
|
|
#define ACC_CODEC_STATUS 0x08
|
|
|
|
#define ACC_CODEC_CNTL 0x0C
|
|
|
|
#define ACC_IRQ_STATUS 0x12
|
|
|
|
#define ACC_BM0_CMD 0x20
|
|
|
|
#define ACC_BM1_CMD 0x28
|
|
|
|
#define ACC_BM0_PRD 0x24
|
|
|
|
#define ACC_BM1_PRD 0x2C
|
|
|
|
#define ACC_BM0_STATUS 0x21
|
|
|
|
#define ACC_BM1_STATUS 0x29
|
|
|
|
#define ACC_BM0_PNTR 0x60
|
|
|
|
#define ACC_BM1_PNTR 0x64
|
2007-09-03 15:43:43 +02:00
|
|
|
|
2005-11-17 10:12:23 +01:00
|
|
|
/* acc_codec bar0 reg bits */
|
|
|
|
/* ACC_IRQ_STATUS */
|
|
|
|
#define IRQ_STS 0
|
|
|
|
#define WU_IRQ_STS 1
|
|
|
|
#define BM0_IRQ_STS 2
|
|
|
|
#define BM1_IRQ_STS 3
|
|
|
|
/* ACC_BMX_STATUS */
|
|
|
|
#define EOP (1<<0)
|
|
|
|
#define BM_EOP_ERR (1<<1)
|
|
|
|
/* ACC_BMX_CTL */
|
2007-09-03 15:43:18 +02:00
|
|
|
#define BM_CTL_EN 0x01
|
|
|
|
#define BM_CTL_PAUSE 0x03
|
|
|
|
#define BM_CTL_DIS 0x00
|
|
|
|
#define BM_CTL_BYTE_ORD_LE 0x00
|
|
|
|
#define BM_CTL_BYTE_ORD_BE 0x04
|
2005-11-17 10:12:23 +01:00
|
|
|
/* cs5535 specific ac97 codec register defines */
|
|
|
|
#define CMD_MASK 0xFF00FFFF
|
|
|
|
#define CMD_NEW 0x00010000
|
|
|
|
#define STS_NEW 0x00020000
|
|
|
|
#define PRM_RDY_STS 0x00800000
|
|
|
|
#define ACC_CODEC_CNTL_WR_CMD (~0x80000000)
|
|
|
|
#define ACC_CODEC_CNTL_RD_CMD 0x80000000
|
2006-04-28 14:34:49 +02:00
|
|
|
#define ACC_CODEC_CNTL_LNK_SHUTDOWN 0x00040000
|
|
|
|
#define ACC_CODEC_CNTL_LNK_WRM_RST 0x00020000
|
2005-11-17 10:12:23 +01:00
|
|
|
#define PRD_JMP 0x2000
|
|
|
|
#define PRD_EOP 0x4000
|
|
|
|
#define PRD_EOT 0x8000
|
|
|
|
|
|
|
|
enum { CS5535AUDIO_DMA_PLAYBACK, CS5535AUDIO_DMA_CAPTURE, NUM_CS5535AUDIO_DMAS };
|
2005-11-17 14:56:21 +01:00
|
|
|
|
|
|
|
struct cs5535audio;
|
|
|
|
|
|
|
|
struct cs5535audio_dma_ops {
|
2005-11-17 10:12:23 +01:00
|
|
|
int type;
|
2005-11-17 14:56:21 +01:00
|
|
|
void (*enable_dma)(struct cs5535audio *cs5535au);
|
|
|
|
void (*disable_dma)(struct cs5535audio *cs5535au);
|
|
|
|
void (*pause_dma)(struct cs5535audio *cs5535au);
|
|
|
|
void (*setup_prd)(struct cs5535audio *cs5535au, u32 prd_addr);
|
2006-04-28 14:34:49 +02:00
|
|
|
u32 (*read_prd)(struct cs5535audio *cs5535au);
|
2005-11-17 14:56:21 +01:00
|
|
|
u32 (*read_dma_pntr)(struct cs5535audio *cs5535au);
|
2005-11-17 10:12:23 +01:00
|
|
|
};
|
|
|
|
|
2005-11-17 14:56:21 +01:00
|
|
|
struct cs5535audio_dma_desc {
|
2005-11-17 10:12:23 +01:00
|
|
|
u32 addr;
|
|
|
|
u16 size;
|
|
|
|
u16 ctlreserved;
|
2005-11-17 14:56:21 +01:00
|
|
|
};
|
2005-11-17 10:12:23 +01:00
|
|
|
|
2005-11-17 14:56:21 +01:00
|
|
|
struct cs5535audio_dma {
|
|
|
|
const struct cs5535audio_dma_ops *ops;
|
2005-11-17 10:12:23 +01:00
|
|
|
struct snd_dma_buffer desc_buf;
|
2005-11-17 14:56:21 +01:00
|
|
|
struct snd_pcm_substream *substream;
|
2005-11-17 10:12:23 +01:00
|
|
|
unsigned int buf_addr, buf_bytes;
|
|
|
|
unsigned int period_bytes, periods;
|
2006-04-28 14:34:49 +02:00
|
|
|
u32 saved_prd;
|
2008-11-05 23:30:08 +01:00
|
|
|
int pcm_open_flag;
|
2005-11-17 10:12:23 +01:00
|
|
|
};
|
|
|
|
|
2005-11-17 14:56:21 +01:00
|
|
|
struct cs5535audio {
|
|
|
|
struct snd_card *card;
|
|
|
|
struct snd_ac97 *ac97;
|
2006-04-28 14:34:49 +02:00
|
|
|
struct snd_pcm *pcm;
|
2005-11-17 10:12:23 +01:00
|
|
|
int irq;
|
|
|
|
struct pci_dev *pci;
|
|
|
|
unsigned long port;
|
|
|
|
spinlock_t reg_lock;
|
2005-11-17 14:56:21 +01:00
|
|
|
struct snd_pcm_substream *playback_substream;
|
|
|
|
struct snd_pcm_substream *capture_substream;
|
|
|
|
struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS];
|
2005-11-17 10:12:23 +01:00
|
|
|
};
|
|
|
|
|
2008-11-05 23:30:30 +01:00
|
|
|
#ifdef CONFIG_PM
|
2006-04-28 14:34:49 +02:00
|
|
|
int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state);
|
|
|
|
int snd_cs5535audio_resume(struct pci_dev *pci);
|
2008-11-05 23:30:30 +01:00
|
|
|
#endif
|
|
|
|
|
2009-12-15 03:00:36 +01:00
|
|
|
#ifdef CONFIG_OLPC
|
2008-11-06 22:44:08 +01:00
|
|
|
void __devinit olpc_prequirks(struct snd_card *card,
|
|
|
|
struct snd_ac97_template *ac97);
|
|
|
|
int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97);
|
2009-12-15 03:00:36 +01:00
|
|
|
void __devexit olpc_quirks_cleanup(void);
|
2008-11-06 22:49:38 +01:00
|
|
|
void olpc_analog_input(struct snd_ac97 *ac97, int on);
|
2008-11-06 22:53:03 +01:00
|
|
|
void olpc_mic_bias(struct snd_ac97 *ac97, int on);
|
|
|
|
|
|
|
|
static inline void olpc_capture_open(struct snd_ac97 *ac97)
|
|
|
|
{
|
2008-11-06 22:53:11 +01:00
|
|
|
/* default to Analog Input off */
|
|
|
|
olpc_analog_input(ac97, 0);
|
2008-11-06 22:53:03 +01:00
|
|
|
/* enable MIC Bias for recording */
|
|
|
|
olpc_mic_bias(ac97, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void olpc_capture_close(struct snd_ac97 *ac97)
|
|
|
|
{
|
2008-11-06 22:53:11 +01:00
|
|
|
/* disable Analog Input */
|
|
|
|
olpc_analog_input(ac97, 0);
|
2008-11-06 22:53:03 +01:00
|
|
|
/* disable the MIC Bias (so the recording LED turns off) */
|
|
|
|
olpc_mic_bias(ac97, 0);
|
|
|
|
}
|
2008-11-06 22:43:34 +01:00
|
|
|
#else
|
2008-11-06 22:44:08 +01:00
|
|
|
static inline void olpc_prequirks(struct snd_card *card,
|
|
|
|
struct snd_ac97_template *ac97) { }
|
|
|
|
static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2009-12-15 03:00:36 +01:00
|
|
|
static inline void olpc_quirks_cleanup(void) { }
|
2008-11-06 22:49:38 +01:00
|
|
|
static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { }
|
2008-11-06 22:53:03 +01:00
|
|
|
static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { }
|
|
|
|
static inline void olpc_capture_open(struct snd_ac97 *ac97) { }
|
|
|
|
static inline void olpc_capture_close(struct snd_ac97 *ac97) { }
|
2008-11-06 22:43:34 +01:00
|
|
|
#endif
|
|
|
|
|
2005-11-17 14:56:21 +01:00
|
|
|
int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535audio);
|
|
|
|
|
2005-11-17 10:12:23 +01:00
|
|
|
#endif /* __SOUND_CS5535AUDIO_H */
|
|
|
|
|