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