[PATCH] x86: Add the check for all the cores in a package in cache information
[linux-2.6/next.git] / include / sound / trident.h
blobf5254ec36e6af5335b7d96728a8a754f596ac29a
1 #ifndef __SOUND_TRIDENT_H
2 #define __SOUND_TRIDENT_H
4 /*
5 * audio@tridentmicro.com
6 * Fri Feb 19 15:55:28 MST 1999
7 * Definitions for Trident 4DWave DX/NX chips
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "pcm.h"
27 #include "mpu401.h"
28 #include "ac97_codec.h"
29 #include "seq_midi_emul.h"
30 #include "seq_device.h"
31 #include "util_mem.h"
32 //#include "ainstr_iw.h"
33 //#include "ainstr_gf1.h"
34 #include "ainstr_simple.h"
36 #ifndef PCI_VENDOR_ID_TRIDENT
37 #define PCI_VENDOR_ID_TRIDENT 0x1023
38 #endif
39 #ifndef PCI_DEVICE_ID_TRIDENT_4DWAVE_DX
40 #define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000
41 #endif
42 #ifndef PCI_DEVICE_ID_TRIDENT_4DWAVE_NX
43 #define PCI_DEVICE_ID_TRIDENT_4DWAVE_NX 0x2001
44 #endif
46 #ifndef PCI_VENDOR_ID_SI
47 #define PCI_VENDOR_ID_SI 0x1039
48 #endif
49 #ifndef PCI_DEVICE_ID_SI_7018
50 #define PCI_DEVICE_ID_SI_7018 0x7018
51 #endif
53 #define TRIDENT_DEVICE_ID_DX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_DX)
54 #define TRIDENT_DEVICE_ID_NX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_NX)
55 #define TRIDENT_DEVICE_ID_SI7018 ((PCI_VENDOR_ID_SI<<16)|PCI_DEVICE_ID_SI_7018)
57 #define SNDRV_SEQ_DEV_ID_TRIDENT "trident-synth"
59 #define SNDRV_TRIDENT_VOICE_TYPE_PCM 0
60 #define SNDRV_TRIDENT_VOICE_TYPE_SYNTH 1
61 #define SNDRV_TRIDENT_VOICE_TYPE_MIDI 2
63 #define SNDRV_TRIDENT_VFLG_RUNNING (1<<0)
65 /* TLB code constants */
66 #define SNDRV_TRIDENT_PAGE_SIZE 4096
67 #define SNDRV_TRIDENT_PAGE_SHIFT 12
68 #define SNDRV_TRIDENT_PAGE_MASK ((1<<SNDRV_TRIDENT_PAGE_SHIFT)-1)
69 #define SNDRV_TRIDENT_MAX_PAGES 4096
72 * Direct registers
75 #define TRID_REG(trident, x) ((trident)->port + (x))
77 #define ID_4DWAVE_DX 0x2000
78 #define ID_4DWAVE_NX 0x2001
80 /* Bank definitions */
82 #define T4D_BANK_A 0
83 #define T4D_BANK_B 1
84 #define T4D_NUM_BANKS 2
86 /* Register definitions */
88 /* Global registers */
90 enum global_control_bits {
91 CHANNEL_IDX = 0x0000003f,
92 OVERRUN_IE = 0x00000400, /* interrupt enable: capture overrun */
93 UNDERRUN_IE = 0x00000800, /* interrupt enable: playback underrun */
94 ENDLP_IE = 0x00001000, /* interrupt enable: end of buffer */
95 MIDLP_IE = 0x00002000, /* interrupt enable: middle buffer */
96 ETOG_IE = 0x00004000, /* interrupt enable: envelope toggling */
97 EDROP_IE = 0x00008000, /* interrupt enable: envelope drop */
98 BANK_B_EN = 0x00010000, /* SiS: enable bank B (64 channels) */
99 PCMIN_B_MIX = 0x00020000, /* SiS: PCM IN B mixing enable */
100 I2S_OUT_ASSIGN = 0x00040000, /* SiS: I2S Out contains surround PCM */
101 SPDIF_OUT_ASSIGN= 0x00080000, /* SiS: 0=S/PDIF L/R | 1=PCM Out FIFO */
102 MAIN_OUT_ASSIGN = 0x00100000, /* SiS: 0=PCM Out FIFO | 1=MMC Out buffer */
105 enum miscint_bits {
106 PB_UNDERRUN_IRQ = 0x00000001, REC_OVERRUN_IRQ = 0x00000002,
107 SB_IRQ = 0x00000004, MPU401_IRQ = 0x00000008,
108 OPL3_IRQ = 0x00000010, ADDRESS_IRQ = 0x00000020,
109 ENVELOPE_IRQ = 0x00000040, PB_UNDERRUN = 0x00000100,
110 REC_OVERRUN = 0x00000200, MIXER_UNDERFLOW = 0x00000400,
111 MIXER_OVERFLOW = 0x00000800, NX_SB_IRQ_DISABLE = 0x00001000,
112 ST_TARGET_REACHED = 0x00008000,
113 PB_24K_MODE = 0x00010000, ST_IRQ_EN = 0x00800000,
114 ACGPIO_IRQ = 0x01000000
117 /* T2 legacy dma control registers. */
118 #define LEGACY_DMAR0 0x00 // ADR0
119 #define LEGACY_DMAR4 0x04 // CNT0
120 #define LEGACY_DMAR6 0x06 // CNT0 - High bits
121 #define LEGACY_DMAR11 0x0b // MOD
122 #define LEGACY_DMAR15 0x0f // MMR
124 #define T4D_START_A 0x80
125 #define T4D_STOP_A 0x84
126 #define T4D_DLY_A 0x88
127 #define T4D_SIGN_CSO_A 0x8c
128 #define T4D_CSPF_A 0x90
129 #define T4D_CSPF_B 0xbc
130 #define T4D_CEBC_A 0x94
131 #define T4D_AINT_A 0x98
132 #define T4D_AINTEN_A 0x9c
133 #define T4D_LFO_GC_CIR 0xa0
134 #define T4D_MUSICVOL_WAVEVOL 0xa8
135 #define T4D_SBDELTA_DELTA_R 0xac
136 #define T4D_MISCINT 0xb0
137 #define T4D_START_B 0xb4
138 #define T4D_STOP_B 0xb8
139 #define T4D_SBBL_SBCL 0xc0
140 #define T4D_SBCTRL_SBE2R_SBDD 0xc4
141 #define T4D_STIMER 0xc8
142 #define T4D_AINT_B 0xd8
143 #define T4D_AINTEN_B 0xdc
144 #define T4D_RCI 0x70
146 /* MPU-401 UART */
147 #define T4D_MPU401_BASE 0x20
148 #define T4D_MPUR0 0x20
149 #define T4D_MPUR1 0x21
150 #define T4D_MPUR2 0x22
151 #define T4D_MPUR3 0x23
153 /* S/PDIF Registers */
154 #define NX_SPCTRL_SPCSO 0x24
155 #define NX_SPLBA 0x28
156 #define NX_SPESO 0x2c
157 #define NX_SPCSTATUS 0x64
159 /* Joystick */
160 #define GAMEPORT_GCR 0x30
161 #define GAMEPORT_MODE_ADC 0x80
162 #define GAMEPORT_LEGACY 0x31
163 #define GAMEPORT_AXES 0x34
165 /* NX Specific Registers */
166 #define NX_TLBC 0x6c
168 /* Channel Registers */
170 #define CH_START 0xe0
172 #define CH_DX_CSO_ALPHA_FMS 0xe0
173 #define CH_DX_ESO_DELTA 0xe8
174 #define CH_DX_FMC_RVOL_CVOL 0xec
176 #define CH_NX_DELTA_CSO 0xe0
177 #define CH_NX_DELTA_ESO 0xe8
178 #define CH_NX_ALPHA_FMS_FMC_RVOL_CVOL 0xec
180 #define CH_LBA 0xe4
181 #define CH_GVSEL_PAN_VOL_CTRL_EC 0xf0
182 #define CH_EBUF1 0xf4
183 #define CH_EBUF2 0xf8
185 /* AC-97 Registers */
187 #define DX_ACR0_AC97_W 0x40
188 #define DX_ACR1_AC97_R 0x44
189 #define DX_ACR2_AC97_COM_STAT 0x48
191 #define NX_ACR0_AC97_COM_STAT 0x40
192 #define NX_ACR1_AC97_W 0x44
193 #define NX_ACR2_AC97_R_PRIMARY 0x48
194 #define NX_ACR3_AC97_R_SECONDARY 0x4c
196 #define SI_AC97_WRITE 0x40
197 #define SI_AC97_READ 0x44
198 #define SI_SERIAL_INTF_CTRL 0x48
199 #define SI_AC97_GPIO 0x4c
200 #define SI_ASR0 0x50
201 #define SI_SPDIF_CS 0x70
202 #define SI_GPIO 0x7c
204 enum trident_nx_ac97_bits {
205 /* ACR1-3 */
206 NX_AC97_BUSY_WRITE = 0x0800,
207 NX_AC97_BUSY_READ = 0x0800,
208 NX_AC97_BUSY_DATA = 0x0400,
209 NX_AC97_WRITE_SECONDARY = 0x0100,
210 /* ACR0 */
211 NX_AC97_SECONDARY_READY = 0x0040,
212 NX_AC97_SECONDARY_RECORD = 0x0020,
213 NX_AC97_SURROUND_OUTPUT = 0x0010,
214 NX_AC97_PRIMARY_READY = 0x0008,
215 NX_AC97_PRIMARY_RECORD = 0x0004,
216 NX_AC97_PCM_OUTPUT = 0x0002,
217 NX_AC97_WARM_RESET = 0x0001
220 enum trident_dx_ac97_bits {
221 DX_AC97_BUSY_WRITE = 0x8000,
222 DX_AC97_BUSY_READ = 0x8000,
223 DX_AC97_READY = 0x0010,
224 DX_AC97_RECORD = 0x0008,
225 DX_AC97_PLAYBACK = 0x0002
228 enum sis7018_ac97_bits {
229 SI_AC97_BUSY_WRITE = 0x00008000,
230 SI_AC97_AUDIO_BUSY = 0x00004000,
231 SI_AC97_MODEM_BUSY = 0x00002000,
232 SI_AC97_BUSY_READ = 0x00008000,
233 SI_AC97_SECONDARY = 0x00000080,
236 enum serial_intf_ctrl_bits {
237 WARM_RESET = 0x00000001,
238 COLD_RESET = 0x00000002,
239 I2S_CLOCK = 0x00000004,
240 PCM_SEC_AC97 = 0x00000008,
241 AC97_DBL_RATE = 0x00000010,
242 SPDIF_EN = 0x00000020,
243 I2S_OUTPUT_EN = 0x00000040,
244 I2S_INPUT_EN = 0x00000080,
245 PCMIN = 0x00000100,
246 LINE1IN = 0x00000200,
247 MICIN = 0x00000400,
248 LINE2IN = 0x00000800,
249 HEAD_SET_IN = 0x00001000,
250 GPIOIN = 0x00002000,
251 /* 7018 spec says id = 01 but the demo board routed to 10
252 SECONDARY_ID= 0x00004000, */
253 SECONDARY_ID = 0x00004000,
254 PCMOUT = 0x00010000,
255 SURROUT = 0x00020000,
256 CENTEROUT = 0x00040000,
257 LFEOUT = 0x00080000,
258 LINE1OUT = 0x00100000,
259 LINE2OUT = 0x00200000,
260 GPIOOUT = 0x00400000,
261 SI_AC97_PRIMARY_READY = 0x01000000,
262 SI_AC97_SECONDARY_READY = 0x02000000,
263 SI_AC97_POWERDOWN = 0x04000000,
266 /* PCM defaults */
268 #define T4D_DEFAULT_PCM_VOL 10 /* 0 - 255 */
269 #define T4D_DEFAULT_PCM_PAN 0 /* 0 - 127 */
270 #define T4D_DEFAULT_PCM_RVOL 127 /* 0 - 127 */
271 #define T4D_DEFAULT_PCM_CVOL 127 /* 0 - 127 */
273 typedef struct _snd_trident trident_t;
274 typedef struct _snd_trident_voice snd_trident_voice_t;
275 typedef struct _snd_trident_pcm_mixer snd_trident_pcm_mixer_t;
277 typedef struct {
278 void (*sample_start)(trident_t *gus, snd_trident_voice_t *voice, snd_seq_position_t position);
279 void (*sample_stop)(trident_t *gus, snd_trident_voice_t *voice, snd_seq_stop_mode_t mode);
280 void (*sample_freq)(trident_t *gus, snd_trident_voice_t *voice, snd_seq_frequency_t freq);
281 void (*sample_volume)(trident_t *gus, snd_trident_voice_t *voice, snd_seq_ev_volume_t *volume);
282 void (*sample_loop)(trident_t *card, snd_trident_voice_t *voice, snd_seq_ev_loop_t *loop);
283 void (*sample_pos)(trident_t *card, snd_trident_voice_t *voice, snd_seq_position_t position);
284 void (*sample_private1)(trident_t *card, snd_trident_voice_t *voice, unsigned char *data);
285 } snd_trident_sample_ops_t;
287 typedef struct {
288 snd_midi_channel_set_t * chset;
289 trident_t * trident;
290 int mode; /* operation mode */
291 int client; /* sequencer client number */
292 int port; /* sequencer port number */
293 unsigned int midi_has_voices: 1;
294 } snd_trident_port_t;
296 typedef struct snd_trident_memblk_arg {
297 short first_page, last_page;
298 } snd_trident_memblk_arg_t;
300 typedef struct {
301 unsigned int * entries; /* 16k-aligned TLB table */
302 dma_addr_t entries_dmaaddr; /* 16k-aligned PCI address to TLB table */
303 unsigned long * shadow_entries; /* shadow entries with virtual addresses */
304 struct snd_dma_buffer buffer;
305 snd_util_memhdr_t * memhdr; /* page allocation list */
306 struct snd_dma_buffer silent_page;
307 } snd_trident_tlb_t;
309 struct _snd_trident_voice {
310 unsigned int number;
311 unsigned int use: 1,
312 pcm: 1,
313 synth:1,
314 midi: 1;
315 unsigned int flags;
316 unsigned char client;
317 unsigned char port;
318 unsigned char index;
320 snd_seq_instr_t instr;
321 snd_trident_sample_ops_t *sample_ops;
323 /* channel parameters */
324 unsigned int CSO; /* 24 bits (16 on DX) */
325 unsigned int ESO; /* 24 bits (16 on DX) */
326 unsigned int LBA; /* 30 bits */
327 unsigned short EC; /* 12 bits */
328 unsigned short Alpha; /* 12 bits */
329 unsigned short Delta; /* 16 bits */
330 unsigned short Attribute; /* 16 bits - SiS 7018 */
331 unsigned short Vol; /* 12 bits (6.6) */
332 unsigned char Pan; /* 7 bits (1.4.2) */
333 unsigned char GVSel; /* 1 bit */
334 unsigned char RVol; /* 7 bits (5.2) */
335 unsigned char CVol; /* 7 bits (5.2) */
336 unsigned char FMC; /* 2 bits */
337 unsigned char CTRL; /* 4 bits */
338 unsigned char FMS; /* 4 bits */
339 unsigned char LFO; /* 8 bits */
341 unsigned int negCSO; /* nonzero - use negative CSO */
343 snd_util_memblk_t *memblk; /* memory block if TLB enabled */
345 /* PCM data */
347 trident_t *trident;
348 snd_pcm_substream_t *substream;
349 snd_trident_voice_t *extra; /* extra PCM voice (acts as interrupt generator) */
350 unsigned int running: 1,
351 capture: 1,
352 spdif: 1,
353 foldback: 1,
354 isync: 1,
355 isync2: 1,
356 isync3: 1;
357 int foldback_chan; /* foldback subdevice number */
358 unsigned int stimer; /* global sample timer (to detect spurious interrupts) */
359 unsigned int spurious_threshold; /* spurious threshold */
360 unsigned int isync_mark;
361 unsigned int isync_max;
362 unsigned int isync_ESO;
364 /* --- */
366 void *private_data;
367 void (*private_free)(snd_trident_voice_t *voice);
370 struct _snd_4dwave {
371 int seq_client;
373 snd_trident_port_t seq_ports[4];
374 snd_simple_ops_t simple_ops;
375 snd_seq_kinstr_list_t *ilist;
377 snd_trident_voice_t voices[64];
379 int ChanSynthCount; /* number of allocated synth channels */
380 int max_size; /* maximum synth memory size in bytes */
381 int current_size; /* current allocated synth mem in bytes */
384 struct _snd_trident_pcm_mixer {
385 snd_trident_voice_t *voice; /* active voice */
386 unsigned short vol; /* front volume */
387 unsigned char pan; /* pan control */
388 unsigned char rvol; /* rear volume */
389 unsigned char cvol; /* center volume */
390 unsigned char pad;
393 struct _snd_trident {
394 int irq;
396 unsigned int device; /* device ID */
398 unsigned char bDMAStart;
400 unsigned long port;
401 unsigned long midi_port;
403 unsigned int spurious_irq_count;
404 unsigned int spurious_irq_max_delta;
406 snd_trident_tlb_t tlb; /* TLB entries for NX cards */
408 unsigned char spdif_ctrl;
409 unsigned char spdif_pcm_ctrl;
410 unsigned int spdif_bits;
411 unsigned int spdif_pcm_bits;
412 snd_kcontrol_t *spdif_pcm_ctl; /* S/PDIF settings */
413 unsigned int ac97_ctrl;
415 unsigned int ChanMap[2]; /* allocation map for hardware channels */
417 int ChanPCM; /* max number of PCM channels */
418 int ChanPCMcnt; /* actual number of PCM channels */
420 unsigned int ac97_detect: 1; /* 1 = AC97 in detection phase */
421 unsigned int in_suspend: 1; /* 1 during suspend/resume */
423 struct _snd_4dwave synth; /* synth specific variables */
425 spinlock_t event_lock;
426 spinlock_t voice_alloc;
428 struct snd_dma_device dma_dev;
430 struct pci_dev *pci;
431 snd_card_t *card;
432 snd_pcm_t *pcm; /* ADC/DAC PCM */
433 snd_pcm_t *foldback; /* Foldback PCM */
434 snd_pcm_t *spdif; /* SPDIF PCM */
435 snd_rawmidi_t *rmidi;
436 snd_seq_device_t *seq_dev;
438 ac97_bus_t *ac97_bus;
439 ac97_t *ac97;
440 ac97_t *ac97_sec;
442 unsigned int musicvol_wavevol;
443 snd_trident_pcm_mixer_t pcm_mixer[32];
444 snd_kcontrol_t *ctl_vol; /* front volume */
445 snd_kcontrol_t *ctl_pan; /* pan */
446 snd_kcontrol_t *ctl_rvol; /* rear volume */
447 snd_kcontrol_t *ctl_cvol; /* center volume */
449 spinlock_t reg_lock;
451 struct gameport *gameport;
454 int snd_trident_create(snd_card_t * card,
455 struct pci_dev *pci,
456 int pcm_streams,
457 int pcm_spdif_device,
458 int max_wavetable_size,
459 trident_t ** rtrident);
460 int snd_trident_create_gameport(trident_t *trident);
462 int snd_trident_pcm(trident_t * trident, int device, snd_pcm_t **rpcm);
463 int snd_trident_foldback_pcm(trident_t * trident, int device, snd_pcm_t **rpcm);
464 int snd_trident_spdif_pcm(trident_t * trident, int device, snd_pcm_t **rpcm);
465 int snd_trident_attach_synthesizer(trident_t * trident);
466 snd_trident_voice_t *snd_trident_alloc_voice(trident_t * trident, int type, int client, int port);
467 void snd_trident_free_voice(trident_t * trident, snd_trident_voice_t *voice);
468 void snd_trident_start_voice(trident_t * trident, unsigned int voice);
469 void snd_trident_stop_voice(trident_t * trident, unsigned int voice);
470 void snd_trident_write_voice_regs(trident_t * trident, snd_trident_voice_t *voice);
472 /* TLB memory allocation */
473 snd_util_memblk_t *snd_trident_alloc_pages(trident_t *trident, snd_pcm_substream_t *substream);
474 int snd_trident_free_pages(trident_t *trident, snd_util_memblk_t *blk);
475 snd_util_memblk_t *snd_trident_synth_alloc(trident_t *trident, unsigned int size);
476 int snd_trident_synth_free(trident_t *trident, snd_util_memblk_t *blk);
477 int snd_trident_synth_copy_from_user(trident_t *trident, snd_util_memblk_t *blk, int offset, const char __user *data, int size);
479 #endif /* __SOUND_TRIDENT_H */