Merge branch 'for-2.6.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux-2.6] / include / sound / gus.h
1 #ifndef __SOUND_GUS_H
2 #define __SOUND_GUS_H
3
4 /*
5  *  Global structures used for GUS part of ALSA driver
6  *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
7  *
8  *
9  *   This program is free software; you can redistribute it and/or modify
10  *   it under the terms of the GNU General Public License as published by
11  *   the Free Software Foundation; either version 2 of the License, or
12  *   (at your option) any later version.
13  *
14  *   This program is distributed in the hope that it will be useful,
15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *   GNU General Public License for more details.
18  *
19  *   You should have received a copy of the GNU General Public License
20  *   along with this program; if not, write to the Free Software
21  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22  *
23  */
24
25 #include "pcm.h"
26 #include "rawmidi.h"
27 #include "timer.h"
28 #include "seq_midi_emul.h"
29 #include "seq_device.h"
30 #include "ainstr_iw.h"
31 #include "ainstr_gf1.h"
32 #include "ainstr_simple.h"
33 #include <asm/io.h>
34
35 #define SNDRV_SEQ_DEV_ID_GUS                    "gus-synth"
36
37 /* IO ports */
38
39 #define GUSP(gus, x)                    ((gus)->gf1.port + SNDRV_g_u_s_##x)
40
41 #define SNDRV_g_u_s_MIDICTRL            (0x320-0x220)
42 #define SNDRV_g_u_s_MIDISTAT            (0x320-0x220)
43 #define SNDRV_g_u_s_MIDIDATA            (0x321-0x220)
44
45 #define SNDRV_g_u_s_GF1PAGE             (0x322-0x220)
46 #define SNDRV_g_u_s_GF1REGSEL           (0x323-0x220)
47 #define SNDRV_g_u_s_GF1DATALOW          (0x324-0x220)
48 #define SNDRV_g_u_s_GF1DATAHIGH         (0x325-0x220)
49 #define SNDRV_g_u_s_IRQSTAT             (0x226-0x220)
50 #define SNDRV_g_u_s_TIMERCNTRL          (0x228-0x220)
51 #define SNDRV_g_u_s_TIMERDATA           (0x229-0x220)
52 #define SNDRV_g_u_s_DRAM                (0x327-0x220)
53 #define SNDRV_g_u_s_MIXCNTRLREG         (0x220-0x220)
54 #define SNDRV_g_u_s_IRQDMACNTRLREG      (0x22b-0x220)
55 #define SNDRV_g_u_s_REGCNTRLS           (0x22f-0x220)
56 #define SNDRV_g_u_s_BOARDVERSION        (0x726-0x220)
57 #define SNDRV_g_u_s_MIXCNTRLPORT        (0x726-0x220)
58 #define SNDRV_g_u_s_IVER                (0x325-0x220)
59 #define SNDRV_g_u_s_MIXDATAPORT         (0x326-0x220)
60 #define SNDRV_g_u_s_MAXCNTRLPORT        (0x326-0x220)
61
62 /* GF1 registers */
63
64 /* global registers */
65 #define SNDRV_GF1_GB_ACTIVE_VOICES              0x0e
66 #define SNDRV_GF1_GB_VOICES_IRQ                 0x0f
67 #define SNDRV_GF1_GB_GLOBAL_MODE                0x19
68 #define SNDRV_GF1_GW_LFO_BASE                   0x1a
69 #define SNDRV_GF1_GB_VOICES_IRQ_READ            0x1f
70 #define SNDRV_GF1_GB_DRAM_DMA_CONTROL           0x41
71 #define SNDRV_GF1_GW_DRAM_DMA_LOW               0x42
72 #define SNDRV_GF1_GW_DRAM_IO_LOW                0x43
73 #define SNDRV_GF1_GB_DRAM_IO_HIGH               0x44
74 #define SNDRV_GF1_GB_SOUND_BLASTER_CONTROL      0x45
75 #define SNDRV_GF1_GB_ADLIB_TIMER_1              0x46
76 #define SNDRV_GF1_GB_ADLIB_TIMER_2              0x47
77 #define SNDRV_GF1_GB_RECORD_RATE                0x48
78 #define SNDRV_GF1_GB_REC_DMA_CONTROL            0x49
79 #define SNDRV_GF1_GB_JOYSTICK_DAC_LEVEL         0x4b
80 #define SNDRV_GF1_GB_RESET                      0x4c
81 #define SNDRV_GF1_GB_DRAM_DMA_HIGH              0x50
82 #define SNDRV_GF1_GW_DRAM_IO16                  0x51
83 #define SNDRV_GF1_GW_MEMORY_CONFIG              0x52
84 #define SNDRV_GF1_GB_MEMORY_CONTROL             0x53
85 #define SNDRV_GF1_GW_FIFO_RECORD_BASE_ADDR      0x54
86 #define SNDRV_GF1_GW_FIFO_PLAY_BASE_ADDR        0x55
87 #define SNDRV_GF1_GW_FIFO_SIZE                  0x56
88 #define SNDRV_GF1_GW_INTERLEAVE                 0x57
89 #define SNDRV_GF1_GB_COMPATIBILITY              0x59
90 #define SNDRV_GF1_GB_DECODE_CONTROL             0x5a
91 #define SNDRV_GF1_GB_VERSION_NUMBER             0x5b
92 #define SNDRV_GF1_GB_MPU401_CONTROL_A           0x5c
93 #define SNDRV_GF1_GB_MPU401_CONTROL_B           0x5d
94 #define SNDRV_GF1_GB_EMULATION_IRQ              0x60
95 /* voice specific registers */
96 #define SNDRV_GF1_VB_ADDRESS_CONTROL            0x00
97 #define SNDRV_GF1_VW_FREQUENCY                  0x01
98 #define SNDRV_GF1_VW_START_HIGH                 0x02
99 #define SNDRV_GF1_VW_START_LOW                  0x03
100 #define SNDRV_GF1_VA_START                      SNDRV_GF1_VW_START_HIGH
101 #define SNDRV_GF1_VW_END_HIGH                   0x04
102 #define SNDRV_GF1_VW_END_LOW                    0x05
103 #define SNDRV_GF1_VA_END                        SNDRV_GF1_VW_END_HIGH
104 #define SNDRV_GF1_VB_VOLUME_RATE                0x06
105 #define SNDRV_GF1_VB_VOLUME_START               0x07
106 #define SNDRV_GF1_VB_VOLUME_END                 0x08
107 #define SNDRV_GF1_VW_VOLUME                     0x09
108 #define SNDRV_GF1_VW_CURRENT_HIGH               0x0a
109 #define SNDRV_GF1_VW_CURRENT_LOW                0x0b
110 #define SNDRV_GF1_VA_CURRENT                    SNDRV_GF1_VW_CURRENT_HIGH
111 #define SNDRV_GF1_VB_PAN                        0x0c
112 #define SNDRV_GF1_VW_OFFSET_RIGHT               0x0c
113 #define SNDRV_GF1_VB_VOLUME_CONTROL             0x0d
114 #define SNDRV_GF1_VB_UPPER_ADDRESS              0x10
115 #define SNDRV_GF1_VW_EFFECT_HIGH                0x11
116 #define SNDRV_GF1_VW_EFFECT_LOW                 0x12
117 #define SNDRV_GF1_VA_EFFECT                     SNDRV_GF1_VW_EFFECT_HIGH
118 #define SNDRV_GF1_VW_OFFSET_LEFT                0x13
119 #define SNDRV_GF1_VB_ACCUMULATOR                0x14
120 #define SNDRV_GF1_VB_MODE                       0x15
121 #define SNDRV_GF1_VW_EFFECT_VOLUME              0x16
122 #define SNDRV_GF1_VB_FREQUENCY_LFO              0x17
123 #define SNDRV_GF1_VB_VOLUME_LFO                 0x18
124 #define SNDRV_GF1_VW_OFFSET_RIGHT_FINAL         0x1b
125 #define SNDRV_GF1_VW_OFFSET_LEFT_FINAL          0x1c
126 #define SNDRV_GF1_VW_EFFECT_VOLUME_FINAL        0x1d
127
128 /* ICS registers */
129
130 #define SNDRV_ICS_MIC_DEV               0
131 #define SNDRV_ICS_LINE_DEV              1
132 #define SNDRV_ICS_CD_DEV                2
133 #define SNDRV_ICS_GF1_DEV               3
134 #define SNDRV_ICS_NONE_DEV              4
135 #define SNDRV_ICS_MASTER_DEV            5
136
137 /* LFO */
138
139 #define SNDRV_LFO_TREMOLO               0
140 #define SNDRV_LFO_VIBRATO               1
141
142 /* misc */
143
144 #define SNDRV_GF1_DMA_UNSIGNED  0x80
145 #define SNDRV_GF1_DMA_16BIT     0x40
146 #define SNDRV_GF1_DMA_IRQ       0x20
147 #define SNDRV_GF1_DMA_WIDTH16   0x04
148 #define SNDRV_GF1_DMA_READ      0x02    /* read from GUS's DRAM */
149 #define SNDRV_GF1_DMA_ENABLE    0x01
150
151 /* ramp ranges */
152
153 #define SNDRV_GF1_ATTEN(x)      (snd_gf1_atten_table[x])
154 #define SNDRV_GF1_MIN_VOLUME    1800
155 #define SNDRV_GF1_MAX_VOLUME    4095
156 #define SNDRV_GF1_MIN_OFFSET    (SNDRV_GF1_MIN_VOLUME>>4)
157 #define SNDRV_GF1_MAX_OFFSET    255
158 #define SNDRV_GF1_MAX_TDEPTH    90
159
160 /* defines for memory manager */
161
162 #define SNDRV_GF1_MEM_BLOCK_16BIT       0x0001
163
164 #define SNDRV_GF1_MEM_OWNER_DRIVER      0x0001
165 #define SNDRV_GF1_MEM_OWNER_WAVE_SIMPLE 0x0002
166 #define SNDRV_GF1_MEM_OWNER_WAVE_GF1    0x0003
167 #define SNDRV_GF1_MEM_OWNER_WAVE_IWFFFF 0x0004
168
169 /* constants for interrupt handlers */
170
171 #define SNDRV_GF1_HANDLER_MIDI_OUT      0x00010000
172 #define SNDRV_GF1_HANDLER_MIDI_IN       0x00020000
173 #define SNDRV_GF1_HANDLER_TIMER1        0x00040000
174 #define SNDRV_GF1_HANDLER_TIMER2        0x00080000
175 #define SNDRV_GF1_HANDLER_VOICE         0x00100000
176 #define SNDRV_GF1_HANDLER_DMA_WRITE     0x00200000
177 #define SNDRV_GF1_HANDLER_DMA_READ      0x00400000
178 #define SNDRV_GF1_HANDLER_ALL           (0xffff0000&~SNDRV_GF1_HANDLER_VOICE)
179
180 /* constants for DMA flags */
181
182 #define SNDRV_GF1_DMA_TRIGGER           1
183
184 /* --- */
185
186 struct snd_gus_card;
187
188 /* GF1 specific structure */
189
190 struct snd_gf1_bank_info {
191         unsigned int address;
192         unsigned int size;
193 };
194
195 struct snd_gf1_mem_block {
196         unsigned short flags;   /* flags - SNDRV_GF1_MEM_BLOCK_XXXX */
197         unsigned short owner;   /* owner - SNDRV_GF1_MEM_OWNER_XXXX */
198         unsigned int share;     /* share count */
199         unsigned int share_id[4]; /* share ID */
200         unsigned int ptr;
201         unsigned int size;
202         char *name;
203         struct snd_gf1_mem_block *next;
204         struct snd_gf1_mem_block *prev;
205 };
206
207 struct snd_gf1_mem {
208         struct snd_gf1_bank_info banks_8[4];
209         struct snd_gf1_bank_info banks_16[4];
210         struct snd_gf1_mem_block *first;
211         struct snd_gf1_mem_block *last;
212         struct mutex memory_mutex;
213 };
214
215 struct snd_gf1_dma_block {
216         void *buffer;           /* buffer in computer's RAM */
217         unsigned long buf_addr; /* buffer address */
218         unsigned int addr;      /* address in onboard memory */
219         unsigned int count;     /* count in bytes */
220         unsigned int cmd;       /* DMA command (format) */
221         void (*ack)(struct snd_gus_card * gus, void *private_data);
222         void *private_data;
223         struct snd_gf1_dma_block *next;
224 };
225
226 struct snd_gus_port {
227         struct snd_midi_channel_set * chset;
228         struct snd_gus_card * gus;
229         int mode;               /* operation mode */
230         int client;             /* sequencer client number */
231         int port;               /* sequencer port number */
232         unsigned int midi_has_voices: 1;
233 };
234
235 struct snd_gus_voice;
236
237 struct snd_gus_sample_ops {
238         void (*sample_start)(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position);
239         void (*sample_stop)(struct snd_gus_card *gus, struct snd_gus_voice *voice, int mode);
240         void (*sample_freq)(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_frequency_t freq);
241         void (*sample_volume)(struct snd_gus_card *gus, struct snd_gus_voice *voice, struct snd_seq_ev_volume *volume);
242         void (*sample_loop)(struct snd_gus_card *card, struct snd_gus_voice *voice, struct snd_seq_ev_loop *loop);
243         void (*sample_pos)(struct snd_gus_card *card, struct snd_gus_voice *voice, snd_seq_position_t position);
244         void (*sample_private1)(struct snd_gus_card *card, struct snd_gus_voice *voice, unsigned char *data);
245 };
246
247 #define SNDRV_GF1_VOICE_TYPE_PCM        0
248 #define SNDRV_GF1_VOICE_TYPE_SYNTH      1
249 #define SNDRV_GF1_VOICE_TYPE_MIDI       2
250
251 #define SNDRV_GF1_VFLG_RUNNING          (1<<0)
252 #define SNDRV_GF1_VFLG_EFFECT_TIMER1    (1<<1)
253 #define SNDRV_GF1_VFLG_PAN              (1<<2)
254
255 enum snd_gus_volume_state {
256         VENV_BEFORE,
257         VENV_ATTACK,
258         VENV_SUSTAIN,
259         VENV_RELEASE,
260         VENV_DONE,
261         VENV_VOLUME
262 };
263
264 struct snd_gus_voice {
265         int number;
266         unsigned int use: 1,
267             pcm: 1,
268             synth:1,
269             midi: 1;
270         unsigned int flags;
271         unsigned char client;
272         unsigned char port;
273         unsigned char index;
274         unsigned char pad;
275         
276 #ifdef CONFIG_SND_DEBUG
277         unsigned int interrupt_stat_wave;
278         unsigned int interrupt_stat_volume;
279 #endif
280         void (*handler_wave) (struct snd_gus_card * gus, struct snd_gus_voice * voice);
281         void (*handler_volume) (struct snd_gus_card * gus, struct snd_gus_voice * voice);
282         void (*handler_effect) (struct snd_gus_card * gus, struct snd_gus_voice * voice);
283         void (*volume_change) (struct snd_gus_card * gus);
284
285         struct snd_gus_sample_ops *sample_ops;
286
287         struct snd_seq_instr instr;
288
289         /* running status / registers */
290
291         struct snd_seq_ev_volume sample_volume;
292
293         unsigned short fc_register;
294         unsigned short fc_lfo;
295         unsigned short gf1_volume;
296         unsigned char control;
297         unsigned char mode;
298         unsigned char gf1_pan;
299         unsigned char effect_accumulator;
300         unsigned char volume_control;
301         unsigned char venv_value_next;
302         enum snd_gus_volume_state venv_state;
303         enum snd_gus_volume_state venv_state_prev;
304         unsigned short vlo;
305         unsigned short vro;
306         unsigned short gf1_effect_volume;
307         
308         /* --- */
309
310         void *private_data;
311         void (*private_free)(struct snd_gus_voice *voice);
312 };
313
314 struct snd_gf1 {
315
316         unsigned int enh_mode:1,        /* enhanced mode (GFA1) */
317                      hw_lfo:1,          /* use hardware LFO */
318                      sw_lfo:1,          /* use software LFO */
319                      effect:1;          /* use effect voices */
320
321         unsigned long port;             /* port of GF1 chip */
322         struct resource *res_port1;
323         struct resource *res_port2;
324         int irq;                        /* IRQ number */
325         int dma1;                       /* DMA1 number */
326         int dma2;                       /* DMA2 number */
327         unsigned int memory;            /* GUS's DRAM size in bytes */
328         unsigned int rom_memory;        /* GUS's ROM size in bytes */
329         unsigned int rom_present;       /* bitmask */
330         unsigned int rom_banks;         /* GUS's ROM banks */
331
332         struct snd_gf1_mem mem_alloc;
333
334         /* registers */
335         unsigned short reg_page;
336         unsigned short reg_regsel;
337         unsigned short reg_data8;
338         unsigned short reg_data16;
339         unsigned short reg_irqstat;
340         unsigned short reg_dram;
341         unsigned short reg_timerctrl;
342         unsigned short reg_timerdata;
343         unsigned char ics_regs[6][2];
344         /* --------- */
345
346         unsigned char active_voices;    /* active voices */
347         unsigned char active_voice;     /* selected voice (GF1PAGE register) */
348
349         struct snd_gus_voice voices[32];        /* GF1 voices */
350
351         unsigned int default_voice_address;
352
353         unsigned short playback_freq;   /* GF1 playback (mixing) frequency */
354         unsigned short mode;            /* see to SNDRV_GF1_MODE_XXXX */
355         unsigned char volume_ramp;
356         unsigned char smooth_pan;
357         unsigned char full_range_pan;
358         unsigned char pad0;
359
360         unsigned char *lfos;
361
362         /* interrupt handlers */
363
364         void (*interrupt_handler_midi_out) (struct snd_gus_card * gus);
365         void (*interrupt_handler_midi_in) (struct snd_gus_card * gus);
366         void (*interrupt_handler_timer1) (struct snd_gus_card * gus);
367         void (*interrupt_handler_timer2) (struct snd_gus_card * gus);
368         void (*interrupt_handler_dma_write) (struct snd_gus_card * gus);
369         void (*interrupt_handler_dma_read) (struct snd_gus_card * gus);
370
371 #ifdef CONFIG_SND_DEBUG
372         unsigned int interrupt_stat_midi_out;
373         unsigned int interrupt_stat_midi_in;
374         unsigned int interrupt_stat_timer1;
375         unsigned int interrupt_stat_timer2;
376         unsigned int interrupt_stat_dma_write;
377         unsigned int interrupt_stat_dma_read;
378         unsigned int interrupt_stat_voice_lost;
379 #endif
380
381         /* synthesizer */
382
383         int seq_client;
384         struct snd_gus_port seq_ports[4];
385         struct snd_seq_kinstr_list *ilist;
386         struct snd_iwffff_ops iwffff_ops;
387         struct snd_gf1_ops gf1_ops;
388         struct snd_simple_ops simple_ops;
389
390         /* timer */
391
392         unsigned short timer_enabled;
393         struct snd_timer *timer1;
394         struct snd_timer *timer2;
395
396         /* midi */
397
398         unsigned short uart_cmd;
399         unsigned int uart_framing;
400         unsigned int uart_overrun;
401
402         /* dma operations */
403
404         unsigned int dma_flags;
405         unsigned int dma_shared;
406         struct snd_gf1_dma_block *dma_data_pcm;
407         struct snd_gf1_dma_block *dma_data_pcm_last;
408         struct snd_gf1_dma_block *dma_data_synth;
409         struct snd_gf1_dma_block *dma_data_synth_last;
410         void (*dma_ack)(struct snd_gus_card * gus, void *private_data);
411         void *dma_private_data;
412
413         /* pcm */
414         int pcm_channels;
415         int pcm_alloc_voices;
416         unsigned short pcm_volume_level_left;
417         unsigned short pcm_volume_level_right;
418         unsigned short pcm_volume_level_left1;
419         unsigned short pcm_volume_level_right1;
420                                 
421         unsigned char pcm_rcntrl_reg;
422         unsigned char pad_end;
423 };
424
425 /* main structure for GUS card */
426
427 struct snd_gus_card {
428         struct snd_card *card;
429
430         unsigned int
431          initialized: 1,                /* resources were initialized */
432          equal_irq:1,                   /* GF1 and CODEC shares IRQ (GUS MAX only) */
433          equal_dma:1,                   /* if dma channels are equal (not valid for daughter board) */
434          ics_flag:1,                    /* have we ICS mixer chip */
435          ics_flipped:1,                 /* ICS mixer have flipped some channels? */
436          codec_flag:1,                  /* have we CODEC chip? */
437          max_flag:1,                    /* have we GUS MAX card? */
438          max_ctrl_flag:1,               /* have we original GUS MAX card? */
439          daughter_flag:1,               /* have we daughter board? */
440          interwave:1,                   /* hey - we have InterWave card */
441          ess_flag:1,                    /* ESS chip found... GUS Extreme */
442          ace_flag:1,                    /* GUS ACE detected */
443          uart_enable:1;                 /* enable MIDI UART */
444         unsigned short revision;        /* revision of chip */
445         unsigned short max_cntrl_val;   /* GUS MAX control value */
446         unsigned short mix_cntrl_reg;   /* mixer control register */
447         unsigned short joystick_dac;    /* joystick DAC level */
448         int timer_dev;                  /* timer device */
449
450         struct snd_gf1 gf1;     /* gf1 specific variables */
451         struct snd_pcm *pcm;
452         struct snd_pcm_substream *pcm_cap_substream;
453         unsigned int c_dma_size;
454         unsigned int c_period_size;
455         unsigned int c_pos;
456
457         struct snd_rawmidi *midi_uart;
458         struct snd_rawmidi_substream *midi_substream_output;
459         struct snd_rawmidi_substream *midi_substream_input;
460
461         struct snd_seq_device *seq_dev;
462
463         spinlock_t reg_lock;
464         spinlock_t voice_alloc;
465         spinlock_t active_voice_lock;
466         spinlock_t event_lock;
467         spinlock_t dma_lock;
468         spinlock_t pcm_volume_level_lock;
469         spinlock_t uart_cmd_lock;
470         struct mutex dma_mutex;
471         struct mutex register_mutex;
472 };
473
474 /* I/O functions for GF1/InterWave chip - gus_io.c */
475
476 static inline void snd_gf1_select_voice(struct snd_gus_card * gus, int voice)
477 {
478         unsigned long flags;
479
480         spin_lock_irqsave(&gus->active_voice_lock, flags);
481         if (voice != gus->gf1.active_voice) {
482                 gus->gf1.active_voice = voice;
483                 outb(voice, GUSP(gus, GF1PAGE));
484         }
485         spin_unlock_irqrestore(&gus->active_voice_lock, flags);
486 }
487
488 static inline void snd_gf1_uart_cmd(struct snd_gus_card * gus, unsigned char b)
489 {
490         outb(gus->gf1.uart_cmd = b, GUSP(gus, MIDICTRL));
491 }
492
493 static inline unsigned char snd_gf1_uart_stat(struct snd_gus_card * gus)
494 {
495         return inb(GUSP(gus, MIDISTAT));
496 }
497
498 static inline void snd_gf1_uart_put(struct snd_gus_card * gus, unsigned char b)
499 {
500         outb(b, GUSP(gus, MIDIDATA));
501 }
502
503 static inline unsigned char snd_gf1_uart_get(struct snd_gus_card * gus)
504 {
505         return inb(GUSP(gus, MIDIDATA));
506 }
507
508 extern void snd_gf1_delay(struct snd_gus_card * gus);
509
510 extern void snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg);
511
512 extern void snd_gf1_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
513 extern unsigned char snd_gf1_look8(struct snd_gus_card * gus, unsigned char reg);
514 static inline unsigned char snd_gf1_read8(struct snd_gus_card * gus, unsigned char reg)
515 {
516         return snd_gf1_look8(gus, reg | 0x80);
517 }
518 extern void snd_gf1_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data);
519 extern unsigned short snd_gf1_look16(struct snd_gus_card * gus, unsigned char reg);
520 static inline unsigned short snd_gf1_read16(struct snd_gus_card * gus, unsigned char reg)
521 {
522         return snd_gf1_look16(gus, reg | 0x80);
523 }
524 extern void snd_gf1_adlib_write(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
525 extern void snd_gf1_dram_addr(struct snd_gus_card * gus, unsigned int addr);
526 extern void snd_gf1_poke(struct snd_gus_card * gus, unsigned int addr, unsigned char data);
527 extern unsigned char snd_gf1_peek(struct snd_gus_card * gus, unsigned int addr);
528 extern void snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg, unsigned int addr, short w_16bit);
529 extern unsigned int snd_gf1_read_addr(struct snd_gus_card * gus, unsigned char reg, short w_16bit);
530 extern void snd_gf1_i_ctrl_stop(struct snd_gus_card * gus, unsigned char reg);
531 extern void snd_gf1_i_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data);
532 extern unsigned char snd_gf1_i_look8(struct snd_gus_card * gus, unsigned char reg);
533 extern void snd_gf1_i_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data);
534 static inline unsigned char snd_gf1_i_read8(struct snd_gus_card * gus, unsigned char reg)
535 {
536         return snd_gf1_i_look8(gus, reg | 0x80);
537 }
538 extern unsigned short snd_gf1_i_look16(struct snd_gus_card * gus, unsigned char reg);
539 static inline unsigned short snd_gf1_i_read16(struct snd_gus_card * gus, unsigned char reg)
540 {
541         return snd_gf1_i_look16(gus, reg | 0x80);
542 }
543
544 extern void snd_gf1_select_active_voices(struct snd_gus_card * gus);
545
546 /* gus_lfo.c */
547
548 struct _SND_IW_LFO_PROGRAM {
549         unsigned short freq_and_control;
550         unsigned char depth_final;
551         unsigned char depth_inc;
552         unsigned short twave;
553         unsigned short depth;
554 };
555
556 #if 0
557 extern irqreturn_t snd_gf1_lfo_effect_interrupt(struct snd_gus_card * gus, snd_gf1_voice_t * voice);
558 #endif
559 extern void snd_gf1_lfo_init(struct snd_gus_card * gus);
560 extern void snd_gf1_lfo_done(struct snd_gus_card * gus);
561 extern void snd_gf1_lfo_program(struct snd_gus_card * gus, int voice, int lfo_type, struct _SND_IW_LFO_PROGRAM *program);
562 extern void snd_gf1_lfo_enable(struct snd_gus_card * gus, int voice, int lfo_type);
563 extern void snd_gf1_lfo_disable(struct snd_gus_card * gus, int voice, int lfo_type);
564 extern void snd_gf1_lfo_change_freq(struct snd_gus_card * gus, int voice, int lfo_type, int freq);
565 extern void snd_gf1_lfo_change_depth(struct snd_gus_card * gus, int voice, int lfo_type, int depth);
566 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);
567 extern void snd_gf1_lfo_shutdown(struct snd_gus_card * gus, int voice, int lfo_type);
568 #if 0
569 extern void snd_gf1_lfo_command(struct snd_gus_card * gus, int voice, unsigned char *command);
570 #endif
571
572 /* gus_mem.c */
573
574 void snd_gf1_mem_lock(struct snd_gf1_mem * alloc, int xup);
575 int snd_gf1_mem_xfree(struct snd_gf1_mem * alloc, struct snd_gf1_mem_block * block);
576 struct snd_gf1_mem_block *snd_gf1_mem_alloc(struct snd_gf1_mem * alloc, int owner,
577                                        char *name, int size, int w_16,
578                                        int align, unsigned int *share_id);
579 int snd_gf1_mem_free(struct snd_gf1_mem * alloc, unsigned int address);
580 int snd_gf1_mem_free_owner(struct snd_gf1_mem * alloc, int owner);
581 int snd_gf1_mem_init(struct snd_gus_card * gus);
582 int snd_gf1_mem_done(struct snd_gus_card * gus);
583
584 /* gus_mem_proc.c */
585
586 int snd_gf1_mem_proc_init(struct snd_gus_card * gus);
587
588 /* gus_dma.c */
589
590 int snd_gf1_dma_init(struct snd_gus_card * gus);
591 int snd_gf1_dma_done(struct snd_gus_card * gus);
592 int snd_gf1_dma_transfer_block(struct snd_gus_card * gus,
593                                struct snd_gf1_dma_block * block,
594                                int atomic,
595                                int synth);
596
597 /* gus_volume.c */
598
599 unsigned short snd_gf1_lvol_to_gvol_raw(unsigned int vol);
600 unsigned short snd_gf1_translate_freq(struct snd_gus_card * gus, unsigned int freq2);
601
602 /* gus_reset.c */
603
604 void snd_gf1_set_default_handlers(struct snd_gus_card * gus, unsigned int what);
605 void snd_gf1_smart_stop_voice(struct snd_gus_card * gus, unsigned short voice);
606 void snd_gf1_stop_voice(struct snd_gus_card * gus, unsigned short voice);
607 void snd_gf1_stop_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max);
608 struct snd_gus_voice *snd_gf1_alloc_voice(struct snd_gus_card * gus, int type, int client, int port);
609 void snd_gf1_free_voice(struct snd_gus_card * gus, struct snd_gus_voice *voice);
610 int snd_gf1_start(struct snd_gus_card * gus);
611 int snd_gf1_stop(struct snd_gus_card * gus);
612
613 /* gus_mixer.c */
614
615 int snd_gf1_new_mixer(struct snd_gus_card * gus);
616
617 /* gus_pcm.c */
618
619 int snd_gf1_pcm_new(struct snd_gus_card * gus, int pcm_dev, int control_index, struct snd_pcm ** rpcm);
620
621 #ifdef CONFIG_SND_DEBUG
622 extern void snd_gf1_print_voice_registers(struct snd_gus_card * gus);
623 #endif
624
625 /* gus.c */
626
627 int snd_gus_use_inc(struct snd_gus_card * gus);
628 void snd_gus_use_dec(struct snd_gus_card * gus);
629 int snd_gus_create(struct snd_card *card,
630                    unsigned long port,
631                    int irq, int dma1, int dma2,
632                    int timer_dev,
633                    int voices,
634                    int pcm_channels,
635                    int effect,
636                    struct snd_gus_card ** rgus);
637 int snd_gus_initialize(struct snd_gus_card * gus);
638
639 /* gus_irq.c */
640
641 irqreturn_t snd_gus_interrupt(int irq, void *dev_id);
642 #ifdef CONFIG_SND_DEBUG
643 void snd_gus_irq_profile_init(struct snd_gus_card *gus);
644 #endif
645
646 /* gus_uart.c */
647
648 int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmidi **rrawmidi);
649
650 #if 0
651 extern void snd_engine_instrument_register(unsigned short mode,
652                 struct _SND_INSTRUMENT_VOICE_COMMANDS *voice_cmds,
653                 struct _SND_INSTRUMENT_NOTE_COMMANDS *note_cmds,
654                 struct _SND_INSTRUMENT_CHANNEL_COMMANDS *channel_cmds);
655 extern int snd_engine_instrument_register_ask(unsigned short mode);
656 #endif
657
658 /* gus_dram.c */
659 int snd_gus_dram_write(struct snd_gus_card *gus, char __user *ptr,
660                        unsigned int addr, unsigned int size);
661 int snd_gus_dram_read(struct snd_gus_card *gus, char __user *ptr,
662                       unsigned int addr, unsigned int size, int rom);
663
664 #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
665
666 /* gus_sample.c */
667 void snd_gus_sample_event(struct snd_seq_event *ev, struct snd_gus_port *p);
668
669 /* gus_simple.c */
670 void snd_gf1_simple_init(struct snd_gus_voice *voice);
671
672 /* gus_instr.c */
673 int snd_gus_iwffff_put_sample(void *private_data, struct iwffff_wave *wave,
674                               char __user *data, long len, int atomic);
675 int snd_gus_iwffff_get_sample(void *private_data, struct iwffff_wave *wave,
676                               char __user *data, long len, int atomic);
677 int snd_gus_iwffff_remove_sample(void *private_data, struct iwffff_wave *wave,
678                                  int atomic);
679 int snd_gus_gf1_put_sample(void *private_data, struct gf1_wave *wave,
680                            char __user *data, long len, int atomic);
681 int snd_gus_gf1_get_sample(void *private_data, struct gf1_wave *wave,
682                            char __user *data, long len, int atomic);
683 int snd_gus_gf1_remove_sample(void *private_data, struct gf1_wave *wave,
684                               int atomic);
685 int snd_gus_simple_put_sample(void *private_data, struct simple_instrument *instr,
686                               char __user *data, long len, int atomic);
687 int snd_gus_simple_get_sample(void *private_data, struct simple_instrument *instr,
688                               char __user *data, long len, int atomic);
689 int snd_gus_simple_remove_sample(void *private_data, struct simple_instrument *instr,
690                                  int atomic);
691
692 #endif /* CONFIG_SND_SEQUENCER */
693
694 #endif /* __SOUND_GUS_H */