Home | History | Annotate | Line # | Download | only in isa
sbdspvar.h revision 1.2
      1 /*	$NetBSD: sbdspvar.h,v 1.2 1995/03/08 18:27:40 brezak Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1991-1993 Regents of the University of California.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by the Computer Systems
     18  *	Engineering Group at Lawrence Berkeley Laboratory.
     19  * 4. Neither the name of the University nor of the Laboratory may be used
     20  *    to endorse or promote products derived from this software without
     21  *    specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  *
     35  *	$Id: sbdspvar.h,v 1.2 1995/03/08 18:27:40 brezak Exp $
     36  */
     37 
     38 #define SB_MIC_PORT	0
     39 #define SB_SPEAKER	1
     40 #define SB_LINE_IN_PORT	2
     41 #define SB_DAC_PORT	3
     42 #define SB_FM_PORT	4
     43 #define SB_CD_PORT	5
     44 #define SB_MASTER_VOL	6
     45 #define SB_TREBLE	7
     46 #define SB_BASS		8
     47 #define SB_NDEVS	9
     48 
     49 #define SB_OUTPUT_MODE	9
     50 #define 	SB_SPKR_MONO	0
     51 #define 	SB_SPKR_STEREO	1
     52 
     53 #define	SB_RECORD_SOURCE 10
     54 
     55 #define SB_INPUT_CLASS	11
     56 #define SB_OUTPUT_CLASS	12
     57 #define SB_RECORD_CLASS	13
     58 
     59 
     60 /*
     61  * Software state, per SoundBlaster card.
     62  * The soundblaster has multiple functionality, which we must demultiplex.
     63  * One approach is to have one major device number for the soundblaster card,
     64  * and use different minor numbers to indicate which hardware function
     65  * we want.  This would make for one large driver.  Instead our approach
     66  * is to partition the design into a set of drivers that share an underlying
     67  * piece of hardware.  Most things are hard to share, for example, the audio
     68  * and midi ports.  For audio, we might want to mix two processes' signals,
     69  * and for midi we might want to merge streams (this is hard due to
     70  * running status).  Moreover, we should be able to re-use the high-level
     71  * modules with other kinds of hardware.  In this module, we only handle the
     72  * most basic communications with the sb card.
     73  */
     74 struct sbdsp_softc {
     75 	struct	device sc_dev;		/* base device */
     76 	struct	isadev sc_id;		/* ISA device */
     77 	struct	intrhand sc_ih;		/* interrupt vectoring */
     78 
     79 	u_short	sc_iobase;		/* I/O port base address */
     80 	u_short sc_irq;			/* interrupt */
     81 	u_short sc_drq;			/* DMA */
     82 
     83 	u_short	sc_open;		/* reference count of open calls */
     84 	u_short	sc_locked;		/* true when doing HS DMA  */
     85  	u_short	sc_adacmode;		/* low/high speed mode indicator */
     86 
     87 	u_long	sc_irate;		/* Sample rate for input */
     88 	u_long	sc_orate;		/* ...and output */
     89 
     90 	u_int	gain[SB_NDEVS];		/* kept in SB levels: right/left each
     91 					   in a nibble */
     92 
     93 	u_int	encoding;		/* ulaw/linear -- keep track */
     94 
     95 	u_int	out_port;		/* output port */
     96 	u_int	in_port;		/* input port */
     97 
     98 	u_int	spkr_state;		/* non-null is on */
     99 
    100 #define SB_ADAC_LS 0
    101 #define SB_ADAC_HS 1
    102  	u_short	sc_adactc;		/* current adac time constant */
    103 	u_long	sc_interrupts;		/* number of interrupts taken */
    104 	void	(*sc_intr)(void*);	/* dma completion intr handler */
    105 	void	(*sc_mintr)(void*, int);/* midi input intr handler */
    106 	void	*sc_arg;		/* arg for sc_intr() */
    107 
    108 	int	dmaflags;
    109 	caddr_t	dmaaddr;
    110 	vm_size_t	dmacnt;
    111 	int	sc_last_hsw_size;	/* last HS dma size */
    112 	int	sc_last_hsr_size;	/* last HS dma size */
    113 	int	sc_chans;		/* # of channels */
    114 	char	sc_dmain_inprogress;	/* DMA input in progress? */
    115 	char	sc_dmaout_inprogress;	/* DMA output in progress? */
    116 
    117 	u_int	sc_model;		/* DSP model */
    118 #define SBVER_MAJOR(v)	((v)>>8)
    119 #define SBVER_MINOR(v)	((v)&0xff)
    120 };
    121 
    122 #define ISSBPRO(sc) \
    123 	(SBVER_MAJOR((sc)->sc_model) == 3)
    124 
    125 #define ISSBPROCLASS(sc) \
    126 	(SBVER_MAJOR((sc)->sc_model) > 2)
    127 
    128 #define ISSB16CLASS(sc) \
    129       (SBVER_MAJOR((sc)->sc_model) > 3)
    130 
    131 
    132 #ifdef KERNEL
    133 int	sbdsp_open __P((struct sbdsp_softc *, dev_t, int));
    134 void	sbdsp_close __P((caddr_t));
    135 
    136 int	sbdsp_probe __P((struct sbdsp_softc *));
    137 void	sbdsp_attach __P((struct sbdsp_softc *));
    138 
    139 int	sbdsp_set_in_gain __P((caddr_t, u_int, u_char));
    140 int	sbdsp_set_in_gain_real __P((caddr_t, u_int, u_char));
    141 int	sbdsp_get_in_gain __P((caddr_t));
    142 int	sbdsp_set_out_gain __P((caddr_t, u_int, u_char));
    143 int	sbdsp_set_out_gain_real __P((caddr_t, u_int, u_char));
    144 int	sbdsp_get_out_gain __P((caddr_t));
    145 int	sbdsp_set_monitor_gain __P((caddr_t, u_int));
    146 int	sbdsp_get_monitor_gain __P((caddr_t));
    147 int	sbdsp_set_in_sr __P((caddr_t, u_long));
    148 int	sbdsp_set_in_sr_real __P((caddr_t, u_long));
    149 u_long	sbdsp_get_in_sr __P((caddr_t));
    150 int	sbdsp_set_out_sr __P((caddr_t, u_long));
    151 int	sbdsp_set_out_sr_real __P((caddr_t, u_long));
    152 u_long	sbdsp_get_out_sr __P((caddr_t));
    153 int	sbdsp_query_encoding __P((caddr_t, struct audio_encoding *));
    154 int	sbdsp_set_encoding __P((caddr_t, u_int));
    155 int	sbdsp_get_encoding __P((caddr_t));
    156 int	sbdsp_set_precision __P((caddr_t, u_int));
    157 int	sbdsp_get_precision __P((caddr_t));
    158 int	sbdsp_set_channels __P((caddr_t, int));
    159 int	sbdsp_get_channels __P((caddr_t));
    160 int	sbdsp_round_blocksize __P((caddr_t, int));
    161 int	sbdsp_set_out_port __P((caddr_t, int));
    162 int	sbdsp_get_out_port __P((caddr_t));
    163 int	sbdsp_set_in_port __P((caddr_t, int));
    164 int	sbdsp_get_in_port __P((caddr_t));
    165 int	sbdsp_get_avail_in_ports __P((caddr_t));
    166 int	sbdsp_get_avail_out_ports __P((caddr_t));
    167 int	sbdsp_speaker_ctl __P((caddr_t, int));
    168 int	sbdsp_commit_settings __P((caddr_t));
    169 
    170 int	sbdsp_dma_output __P((caddr_t, void *, int, void (*)(), void*));
    171 int	sbdsp_dma_input __P((caddr_t, void *, int, void (*)(), void*));
    172 
    173 int	sbdsp_haltdma __P((caddr_t));
    174 int	sbdsp_contdma __P((caddr_t));
    175 
    176 u_int	sbdsp_get_silence __P((int));
    177 void	sbdsp_compress __P((int, u_char *, int));
    178 void	sbdsp_expand __P((int, u_char *, int));
    179 
    180 int	sbdsp_reset __P((struct sbdsp_softc *));
    181 void	sbdsp_spkron __P((struct sbdsp_softc *));
    182 void	sbdsp_spkroff __P((struct sbdsp_softc *));
    183 
    184 int	sbdsp_wdsp(u_short iobase, int v);
    185 int	sbdsp_rdsp(u_short iobase);
    186 
    187 int	sbdsp_intr __P((struct sbdsp_softc *));
    188 short	sbversion __P((struct sbdsp_softc *));
    189 
    190 int	sbdsp_set_sr __P((struct sbdsp_softc *, u_long *, int));
    191 int	sbdsp_setfd __P((caddr_t, int));
    192 
    193 void	sbdsp_mix_write __P((struct sbdsp_softc *, int, int));
    194 int	sbdsp_mix_read __P((struct sbdsp_softc *, int));
    195 
    196 int	sbdsp_mixer_set_port __P((caddr_t, mixer_ctrl_t *));
    197 int	sbdsp_mixer_get_port __P((caddr_t, mixer_ctrl_t *));
    198 int	sbdsp_mixer_query_devinfo __P((caddr_t, mixer_devinfo_t *));
    199 
    200 #endif
    201