5 * Global structures used for GUS part of ALSA driver
6 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
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.
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.
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
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"
35 #define SNDRV_SEQ_DEV_ID_GUS "gus-synth"
39 #define GUSP(gus, x) ((gus)->gf1.port + SNDRV_g_u_s_##x)
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)
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)
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
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
139 #define SNDRV_LFO_TREMOLO 0
140 #define SNDRV_LFO_VIBRATO 1
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
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
160 /* defines for memory manager */
162 #define SNDRV_GF1_MEM_BLOCK_16BIT 0x0001
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
169 /* constants for interrupt handlers */
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)
180 /* constants for DMA flags */
182 #define SNDRV_GF1_DMA_TRIGGER 1
186 struct _snd_gus_card
;
187 typedef struct _snd_gus_card snd_gus_card_t
;
189 /* GF1 specific structure */
191 typedef struct _snd_gf1_bank_info
{
192 unsigned int address
;
194 } snd_gf1_bank_info_t
;
196 typedef struct _snd_gf1_mem_block
{
197 unsigned short flags
; /* flags - SNDRV_GF1_MEM_BLOCK_XXXX */
198 unsigned short owner
; /* owner - SNDRV_GF1_MEM_OWNER_XXXX */
199 unsigned int share
; /* share count */
200 unsigned int share_id
[4]; /* share ID */
204 struct _snd_gf1_mem_block
*next
;
205 struct _snd_gf1_mem_block
*prev
;
206 } snd_gf1_mem_block_t
;
208 typedef struct _snd_gf1_mem
{
209 snd_gf1_bank_info_t banks_8
[4];
210 snd_gf1_bank_info_t banks_16
[4];
211 snd_gf1_mem_block_t
*first
;
212 snd_gf1_mem_block_t
*last
;
213 struct semaphore memory_mutex
;
216 typedef struct snd_gf1_dma_block
{
217 void *buffer
; /* buffer in computer's RAM */
218 unsigned long buf_addr
; /* buffer address */
219 unsigned int addr
; /* address in onboard memory */
220 unsigned int count
; /* count in bytes */
221 unsigned int cmd
; /* DMA command (format) */
222 void (*ack
)(snd_gus_card_t
* gus
, void *private_data
);
224 struct snd_gf1_dma_block
*next
;
225 } snd_gf1_dma_block_t
;
228 snd_midi_channel_set_t
* chset
;
229 snd_gus_card_t
* gus
;
230 int mode
; /* operation mode */
231 int client
; /* sequencer client number */
232 int port
; /* sequencer port number */
233 unsigned int midi_has_voices
: 1;
236 typedef struct _snd_gus_voice snd_gus_voice_t
;
239 void (*sample_start
)(snd_gus_card_t
*gus
, snd_gus_voice_t
*voice
, snd_seq_position_t position
);
240 void (*sample_stop
)(snd_gus_card_t
*gus
, snd_gus_voice_t
*voice
, snd_seq_stop_mode_t mode
);
241 void (*sample_freq
)(snd_gus_card_t
*gus
, snd_gus_voice_t
*voice
, snd_seq_frequency_t freq
);
242 void (*sample_volume
)(snd_gus_card_t
*gus
, snd_gus_voice_t
*voice
, snd_seq_ev_volume_t
*volume
);
243 void (*sample_loop
)(snd_gus_card_t
*card
, snd_gus_voice_t
*voice
, snd_seq_ev_loop_t
*loop
);
244 void (*sample_pos
)(snd_gus_card_t
*card
, snd_gus_voice_t
*voice
, snd_seq_position_t position
);
245 void (*sample_private1
)(snd_gus_card_t
*card
, snd_gus_voice_t
*voice
, unsigned char *data
);
246 } snd_gus_sample_ops_t
;
248 #define SNDRV_GF1_VOICE_TYPE_PCM 0
249 #define SNDRV_GF1_VOICE_TYPE_SYNTH 1
250 #define SNDRV_GF1_VOICE_TYPE_MIDI 2
252 #define SNDRV_GF1_VFLG_RUNNING (1<<0)
253 #define SNDRV_GF1_VFLG_EFFECT_TIMER1 (1<<1)
254 #define SNDRV_GF1_VFLG_PAN (1<<2)
263 } snd_gus_volume_state_t
;
265 struct _snd_gus_voice
{
272 unsigned char client
;
277 #ifdef CONFIG_SND_DEBUG
278 unsigned int interrupt_stat_wave
;
279 unsigned int interrupt_stat_volume
;
281 void (*handler_wave
) (snd_gus_card_t
* gus
, snd_gus_voice_t
* voice
);
282 void (*handler_volume
) (snd_gus_card_t
* gus
, snd_gus_voice_t
* voice
);
283 void (*handler_effect
) (snd_gus_card_t
* gus
, snd_gus_voice_t
* voice
);
284 void (*volume_change
) (snd_gus_card_t
* gus
);
286 snd_gus_sample_ops_t
*sample_ops
;
288 snd_seq_instr_t instr
;
290 /* running status / registers */
292 snd_seq_ev_volume_t sample_volume
;
294 unsigned short fc_register
;
295 unsigned short fc_lfo
;
296 unsigned short gf1_volume
;
297 unsigned char control
;
299 unsigned char gf1_pan
;
300 unsigned char effect_accumulator
;
301 unsigned char volume_control
;
302 unsigned char venv_value_next
;
303 snd_gus_volume_state_t venv_state
;
304 snd_gus_volume_state_t venv_state_prev
;
307 unsigned short gf1_effect_volume
;
312 void (*private_free
)(snd_gus_voice_t
*voice
);
317 unsigned int enh_mode
:1, /* enhanced mode (GFA1) */
318 hw_lfo
:1, /* use hardware LFO */
319 sw_lfo
:1, /* use software LFO */
320 effect
:1; /* use effect voices */
322 unsigned long port
; /* port of GF1 chip */
323 struct resource
*res_port1
;
324 struct resource
*res_port2
;
325 int irq
; /* IRQ number */
326 int dma1
; /* DMA1 number */
327 int dma2
; /* DMA2 number */
328 unsigned int memory
; /* GUS's DRAM size in bytes */
329 unsigned int rom_memory
; /* GUS's ROM size in bytes */
330 unsigned int rom_present
; /* bitmask */
331 unsigned int rom_banks
; /* GUS's ROM banks */
333 snd_gf1_mem_t mem_alloc
;
336 unsigned short reg_page
;
337 unsigned short reg_regsel
;
338 unsigned short reg_data8
;
339 unsigned short reg_data16
;
340 unsigned short reg_irqstat
;
341 unsigned short reg_dram
;
342 unsigned short reg_timerctrl
;
343 unsigned short reg_timerdata
;
344 unsigned char ics_regs
[6][2];
347 unsigned char active_voices
; /* active voices */
348 unsigned char active_voice
; /* selected voice (GF1PAGE register) */
350 snd_gus_voice_t voices
[32]; /* GF1 voices */
352 unsigned int default_voice_address
;
354 unsigned short playback_freq
; /* GF1 playback (mixing) frequency */
355 unsigned short mode
; /* see to SNDRV_GF1_MODE_XXXX */
356 unsigned char volume_ramp
;
357 unsigned char smooth_pan
;
358 unsigned char full_range_pan
;
363 /* interrupt handlers */
365 void (*interrupt_handler_midi_out
) (snd_gus_card_t
* gus
);
366 void (*interrupt_handler_midi_in
) (snd_gus_card_t
* gus
);
367 void (*interrupt_handler_timer1
) (snd_gus_card_t
* gus
);
368 void (*interrupt_handler_timer2
) (snd_gus_card_t
* gus
);
369 void (*interrupt_handler_dma_write
) (snd_gus_card_t
* gus
);
370 void (*interrupt_handler_dma_read
) (snd_gus_card_t
* gus
);
372 #ifdef CONFIG_SND_DEBUG
373 unsigned int interrupt_stat_midi_out
;
374 unsigned int interrupt_stat_midi_in
;
375 unsigned int interrupt_stat_timer1
;
376 unsigned int interrupt_stat_timer2
;
377 unsigned int interrupt_stat_dma_write
;
378 unsigned int interrupt_stat_dma_read
;
379 unsigned int interrupt_stat_voice_lost
;
385 snd_gus_port_t seq_ports
[4];
386 snd_seq_kinstr_list_t
*ilist
;
387 snd_iwffff_ops_t iwffff_ops
;
388 snd_gf1_ops_t gf1_ops
;
389 snd_simple_ops_t simple_ops
;
393 unsigned short timer_enabled
;
399 unsigned short uart_cmd
;
400 unsigned int uart_framing
;
401 unsigned int uart_overrun
;
405 unsigned int dma_flags
;
406 unsigned int dma_shared
;
407 snd_gf1_dma_block_t
*dma_data_pcm
;
408 snd_gf1_dma_block_t
*dma_data_pcm_last
;
409 snd_gf1_dma_block_t
*dma_data_synth
;
410 snd_gf1_dma_block_t
*dma_data_synth_last
;
411 void (*dma_ack
)(snd_gus_card_t
* gus
, void *private_data
);
412 void *dma_private_data
;
416 int pcm_alloc_voices
;
417 unsigned short pcm_volume_level_left
;
418 unsigned short pcm_volume_level_right
;
419 unsigned short pcm_volume_level_left1
;
420 unsigned short pcm_volume_level_right1
;
422 unsigned char pcm_rcntrl_reg
;
423 unsigned char pad_end
;
426 /* main structure for GUS card */
428 struct _snd_gus_card
{
432 initialized
: 1, /* resources were initialized */
433 equal_irq
:1, /* GF1 and CODEC shares IRQ (GUS MAX only) */
434 equal_dma
:1, /* if dma channels are equal (not valid for daughter board) */
435 ics_flag
:1, /* have we ICS mixer chip */
436 ics_flipped
:1, /* ICS mixer have flipped some channels? */
437 codec_flag
:1, /* have we CODEC chip? */
438 max_flag
:1, /* have we GUS MAX card? */
439 max_ctrl_flag
:1, /* have we original GUS MAX card? */
440 daughter_flag
:1, /* have we daughter board? */
441 interwave
:1, /* hey - we have InterWave card */
442 ess_flag
:1, /* ESS chip found... GUS Extreme */
443 ace_flag
:1, /* GUS ACE detected */
444 uart_enable
:1; /* enable MIDI UART */
445 unsigned short revision
; /* revision of chip */
446 unsigned short max_cntrl_val
; /* GUS MAX control value */
447 unsigned short mix_cntrl_reg
; /* mixer control register */
448 unsigned short joystick_dac
; /* joystick DAC level */
449 int timer_dev
; /* timer device */
451 struct _snd_gf1 gf1
; /* gf1 specific variables */
453 snd_pcm_substream_t
*pcm_cap_substream
;
454 unsigned int c_dma_size
;
455 unsigned int c_period_size
;
458 snd_rawmidi_t
*midi_uart
;
459 snd_rawmidi_substream_t
*midi_substream_output
;
460 snd_rawmidi_substream_t
*midi_substream_input
;
462 snd_seq_device_t
*seq_dev
;
465 spinlock_t voice_alloc
;
466 spinlock_t active_voice_lock
;
467 spinlock_t event_lock
;
469 spinlock_t pcm_volume_level_lock
;
470 spinlock_t uart_cmd_lock
;
471 struct semaphore dma_mutex
;
472 struct semaphore register_mutex
;
475 /* I/O functions for GF1/InterWave chip - gus_io.c */
477 static inline void snd_gf1_select_voice(snd_gus_card_t
* gus
, int voice
)
481 spin_lock_irqsave(&gus
->active_voice_lock
, flags
);
482 if (voice
!= gus
->gf1
.active_voice
) {
483 gus
->gf1
.active_voice
= voice
;
484 outb(voice
, GUSP(gus
, GF1PAGE
));
486 spin_unlock_irqrestore(&gus
->active_voice_lock
, flags
);
489 static inline void snd_gf1_uart_cmd(snd_gus_card_t
* gus
, unsigned char b
)
491 outb(gus
->gf1
.uart_cmd
= b
, GUSP(gus
, MIDICTRL
));
494 static inline unsigned char snd_gf1_uart_stat(snd_gus_card_t
* gus
)
496 return inb(GUSP(gus
, MIDISTAT
));
499 static inline void snd_gf1_uart_put(snd_gus_card_t
* gus
, unsigned char b
)
501 outb(b
, GUSP(gus
, MIDIDATA
));
504 static inline unsigned char snd_gf1_uart_get(snd_gus_card_t
* gus
)
506 return inb(GUSP(gus
, MIDIDATA
));
509 extern void snd_gf1_delay(snd_gus_card_t
* gus
);
511 extern void snd_gf1_ctrl_stop(snd_gus_card_t
* gus
, unsigned char reg
);
513 extern void snd_gf1_write8(snd_gus_card_t
* gus
, unsigned char reg
, unsigned char data
);
514 extern unsigned char snd_gf1_look8(snd_gus_card_t
* gus
, unsigned char reg
);
515 extern inline unsigned char snd_gf1_read8(snd_gus_card_t
* gus
, unsigned char reg
)
517 return snd_gf1_look8(gus
, reg
| 0x80);
519 extern void snd_gf1_write16(snd_gus_card_t
* gus
, unsigned char reg
, unsigned int data
);
520 extern unsigned short snd_gf1_look16(snd_gus_card_t
* gus
, unsigned char reg
);
521 extern inline unsigned short snd_gf1_read16(snd_gus_card_t
* gus
, unsigned char reg
)
523 return snd_gf1_look16(gus
, reg
| 0x80);
525 extern void snd_gf1_adlib_write(snd_gus_card_t
* gus
, unsigned char reg
, unsigned char data
);
526 extern void snd_gf1_dram_addr(snd_gus_card_t
* gus
, unsigned int addr
);
527 extern void snd_gf1_poke(snd_gus_card_t
* gus
, unsigned int addr
, unsigned char data
);
528 extern unsigned char snd_gf1_peek(snd_gus_card_t
* gus
, unsigned int addr
);
529 extern void snd_gf1_pokew(snd_gus_card_t
* gus
, unsigned int addr
, unsigned short data
);
530 extern unsigned short snd_gf1_peekw(snd_gus_card_t
* gus
, unsigned int addr
);
531 extern void snd_gf1_dram_setmem(snd_gus_card_t
* gus
, unsigned int addr
, unsigned short value
, unsigned int count
);
532 extern void snd_gf1_write_addr(snd_gus_card_t
* gus
, unsigned char reg
, unsigned int addr
, short w_16bit
);
533 extern unsigned int snd_gf1_read_addr(snd_gus_card_t
* gus
, unsigned char reg
, short w_16bit
);
534 extern void snd_gf1_i_ctrl_stop(snd_gus_card_t
* gus
, unsigned char reg
);
535 extern void snd_gf1_i_write8(snd_gus_card_t
* gus
, unsigned char reg
, unsigned char data
);
536 extern unsigned char snd_gf1_i_look8(snd_gus_card_t
* gus
, unsigned char reg
);
537 extern void snd_gf1_i_write16(snd_gus_card_t
* gus
, unsigned char reg
, unsigned int data
);
538 extern inline unsigned char snd_gf1_i_read8(snd_gus_card_t
* gus
, unsigned char reg
)
540 return snd_gf1_i_look8(gus
, reg
| 0x80);
542 extern unsigned short snd_gf1_i_look16(snd_gus_card_t
* gus
, unsigned char reg
);
543 extern inline unsigned short snd_gf1_i_read16(snd_gus_card_t
* gus
, unsigned char reg
)
545 return snd_gf1_i_look16(gus
, reg
| 0x80);
547 extern void snd_gf1_i_adlib_write(snd_gus_card_t
* gus
, unsigned char reg
, unsigned char data
);
548 extern void snd_gf1_i_write_addr(snd_gus_card_t
* gus
, unsigned char reg
, unsigned int addr
, short w_16bit
);
549 extern unsigned int snd_gf1_i_read_addr(snd_gus_card_t
* gus
, unsigned char reg
, short w_16bit
);
551 extern void snd_gf1_select_active_voices(snd_gus_card_t
* gus
);
555 struct _SND_IW_LFO_PROGRAM
{
556 unsigned short freq_and_control
;
557 unsigned char depth_final
;
558 unsigned char depth_inc
;
559 unsigned short twave
;
560 unsigned short depth
;
564 extern irqreturn_t
snd_gf1_lfo_effect_interrupt(snd_gus_card_t
* gus
, snd_gf1_voice_t
* voice
);
566 extern void snd_gf1_lfo_init(snd_gus_card_t
* gus
);
567 extern void snd_gf1_lfo_done(snd_gus_card_t
* gus
);
568 extern void snd_gf1_lfo_program(snd_gus_card_t
* gus
, int voice
, int lfo_type
, struct _SND_IW_LFO_PROGRAM
*program
);
569 extern void snd_gf1_lfo_enable(snd_gus_card_t
* gus
, int voice
, int lfo_type
);
570 extern void snd_gf1_lfo_disable(snd_gus_card_t
* gus
, int voice
, int lfo_type
);
571 extern void snd_gf1_lfo_change_freq(snd_gus_card_t
* gus
, int voice
, int lfo_type
, int freq
);
572 extern void snd_gf1_lfo_change_depth(snd_gus_card_t
* gus
, int voice
, int lfo_type
, int depth
);
573 extern void snd_gf1_lfo_setup(snd_gus_card_t
* gus
, int voice
, int lfo_type
, int freq
, int current_depth
, int depth
, int sweep
, int shape
);
574 extern void snd_gf1_lfo_shutdown(snd_gus_card_t
* gus
, int voice
, int lfo_type
);
576 extern void snd_gf1_lfo_command(snd_gus_card_t
* gus
, int voice
, unsigned char *command
);
581 void snd_gf1_mem_lock(snd_gf1_mem_t
* alloc
, int xup
);
582 int snd_gf1_mem_xfree(snd_gf1_mem_t
* alloc
, snd_gf1_mem_block_t
* block
);
583 snd_gf1_mem_block_t
*snd_gf1_mem_look(snd_gf1_mem_t
* alloc
,
584 unsigned int address
);
585 snd_gf1_mem_block_t
*snd_gf1_mem_share(snd_gf1_mem_t
* alloc
,
586 unsigned int *share_id
);
587 snd_gf1_mem_block_t
*snd_gf1_mem_alloc(snd_gf1_mem_t
* alloc
, int owner
,
588 char *name
, int size
, int w_16
,
589 int align
, unsigned int *share_id
);
590 int snd_gf1_mem_free(snd_gf1_mem_t
* alloc
, unsigned int address
);
591 int snd_gf1_mem_free_owner(snd_gf1_mem_t
* alloc
, int owner
);
592 int snd_gf1_mem_init(snd_gus_card_t
* gus
);
593 int snd_gf1_mem_done(snd_gus_card_t
* gus
);
597 int snd_gf1_mem_proc_init(snd_gus_card_t
* gus
);
601 int snd_gf1_dma_init(snd_gus_card_t
* gus
);
602 int snd_gf1_dma_done(snd_gus_card_t
* gus
);
603 int snd_gf1_dma_transfer_block(snd_gus_card_t
* gus
,
604 snd_gf1_dma_block_t
* block
,
610 unsigned short snd_gf1_lvol_to_gvol_raw(unsigned int vol
);
611 unsigned int snd_gf1_gvol_to_lvol_raw(unsigned short gf1_vol
);
612 unsigned int snd_gf1_calc_ramp_rate(snd_gus_card_t
* gus
,
613 unsigned short start
,
616 unsigned short snd_gf1_translate_freq(snd_gus_card_t
* gus
, unsigned int freq2
);
617 unsigned short snd_gf1_compute_pitchbend(unsigned short pitchbend
, unsigned short sens
);
618 unsigned short snd_gf1_compute_freq(unsigned int freq
,
620 unsigned short mix_rate
);
624 void snd_gf1_set_default_handlers(snd_gus_card_t
* gus
, unsigned int what
);
625 void snd_gf1_smart_stop_voice(snd_gus_card_t
* gus
, unsigned short voice
);
626 void snd_gf1_stop_voice(snd_gus_card_t
* gus
, unsigned short voice
);
627 void snd_gf1_clear_voices(snd_gus_card_t
* gus
, unsigned short v_min
, unsigned short v_max
);
628 void snd_gf1_stop_voices(snd_gus_card_t
* gus
, unsigned short v_min
, unsigned short v_max
);
629 snd_gus_voice_t
*snd_gf1_alloc_voice(snd_gus_card_t
* gus
, int type
, int client
, int port
);
630 void snd_gf1_free_voice(snd_gus_card_t
* gus
, snd_gus_voice_t
*voice
);
631 int snd_gf1_start(snd_gus_card_t
* gus
);
632 int snd_gf1_stop(snd_gus_card_t
* gus
);
636 int snd_gf1_new_mixer(snd_gus_card_t
* gus
);
640 int snd_gf1_pcm_new(snd_gus_card_t
* gus
, int pcm_dev
, int control_index
, snd_pcm_t
** rpcm
);
642 #ifdef CONFIG_SND_DEBUG
643 extern void snd_gf1_print_voice_registers(snd_gus_card_t
* gus
);
644 extern void snd_gf1_print_global_registers(snd_gus_card_t
* gus
);
645 extern void snd_gf1_print_setup_registers(snd_gus_card_t
* gus
);
646 extern void snd_gf1_peek_print_block(snd_gus_card_t
* gus
, unsigned int addr
, int count
, int w_16bit
);
651 int snd_gus_use_inc(snd_gus_card_t
* gus
);
652 void snd_gus_use_dec(snd_gus_card_t
* gus
);
653 int snd_gus_create(snd_card_t
* card
,
655 int irq
, int dma1
, int dma2
,
660 snd_gus_card_t
** rgus
);
661 int snd_gus_initialize(snd_gus_card_t
* gus
);
665 irqreturn_t
snd_gus_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
);
666 #ifdef CONFIG_SND_DEBUG
667 void snd_gus_irq_profile_init(snd_gus_card_t
*gus
);
672 int snd_gf1_rawmidi_new(snd_gus_card_t
* gus
, int device
, snd_rawmidi_t
**rrawmidi
);
675 extern void snd_engine_instrument_register(unsigned short mode
,
676 struct _SND_INSTRUMENT_VOICE_COMMANDS
*voice_cmds
,
677 struct _SND_INSTRUMENT_NOTE_COMMANDS
*note_cmds
,
678 struct _SND_INSTRUMENT_CHANNEL_COMMANDS
*channel_cmds
);
679 extern int snd_engine_instrument_register_ask(unsigned short mode
);
683 int snd_gus_dram_write(snd_gus_card_t
*gus
, char __user
*ptr
,
684 unsigned int addr
, unsigned int size
);
685 int snd_gus_dram_read(snd_gus_card_t
*gus
, char __user
*ptr
,
686 unsigned int addr
, unsigned int size
, int rom
);
688 #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
691 void snd_gus_sample_event(snd_seq_event_t
*ev
, snd_gus_port_t
*p
);
694 void snd_gf1_simple_init(snd_gus_voice_t
*voice
);
697 int snd_gus_iwffff_put_sample(void *private_data
, iwffff_wave_t
*wave
,
698 char __user
*data
, long len
, int atomic
);
699 int snd_gus_iwffff_get_sample(void *private_data
, iwffff_wave_t
*wave
,
700 char __user
*data
, long len
, int atomic
);
701 int snd_gus_iwffff_remove_sample(void *private_data
, iwffff_wave_t
*wave
,
703 int snd_gus_gf1_put_sample(void *private_data
, gf1_wave_t
*wave
,
704 char __user
*data
, long len
, int atomic
);
705 int snd_gus_gf1_get_sample(void *private_data
, gf1_wave_t
*wave
,
706 char __user
*data
, long len
, int atomic
);
707 int snd_gus_gf1_remove_sample(void *private_data
, gf1_wave_t
*wave
,
709 int snd_gus_simple_put_sample(void *private_data
, simple_instrument_t
*instr
,
710 char __user
*data
, long len
, int atomic
);
711 int snd_gus_simple_get_sample(void *private_data
, simple_instrument_t
*instr
,
712 char __user
*data
, long len
, int atomic
);
713 int snd_gus_simple_remove_sample(void *private_data
, simple_instrument_t
*instr
,
716 #endif /* CONFIG_SND_SEQUENCER */
718 #endif /* __SOUND_GUS_H */