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