1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef __SOUND_AU88X0_H
18#define __SOUND_AU88X0_H
19
20#ifdef __KERNEL__
21#include <linux/pci.h>
22#include <asm/io.h>
23#include <sound/core.h>
24#include <sound/pcm.h>
25#include <sound/rawmidi.h>
26#include <sound/mpu401.h>
27#include <sound/hwdep.h>
28#include <sound/ac97_codec.h>
29
30#endif
31
32#ifndef CHIP_AU8820
33#include "au88x0_eq.h"
34#include "au88x0_a3d.h"
35#endif
36#ifndef CHIP_AU8810
37#include "au88x0_wt.h"
38#endif
39
40#define hwread(x,y) readl((x)+(y))
41#define hwwrite(x,y,z) writel((z),(x)+(y))
42
43
44#define MIDI_CLOCK_DIV 0x61
45
46#define MPU401_RESET 0xff
47#define MPU401_ENTER_UART 0x3f
48#define MPU401_ACK 0xfe
49
50
51#define SRC_RATIO(x,y) ((((x<<15)/y) + 1)/2)
52
53
54#define FIFO_STOP 0
55#define FIFO_START 1
56#define FIFO_PAUSE 2
57
58
59#define IRQ_ERR_MASK 0x00ff
60#define IRQ_FATAL 0x0001
61#define IRQ_PARITY 0x0002
62#define IRQ_REG 0x0004
63#define IRQ_FIFO 0x0008
64#define IRQ_DMA 0x0010
65#define IRQ_PCMOUT 0x0020
66#define IRQ_TIMER 0x1000
67#define IRQ_MIDI 0x2000
68#define IRQ_MODEM 0x4000
69
70
71#define VORTEX_RESOURCE_DMA 0x00000000
72#define VORTEX_RESOURCE_SRC 0x00000001
73#define VORTEX_RESOURCE_MIXIN 0x00000002
74#define VORTEX_RESOURCE_MIXOUT 0x00000003
75#define VORTEX_RESOURCE_A3D 0x00000004
76#define VORTEX_RESOURCE_LAST 0x00000005
77
78
79#define VORTEX_CODEC_ID_SHIFT 24
80#define VORTEX_CODEC_WRITE 0x00800000
81#define VORTEX_CODEC_ADDSHIFT 16
82#define VORTEX_CODEC_ADDMASK 0x7f0000
83#define VORTEX_CODEC_DATSHIFT 0
84#define VORTEX_CODEC_DATMASK 0xffff
85
86
87
88#define VORTEX_IS_QUAD(x) ((x)->isquad)
89
90#define IS_BAD_CHIP(x) (\
91 (x->rev == 0xfe && x->device == PCI_DEVICE_ID_AUREAL_VORTEX_2) || \
92 (x->rev == 0xfe && x->device == PCI_DEVICE_ID_AUREAL_ADVANTAGE))
93
94
95
96#define VORTEX_PCM_ADB 0
97#define VORTEX_PCM_SPDIF 1
98#define VORTEX_PCM_A3D 2
99#define VORTEX_PCM_WT 3
100#define VORTEX_PCM_I2S 4
101#define VORTEX_PCM_LAST 5
102
103#define MIX_CAPT(x) (vortex->mixcapt[x])
104#define MIX_PLAYB(x) (vortex->mixplayb[x])
105#define MIX_SPDIF(x) (vortex->mixspdif[x])
106
107#define NR_WTPB 0x20
108
109
110typedef struct {
111
112 int fifo_enabled;
113 int fifo_status;
114 u32 dma_ctrl;
115 int dma_unknown;
116 int cfg0;
117 int cfg1;
118
119 int nr_ch;
120 int type;
121 int dma;
122 int dir;
123 u32 resources[5];
124
125
126 int nr_periods;
127 int period_bytes;
128 int period_real;
129 int period_virt;
130
131 struct snd_pcm_substream *substream;
132} stream_t;
133
134typedef struct snd_vortex vortex_t;
135struct snd_vortex {
136
137 struct snd_card *card;
138 struct snd_pcm *pcm[VORTEX_PCM_LAST];
139
140 struct snd_rawmidi *rmidi;
141 struct snd_ac97 *codec;
142
143
144 stream_t dma_adb[NR_ADB];
145 int spdif_sr;
146#ifndef CHIP_AU8810
147 stream_t dma_wt[NR_WT];
148 wt_voice_t wt_voice[NR_WT];
149 char mixwt[(NR_WT / NR_WTPB) * 6];
150#endif
151
152
153 s8 mixcapt[2];
154 s8 mixplayb[4];
155#ifndef CHIP_AU8820
156 s8 mixspdif[2];
157 s8 mixa3d[2];
158 s8 mixxtlk[2];
159#endif
160 u32 fixed_res[5];
161
162#ifndef CHIP_AU8820
163
164 eqlzr_t eq;
165
166 a3dsrc_t a3d[NR_A3D];
167
168 int xt_mode;
169#endif
170
171 int isquad;
172
173
174 struct gameport *gameport;
175
176
177 unsigned long io;
178 void __iomem *mmio;
179 unsigned int irq;
180 spinlock_t lock;
181
182
183 struct pci_dev *pci_dev;
184 u16 vendor;
185 u16 device;
186 u8 rev;
187};
188
189
190
191
192static void vortex_adb_setsrc(vortex_t * vortex, int adbdma,
193 unsigned int cvrt, int dir);
194
195
196static void vortex_adbdma_setbuffers(vortex_t * vortex, int adbdma,
197 int size, int count);
198static void vortex_adbdma_setmode(vortex_t * vortex, int adbdma, int ie,
199 int dir, int fmt, int d,
200 u32 offset);
201static void vortex_adbdma_setstartbuffer(vortex_t * vortex, int adbdma, int sb);
202#ifndef CHIP_AU8810
203static void vortex_wtdma_setbuffers(vortex_t * vortex, int wtdma,
204 int size, int count);
205static void vortex_wtdma_setmode(vortex_t * vortex, int wtdma, int ie, int fmt, int d,
206 u32 offset);
207static void vortex_wtdma_setstartbuffer(vortex_t * vortex, int wtdma, int sb);
208#endif
209
210static void vortex_adbdma_startfifo(vortex_t * vortex, int adbdma);
211
212static void vortex_adbdma_pausefifo(vortex_t * vortex, int adbdma);
213static void vortex_adbdma_resumefifo(vortex_t * vortex, int adbdma);
214static int inline vortex_adbdma_getlinearpos(vortex_t * vortex, int adbdma);
215static void vortex_adbdma_resetup(vortex_t *vortex, int adbdma);
216
217#ifndef CHIP_AU8810
218static void vortex_wtdma_startfifo(vortex_t * vortex, int wtdma);
219static void vortex_wtdma_stopfifo(vortex_t * vortex, int wtdma);
220static void vortex_wtdma_pausefifo(vortex_t * vortex, int wtdma);
221static void vortex_wtdma_resumefifo(vortex_t * vortex, int wtdma);
222static int inline vortex_wtdma_getlinearpos(vortex_t * vortex, int wtdma);
223#endif
224
225
226static void vortex_codec_init(vortex_t * vortex);
227static void vortex_codec_write(struct snd_ac97 * codec, unsigned short addr,
228 unsigned short data);
229static unsigned short vortex_codec_read(struct snd_ac97 * codec, unsigned short addr);
230static void vortex_spdif_init(vortex_t * vortex, int spdif_sr, int spdif_mode);
231
232static int vortex_core_init(vortex_t * card);
233static int vortex_core_shutdown(vortex_t * card);
234static void vortex_enable_int(vortex_t * card);
235static irqreturn_t vortex_interrupt(int irq, void *dev_id);
236static int vortex_alsafmt_aspfmt(int alsafmt);
237
238
239static void vortex_connect_default(vortex_t * vortex, int en);
240static int vortex_adb_allocroute(vortex_t * vortex, int dma, int nr_ch,
241 int dir, int type);
242static char vortex_adb_checkinout(vortex_t * vortex, int resmap[], int out,
243 int restype);
244#ifndef CHIP_AU8810
245static int vortex_wt_allocroute(vortex_t * vortex, int dma, int nr_ch);
246static void vortex_wt_connect(vortex_t * vortex, int en);
247static void vortex_wt_init(vortex_t * vortex);
248#endif
249
250static void vortex_route(vortex_t * vortex, int en, unsigned char channel,
251 unsigned char source, unsigned char dest);
252#if 0
253static void vortex_routes(vortex_t * vortex, int en, unsigned char channel,
254 unsigned char source, unsigned char dest0,
255 unsigned char dest1);
256#endif
257static void vortex_connection_mixin_mix(vortex_t * vortex, int en,
258 unsigned char mixin,
259 unsigned char mix, int a);
260static void vortex_mix_setinputvolumebyte(vortex_t * vortex,
261 unsigned char mix, int mixin,
262 unsigned char vol);
263static void vortex_mix_setvolumebyte(vortex_t * vortex, unsigned char mix,
264 unsigned char vol);
265
266
267#ifndef CHIP_AU8820
268static void vortex_Vort3D_enable(vortex_t * v);
269static void vortex_Vort3D_disable(vortex_t * v);
270static void vortex_Vort3D_connect(vortex_t * vortex, int en);
271static void vortex_Vort3D_InitializeSource(a3dsrc_t * a, int en);
272#endif
273
274
275static int vortex_gameport_register(vortex_t * card);
276static void vortex_gameport_unregister(vortex_t * card);
277#ifndef CHIP_AU8820
278static int vortex_eq_init(vortex_t * vortex);
279static int vortex_eq_free(vortex_t * vortex);
280#endif
281
282static int snd_vortex_new_pcm(vortex_t * vortex, int idx, int nr);
283static int snd_vortex_mixer(vortex_t * vortex);
284static int snd_vortex_midi(vortex_t * vortex);
285#endif
286