Home | History | Annotate | Line # | Download | only in isa
sbdspvar.h revision 1.20
      1 /*	$NetBSD: sbdspvar.h,v 1.20 1997/05/09 22:16:42 augustss 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  */
     36 
     37 #define SB_MIC_PORT	0
     38 #define SB_SPEAKER	1
     39 #define SB_INPUT_CLASS	2
     40 #define SB_OUTPUT_CLASS	3
     41 #define SB_LINE_IN_PORT	4
     42 #define SB_DAC_PORT	5
     43 #define SB_FM_PORT	6
     44 #define SB_CD_PORT	7
     45 #define SB_MASTER_VOL	8
     46 #define SB_TREBLE	9
     47 #define SB_BASS		10
     48 #define SB_NDEVS	11		/* XXX include classes above for
     49 					   contiguous number space on
     50 					   original SB */
     51 
     52 /*#define SB_OUTPUT_MODE	9
     53 #define 	SB_SPKR_MONO	0
     54 #define 	SB_SPKR_STEREO	1*/
     55 
     56 #define	SB_RECORD_SOURCE 11
     57 
     58 #define SB_RECORD_CLASS	12
     59 
     60 
     61 /*
     62  * Software state, per SoundBlaster card.
     63  * The soundblaster has multiple functionality, which we must demultiplex.
     64  * One approach is to have one major device number for the soundblaster card,
     65  * and use different minor numbers to indicate which hardware function
     66  * we want.  This would make for one large driver.  Instead our approach
     67  * is to partition the design into a set of drivers that share an underlying
     68  * piece of hardware.  Most things are hard to share, for example, the audio
     69  * and midi ports.  For audio, we might want to mix two processes' signals,
     70  * and for midi we might want to merge streams (this is hard due to
     71  * running status).  Moreover, we should be able to re-use the high-level
     72  * modules with other kinds of hardware.  In this module, we only handle the
     73  * most basic communications with the sb card.
     74  */
     75 struct sbdsp_softc {
     76 	struct	device sc_dev;		/* base device */
     77 	struct	isadev sc_id;		/* ISA device */
     78 	isa_chipset_tag_t sc_ic;
     79 	bus_space_tag_t sc_iot;		/* tag */
     80 	bus_space_handle_t sc_ioh;	/* handle */
     81 	void	*sc_ih;			/* interrupt vectoring */
     82 
     83 	int	sc_iobase;		/* I/O port base address */
     84 	int	sc_irq;			/* interrupt */
     85 	int	sc_drq8;		/* DMA (8-bit) */
     86 	int	sc_drq16;		/* DMA (16-bit) */
     87 
     88 	u_short	sc_open;		/* reference count of open calls */
     89 
     90 	u_int	gain[SB_NDEVS];		/* kept in SB levels: right/left each
     91 					   in a nibble */
     92 
     93 	u_int	out_port;		/* output port */
     94 	u_int	in_port;		/* input port */
     95 	u_int	in_filter;		/* one of SB_TREBLE_EQ, SB_BASS_EQ, 0 */
     96 
     97 	u_int	spkr_state;		/* non-null is on */
     98 
     99 	int	sc_irate, sc_itc;	/* Sample rate for input */
    100 	int	sc_orate, sc_otc;	/* ...and output */
    101 
    102 	int	sc_imode;
    103 	int	sc_omode;
    104 #define SB_ADAC_LS 0
    105 #define SB_ADAC_HS 1
    106 
    107 	u_long	sc_interrupts;		/* number of interrupts taken */
    108 	void	(*sc_intr)(void*);	/* dma completion intr handler */
    109 	void	(*sc_mintr)(void*, int);/* midi input intr handler */
    110 	void	*sc_arg;		/* arg for sc_intr() */
    111 
    112 	int	dmaflags;
    113 	caddr_t	dmaaddr;
    114 	vm_size_t	dmacnt;
    115 	int	dmachan;		/* active DMA channel */
    116 	int	sc_last_hs_size;	/* last HS dma size */
    117 
    118 	u_int	sc_precision;		/* size of samples */
    119 	int	sc_channels;		/* # of channels */
    120 
    121 	int	sc_dmadir;		/* DMA direction */
    122 #define	SB_DMA_NONE	0
    123 #define	SB_DMA_IN	1
    124 #define	SB_DMA_OUT	2
    125 
    126 	u_int	sc_model;		/* DSP model */
    127 #define SBVER_MAJOR(v)	(((v)>>8) & 0xff)
    128 #define SBVER_MINOR(v)	((v)&0xff)
    129 
    130 #define MODEL_JAZZ16 0x80000000
    131 };
    132 
    133 #define	ISSB2CLASS(sc) \
    134 	(SBVER_MAJOR((sc)->sc_model) >= 2)
    135 
    136 #define ISSBPROCLASS(sc) \
    137 	(SBVER_MAJOR((sc)->sc_model) > 2)
    138 
    139 #define ISSBPRO(sc) \
    140 	(SBVER_MAJOR((sc)->sc_model) == 3)
    141 
    142 #define ISSB16CLASS(sc) \
    143 	(SBVER_MAJOR((sc)->sc_model) > 3)
    144 
    145 #define ISJAZZ16(sc) \
    146 	((sc)->sc_model & MODEL_JAZZ16)
    147 
    148 
    149 #ifdef _KERNEL
    150 int	sbdsp_open __P((struct sbdsp_softc *, dev_t, int));
    151 void	sbdsp_close __P((void *));
    152 
    153 int	sbdsp_probe __P((struct sbdsp_softc *));
    154 void	sbdsp_attach __P((struct sbdsp_softc *));
    155 
    156 int	sbdsp_set_in_gain __P((void *, u_int, u_char));
    157 int	sbdsp_set_in_gain_real __P((void *, u_int, u_char));
    158 int	sbdsp_get_in_gain __P((void *));
    159 int	sbdsp_set_out_gain __P((void *, u_int, u_char));
    160 int	sbdsp_set_out_gain_real __P((void *, u_int, u_char));
    161 int	sbdsp_get_out_gain __P((void *));
    162 int	sbdsp_set_monitor_gain __P((void *, u_int));
    163 int	sbdsp_get_monitor_gain __P((void *));
    164 int	sbdsp_query_encoding __P((void *, struct audio_encoding *));
    165 int	sbdsp_set_params __P((void *, int, struct audio_params *, struct audio_params *));
    166 int	sbdsp_set_ifilter __P((void *, int));
    167 int	sbdsp_get_ifilter __P((void *));
    168 int	sbdsp_round_blocksize __P((void *, int));
    169 int	sbdsp_set_out_port __P((void *, int));
    170 int	sbdsp_get_out_port __P((void *));
    171 int	sbdsp_set_in_port __P((void *, int));
    172 int	sbdsp_get_in_port __P((void *));
    173 int	sbdsp_get_avail_in_ports __P((void *));
    174 int	sbdsp_get_avail_out_ports __P((void *));
    175 int	sbdsp_speaker_ctl __P((void *, int));
    176 int	sbdsp_commit_settings __P((void *));
    177 
    178 int	sbdsp_dma_output __P((void *, void *, int, void (*)(void *), void*));
    179 int	sbdsp_dma_input __P((void *, void *, int, void (*)(void *), void*));
    180 
    181 int	sbdsp_haltdma __P((void *));
    182 int	sbdsp_contdma __P((void *));
    183 
    184 void	sbdsp_compress __P((int, u_char *, int));
    185 void	sbdsp_expand __P((int, u_char *, int));
    186 
    187 int	sbdsp_reset __P((struct sbdsp_softc *));
    188 void	sbdsp_spkron __P((struct sbdsp_softc *));
    189 void	sbdsp_spkroff __P((struct sbdsp_softc *));
    190 
    191 int	sbdsp_wdsp __P((struct sbdsp_softc *, int v));
    192 int	sbdsp_rdsp __P((struct sbdsp_softc *));
    193 
    194 int	sbdsp_intr __P((void *));
    195 short	sbversion __P((struct sbdsp_softc *));
    196 
    197 int	sbdsp_set_sr __P((struct sbdsp_softc *, u_long *, int));
    198 int	sbdsp_setfd __P((void *, int));
    199 
    200 void	sbdsp_mix_write __P((struct sbdsp_softc *, int, int));
    201 int	sbdsp_mix_read __P((struct sbdsp_softc *, int));
    202 
    203 int	sbdsp_mixer_set_port __P((void *, mixer_ctrl_t *));
    204 int	sbdsp_mixer_get_port __P((void *, mixer_ctrl_t *));
    205 int	sbdsp_mixer_query_devinfo __P((void *, mixer_devinfo_t *));
    206 
    207 #endif
    208