Blame view

include/sound/gus.h 20.2 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
  #ifndef __SOUND_GUS_H
  #define __SOUND_GUS_H
  
  /*
   *  Global structures used for GUS part of ALSA driver
c1017a4cd   Jaroslav Kysela   [ALSA] Changed Ja...
6
   *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
   *
   *
   *   This program is free software; you can redistribute it and/or modify
   *   it under the terms of the GNU General Public License as published by
   *   the Free Software Foundation; either version 2 of the License, or
   *   (at your option) any later version.
   *
   *   This program is distributed in the hope that it will be useful,
   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *   GNU General Public License for more details.
   *
   *   You should have received a copy of the GNU General Public License
   *   along with this program; if not, write to the Free Software
   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
   *
   */
  
  #include "pcm.h"
  #include "rawmidi.h"
  #include "timer.h"
  #include "seq_midi_emul.h"
  #include "seq_device.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30
  #include <asm/io.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  /* IO ports */
  
  #define GUSP(gus, x)			((gus)->gf1.port + SNDRV_g_u_s_##x)
  
  #define SNDRV_g_u_s_MIDICTRL		(0x320-0x220)
  #define SNDRV_g_u_s_MIDISTAT		(0x320-0x220)
  #define SNDRV_g_u_s_MIDIDATA		(0x321-0x220)
  
  #define SNDRV_g_u_s_GF1PAGE		(0x322-0x220)
  #define SNDRV_g_u_s_GF1REGSEL		(0x323-0x220)
  #define SNDRV_g_u_s_GF1DATALOW		(0x324-0x220)
  #define SNDRV_g_u_s_GF1DATAHIGH		(0x325-0x220)
  #define SNDRV_g_u_s_IRQSTAT		(0x226-0x220)
  #define SNDRV_g_u_s_TIMERCNTRL		(0x228-0x220)
  #define SNDRV_g_u_s_TIMERDATA		(0x229-0x220)
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
46
  #define SNDRV_g_u_s_DRAM		(0x327-0x220)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47
48
49
  #define SNDRV_g_u_s_MIXCNTRLREG		(0x220-0x220)
  #define SNDRV_g_u_s_IRQDMACNTRLREG	(0x22b-0x220)
  #define SNDRV_g_u_s_REGCNTRLS		(0x22f-0x220)
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
50
51
52
  #define SNDRV_g_u_s_BOARDVERSION	(0x726-0x220)
  #define SNDRV_g_u_s_MIXCNTRLPORT	(0x726-0x220)
  #define SNDRV_g_u_s_IVER		(0x325-0x220)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
53
  #define SNDRV_g_u_s_MIXDATAPORT		(0x326-0x220)
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
54
  #define SNDRV_g_u_s_MAXCNTRLPORT	(0x326-0x220)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
55
56
57
58
59
60
  
  /* GF1 registers */
  
  /* global registers */
  #define SNDRV_GF1_GB_ACTIVE_VOICES		0x0e
  #define SNDRV_GF1_GB_VOICES_IRQ			0x0f
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
61
  #define SNDRV_GF1_GB_GLOBAL_MODE		0x19
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62
63
64
  #define SNDRV_GF1_GW_LFO_BASE			0x1a
  #define SNDRV_GF1_GB_VOICES_IRQ_READ		0x1f
  #define SNDRV_GF1_GB_DRAM_DMA_CONTROL		0x41
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
65
66
67
  #define SNDRV_GF1_GW_DRAM_DMA_LOW		0x42
  #define SNDRV_GF1_GW_DRAM_IO_LOW		0x43
  #define SNDRV_GF1_GB_DRAM_IO_HIGH		0x44
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68
69
70
  #define SNDRV_GF1_GB_SOUND_BLASTER_CONTROL	0x45
  #define SNDRV_GF1_GB_ADLIB_TIMER_1		0x46
  #define SNDRV_GF1_GB_ADLIB_TIMER_2		0x47
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
71
  #define SNDRV_GF1_GB_RECORD_RATE		0x48
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
72
73
74
75
76
77
78
79
  #define SNDRV_GF1_GB_REC_DMA_CONTROL		0x49
  #define SNDRV_GF1_GB_JOYSTICK_DAC_LEVEL		0x4b
  #define SNDRV_GF1_GB_RESET			0x4c
  #define SNDRV_GF1_GB_DRAM_DMA_HIGH		0x50
  #define SNDRV_GF1_GW_DRAM_IO16			0x51
  #define SNDRV_GF1_GW_MEMORY_CONFIG		0x52
  #define SNDRV_GF1_GB_MEMORY_CONTROL		0x53
  #define SNDRV_GF1_GW_FIFO_RECORD_BASE_ADDR	0x54
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
80
  #define SNDRV_GF1_GW_FIFO_PLAY_BASE_ADDR	0x55
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
  #define SNDRV_GF1_GW_FIFO_SIZE			0x56
  #define SNDRV_GF1_GW_INTERLEAVE			0x57
  #define SNDRV_GF1_GB_COMPATIBILITY		0x59
  #define SNDRV_GF1_GB_DECODE_CONTROL		0x5a
  #define SNDRV_GF1_GB_VERSION_NUMBER		0x5b
  #define SNDRV_GF1_GB_MPU401_CONTROL_A		0x5c
  #define SNDRV_GF1_GB_MPU401_CONTROL_B		0x5d
  #define SNDRV_GF1_GB_EMULATION_IRQ		0x60
  /* voice specific registers */
  #define SNDRV_GF1_VB_ADDRESS_CONTROL		0x00
  #define SNDRV_GF1_VW_FREQUENCY			0x01
  #define SNDRV_GF1_VW_START_HIGH			0x02
  #define SNDRV_GF1_VW_START_LOW			0x03
  #define SNDRV_GF1_VA_START			SNDRV_GF1_VW_START_HIGH
  #define SNDRV_GF1_VW_END_HIGH			0x04
  #define SNDRV_GF1_VW_END_LOW			0x05
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
97
98
99
  #define SNDRV_GF1_VA_END			SNDRV_GF1_VW_END_HIGH
  #define SNDRV_GF1_VB_VOLUME_RATE		0x06
  #define SNDRV_GF1_VB_VOLUME_START		0x07
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
101
  #define SNDRV_GF1_VB_VOLUME_END			0x08
  #define SNDRV_GF1_VW_VOLUME			0x09
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
102
103
  #define SNDRV_GF1_VW_CURRENT_HIGH		0x0a
  #define SNDRV_GF1_VW_CURRENT_LOW		0x0b
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
104
  #define SNDRV_GF1_VA_CURRENT			SNDRV_GF1_VW_CURRENT_HIGH
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
105
106
  #define SNDRV_GF1_VB_PAN			0x0c
  #define SNDRV_GF1_VW_OFFSET_RIGHT		0x0c
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
108
  #define SNDRV_GF1_VB_VOLUME_CONTROL		0x0d
  #define SNDRV_GF1_VB_UPPER_ADDRESS		0x10
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
109
  #define SNDRV_GF1_VW_EFFECT_HIGH		0x11
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
111
  #define SNDRV_GF1_VW_EFFECT_LOW			0x12
  #define SNDRV_GF1_VA_EFFECT			SNDRV_GF1_VW_EFFECT_HIGH
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
112
113
114
  #define SNDRV_GF1_VW_OFFSET_LEFT		0x13
  #define SNDRV_GF1_VB_ACCUMULATOR		0x14
  #define SNDRV_GF1_VB_MODE			0x15
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
115
116
117
118
119
  #define SNDRV_GF1_VW_EFFECT_VOLUME		0x16
  #define SNDRV_GF1_VB_FREQUENCY_LFO		0x17
  #define SNDRV_GF1_VB_VOLUME_LFO			0x18
  #define SNDRV_GF1_VW_OFFSET_RIGHT_FINAL		0x1b
  #define SNDRV_GF1_VW_OFFSET_LEFT_FINAL		0x1c
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
120
  #define SNDRV_GF1_VW_EFFECT_VOLUME_FINAL	0x1d
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
121
122
123
124
  
  /* ICS registers */
  
  #define SNDRV_ICS_MIC_DEV		0
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
125
  #define SNDRV_ICS_LINE_DEV		1
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
126
127
  #define SNDRV_ICS_CD_DEV		2
  #define SNDRV_ICS_GF1_DEV		3
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
128
129
  #define SNDRV_ICS_NONE_DEV		4
  #define SNDRV_ICS_MASTER_DEV		5
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
130
131
132
133
134
135
136
137
138
139
  
  /* LFO */
  
  #define SNDRV_LFO_TREMOLO		0
  #define SNDRV_LFO_VIBRATO		1
  
  /* misc */
  
  #define SNDRV_GF1_DMA_UNSIGNED	0x80
  #define SNDRV_GF1_DMA_16BIT	0x40
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
140
  #define SNDRV_GF1_DMA_IRQ	0x20
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
141
142
143
144
145
146
147
148
149
150
151
152
153
154
  #define SNDRV_GF1_DMA_WIDTH16	0x04
  #define SNDRV_GF1_DMA_READ	0x02	/* read from GUS's DRAM */
  #define SNDRV_GF1_DMA_ENABLE	0x01
  
  /* ramp ranges */
  
  #define SNDRV_GF1_ATTEN(x)	(snd_gf1_atten_table[x])
  #define SNDRV_GF1_MIN_VOLUME	1800
  #define SNDRV_GF1_MAX_VOLUME	4095
  #define SNDRV_GF1_MIN_OFFSET	(SNDRV_GF1_MIN_VOLUME>>4)
  #define SNDRV_GF1_MAX_OFFSET	255
  #define SNDRV_GF1_MAX_TDEPTH	90
  
  /* defines for memory manager */
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
155
  #define SNDRV_GF1_MEM_BLOCK_16BIT	0x0001
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
156
157
158
159
160
161
162
163
164
  
  #define SNDRV_GF1_MEM_OWNER_DRIVER	0x0001
  #define SNDRV_GF1_MEM_OWNER_WAVE_SIMPLE	0x0002
  #define SNDRV_GF1_MEM_OWNER_WAVE_GF1	0x0003
  #define SNDRV_GF1_MEM_OWNER_WAVE_IWFFFF	0x0004
  
  /* constants for interrupt handlers */
  
  #define SNDRV_GF1_HANDLER_MIDI_OUT	0x00010000
bc1ff7fc0   Takashi Iwai   [ALSA] [Trivial] ...
165
166
167
  #define SNDRV_GF1_HANDLER_MIDI_IN	0x00020000
  #define SNDRV_GF1_HANDLER_TIMER1	0x00040000
  #define SNDRV_GF1_HANDLER_TIMER2	0x00080000
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
168
169
170
171
172
173
174
175
176
177
  #define SNDRV_GF1_HANDLER_VOICE		0x00100000
  #define SNDRV_GF1_HANDLER_DMA_WRITE	0x00200000
  #define SNDRV_GF1_HANDLER_DMA_READ	0x00400000
  #define SNDRV_GF1_HANDLER_ALL		(0xffff0000&~SNDRV_GF1_HANDLER_VOICE)
  
  /* constants for DMA flags */
  
  #define SNDRV_GF1_DMA_TRIGGER		1
  
  /* --- */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
178
  struct snd_gus_card;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
179
180
  
  /* GF1 specific structure */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
181
  struct snd_gf1_bank_info {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
182
183
  	unsigned int address;
  	unsigned int size;
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
184
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
185

5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
186
  struct snd_gf1_mem_block {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
187
188
189
190
191
192
193
  	unsigned short flags;	/* flags - SNDRV_GF1_MEM_BLOCK_XXXX */
  	unsigned short owner;	/* owner - SNDRV_GF1_MEM_OWNER_XXXX */
  	unsigned int share;	/* share count */
  	unsigned int share_id[4]; /* share ID */
  	unsigned int ptr;
  	unsigned int size;
  	char *name;
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
194
195
196
197
198
199
200
201
202
  	struct snd_gf1_mem_block *next;
  	struct snd_gf1_mem_block *prev;
  };
  
  struct snd_gf1_mem {
  	struct snd_gf1_bank_info banks_8[4];
  	struct snd_gf1_bank_info banks_16[4];
  	struct snd_gf1_mem_block *first;
  	struct snd_gf1_mem_block *last;
8b7547f95   Ingo Molnar   [ALSA] semaphore ...
203
  	struct mutex memory_mutex;
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
204
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
205

5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
206
  struct snd_gf1_dma_block {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
207
208
209
210
211
  	void *buffer;		/* buffer in computer's RAM */
  	unsigned long buf_addr;	/* buffer address */
  	unsigned int addr;	/* address in onboard memory */
  	unsigned int count;	/* count in bytes */
  	unsigned int cmd;	/* DMA command (format) */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
212
  	void (*ack)(struct snd_gus_card * gus, void *private_data);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
213
214
  	void *private_data;
  	struct snd_gf1_dma_block *next;
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
215
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
216

5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
217
218
219
  struct snd_gus_port {
  	struct snd_midi_channel_set * chset;
  	struct snd_gus_card * gus;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
220
221
222
223
  	int mode;		/* operation mode */
  	int client;		/* sequencer client number */
  	int port;		/* sequencer port number */
  	unsigned int midi_has_voices: 1;
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
224
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
225

5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
226
  struct snd_gus_voice;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
227

5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
228
  #define SNDRV_GF1_VOICE_TYPE_PCM	0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
229
  #define SNDRV_GF1_VOICE_TYPE_SYNTH 	1
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
230
  #define SNDRV_GF1_VOICE_TYPE_MIDI	2
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
231
232
233
234
  
  #define SNDRV_GF1_VFLG_RUNNING		(1<<0)
  #define SNDRV_GF1_VFLG_EFFECT_TIMER1	(1<<1)
  #define SNDRV_GF1_VFLG_PAN		(1<<2)
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
235
  enum snd_gus_volume_state {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
236
237
238
239
240
241
  	VENV_BEFORE,
  	VENV_ATTACK,
  	VENV_SUSTAIN,
  	VENV_RELEASE,
  	VENV_DONE,
  	VENV_VOLUME
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
242
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
243

5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
244
  struct snd_gus_voice {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
  	int number;
  	unsigned int use: 1,
  	    pcm: 1,
  	    synth:1,
  	    midi: 1;
  	unsigned int flags;
  	unsigned char client;
  	unsigned char port;
  	unsigned char index;
  	unsigned char pad;
  	
  #ifdef CONFIG_SND_DEBUG
  	unsigned int interrupt_stat_wave;
  	unsigned int interrupt_stat_volume;
  #endif
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
260
261
262
263
  	void (*handler_wave) (struct snd_gus_card * gus, struct snd_gus_voice * voice);
  	void (*handler_volume) (struct snd_gus_card * gus, struct snd_gus_voice * voice);
  	void (*handler_effect) (struct snd_gus_card * gus, struct snd_gus_voice * voice);
  	void (*volume_change) (struct snd_gus_card * gus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
264

5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
265
  	struct snd_gus_sample_ops *sample_ops;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
266

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
267
  	/* running status / registers */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
268
269
270
271
272
273
274
275
276
  	unsigned short fc_register;
  	unsigned short fc_lfo;
  	unsigned short gf1_volume;
  	unsigned char control;
  	unsigned char mode;
  	unsigned char gf1_pan;
  	unsigned char effect_accumulator;
  	unsigned char volume_control;
  	unsigned char venv_value_next;
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
277
278
  	enum snd_gus_volume_state venv_state;
  	enum snd_gus_volume_state venv_state_prev;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
279
280
281
282
283
284
285
  	unsigned short vlo;
  	unsigned short vro;
  	unsigned short gf1_effect_volume;
  	
  	/* --- */
  
  	void *private_data;
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
286
  	void (*private_free)(struct snd_gus_voice *voice);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
287
  };
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
288
  struct snd_gf1 {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
  
  	unsigned int enh_mode:1,	/* enhanced mode (GFA1) */
  		     hw_lfo:1,		/* use hardware LFO */
  		     sw_lfo:1,		/* use software LFO */
  		     effect:1;		/* use effect voices */
  
  	unsigned long port;		/* port of GF1 chip */
  	struct resource *res_port1;
  	struct resource *res_port2;
  	int irq;			/* IRQ number */
  	int dma1;			/* DMA1 number */
  	int dma2;			/* DMA2 number */
  	unsigned int memory;		/* GUS's DRAM size in bytes */
  	unsigned int rom_memory;	/* GUS's ROM size in bytes */
  	unsigned int rom_present;	/* bitmask */
  	unsigned int rom_banks;		/* GUS's ROM banks */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
305
  	struct snd_gf1_mem mem_alloc;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
  
  	/* registers */
  	unsigned short reg_page;
  	unsigned short reg_regsel;
  	unsigned short reg_data8;
  	unsigned short reg_data16;
  	unsigned short reg_irqstat;
  	unsigned short reg_dram;
  	unsigned short reg_timerctrl;
  	unsigned short reg_timerdata;
  	unsigned char ics_regs[6][2];
  	/* --------- */
  
  	unsigned char active_voices;	/* active voices */
  	unsigned char active_voice;	/* selected voice (GF1PAGE register) */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
321
  	struct snd_gus_voice voices[32];	/* GF1 voices */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
322
323
324
325
326
327
328
329
330
331
332
333
334
  
  	unsigned int default_voice_address;
  
  	unsigned short playback_freq;	/* GF1 playback (mixing) frequency */
  	unsigned short mode;		/* see to SNDRV_GF1_MODE_XXXX */
  	unsigned char volume_ramp;
  	unsigned char smooth_pan;
  	unsigned char full_range_pan;
  	unsigned char pad0;
  
  	unsigned char *lfos;
  
  	/* interrupt handlers */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
335
336
337
338
339
340
  	void (*interrupt_handler_midi_out) (struct snd_gus_card * gus);
  	void (*interrupt_handler_midi_in) (struct snd_gus_card * gus);
  	void (*interrupt_handler_timer1) (struct snd_gus_card * gus);
  	void (*interrupt_handler_timer2) (struct snd_gus_card * gus);
  	void (*interrupt_handler_dma_write) (struct snd_gus_card * gus);
  	void (*interrupt_handler_dma_read) (struct snd_gus_card * gus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
341
342
343
344
345
346
347
348
349
350
351
352
353
354
  
  #ifdef CONFIG_SND_DEBUG
  	unsigned int interrupt_stat_midi_out;
  	unsigned int interrupt_stat_midi_in;
  	unsigned int interrupt_stat_timer1;
  	unsigned int interrupt_stat_timer2;
  	unsigned int interrupt_stat_dma_write;
  	unsigned int interrupt_stat_dma_read;
  	unsigned int interrupt_stat_voice_lost;
  #endif
  
  	/* synthesizer */
  
  	int seq_client;
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
355
  	struct snd_gus_port seq_ports[4];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
356
357
358
359
  
  	/* timer */
  
  	unsigned short timer_enabled;
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
360
361
  	struct snd_timer *timer1;
  	struct snd_timer *timer2;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
362
363
364
365
366
367
368
369
370
371
372
  
  	/* midi */
  
  	unsigned short uart_cmd;
  	unsigned int uart_framing;
  	unsigned int uart_overrun;
  
  	/* dma operations */
  
  	unsigned int dma_flags;
  	unsigned int dma_shared;
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
373
374
375
376
377
  	struct snd_gf1_dma_block *dma_data_pcm;
  	struct snd_gf1_dma_block *dma_data_pcm_last;
  	struct snd_gf1_dma_block *dma_data_synth;
  	struct snd_gf1_dma_block *dma_data_synth_last;
  	void (*dma_ack)(struct snd_gus_card * gus, void *private_data);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
  	void *dma_private_data;
  
  	/* pcm */
  	int pcm_channels;
  	int pcm_alloc_voices;
          unsigned short pcm_volume_level_left;
  	unsigned short pcm_volume_level_right;
  	unsigned short pcm_volume_level_left1;
  	unsigned short pcm_volume_level_right1;
                                  
  	unsigned char pcm_rcntrl_reg;
  	unsigned char pad_end;
  };
  
  /* main structure for GUS card */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
393
394
  struct snd_gus_card {
  	struct snd_card *card;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
  
  	unsigned int
  	 initialized: 1,		/* resources were initialized */
  	 equal_irq:1,			/* GF1 and CODEC shares IRQ (GUS MAX only) */
  	 equal_dma:1,			/* if dma channels are equal (not valid for daughter board) */
  	 ics_flag:1,			/* have we ICS mixer chip */
  	 ics_flipped:1,			/* ICS mixer have flipped some channels? */
  	 codec_flag:1,			/* have we CODEC chip? */
  	 max_flag:1,			/* have we GUS MAX card? */
  	 max_ctrl_flag:1,		/* have we original GUS MAX card? */
  	 daughter_flag:1,		/* have we daughter board? */
  	 interwave:1,			/* hey - we have InterWave card */
  	 ess_flag:1,			/* ESS chip found... GUS Extreme */
  	 ace_flag:1,			/* GUS ACE detected */
  	 uart_enable:1;			/* enable MIDI UART */
  	unsigned short revision;	/* revision of chip */
  	unsigned short max_cntrl_val;	/* GUS MAX control value */
  	unsigned short mix_cntrl_reg;	/* mixer control register */
  	unsigned short joystick_dac;	/* joystick DAC level */
  	int timer_dev;			/* timer device */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
415
416
417
  	struct snd_gf1 gf1;	/* gf1 specific variables */
  	struct snd_pcm *pcm;
  	struct snd_pcm_substream *pcm_cap_substream;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
418
419
420
  	unsigned int c_dma_size;
  	unsigned int c_period_size;
  	unsigned int c_pos;
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
421
422
423
  	struct snd_rawmidi *midi_uart;
  	struct snd_rawmidi_substream *midi_substream_output;
  	struct snd_rawmidi_substream *midi_substream_input;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
424

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
425
426
427
428
429
430
431
  	spinlock_t reg_lock;
  	spinlock_t voice_alloc;
  	spinlock_t active_voice_lock;
  	spinlock_t event_lock;
  	spinlock_t dma_lock;
  	spinlock_t pcm_volume_level_lock;
  	spinlock_t uart_cmd_lock;
8b7547f95   Ingo Molnar   [ALSA] semaphore ...
432
433
  	struct mutex dma_mutex;
  	struct mutex register_mutex;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
434
435
436
  };
  
  /* I/O functions for GF1/InterWave chip - gus_io.c */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
437
  static inline void snd_gf1_select_voice(struct snd_gus_card * gus, int voice)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
438
439
440
441
442
443
444
445
446
447
  {
  	unsigned long flags;
  
  	spin_lock_irqsave(&gus->active_voice_lock, flags);
  	if (voice != gus->gf1.active_voice) {
  		gus->gf1.active_voice = voice;
  		outb(voice, GUSP(gus, GF1PAGE));
  	}
  	spin_unlock_irqrestore(&gus->active_voice_lock, flags);
  }
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
448
  static inline void snd_gf1_uart_cmd(struct snd_gus_card * gus, unsigned char b)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
449
450
451
  {
  	outb(gus->gf1.uart_cmd = b, GUSP(gus, MIDICTRL));
  }
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
452
  static inline unsigned char snd_gf1_uart_stat(struct snd_gus_card * gus)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
453
454
455
  {
  	return inb(GUSP(gus, MIDISTAT));
  }
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
456
  static inline void snd_gf1_uart_put(struct snd_gus_card * gus, unsigned char b)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
457
458
459
  {
  	outb(b, GUSP(gus, MIDIDATA));
  }
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
460
  static inline unsigned char snd_gf1_uart_get(struct snd_gus_card * gus)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
461
462
463
  {
  	return inb(GUSP(gus, MIDIDATA));
  }
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
464
  extern void snd_gf1_delay(struct snd_gus_card * gus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
465

5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
466
  extern void snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
467

5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
468
469
470
  extern void snd_gf1_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
  extern unsigned char snd_gf1_look8(struct snd_gus_card * gus, unsigned char reg);
  static inline unsigned char snd_gf1_read8(struct snd_gus_card * gus, unsigned char reg)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
471
472
473
  {
  	return snd_gf1_look8(gus, reg | 0x80);
  }
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
474
475
476
  extern void snd_gf1_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data);
  extern unsigned short snd_gf1_look16(struct snd_gus_card * gus, unsigned char reg);
  static inline unsigned short snd_gf1_read16(struct snd_gus_card * gus, unsigned char reg)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
477
478
479
  {
  	return snd_gf1_look16(gus, reg | 0x80);
  }
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
480
481
482
483
484
485
486
487
488
489
490
  extern void snd_gf1_adlib_write(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
  extern void snd_gf1_dram_addr(struct snd_gus_card * gus, unsigned int addr);
  extern void snd_gf1_poke(struct snd_gus_card * gus, unsigned int addr, unsigned char data);
  extern unsigned char snd_gf1_peek(struct snd_gus_card * gus, unsigned int addr);
  extern void snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg, unsigned int addr, short w_16bit);
  extern unsigned int snd_gf1_read_addr(struct snd_gus_card * gus, unsigned char reg, short w_16bit);
  extern void snd_gf1_i_ctrl_stop(struct snd_gus_card * gus, unsigned char reg);
  extern void snd_gf1_i_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
  extern unsigned char snd_gf1_i_look8(struct snd_gus_card * gus, unsigned char reg);
  extern void snd_gf1_i_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data);
  static inline unsigned char snd_gf1_i_read8(struct snd_gus_card * gus, unsigned char reg)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
491
492
493
  {
  	return snd_gf1_i_look8(gus, reg | 0x80);
  }
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
494
495
  extern unsigned short snd_gf1_i_look16(struct snd_gus_card * gus, unsigned char reg);
  static inline unsigned short snd_gf1_i_read16(struct snd_gus_card * gus, unsigned char reg)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
496
497
498
  {
  	return snd_gf1_i_look16(gus, reg | 0x80);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
499

5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
500
  extern void snd_gf1_select_active_voices(struct snd_gus_card * gus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
501
502
503
504
505
506
507
508
509
510
511
512
  
  /* gus_lfo.c */
  
  struct _SND_IW_LFO_PROGRAM {
  	unsigned short freq_and_control;
  	unsigned char depth_final;
  	unsigned char depth_inc;
  	unsigned short twave;
  	unsigned short depth;
  };
  
  #if 0
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
513
  extern irqreturn_t snd_gf1_lfo_effect_interrupt(struct snd_gus_card * gus, snd_gf1_voice_t * voice);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
514
  #endif
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
515
516
517
518
519
520
521
522
523
  extern void snd_gf1_lfo_init(struct snd_gus_card * gus);
  extern void snd_gf1_lfo_done(struct snd_gus_card * gus);
  extern void snd_gf1_lfo_program(struct snd_gus_card * gus, int voice, int lfo_type, struct _SND_IW_LFO_PROGRAM *program);
  extern void snd_gf1_lfo_enable(struct snd_gus_card * gus, int voice, int lfo_type);
  extern void snd_gf1_lfo_disable(struct snd_gus_card * gus, int voice, int lfo_type);
  extern void snd_gf1_lfo_change_freq(struct snd_gus_card * gus, int voice, int lfo_type, int freq);
  extern void snd_gf1_lfo_change_depth(struct snd_gus_card * gus, int voice, int lfo_type, int depth);
  extern void snd_gf1_lfo_setup(struct snd_gus_card * gus, int voice, int lfo_type, int freq, int current_depth, int depth, int sweep, int shape);
  extern void snd_gf1_lfo_shutdown(struct snd_gus_card * gus, int voice, int lfo_type);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
524
  #if 0
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
525
  extern void snd_gf1_lfo_command(struct snd_gus_card * gus, int voice, unsigned char *command);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
526
527
528
  #endif
  
  /* gus_mem.c */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
529
530
531
  void snd_gf1_mem_lock(struct snd_gf1_mem * alloc, int xup);
  int snd_gf1_mem_xfree(struct snd_gf1_mem * alloc, struct snd_gf1_mem_block * block);
  struct snd_gf1_mem_block *snd_gf1_mem_alloc(struct snd_gf1_mem * alloc, int owner,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
532
533
  				       char *name, int size, int w_16,
  				       int align, unsigned int *share_id);
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
534
535
536
537
  int snd_gf1_mem_free(struct snd_gf1_mem * alloc, unsigned int address);
  int snd_gf1_mem_free_owner(struct snd_gf1_mem * alloc, int owner);
  int snd_gf1_mem_init(struct snd_gus_card * gus);
  int snd_gf1_mem_done(struct snd_gus_card * gus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
538
539
  
  /* gus_mem_proc.c */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
540
  int snd_gf1_mem_proc_init(struct snd_gus_card * gus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
541
542
  
  /* gus_dma.c */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
543
544
545
546
  int snd_gf1_dma_init(struct snd_gus_card * gus);
  int snd_gf1_dma_done(struct snd_gus_card * gus);
  int snd_gf1_dma_transfer_block(struct snd_gus_card * gus,
  			       struct snd_gf1_dma_block * block,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
547
548
549
550
551
552
  			       int atomic,
  			       int synth);
  
  /* gus_volume.c */
  
  unsigned short snd_gf1_lvol_to_gvol_raw(unsigned int vol);
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
553
  unsigned short snd_gf1_translate_freq(struct snd_gus_card * gus, unsigned int freq2);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
554
555
  
  /* gus_reset.c */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
556
557
558
559
560
561
562
563
  void snd_gf1_set_default_handlers(struct snd_gus_card * gus, unsigned int what);
  void snd_gf1_smart_stop_voice(struct snd_gus_card * gus, unsigned short voice);
  void snd_gf1_stop_voice(struct snd_gus_card * gus, unsigned short voice);
  void snd_gf1_stop_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max);
  struct snd_gus_voice *snd_gf1_alloc_voice(struct snd_gus_card * gus, int type, int client, int port);
  void snd_gf1_free_voice(struct snd_gus_card * gus, struct snd_gus_voice *voice);
  int snd_gf1_start(struct snd_gus_card * gus);
  int snd_gf1_stop(struct snd_gus_card * gus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
564
565
  
  /* gus_mixer.c */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
566
  int snd_gf1_new_mixer(struct snd_gus_card * gus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
567
568
  
  /* gus_pcm.c */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
569
  int snd_gf1_pcm_new(struct snd_gus_card * gus, int pcm_dev, int control_index, struct snd_pcm ** rpcm);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
570
571
  
  #ifdef CONFIG_SND_DEBUG
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
572
  extern void snd_gf1_print_voice_registers(struct snd_gus_card * gus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
573
574
575
  #endif
  
  /* gus.c */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
576
577
578
  int snd_gus_use_inc(struct snd_gus_card * gus);
  void snd_gus_use_dec(struct snd_gus_card * gus);
  int snd_gus_create(struct snd_card *card,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
579
580
581
582
583
584
  		   unsigned long port,
  		   int irq, int dma1, int dma2,
  		   int timer_dev,
  		   int voices,
  		   int pcm_channels,
  		   int effect,
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
585
586
  		   struct snd_gus_card ** rgus);
  int snd_gus_initialize(struct snd_gus_card * gus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
587
588
  
  /* gus_irq.c */
7d12e780e   David Howells   IRQ: Maintain reg...
589
  irqreturn_t snd_gus_interrupt(int irq, void *dev_id);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
590
  #ifdef CONFIG_SND_DEBUG
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
591
  void snd_gus_irq_profile_init(struct snd_gus_card *gus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
592
593
594
  #endif
  
  /* gus_uart.c */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
595
  int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmidi **rrawmidi);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
596

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
597
  /* gus_dram.c */
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
598
  int snd_gus_dram_write(struct snd_gus_card *gus, char __user *ptr,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
599
  		       unsigned int addr, unsigned int size);
5e2da2064   Takashi Iwai   [ALSA] Remove xxx...
600
  int snd_gus_dram_read(struct snd_gus_card *gus, char __user *ptr,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
601
  		      unsigned int addr, unsigned int size, int rom);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
602
  #endif /* __SOUND_GUS_H */