home *** CD-ROM | disk | FTP | other *** search
/ Shareware 1 2 the Maxx / sw_1.zip / sw_1 / PROGRAM / SBDOS10.ZIP / SB_REGS.H < prev    next >
Text File  |  1992-06-24  |  9KB  |  216 lines

  1. /*======================================================================
  2.  
  3.    [ This file is part of the SBMSDOS v1.0 distibution ]
  4.  
  5.    Michael Fulbright (msf@as.arizona.edu)
  6.  
  7.    This file was originally distributed by the fellow below, I'm
  8.    just borrowing it.
  9.  
  10.    =====================================================================
  11.    ORIGINAL HEADER FOLLOWS (msf)
  12.    =====================================================================
  13.  
  14.    Huge collection of SoundBlaster registers, flags, and such.
  15.    [ This file is a part of SBlast-BSD-1.4 ]
  16.  
  17.    Steve Haehnichen <shaehnic@ucsd.edu>
  18.  
  19.    $Id: sb_regs.h,v 1.9 1992/06/13 01:47:23 steve Exp steve $
  20.  
  21.    Copyright (C) 1992 Steve Haehnichen.
  22.  
  23.    This program is free software; you can redistribute it and/or modify
  24.    it under the terms of the GNU General Public License as published by
  25.    the Free Software Foundation; either version 1, or (at your option)
  26.    any later version.
  27.  
  28.    This program is distributed in the hope that it will be useful,
  29.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  30.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  31.    GNU General Public License for more details.
  32.  
  33.    You should have received a copy of the GNU General Public License
  34.    along with this program; if not, write to the Free Software
  35.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  36.  
  37.  * $Log: sb_regs.h,v $
  38.  * Revision 1.9  1992/06/13  01:47:23  steve
  39.  * Released in SBlast-BSD-1.4
  40.  
  41. ======================================================================*/
  42.  
  43. /*
  44.  * This is where you set the Sound Blaster DMA channel.
  45.  * Possible settings are 0, 1, and 3.  The card defaults to
  46.  * channel 1, which works just fine for me.
  47.  *
  48.  * The IRQ and I/O Port must be set in autoconf.c to match your card
  49.  * settings.  See the directions in INSTALL for details.
  50.  */
  51. #define SB_DMA_CHAN     1    /* 0, 1, or 3  (1 is factory default) */
  52.  
  53. /* Convenient byte masks */
  54. #define B1(x)    ((x) & 0x01)
  55. #define B2(x)    ((x) & 0x03)
  56. #define B3(x)    ((x) & 0x07)
  57. #define B4(x)    ((x) & 0x0f)
  58. #define B5(x)    ((x) & 0x1f)
  59. #define B6(x)    ((x) & 0x3f)
  60. #define B7(x)    ((x) & 0x7f)
  61. #define B8(x)    ((x) & 0xff)
  62. #define F(x)    (!!(x))        /* 0 or 1 only */
  63.  
  64. /*
  65.  * DMA registers & values. (Intel 8237: Direct Memory Access Controller)
  66.  */
  67.  
  68. /* Mask register: Send DMA_MASK to this register to suspend DMA on that
  69.  * channel, then DMA_UNMASK to allow transfers.  Generally, you
  70.  * send DMA_MASK as the first thing in the DMA setup, then UNMASK it last */
  71. #define DMA_MASK_REG     0x0A    /* Mask register */
  72. #define DMA_UNMASK    SB_DMA_CHAN
  73. #define DMA_MASK    (DMA_UNMASK | 0x04)
  74.  
  75. /* The DMA_MODE register selects a Read or Write DMA transfer. */
  76. #define DMA_MODE     0x0B    /* Mode register (read/write to card) */
  77. #define DMA_MODE_WRITE    (0x48 + SB_DMA_CHAN) /* DAC */
  78. #define DMA_MODE_READ   (0x44 + SB_DMA_CHAN) /* ADC */
  79.  
  80. /* This is a strange register.  Basically you just have to send
  81.  * a byte to it before writing the address.  (It sets the address
  82.  * state to LSB.)  Always send a 0x00 or anything else before 
  83.  * writing the address. */
  84. #define DMA_CLEAR    0x0C /* Send one byte before writing the address. */
  85.  
  86. /* This is where you send the address of the block of memory involved
  87.  * in the transfer.  This block may start anywhere in the Page, but
  88.  * the Count must not cross a 64K page boundary.   This is very important!
  89.  * Write 2 bytes (low byte first, followed by the high byte) for the
  90.  * least-significant 16 bits of the address. */
  91. #define DMA_ADDRESS     (SB_DMA_CHAN << 1)
  92.  
  93. /* Write 2 bytes, low byte first for the 16 bits of the count.
  94.    Note that one greater than this value will be copied!
  95.    (i.e. the biggest size is 0xFFFF, and 0x0000 would transfer one byte. */
  96. #define DMA_COUNT       (DMA_ADDRESS + 1)
  97.  
  98. /* The DMA_PAGE register gets bits 16-23 of the address.
  99.  * Combined with the LSB and MSB sent to the address register,
  100.  * This allows for a 16Meg addressing range.
  101.  * Note that the Page registers are not in any logical order, so you
  102.  * just have to pick the right one out of some table. */
  103. #ifndef SB_DMA_CHAN
  104. #  error "You must define SB_DMA_CHAN to be 0, 1, or 3!"
  105. #endif
  106.  
  107. #if SB_DMA_CHAN == 0
  108. #  define    DMA_PAGE    0x87
  109. #elif SB_DMA_CHAN == 1
  110. #  define    DMA_PAGE    0x83
  111. #elif SB_DMA_CHAN == 2
  112. #  define    DMA_PAGE    0x81 /* Not available to SB! */
  113. #elif SB_DMA_CHAN == 3
  114. #  define    DMA_PAGE    0x82
  115. #else
  116. #  error "You must define SB_DMA_CHAN to be 0, 1, or 3!"
  117. #endif
  118.  
  119.   
  120. /*  ---- Sound Blaster DSP values ---
  121.  *
  122.  * These are the card addresses where data may be read or written.
  123.  * status.addr is the base address of the card, as defined by 
  124.  * SB_IO_PORT above.  (I use status.addr in the kernel for flexibilty.)
  125.  * The typical settings are 0x220 or 0x240  (0x220 is the default)
  126.  * See the docs for an explanation of each register.
  127.  */
  128. #define DSP_RESET           (status.addr + 0x06) /* Pulse to reset DSP */
  129. #define DSP_RDDATA          (status.addr + 0x0A) /* Read data */
  130. #define DSP_WRDATA          (status.addr + 0x0C) /* Write data */
  131. #define DSP_COMMAND         (status.addr + 0x0C) /* Send command */
  132. #define DSP_STATUS          (status.addr + 0x0C) /* Read status */
  133. #define DSP_RDAVAIL         (status.addr + 0x0E) /* Data available */
  134.  
  135. /* Status bits:
  136.  * These are bits within the named readable registers that mean something. */
  137. #define DSP_BUSY        (1 << 7) /* STATUS flag indicates not ready */
  138. #define DSP_DATA_AVAIL        (1 << 7) /* RDAVAIL flag for data ready */
  139. #define DSP_READY        0xAA     /* RDDATA generated by a good reset */
  140.  
  141. /* DSP commands:
  142.  * These are the possible commands to send to the DSP via the DSP_COMMAND
  143.  * register.  See the docs for more detailed explanations. */
  144. #define SET_TIME_CONSTANT    0x40 /* Set the sampling rate (1 byte) */
  145. #define SPEAKER_ON        0xD1 /* Turn on DSP sound */
  146. #define SPEAKER_OFF        0xD3 /* Mute DSP voice output */
  147. #define READ_SPEAKER        0xD8 /* Read speaker status (00:OFF FF:ON) */
  148. #define HALT_DMA        0xD0 /* Pause the DMA transfer */
  149. #define CONT_DMA        0xD4 /* Continue paused DMA transfer */
  150. #define GET_VERSION        0xE1 /* Get the DSP major & minor versions */
  151.  
  152. #define HIGH_SPEED_SIZE        0x48 /* Set the HS block size. (LSB & MSB) */
  153. #define HS_DAC_8        0x91 /* Start High-Speed 8-bit DMA DAC */
  154. #define HS_ADC_8        0x99 /* Start High-Speed 8-bit DMA ADC */
  155.  
  156. #define SILENCE            0x80 /* Send a block of silence */
  157. #define DIRECT_DAC_8        0x10 /* For sending a single sample byte */
  158. #define DIRECT_ADC_8        0x20 /* For sampling a single byte */
  159.  
  160. /* Commands to start Low-Speed DMA transfers.
  161.    For the decompression modes, add one to get the command for
  162.    data with reference byte (first block of sample) */
  163. #define DAC_8            0x14 /* Start 8-bit DMA DAC */
  164. #define DAC_4            0x74 /* Start 4-bit DMA DAC */
  165. #define DAC_2_6            0x76 /* Start 2.6-bit DMA DAC */
  166. #define DAC_2            0x16 /* Start 2-bit DMA DAC */
  167. #define ADC_8            0x24 /* Start 8-bit DMA ADC */
  168.  
  169. /* MIDI DSP commands. */
  170. #define MIDI_POLL        0x30 /* Poll a byte from the MIDI port */
  171. #define MIDI_READ        0x31 /* Initiate a MIDI read with interrupts */
  172. #define MIDI_UART_POLL        0x34 /* Poll for a byte while allowing write */
  173. #define MIDI_UART_READ        0x35 /* Initiate a read while allowing write */
  174. #define MIDI_WRITE        0x38 /* Write a single MIDI byte */ 
  175.  
  176.  
  177. /*
  178.  * Sound Blaster on-board Mixer chip addresses:
  179.  */
  180. #define MIXER_ADDR        (status.addr + 0x04)
  181. #define MIXER_DATA        (status.addr + 0x05)
  182.  
  183. /* To reset the Mixer to power-up state, send a 0x00 to both the
  184.  * ADDR and DATA ports.  (Actually, you can send any value to DATA after
  185.  * sending 0x00 to the ADDR port.) */
  186. #define MIXER_RESET        0x00 /* Send this to both ADDR & DATA */
  187.  
  188. /*
  189.  * Mixer chip registers:
  190.  */
  191. #define RECORD_SRC      0x0C
  192. /*  bit:  7 6 5 4 3 2 1 0           F=frequency (0=low, 1=high)
  193.           x x T x F S S x           SS=source (00=MIC, 01=CD, 11=LINE)
  194.                                 T=input filter switch (ANFI) */
  195.  
  196. /* Recording sources (SRC_MIC, SRC_CD, SRC_LINE)
  197.    are defined in i386at/sblast.h */
  198.  
  199. #define IN_FILTER       0x0C    /* "ANFI" analog input filter reg */
  200. #define OUT_FILTER      0x0E    /* "DNFI" output filter reg */
  201. #define FREQ_HI         (1 << 3) /* Use High-frequency ANFI filters */
  202. #define FREQ_LOW        0    /* Use Low-frequency ANFI filters */
  203. #define FILT_ON         0    /* Yes, 0 to turn it on, 1 for off */
  204. #define FILT_OFF        (1 << 5)
  205.  
  206. #define CHANNELS    0x0E    /* Stereo/Mono output select */
  207. #define MONO_DAC    0    /* Send to OUT_FILTER for mono output */
  208. #define STEREO_DAC    2    /* Send to OUT_FILTER for stereo output */
  209.  
  210. #define VOL_MASTER      0x22    /* High nibble is left, low is right */
  211. #define VOL_FM          0x26
  212. #define VOL_CD          0x28
  213. #define VOL_LINE        0x2E
  214. #define VOL_VOC         0x04
  215. #define VOL_MIC         0x0A    /* Only the lowest three bits. (0-7) */
  216.