blob: ad0365d6de5e3d7495345aa4c70ee1341ae4dcb7 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __SOUND_EMU8000_H
3#define __SOUND_EMU8000_H
4/*
5 * Defines for the emu8000 (AWE32/64)
6 *
7 * Copyright (C) 1999 Steve Ratcliffe
8 * Copyright (C) 1999-2000 Takashi Iwai <tiwai@suse.de>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 */
10
David Howellsa1ce3922012-10-02 18:01:25 +010011#include <sound/emux_synth.h>
12#include <sound/seq_kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14/*
15 * Hardware parameters.
16 */
17#define EMU8000_MAX_DRAM (28 * 1024 * 1024) /* Max on-board mem is 28Mb ???*/
18#define EMU8000_DRAM_OFFSET 0x200000 /* Beginning of on board ram */
19#define EMU8000_CHANNELS 32 /* Number of hardware channels */
20#define EMU8000_DRAM_VOICES 30 /* number of normal voices */
21
22/* Flags to set a dma channel to read or write */
23#define EMU8000_RAM_READ 0
24#define EMU8000_RAM_WRITE 1
25#define EMU8000_RAM_CLOSE 2
26#define EMU8000_RAM_MODE_MASK 0x03
27#define EMU8000_RAM_RIGHT 0x10 /* use 'right' DMA channel */
28
29enum {
30 EMU8000_CONTROL_BASS = 0,
31 EMU8000_CONTROL_TREBLE,
32 EMU8000_CONTROL_CHORUS_MODE,
33 EMU8000_CONTROL_REVERB_MODE,
34 EMU8000_CONTROL_FM_CHORUS_DEPTH,
35 EMU8000_CONTROL_FM_REVERB_DEPTH,
36 EMU8000_NUM_CONTROLS,
37};
38
39/*
40 * Structure to hold all state information for the emu8000 driver.
41 *
42 * Note 1: The chip supports 32 channels in hardware this is max_channels
43 * some of the channels may be used for other things so max_channels is
44 * the number in use for wave voices.
45 */
Takashi Iwai029d64b2005-11-17 14:34:36 +010046struct snd_emu8000 {
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Takashi Iwai029d64b2005-11-17 14:34:36 +010048 struct snd_emux *emu;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50 int index; /* sequencer client index */
51 int seq_ports; /* number of sequencer ports */
52 int fm_chorus_depth; /* FM OPL3 chorus depth */
53 int fm_reverb_depth; /* FM OPL3 reverb depth */
54
55 int mem_size; /* memory size */
56 unsigned long port1; /* Port usually base+0 */
57 unsigned long port2; /* Port usually at base+0x400 */
58 unsigned long port3; /* Port usually at base+0x800 */
59 struct resource *res_port1;
60 struct resource *res_port2;
61 struct resource *res_port3;
62 unsigned short last_reg;/* Last register command */
63 spinlock_t reg_lock;
64
65 int dram_checked;
66
Takashi Iwai029d64b2005-11-17 14:34:36 +010067 struct snd_card *card; /* The card that this belongs to */
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69 int chorus_mode;
70 int reverb_mode;
71 int bass_level;
72 int treble_level;
73
Takashi Iwai029d64b2005-11-17 14:34:36 +010074 struct snd_util_memhdr *memhdr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76 spinlock_t control_lock;
Takashi Iwai029d64b2005-11-17 14:34:36 +010077 struct snd_kcontrol *controls[EMU8000_NUM_CONTROLS];
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
Takashi Iwai029d64b2005-11-17 14:34:36 +010079 struct snd_pcm *pcm; /* pcm on emu8000 wavetable */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Takashi Iwai029d64b2005-11-17 14:34:36 +010081};
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83/* sequencer device id */
84#define SNDRV_SEQ_DEV_ID_EMU8000 "emu8000-synth"
85
86
87/* exported functions */
Takashi Iwai029d64b2005-11-17 14:34:36 +010088int snd_emu8000_new(struct snd_card *card, int device, long port, int seq_ports,
89 struct snd_seq_device **ret);
90void snd_emu8000_poke(struct snd_emu8000 *emu, unsigned int port, unsigned int reg,
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 unsigned int val);
Takashi Iwai029d64b2005-11-17 14:34:36 +010092unsigned short snd_emu8000_peek(struct snd_emu8000 *emu, unsigned int port,
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 unsigned int reg);
Takashi Iwai029d64b2005-11-17 14:34:36 +010094void snd_emu8000_poke_dw(struct snd_emu8000 *emu, unsigned int port, unsigned int reg,
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 unsigned int val);
Takashi Iwai029d64b2005-11-17 14:34:36 +010096unsigned int snd_emu8000_peek_dw(struct snd_emu8000 *emu, unsigned int port,
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 unsigned int reg);
Takashi Iwai029d64b2005-11-17 14:34:36 +010098void snd_emu8000_dma_chan(struct snd_emu8000 *emu, int ch, int mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
Takashi Iwai029d64b2005-11-17 14:34:36 +0100100void snd_emu8000_init_fm(struct snd_emu8000 *emu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
Takashi Iwai029d64b2005-11-17 14:34:36 +0100102void snd_emu8000_update_chorus_mode(struct snd_emu8000 *emu);
103void snd_emu8000_update_reverb_mode(struct snd_emu8000 *emu);
104void snd_emu8000_update_equalizer(struct snd_emu8000 *emu);
105int snd_emu8000_load_chorus_fx(struct snd_emu8000 *emu, int mode, const void __user *buf, long len);
106int snd_emu8000_load_reverb_fx(struct snd_emu8000 *emu, int mode, const void __user *buf, long len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108#endif /* __SOUND_EMU8000_H */