1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #define DSP_RESET (devc->base + 0x6) 3 #define DSP_READ (devc->base + 0xA) 4 #define DSP_WRITE (devc->base + 0xC) 5 #define DSP_COMMAND (devc->base + 0xC) 6 #define DSP_STATUS (devc->base + 0xC) 7 #define DSP_DATA_AVAIL (devc->base + 0xE) 8 #define DSP_DATA_AVL16 (devc->base + 0xF) 9 #define MIXER_ADDR (devc->base + 0x4) 10 #define MIXER_DATA (devc->base + 0x5) 11 #define OPL3_LEFT (devc->base + 0x0) 12 #define OPL3_RIGHT (devc->base + 0x2) 13 #define OPL3_BOTH (devc->base + 0x8) 14 /* DSP Commands */ 15 16 #define DSP_CMD_SPKON 0xD1 17 #define DSP_CMD_SPKOFF 0xD3 18 #define DSP_CMD_DMAON 0xD0 19 #define DSP_CMD_DMAOFF 0xD4 20 21 #define IMODE_NONE 0 22 #define IMODE_OUTPUT PCM_ENABLE_OUTPUT 23 #define IMODE_INPUT PCM_ENABLE_INPUT 24 #define IMODE_INIT 3 25 #define IMODE_MIDI 4 26 27 #define NORMAL_MIDI 0 28 #define UART_MIDI 1 29 30 31 /* 32 * Device models 33 */ 34 #define MDL_NONE 0 35 #define MDL_SB1 1 /* SB1.0 or 1.5 */ 36 #define MDL_SB2 2 /* SB2.0 */ 37 #define MDL_SB201 3 /* SB2.01 */ 38 #define MDL_SBPRO 4 /* SB Pro */ 39 #define MDL_SB16 5 /* SB16/32/AWE */ 40 #define MDL_SBPNP 6 /* SB16/32/AWE PnP */ 41 #define MDL_JAZZ 10 /* Media Vision Jazz16 */ 42 #define MDL_SMW 11 /* Logitech SoundMan Wave (Jazz16) */ 43 #define MDL_ESS 12 /* ESS ES688 and ES1688 */ 44 #define MDL_AZTECH 13 /* Aztech Sound Galaxy family */ 45 #define MDL_ES1868MIDI 14 /* MIDI port of ESS1868 */ 46 #define MDL_AEDSP 15 /* Audio Excel DSP 16 */ 47 #define MDL_ESSPCI 16 /* ESS PCI card */ 48 #define MDL_YMPCI 17 /* Yamaha PCI sb in emulation */ 49 50 #define SUBMDL_ALS007 42 /* ALS-007 differs from SB16 only in mixer */ 51 /* register assignment */ 52 #define SUBMDL_ALS100 43 /* ALS-100 allows sampling rates of up */ 53 /* to 48kHz */ 54 55 /* 56 * Config flags 57 */ 58 #define SB_NO_MIDI 0x00000001 59 #define SB_NO_MIXER 0x00000002 60 #define SB_NO_AUDIO 0x00000004 61 #define SB_NO_RECORDING 0x00000008 /* No audio recording */ 62 #define SB_MIDI_ONLY (SB_NO_AUDIO|SB_NO_MIXER) 63 #define SB_PCI_IRQ 0x00000010 /* PCI shared IRQ */ 64 65 struct mixer_def { 66 unsigned int regno: 8; 67 unsigned int bitoffs:4; 68 unsigned int nbits:4; 69 }; 70 71 typedef struct mixer_def mixer_tab[32][2]; 72 typedef struct mixer_def mixer_ent; 73 74 struct sb_module_options 75 { 76 int esstype; /* ESS chip type */ 77 int acer; /* Do acer notebook init? */ 78 int sm_games; /* Logitech soundman games? */ 79 }; 80 81 typedef struct sb_devc { 82 int dev; 83 84 /* Hardware parameters */ 85 int *osp; 86 int minor, major; 87 int type; 88 int model, submodel; 89 int caps; 90 # define SBCAP_STEREO 0x00000001 91 # define SBCAP_16BITS 0x00000002 92 93 /* Hardware resources */ 94 int base; 95 int irq; 96 int dma8, dma16; 97 98 int pcibase; /* For ESS Maestro etc */ 99 100 /* State variables */ 101 int opened; 102 /* new audio fields for full duplex support */ 103 int fullduplex; 104 int duplex; 105 int speed, bits, channels; 106 volatile int irq_ok; 107 volatile int intr_active, irq_mode; 108 /* duplicate audio fields for full duplex support */ 109 volatile int intr_active_16, irq_mode_16; 110 111 /* Mixer fields */ 112 int *levels; 113 mixer_tab *iomap; 114 size_t iomap_sz; /* number or records in the iomap table */ 115 int mixer_caps, recmask, outmask, supported_devices; 116 int supported_rec_devices, supported_out_devices; 117 int my_mixerdev; 118 int sbmixnum; 119 120 /* Audio fields */ 121 unsigned long trg_buf; 122 int trigger_bits; 123 int trg_bytes; 124 int trg_intrflag; 125 int trg_restart; 126 /* duplicate audio fields for full duplex support */ 127 unsigned long trg_buf_16; 128 int trigger_bits_16; 129 int trg_bytes_16; 130 int trg_intrflag_16; 131 int trg_restart_16; 132 133 unsigned char tconst; 134 135 /* MIDI fields */ 136 int my_mididev; 137 int input_opened; 138 int midi_broken; 139 void (*midi_input_intr) (int dev, unsigned char data); 140 void *midi_irq_cookie; /* IRQ cookie for the midi */ 141 142 spinlock_t lock; 143 144 struct sb_module_options sbmo; /* Module options */ 145 146 } sb_devc; 147 148 /* 149 * PCI card types 150 */ 151 152 #define SB_PCI_ESSMAESTRO 1 /* ESS Maestro Legacy */ 153 #define SB_PCI_YAMAHA 2 /* Yamaha Legacy */ 154 155 /* 156 * Functions 157 */ 158 159 int sb_dsp_command (sb_devc *devc, unsigned char val); 160 int sb_dsp_get_byte(sb_devc * devc); 161 int sb_dsp_reset (sb_devc *devc); 162 void sb_setmixer (sb_devc *devc, unsigned int port, unsigned int value); 163 unsigned int sb_getmixer (sb_devc *devc, unsigned int port); 164 int sb_dsp_detect (struct address_info *hw_config, int pci, int pciio, struct sb_module_options *sbmo); 165 int sb_dsp_init (struct address_info *hw_config, struct module *owner); 166 void sb_dsp_unload(struct address_info *hw_config, int sbmpu); 167 int sb_mixer_init(sb_devc *devc, struct module *owner); 168 void sb_mixer_unload(sb_devc *devc); 169 void sb_mixer_set_stereo (sb_devc *devc, int mode); 170 void smw_mixer_init(sb_devc *devc); 171 void sb_dsp_midi_init (sb_devc *devc, struct module *owner); 172 void sb_audio_init (sb_devc *devc, char *name, struct module *owner); 173 void sb_midi_interrupt (sb_devc *devc); 174 void sb_chgmixer (sb_devc * devc, unsigned int reg, unsigned int mask, unsigned int val); 175 int sb_common_mixer_set(sb_devc * devc, int dev, int left, int right); 176 177 int sb_audio_open(int dev, int mode); 178 void sb_audio_close(int dev); 179 180 /* From sb_common.c */ 181 void sb_dsp_disable_midi(int port); 182 int probe_sbmpu (struct address_info *hw_config, struct module *owner); 183 void unload_sbmpu (struct address_info *hw_config); 184 185 void unload_sb16(struct address_info *hw_info); 186 void unload_sb16midi(struct address_info *hw_info); 187