1 #ifndef SB16_H 2 #define SB16_H 3 4 #include <minix/sound.h> 5 #include <minix/audio_fw.h> 6 7 #if DEBUG 8 #define Dprint(args) printf args 9 #else 10 #define Dprint(args) 11 #endif 12 13 #define AUDIO 0 14 #define MIXER 1 15 16 #define SB_TIMEOUT 32000 /* timeout count */ 17 18 /* IRQ, base address and DMA channels */ 19 #define SB_IRQ 7 20 #define SB_BASE_ADDR 0x220 /* 0x210, 0x220, 0x230, 0x240, 21 * 0x250, 0x260, 0x280 22 */ 23 #define SB_DMA_8 1 /* 0, 1, 3 */ 24 #define SB_DMA_16 5 /* 5, 6, 7 */ 25 26 /* Some defaults for the DSP */ 27 #define DEFAULT_SPEED 22050 /* Sample rate */ 28 #define DEFAULT_BITS 8 /* Nr. of bits */ 29 #define DEFAULT_SIGN 0 /* 0 = unsigned, 1 = signed */ 30 #define DEFAULT_STEREO 0 /* 0 = mono, 1 = stereo */ 31 32 /* DMA port addresses */ 33 #define DMA8_ADDR ((SB_DMA_8 & 3) << 1) + 0x00 34 #define DMA8_COUNT ((SB_DMA_8 & 3) << 1) + 0x01 35 #define DMA8_MASK 0x0A 36 #define DMA8_MODE 0x0B 37 #define DMA8_CLEAR 0x0C 38 39 40 /* If after this preprocessing stuff DMA8_PAGE is not defined 41 * the 8-bit DMA channel specified is not valid 42 */ 43 #if SB_DMA_8 == 0 44 # define DMA8_PAGE 0x87 45 #else 46 # if SB_DMA_8 == 1 47 # define DMA8_PAGE 0x83 48 # else 49 # if SB_DMA_8 == 3 50 # define DMA8_PAGE 0x82 51 # endif 52 # endif 53 #endif 54 55 56 #define DMA16_ADDR ((SB_DMA_16 & 3) << 2) + 0xC0 57 #define DMA16_COUNT ((SB_DMA_16 & 3) << 2) + 0xC2 58 #define DMA16_MASK 0xD4 59 #define DMA16_MODE 0xD6 60 #define DMA16_CLEAR 0xD8 61 62 63 /* If after this preprocessing stuff DMA16_PAGE is not defined 64 * the 16-bit DMA channel specified is not valid 65 */ 66 #if SB_DMA_16 == 5 67 # define DMA16_PAGE 0x8B 68 #else 69 # if SB_DMA_16 == 6 70 # define DMA16_PAGE 0x89 71 # else 72 # if SB_DMA_16 == 7 73 # define DMA16_PAGE 0x8A 74 # endif 75 # endif 76 #endif 77 78 79 /* DMA modes */ 80 #define DMA16_AUTO_PLAY 0x58 + (SB_DMA_16 & 3) 81 #define DMA16_AUTO_REC 0x54 + (SB_DMA_16 & 3) 82 #define DMA8_AUTO_PLAY 0x58 + SB_DMA_8 83 #define DMA8_AUTO_REC 0x54 + SB_DMA_8 84 85 86 /* IO ports for soundblaster */ 87 #define DSP_RESET 0x6 + SB_BASE_ADDR 88 #define DSP_READ 0xA + SB_BASE_ADDR 89 #define DSP_WRITE 0xC + SB_BASE_ADDR 90 #define DSP_COMMAND 0xC + SB_BASE_ADDR 91 #define DSP_STATUS 0xC + SB_BASE_ADDR 92 #define DSP_DATA_AVL 0xE + SB_BASE_ADDR 93 #define DSP_DATA16_AVL 0xF + SB_BASE_ADDR 94 #define MIXER_REG 0x4 + SB_BASE_ADDR 95 #define MIXER_DATA 0x5 + SB_BASE_ADDR 96 #define OPL3_LEFT 0x0 + SB_BASE_ADDR 97 #define OPL3_RIGHT 0x2 + SB_BASE_ADDR 98 #define OPL3_BOTH 0x8 + SB_BASE_ADDR 99 100 101 /* DSP Commands */ 102 #define DSP_INPUT_RATE 0x42 /* set input sample rate */ 103 #define DSP_OUTPUT_RATE 0x41 /* set output sample rate */ 104 #define DSP_CMD_SPKON 0xD1 /* set speaker on */ 105 #define DSP_CMD_SPKOFF 0xD3 /* set speaker off */ 106 #define DSP_CMD_DMA8HALT 0xD0 /* halt DMA 8-bit operation */ 107 #define DSP_CMD_DMA8CONT 0xD4 /* continue DMA 8-bit operation */ 108 #define DSP_CMD_DMA16HALT 0xD5 /* halt DMA 16-bit operation */ 109 #define DSP_CMD_DMA16CONT 0xD6 /* continue DMA 16-bit operation */ 110 #define DSP_GET_VERSION 0xE1 /* get version number of DSP */ 111 #define DSP_CMD_8BITAUTO_IN 0xCE /* 8 bit auto-initialized input */ 112 #define DSP_CMD_8BITAUTO_OUT 0xC6 /* 8 bit auto-initialized output */ 113 #define DSP_CMD_16BITAUTO_IN 0xBE /* 16 bit auto-initialized input */ 114 #define DSP_CMD_16BITAUTO_OUT 0xB6 /* 16 bit auto-initialized output */ 115 #define DSP_CMD_IRQREQ8 0xF2 /* Interrupt request 8 bit */ 116 #define DSP_CMD_IRQREQ16 0xF3 /* Interrupt request 16 bit */ 117 118 119 /* DSP Modes */ 120 #define DSP_MODE_MONO_US 0x00 /* Mono unsigned */ 121 #define DSP_MODE_MONO_S 0x10 /* Mono signed */ 122 #define DSP_MODE_STEREO_US 0x20 /* Stereo unsigned */ 123 #define DSP_MODE_STEREO_S 0x30 /* Stereo signed */ 124 125 126 /* MIXER commands */ 127 #define MIXER_RESET 0x00 /* Reset */ 128 #define MIXER_DAC_LEVEL 0x04 /* Used for detection only */ 129 #define MIXER_MASTER_LEFT 0x30 /* Master volume left */ 130 #define MIXER_MASTER_RIGHT 0x31 /* Master volume right */ 131 #define MIXER_DAC_LEFT 0x32 /* Dac level left */ 132 #define MIXER_DAC_RIGHT 0x33 /* Dac level right */ 133 #define MIXER_FM_LEFT 0x34 /* Fm level left */ 134 #define MIXER_FM_RIGHT 0x35 /* Fm level right */ 135 #define MIXER_CD_LEFT 0x36 /* Cd audio level left */ 136 #define MIXER_CD_RIGHT 0x37 /* Cd audio level right */ 137 #define MIXER_LINE_LEFT 0x38 /* Line in level left */ 138 #define MIXER_LINE_RIGHT 0x39 /* Line in level right */ 139 #define MIXER_MIC_LEVEL 0x3A /* Microphone level */ 140 #define MIXER_PC_LEVEL 0x3B /* Pc speaker level */ 141 #define MIXER_OUTPUT_CTRL 0x3C /* Output control */ 142 #define MIXER_IN_LEFT 0x3D /* Input control left */ 143 #define MIXER_IN_RIGHT 0x3E /* Input control right */ 144 #define MIXER_GAIN_IN_LEFT 0x3F /* Input gain control left */ 145 #define MIXER_GAIN_IN_RIGHT 0x40 /* Input gain control right */ 146 #define MIXER_GAIN_OUT_LEFT 0x41 /* Output gain control left */ 147 #define MIXER_GAIN_OUT_RIGHT 0x42 /* Output gain control rigth */ 148 #define MIXER_AGC 0x43 /* Automatic gain control */ 149 #define MIXER_TREBLE_LEFT 0x44 /* Treble left */ 150 #define MIXER_TREBLE_RIGHT 0x45 /* Treble right */ 151 #define MIXER_BASS_LEFT 0x46 /* Bass left */ 152 #define MIXER_BASS_RIGHT 0x47 /* Bass right */ 153 #define MIXER_SET_IRQ 0x80 /* Set irq number */ 154 #define MIXER_SET_DMA 0x81 /* Set DMA channels */ 155 #define MIXER_IRQ_STATUS 0x82 /* Irq status */ 156 157 /* Mixer constants */ 158 #define MIC 0x01 /* Microphone */ 159 #define CD_RIGHT 0x02 160 #define CD_LEFT 0x04 161 #define LINE_RIGHT 0x08 162 #define LINE_LEFT 0x10 163 #define FM_RIGHT 0x20 164 #define FM_LEFT 0x40 165 166 /* DSP constants */ 167 #define DSP_MAX_SPEED 44100 /* Max sample speed in KHz */ 168 #define DSP_MIN_SPEED 4000 /* Min sample speed in KHz */ 169 170 171 /* Number of bytes you can DMA before hitting a 64K boundary: */ 172 #define dma_bytes_left(phys) \ 173 ((unsigned) (sizeof(int) == 2 ? 0 : 0x10000) - (unsigned) ((phys) & 0xFFFF)) 174 175 int dsp_command(int value); 176 int sb16_inb(int port); 177 void sb16_outb(int port, int value); 178 179 #endif /* SB16_H */ 180