Home | History | Annotate | Line # | Download | only in isa
      1  1.33    andvar /*	$NetBSD: sbreg.h,v 1.33 2024/02/09 22:08:35 andvar Exp $	*/
      2   1.4       cgd 
      3   1.1       cgd /*
      4   1.1       cgd  * Copyright (c) 1991-1993 Regents of the University of California.
      5   1.1       cgd  * All rights reserved.
      6   1.1       cgd  *
      7   1.1       cgd  * Redistribution and use in source and binary forms, with or without
      8   1.1       cgd  * modification, are permitted provided that the following conditions
      9   1.1       cgd  * are met:
     10   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     11   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     12   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     14   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     15   1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     16   1.1       cgd  *    must display the following acknowledgement:
     17   1.1       cgd  *	This product includes software developed by the Computer Systems
     18   1.1       cgd  *	Engineering Group at Lawrence Berkeley Laboratory.
     19   1.1       cgd  * 4. Neither the name of the University nor of the Laboratory may be used
     20   1.1       cgd  *    to endorse or promote products derived from this software without
     21   1.1       cgd  *    specific prior written permission.
     22   1.1       cgd  *
     23   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33   1.1       cgd  * SUCH DAMAGE.
     34   1.1       cgd  *
     35   1.7    brezak  *	From: Header: sbreg.h,v 1.3 93/07/18 14:07:28 mccanne Exp (LBL)
     36   1.1       cgd  */
     37   1.1       cgd 
     38   1.1       cgd /*
     39   1.1       cgd  * SoundBlaster register definitions.
     40   1.1       cgd  * See "The Developer Kit for Sound Blaster Series, User's Guide" for more
     41  1.33    andvar  * complete information (available from Creative Labs, Inc.).  We refer
     42   1.1       cgd  * to this documentation as "SBK".
     43   1.1       cgd  *
     44   1.1       cgd  * We handle two types of cards: the basic SB version 2.0+, and
     45   1.1       cgd  * the SB PRO.  There are several distinct pieces of the hardware:
     46   1.1       cgd  *
     47   1.1       cgd  *   joystick port	(independent of I/O base address)
     48   1.1       cgd  *   FM synth		(stereo on PRO)
     49   1.1       cgd  *   mixer		(PRO only)
     50   1.1       cgd  *   DSP (sic)
     51   1.1       cgd  *   CD-ROM		(PRO only)
     52   1.1       cgd  *
     53   1.1       cgd  * The MIDI capabilities are handled by the DSP unit.
     54   1.1       cgd  */
     55   1.1       cgd 
     56   1.1       cgd /*
     57   1.1       cgd  * Address map.  The SoundBlaster can be configured (via jumpers) for
     58   1.1       cgd  * either base I/O address 0x220 or 0x240.  The encodings below give
     59   1.1       cgd  * the offsets to specific SB ports.  SBP stands for SB port offset.
     60   1.1       cgd  */
     61   1.1       cgd #define SBP_LFM_STATUS		0	/* R left FM status port */
     62   1.1       cgd #define SBP_LFM_ADDR		0	/* W left FM address register */
     63   1.1       cgd #define SBP_LFM_DATA		1	/* RW left FM data port */
     64   1.1       cgd #define SBP_RFM_STATUS		2	/* R right FM status port */
     65   1.1       cgd #define SBP_RFM_ADDR		2	/* W right FM address register */
     66   1.1       cgd #define SBP_RFM_DATA		3	/* RW right FM data port */
     67   1.7    brezak 
     68   1.1       cgd #define SBP_FM_STATUS		8	/* R FM status port */
     69   1.1       cgd #define SBP_FM_ADDR		8	/* W FM address register */
     70   1.1       cgd #define SBP_FM_DATA		9	/* RW FM data port */
     71   1.1       cgd #define SBP_MIXER_ADDR		4	/* W mixer address register */
     72   1.1       cgd #define SBP_MIXER_DATA		5	/* RW mixer data port */
     73  1.20  augustss 
     74  1.20  augustss #define	SBP_MIX_RESET		0x00	/* mixer reset port, value */
     75  1.20  augustss #define SBP_1335_MASTER_VOL	0x02
     76  1.20  augustss #define	SBP_1335_MIDI_VOL	0x06
     77  1.20  augustss #define	SBP_1335_CD_VOL		0x08
     78  1.20  augustss #define	SBP_1335_VOICE_VOL	0x0A
     79  1.20  augustss 
     80  1.20  augustss #define	SBP_VOICE_VOL		0x04
     81  1.20  augustss #define	SBP_MIC_VOL		0x0A	/* warning: only one channel of volume... */
     82   1.7    brezak #define	SBP_MASTER_VOL		0x22
     83  1.20  augustss #define	SBP_MIDI_VOL		0x26
     84   1.7    brezak #define	SBP_CD_VOL		0x28
     85   1.7    brezak #define	SBP_LINE_VOL		0x2E
     86   1.7    brezak 
     87   1.7    brezak #define	SBP_RECORD_SOURCE	0x0C
     88   1.7    brezak #define	SBP_STEREO		0x0E
     89   1.7    brezak #define		SBP_PLAYMODE_STEREO	0x2
     90   1.7    brezak #define		SBP_PLAYMODE_MONO	0x0
     91   1.7    brezak #define		SBP_PLAYMODE_MASK	0x2
     92   1.7    brezak #define	SBP_OUTFILTER		0x0E
     93   1.7    brezak #define	SBP_INFILTER		0x0C
     94   1.7    brezak 
     95   1.7    brezak #define	SBP_RECORD_FROM(src, filteron, high) ((src) | (filteron) | (high))
     96   1.7    brezak #define		SBP_FILTER_ON		0x0
     97   1.7    brezak #define		SBP_FILTER_OFF		0x20
     98  1.13       jtk #define		SBP_IFILTER_MASK	0x28
     99  1.13       jtk #define		SBP_OFILTER_MASK	0x20
    100  1.13       jtk #define		SBP_IFILTER_LOW		0
    101  1.13       jtk #define		SBP_IFILTER_HIGH	0x08
    102   1.7    brezak #define		SBP_FROM_MIC		0x00
    103   1.7    brezak #define		SBP_FROM_CD		0x02
    104   1.7    brezak #define		SBP_FROM_LINE		0x06
    105  1.20  augustss 
    106  1.20  augustss #define SBP_SET_IRQ		0x80	/* Soft-configured irq (SB16-) */
    107  1.20  augustss #define SBP_SET_DRQ		0x81	/* Soft-configured drq (SB16-) */
    108  1.20  augustss #define	SBP_IRQ_STATUS		0x82	/* Pending IRQ status (SB16-) */
    109  1.21  augustss #define		SBP_IRQ_MPU401	0x04
    110  1.21  augustss #define		SBP_IRQ_DMA16	0x02
    111  1.21  augustss #define		SBP_IRQ_DMA8	0x01
    112  1.26  augustss #define SBP_MPU_ADDR		0x84	/* Vibra16 register */
    113  1.20  augustss 
    114  1.20  augustss #define SB16P_MASTER_L		0x30
    115  1.20  augustss #define SB16P_VOICE_L		0x32
    116  1.20  augustss #define SB16P_MIDI_L		0x34
    117  1.20  augustss #define SB16P_CD_L		0x36
    118  1.20  augustss #define SB16P_LINE_L		0x38
    119  1.20  augustss #define SB16P_MIC_L		0x3a
    120  1.20  augustss #define SB16P_PCSPEAKER		0x3b
    121  1.24  augustss #define SB16P_OSWITCH		0x3c
    122  1.24  augustss #define SB16P_ISWITCH_L		0x3d
    123  1.24  augustss #define SB16P_ISWITCH_R		0x3e
    124  1.30      kent #define		SB16P_SW_MIC	0x01
    125  1.30      kent #define		SB16P_SW_CD_R	0x02
    126  1.30      kent #define		SB16P_SW_CD_L	0x04
    127  1.30      kent #define		SB16P_SW_CD	(SB16P_SW_CD_L|SB16P_SW_CD_R)
    128  1.30      kent #define		SB16P_SW_LINE_R	0x08
    129  1.30      kent #define		SB16P_SW_LINE_L	0x10
    130  1.30      kent #define		SB16P_SW_LINE	(SB16P_SW_LINE_L|SB16P_SW_LINE_R)
    131  1.30      kent #define		SB16P_SW_MIDI_R	0x20
    132  1.30      kent #define		SB16P_SW_MIDI_L	0x40
    133  1.30      kent #define		SB16P_SW_MIDI	(SB16P_SW_MIDI_L|SB16P_SW_MIDI_R)
    134  1.20  augustss #define SB16P_INPUT_GAIN_L	0x3f
    135  1.20  augustss #define SB16P_OUTPUT_GAIN_L	0x41
    136  1.20  augustss #define SB16P_TREBLE_L		0x44
    137  1.20  augustss #define SB16P_BASS_L		0x46
    138  1.20  augustss #define SB16P_L_TO_R(l) ((l)+1)
    139  1.20  augustss 
    140  1.20  augustss #define SB16P_AGC		0x43
    141  1.20  augustss 
    142  1.20  augustss #define SBP_RECORD_SOURCE_L	0x3d
    143  1.20  augustss #define SBP_RECORD_SOURCE_R	0x3e
    144  1.30      kent #define		SBP_MIDI_SRC_R	0x20
    145  1.30      kent #define		SBP_LINE_SRC_R	0x08
    146  1.30      kent #define		SBP_CD_SRC_R	0x02
    147  1.30      kent #define		SBP_MIC_SRC	0x01
    148  1.20  augustss #define SB_SRC_R_TO_L(x) ((x) << 1)
    149  1.20  augustss 
    150  1.20  augustss #define SB_STEREO_GAIN(left, right) ((left) | ((right) >> 4))
    151  1.20  augustss #define SB_MIC_GAIN(v) ((v) >> 5)
    152  1.23  augustss 
    153  1.23  augustss #define SB_ADJUST_MIC_GAIN(sc, x) sbdsp_adjust((x), ISSB16CLASS(sc) ? 0xf8 : 0xc0)
    154  1.23  augustss #define SB_ADJUST_GAIN(sc, x)     sbdsp_adjust((x), ISSB16CLASS(sc) ? 0xf8 : 0xe0)
    155  1.23  augustss #define SB_ADJUST_2_GAIN(sc, x)   sbdsp_adjust((x), 0xc0)
    156  1.23  augustss 
    157  1.20  augustss #define SB_1335_GAIN(x) ((x) >> 4)
    158  1.20  augustss #define SB_1335_MASTER_GAIN(x) ((x) >> 5)
    159  1.20  augustss 
    160   1.1       cgd #define SBP_DSP_RESET		6	/* W reset port */
    161  1.30      kent #define		SB_MAGIC	0xaa	/* card outputs on successful reset */
    162  1.30      kent #define SBP_DSP_READ		10	/* R read port */
    163   1.1       cgd #define SBP_DSP_WRITE		12	/* W write port */
    164   1.1       cgd #define SBP_DSP_WSTAT		12	/* R write status */
    165   1.1       cgd #define SBP_DSP_RSTAT		14	/* R read status */
    166  1.30      kent #define		SB_DSP_BUSY	0x80
    167  1.30      kent #define		SB_DSP_READY	0x80
    168  1.17   mycroft #define	SBP_DSP_IRQACK8		14	/* R acknowledge DSP IRQ, 8-bit */
    169  1.17   mycroft #define	SBP_DSP_IRQACK16	15	/* R acknowledge DSP IRQ, 16-bit */
    170   1.1       cgd #define SBP_CDROM_DATA		16	/* RW send cmds/recv data */
    171   1.1       cgd #define SBP_CDROM_STATUS	17	/* R status port */
    172   1.1       cgd #define SBP_CDROM_RESET		18	/* W reset register */
    173   1.1       cgd #define SBP_CDROM_ENABLE	19	/* W enable register */
    174   1.7    brezak 
    175  1.30      kent #define SBP_NPORT	24
    176  1.30      kent #define SB_NPORT	16
    177  1.30      kent #define SB_NMPUPORT	2
    178   1.1       cgd 
    179   1.1       cgd /*
    180   1.1       cgd  * DSP commands.  This unit handles MIDI and audio capabilities.
    181   1.1       cgd  * The DSP can be reset, data/commands can be read or written to it,
    182   1.1       cgd  * and it can generate interrupts.  Interrupts are generated for MIDI
    183  1.30      kent  * input or DMA completion.  They seem to have neglected the fact
    184   1.1       cgd  * that it would be nice to have a MIDI transmission complete interrupt.
    185   1.1       cgd  * Worse, the DMA engine is half-duplex.  This means you need to do
    186  1.33    andvar  * (timed) programmed I/O to be able to record and play simultaneously.
    187   1.1       cgd  */
    188   1.1       cgd #define SB_DSP_DACWRITE		0x10	/* programmed I/O write to DAC */
    189   1.1       cgd #define SB_DSP_WDMA		0x14	/* begin 8-bit linear DMA output */
    190   1.1       cgd #define SB_DSP_WDMA_2		0x16	/* begin 2-bit ADPCM DMA output */
    191  1.18   mycroft #define	SB_DSP_WDMA_LOOP	0x1C	/* begin 8-bit linear DMA output loop */
    192   1.1       cgd #define SB_DSP_ADCREAD		0x20	/* programmed I/O read from ADC */
    193   1.1       cgd #define SB_DSP_RDMA		0x24	/* begin 8-bit linear DMA input */
    194  1.18   mycroft #define	SB_DSP_RDMA_LOOP	0x2C	/* begin 8-bit linear DMA input loop */
    195   1.1       cgd #define SB_MIDI_POLL		0x30	/* initiate a polling read for MIDI */
    196   1.1       cgd #define SB_MIDI_READ		0x31	/* read a MIDI byte on recv intr */
    197   1.1       cgd #define SB_MIDI_UART_POLL	0x34	/* enter UART mode w/ read polling */
    198   1.1       cgd #define SB_MIDI_UART_INTR	0x35	/* enter UART mode w/ read intrs */
    199   1.1       cgd #define SB_MIDI_WRITE		0x38	/* write a MIDI byte (non-UART mode) */
    200   1.1       cgd #define SB_DSP_TIMECONST	0x40	/* set ADAC time constant */
    201  1.15   mycroft #define	SB_DSP16_OUTPUTRATE	0x41	/* set ADAC output rate */
    202  1.15   mycroft #define	SB_DSP16_INPUTRATE	0x42	/* set ADAC input rate */
    203   1.1       cgd #define SB_DSP_BLOCKSIZE	0x48	/* set blk size for high speed xfer */
    204   1.1       cgd #define SB_DSP_WDMA_4		0x74	/* begin 4-bit ADPCM DMA output */
    205   1.1       cgd #define SB_DSP_WDMA_2_6		0x76	/* begin 2.6-bit ADPCM DMA output */
    206   1.1       cgd #define SB_DSP_SILENCE		0x80	/* send a block of silence */
    207  1.18   mycroft #define SB_DSP_HS_OUTPUT	0x90	/* set high speed mode for wdma */
    208  1.18   mycroft #define SB_DSP_HS_INPUT		0x98	/* set high speed mode for rdma */
    209   1.7    brezak #define SB_DSP_RECORD_MONO	0xA0	/* set mono recording */
    210   1.7    brezak #define SB_DSP_RECORD_STEREO	0xA8	/* set stereo recording */
    211  1.18   mycroft #define	SB_DSP16_WDMA_16	0xB6	/* begin 16-bit linear output */
    212  1.18   mycroft #define	SB_DSP16_RDMA_16	0xBE	/* begin 16-bit linear input */
    213  1.18   mycroft #define	SB_DSP16_WDMA_8		0xC6	/* begin 8-bit linear output */
    214  1.18   mycroft #define	SB_DSP16_RDMA_8		0xCE	/* begin 8-bit linear input */
    215  1.27   mycroft #define SB_DSP_HALT		0xd0	/* suspend 8-bit DMA */
    216   1.1       cgd #define SB_DSP_SPKR_ON		0xd1	/* turn speaker on */
    217   1.1       cgd #define SB_DSP_SPKR_OFF		0xd3	/* turn speaker off */
    218  1.27   mycroft #define SB_DSP_CONT		0xd4	/* continue 8-bit DMA */
    219  1.27   mycroft #define	SB_DSP16_HALT		0xd5	/* suspend 16-bit DMA */
    220  1.27   mycroft #define	SB_DSP16_CONT		0xd6	/* continue 16-bit DMA */
    221   1.1       cgd #define SB_DSP_RD_SPKR		0xd8	/* get speaker status */
    222  1.30      kent #define		SB_SPKR_OFF	0x00
    223  1.30      kent #define		SB_SPKR_ON	0xff
    224   1.1       cgd #define SB_DSP_VERSION		0xe1	/* get version number */
    225  1.22  augustss 
    226  1.22  augustss #define SB_BMODE_UNSIGNED	0x00
    227  1.22  augustss #define SB_BMODE_SIGNED		0x10
    228  1.22  augustss #define SB_BMODE_STEREO		0x20
    229  1.16       jtk 
    230  1.16       jtk /* Some of these come from linux driver (It serves as convenient unencumbered
    231  1.16       jtk    documentation) */
    232  1.16       jtk #define	JAZZ16_READ_VER		0xFA	/* 0x12 means ProSonic/Jazz16? */
    233  1.16       jtk #define		JAZZ16_VER_JAZZ	0x12
    234  1.16       jtk #define	JAZZ16_SET_DMAINTR	0xFB
    235  1.16       jtk 
    236  1.16       jtk #define JAZZ16_CONFIG_PORT	0x201
    237  1.16       jtk #define	JAZZ16_WAKEUP		0xAF
    238  1.16       jtk #define	JAZZ16_SETBASE		0x50
    239  1.16       jtk 
    240  1.16       jtk #define	JAZZ16_RECORD_STEREO	0xAC	/* 16-bit record */
    241  1.16       jtk #define	JAZZ16_RECORD_MONO	0xA4	/* 16-bit record */
    242  1.16       jtk 
    243  1.16       jtk /*
    244  1.16       jtk  * These come from Jazz16 chipset documentation, which doesn't include
    245  1.16       jtk  * full register details, alas.  Their source code CD-ROM probably includes
    246  1.16       jtk  * details, but it has an NDA attached.
    247  1.16       jtk  */
    248  1.30      kent #define	JAZZ16_DIR_PB		0x10
    249  1.16       jtk #define	JAZZ16_SINGLE_PB	0x14
    250  1.30      kent #define	JAZZ16_SINGLE_ALAW_PB	0x17
    251  1.16       jtk #define	JAZZ16_CONT_PB		0x1C
    252  1.30      kent #define	JAZZ16_CONT_ALAW_PB	0x1F
    253  1.16       jtk #define	JAZZ16_DIR_PCM_REC	0x20
    254  1.16       jtk #define	JAZZ16_SINGLE_REC	0x24
    255  1.30      kent #define	JAZZ16_SINGLE_ALAW_REC	0x27
    256  1.16       jtk #define	JAZZ16_CONT_REC		0x2C
    257  1.30      kent #define	JAZZ16_CONT_ALAW_REC	0x2F
    258  1.30      kent #define	JAZZ16_SINGLE_ADPCM_PB	0x74
    259  1.30      kent #define	JAZZ16_SINGLE_MULAW_PB	0x77
    260  1.30      kent #define	JAZZ16_CONT_ADPCM_PB	0x7C
    261  1.16       jtk #define	JAZZ16_SINGLE_ADPCM_REC 0x84
    262  1.16       jtk #define	JAZZ16_SINGLE_MULAW_REC 0x87
    263  1.30      kent #define	JAZZ16_CONT_ADPCM_REC	0x8C
    264  1.30      kent #define	JAZZ16_CONT_MULAW_REC	0x8F
    265  1.30      kent #define	JAZZ16_CONT_PB_XX	0x90
    266  1.16       jtk #define	JAZZ16_SINGLE_PB_XX	0x91
    267  1.16       jtk #define	JAZZ16_SINGLE_REC_XX	0x98
    268  1.16       jtk #define	JAZZ16_CONT_REC_XX	0x99
    269  1.16       jtk 
    270   1.1       cgd 
    271   1.1       cgd /*
    272   1.1       cgd  * The ADPCM encodings are differential, meaning each sample represents
    273  1.32    andvar  * a difference to add to a running sum.  The initial value is called the
    274   1.1       cgd  * reference, or reference byte.  Any of the ADPCM DMA transfers can specify
    275   1.1       cgd  * that the given transfer begins with a reference byte by or'ing
    276   1.1       cgd  * in the bit below.
    277   1.1       cgd  */
    278   1.1       cgd #define SB_DSP_REFERENCE	1
    279   1.1       cgd 
    280   1.1       cgd /*
    281   1.1       cgd  * Macros to detect valid hardware configuration data.
    282   1.1       cgd  */
    283  1.29  augustss #define SBP_IRQ_VALID(irq)  ((irq) == 5 || (irq) == 7 || (irq) == 9 || (irq) == 10 || (irq) == 15)
    284  1.11     glass #define SB_IRQ_VALID(irq)   ((irq) == 3 || (irq) == 5 || (irq) == 7 || (irq) == 9)
    285   1.7    brezak 
    286  1.17   mycroft #define SB16_DRQ_VALID(chan) ((chan) == 0 || (chan) == 1 || (chan) == 3 || \
    287  1.30      kent 			      (chan) == 5 || (chan) == 6 || (chan) == 7)
    288   1.8    brezak #define SBP_DRQ_VALID(chan) ((chan) == 0 || (chan) == 1 || (chan) == 3)
    289   1.7    brezak #define SB_DRQ_VALID(chan)  ((chan) == 1)
    290   1.7    brezak 
    291  1.28   mycroft #define SB_BASE_VALID(base) ((base) == 0x220 || (base) == 0x240 || (base) == 0x260)
    292   1.1       cgd 
    293   1.1       cgd #define SB_INPUT_RATE	0
    294   1.1       cgd #define SB_OUTPUT_RATE	1
    295   1.1       cgd 
    296