Home | History | Annotate | Line # | Download | only in isa
      1  1.62     isaki /*	$NetBSD: sbdspvar.h,v 1.62 2019/05/08 13:40:18 isaki 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.1    brezak  */
     36   1.1    brezak 
     37  1.47   mycroft #include "mpu.h"
     38  1.46   mycroft #if NMPU > 0
     39  1.43  augustss #include <dev/ic/mpuvar.h>
     40  1.36  augustss #endif
     41  1.36  augustss 
     42  1.21  augustss #define SB_MASTER_VOL	0
     43  1.21  augustss #define SB_MIDI_VOL	1
     44  1.21  augustss #define SB_CD_VOL	2
     45  1.21  augustss #define SB_VOICE_VOL	3
     46  1.21  augustss #define SB_OUTPUT_CLASS	4
     47  1.21  augustss 
     48  1.21  augustss #define SB_MIC_VOL	5
     49  1.21  augustss #define SB_LINE_IN_VOL	6
     50  1.21  augustss #define	SB_RECORD_SOURCE 7
     51  1.21  augustss #define SB_TREBLE	8
     52  1.21  augustss #define SB_BASS		9
     53  1.21  augustss #define SB_RECORD_CLASS	10
     54  1.32  augustss #define SB_INPUT_CLASS	11
     55  1.21  augustss 
     56  1.32  augustss #define SB_PCSPEAKER	12
     57  1.32  augustss #define SB_INPUT_GAIN	13
     58  1.32  augustss #define SB_OUTPUT_GAIN	14
     59  1.32  augustss #define SB_AGC		15
     60  1.21  augustss #define SB_EQUALIZATION_CLASS 16
     61   1.1    brezak 
     62  1.30  augustss #define SB_CD_IN_MUTE	17
     63  1.30  augustss #define SB_MIC_IN_MUTE	18
     64  1.30  augustss #define SB_LINE_IN_MUTE	19
     65  1.30  augustss #define SB_MIDI_IN_MUTE	20
     66  1.30  augustss 
     67  1.30  augustss #define SB_CD_SWAP	21
     68  1.30  augustss #define SB_MIC_SWAP	22
     69  1.30  augustss #define SB_LINE_SWAP	23
     70  1.30  augustss #define SB_MIDI_SWAP	24
     71  1.30  augustss 
     72  1.30  augustss #define SB_CD_OUT_MUTE	25
     73  1.30  augustss #define SB_MIC_OUT_MUTE	26
     74  1.30  augustss #define SB_LINE_OUT_MUTE 27
     75  1.30  augustss 
     76  1.30  augustss #define SB_NDEVS	28
     77  1.30  augustss 
     78  1.30  augustss #define SB_IS_IN_MUTE(x) ((x) < SB_CD_SWAP)
     79   1.1    brezak 
     80   1.1    brezak /*
     81   1.1    brezak  * Software state, per SoundBlaster card.
     82   1.1    brezak  * The soundblaster has multiple functionality, which we must demultiplex.
     83   1.1    brezak  * One approach is to have one major device number for the soundblaster card,
     84   1.1    brezak  * and use different minor numbers to indicate which hardware function
     85   1.1    brezak  * we want.  This would make for one large driver.  Instead our approach
     86   1.1    brezak  * is to partition the design into a set of drivers that share an underlying
     87   1.1    brezak  * piece of hardware.  Most things are hard to share, for example, the audio
     88   1.1    brezak  * and midi ports.  For audio, we might want to mix two processes' signals,
     89   1.1    brezak  * and for midi we might want to merge streams (this is hard due to
     90   1.1    brezak  * running status).  Moreover, we should be able to re-use the high-level
     91   1.1    brezak  * modules with other kinds of hardware.  In this module, we only handle the
     92   1.1    brezak  * most basic communications with the sb card.
     93   1.1    brezak  */
     94   1.1    brezak struct sbdsp_softc {
     95  1.59      cube 	device_t sc_dev;		/* base device */
     96  1.14  christos 	isa_chipset_tag_t sc_ic;
     97  1.14  christos 	bus_space_tag_t sc_iot;		/* tag */
     98  1.14  christos 	bus_space_handle_t sc_ioh;	/* handle */
     99   1.5       cgd 	void	*sc_ih;			/* interrupt vectoring */
    100  1.61  jmcneill 	kmutex_t sc_lock;
    101  1.61  jmcneill 	kmutex_t sc_intr_lock;
    102   1.1    brezak 
    103  1.41   mycroft 	/* XXX These are only for setting chip configuration registers. */
    104   1.7   mycroft 	int	sc_iobase;		/* I/O port base address */
    105   1.7   mycroft 	int	sc_irq;			/* interrupt */
    106  1.41   mycroft 
    107  1.17   mycroft 	int	sc_drq8;		/* DMA (8-bit) */
    108  1.48   thorpej 	bus_size_t sc_drq8_maxsize;
    109  1.11   mycroft 	int	sc_drq16;		/* DMA (16-bit) */
    110  1.48   thorpej 	bus_size_t sc_drq16_maxsize;
    111  1.50       mjl 
    112  1.50       mjl 	u_int	sc_quirks;		/* minor variations */
    113  1.50       mjl #define SB_QUIRK_NO_INIT_DRQ	0x01
    114   1.1    brezak 
    115  1.36  augustss 	int	sc_open;		/* reference count of open calls */
    116  1.36  augustss #define SB_CLOSED 0
    117  1.36  augustss #define SB_OPEN_AUDIO 1
    118  1.36  augustss #define SB_OPEN_MIDI 2
    119   1.1    brezak 
    120  1.21  augustss 	u_char	gain[SB_NDEVS][2];	/* kept in input levels */
    121  1.21  augustss #define SB_LEFT 0
    122  1.21  augustss #define SB_RIGHT 1
    123  1.30  augustss #define SB_LR 0
    124  1.56      kent 
    125  1.21  augustss 	u_int	in_mask;		/* input ports */
    126  1.21  augustss 	u_int	in_port;		/* XXX needed for MI interface */
    127  1.10       jtk 	u_int	in_filter;		/* one of SB_TREBLE_EQ, SB_BASS_EQ, 0 */
    128   1.1    brezak 
    129   1.1    brezak 	u_int	spkr_state;		/* non-null is on */
    130  1.56      kent 
    131  1.31  augustss 	struct sbdsp_state {
    132  1.31  augustss 		u_int	rate;		/* Sample rate */
    133  1.31  augustss 		u_char	tc;		/* Time constant */
    134  1.31  augustss 		struct	sbmode *modep;
    135  1.31  augustss 		u_char	bmode;
    136  1.31  augustss 		int	dmachan;	/* DMA channel */
    137  1.37   mycroft 		int	blksize;	/* Block size, preadjusted */
    138  1.31  augustss 		u_char	run;
    139  1.31  augustss #define SB_NOTRUNNING 0		/* Not running, not initialized */
    140  1.31  augustss #define SB_RUNNING 3		/* non-looping mode */
    141  1.37   mycroft #define SB_LOOPING 2		/* DMA&PCM running (looping mode) */
    142  1.31  augustss 	} sc_i, sc_o;			/* Input and output state */
    143   1.9   mycroft 
    144   1.1    brezak 	u_long	sc_interrupts;		/* number of interrupts taken */
    145  1.37   mycroft 
    146  1.52       wiz 	int	(*sc_intr8)(void*);	/* DMA completion intr handler */
    147  1.52       wiz 	int	(*sc_intr16)(void*);	/* DMA completion intr handler */
    148  1.37   mycroft 	void	(*sc_intrp)(void*);	/* PCM output intr handler */
    149  1.37   mycroft 	void	*sc_argp;		/* arg for sc_intrp() */
    150  1.37   mycroft 	void	(*sc_intrr)(void*);	/* PCM input intr handler */
    151  1.37   mycroft 	void	*sc_argr;		/* arg for sc_intrr() */
    152  1.36  augustss 	void	(*sc_intrm)(void*, int);/* midi input intr handler */
    153  1.37   mycroft 	void	*sc_argm;		/* arg for sc_intrm() */
    154   1.1    brezak 
    155  1.21  augustss 	u_int	sc_mixer_model;
    156  1.21  augustss #define SBM_NONE	0
    157  1.21  augustss #define SBM_CT1335	1
    158  1.21  augustss #define SBM_CT1345	2
    159  1.28  augustss #define SBM_CT1XX5	3
    160  1.28  augustss #define SBM_CT1745	4
    161  1.28  augustss #define ISSBM1745(x) ((x)->sc_mixer_model >= SBM_CT1XX5)
    162  1.18   mycroft 
    163  1.22  augustss 	u_int	sc_model;		/* DSP model */
    164  1.22  augustss #define SB_UNK	-1
    165  1.22  augustss #define SB_1	0			/* original SB */
    166  1.22  augustss #define SB_20	1			/* SB 2 */
    167  1.22  augustss #define SB_2x	2			/* SB 2, new version */
    168  1.22  augustss #define SB_PRO	3			/* SB Pro */
    169  1.22  augustss #define SB_JAZZ	4			/* Jazz 16 */
    170  1.22  augustss #define SB_16	5			/* SB 16 */
    171  1.27  augustss #define SB_32	6			/* SB AWE 32 */
    172  1.27  augustss #define SB_64	7			/* SB AWE 64 */
    173  1.27  augustss 
    174  1.56      kent #define SB_NAMES { "SB_1", "SB_2.0", "SB_2.x", "SB_Pro", "Jazz_16", "SB_16", \
    175  1.56      kent 		"SB_AWE_32", "SB_AWE_64" }
    176   1.1    brezak 
    177  1.22  augustss 	u_int	sc_version;		/* DSP version */
    178  1.22  augustss #define SBVER_MAJOR(v)	(((v)>>8) & 0xff)
    179  1.22  augustss #define SBVER_MINOR(v)	((v)&0xff)
    180  1.36  augustss 
    181  1.62     isaki 	struct audio_format sc_formats[4];
    182  1.62     isaki 	int sc_nformats;
    183  1.62     isaki 
    184  1.45   mycroft #if NMPU > 0
    185  1.36  augustss 	int	sc_hasmpu;
    186  1.58      cube #define SBMPU_EXTERNAL	1
    187  1.58      cube #define SBMPU_INTERNAL	0
    188  1.58      cube #define SBMPU_NONE	-1
    189  1.60    cegger 	device_t sc_mpudev;
    190  1.44  augustss 	bus_space_tag_t sc_mpu_iot;	/* tag */
    191  1.44  augustss 	bus_space_handle_t sc_mpu_ioh;	/* handle */
    192  1.36  augustss #endif
    193  1.22  augustss };
    194   1.2    brezak 
    195  1.22  augustss #define ISSBPRO(sc) ((sc)->sc_model == SB_PRO || (sc)->sc_model == SB_JAZZ)
    196  1.22  augustss #define ISSBPROCLASS(sc) ((sc)->sc_model >= SB_PRO)
    197  1.27  augustss #define ISSB16CLASS(sc) ((sc)->sc_model >= SB_16)
    198   1.1    brezak 
    199   1.4       jtc #ifdef _KERNEL
    200  1.51   thorpej struct malloc_type;
    201  1.51   thorpej 
    202  1.56      kent int	sbdsp_open(void *, int);
    203  1.56      kent void	sbdsp_close(void *);
    204   1.1    brezak 
    205  1.59      cube int	sbdsp_probe(struct sbdsp_softc *, cfdata_t);
    206  1.56      kent void	sbdsp_attach(struct sbdsp_softc *);
    207   1.1    brezak 
    208  1.56      kent int	sbdsp_set_in_gain(void *, u_int, u_char);
    209  1.56      kent int	sbdsp_set_in_gain_real(void *, u_int, u_char);
    210  1.56      kent int	sbdsp_get_in_gain(void *);
    211  1.56      kent int	sbdsp_set_out_gain(void *, u_int, u_char);
    212  1.56      kent int	sbdsp_set_out_gain_real(void *, u_int, u_char);
    213  1.56      kent int	sbdsp_get_out_gain(void *);
    214  1.56      kent int	sbdsp_set_monitor_gain(void *, u_int);
    215  1.56      kent int	sbdsp_get_monitor_gain(void *);
    216  1.62     isaki int	sbdsp_query_format(void *, audio_format_query_t *);
    217  1.62     isaki int	sbdsp_set_format(void *, int,
    218  1.62     isaki 	    const audio_params_t *, const audio_params_t *,
    219  1.62     isaki 	    audio_filter_reg_t *, audio_filter_reg_t *);
    220  1.56      kent int	sbdsp_round_blocksize(void *, int, int, const audio_params_t *);
    221  1.56      kent int	sbdsp_get_avail_in_ports(void *);
    222  1.56      kent int	sbdsp_get_avail_out_ports(void *);
    223  1.56      kent int	sbdsp_speaker_ctl(void *, int);
    224  1.56      kent 
    225  1.56      kent int	sbdsp_commit(void *);
    226  1.56      kent int	sbdsp_trigger_output(void *, void *, void *, int, void (*)(void *),
    227  1.56      kent 	    void *, const audio_params_t *);
    228  1.56      kent int	sbdsp_trigger_input(void *, void *, void *, int, void (*)(void *),
    229  1.56      kent 	    void *, const audio_params_t *);
    230  1.56      kent int	sbdsp_halt_output(void *);
    231  1.56      kent int	sbdsp_halt_input(void *);
    232  1.56      kent 
    233  1.56      kent void	sbdsp_compress(int, u_char *, int);
    234  1.56      kent void	sbdsp_expand(int, u_char *, int);
    235  1.56      kent 
    236  1.56      kent int	sbdsp_reset(struct sbdsp_softc *);
    237  1.56      kent void	sbdsp_spkron(struct sbdsp_softc *);
    238  1.56      kent void	sbdsp_spkroff(struct sbdsp_softc *);
    239  1.56      kent 
    240  1.56      kent int	sbdsp_wdsp(struct sbdsp_softc *, int);
    241  1.56      kent int	sbdsp_rdsp(struct sbdsp_softc *);
    242  1.56      kent 
    243  1.56      kent int	sbdsp_intr(void *);
    244  1.56      kent 
    245  1.56      kent int	sbdsp_set_sr(struct sbdsp_softc *, u_long *, int);
    246  1.56      kent 
    247  1.56      kent void	sbdsp_mix_write(struct sbdsp_softc *, int, int);
    248  1.56      kent int	sbdsp_mix_read(struct sbdsp_softc *, int);
    249  1.56      kent 
    250  1.56      kent int	sbdsp_mixer_set_port(void *, mixer_ctrl_t *);
    251  1.56      kent int	sbdsp_mixer_get_port(void *, mixer_ctrl_t *);
    252  1.56      kent int	sbdsp_mixer_query_devinfo(void *, mixer_devinfo_t *);
    253  1.56      kent 
    254  1.61  jmcneill void	*sb_malloc(void *, int, size_t);
    255  1.61  jmcneill void	sb_free(void *, void *, size_t);
    256  1.56      kent size_t	sb_round_buffersize(void *, int, size_t);
    257  1.56      kent 
    258  1.56      kent int	sbdsp_get_props(void *);
    259  1.61  jmcneill void	sbdsp_get_locks(void *, kmutex_t **, kmutex_t **);
    260  1.56      kent 
    261  1.56      kent int	sbdsp_midi_open(void *, int, void (*iintr)(void *, int),
    262  1.56      kent 	    void (*ointr)(void *), void *);
    263  1.56      kent void	sbdsp_midi_close(void *);
    264  1.56      kent int	sbdsp_midi_output(void *, int);
    265  1.56      kent void	sbdsp_midi_getinfo(void *, struct midi_info *);
    266   1.1    brezak #endif
    267