sbdspvar.h revision 1.24
1/*	$NetBSD: sbdspvar.h,v 1.24 1997/07/27 01:17:08 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_MASTER_VOL	0
38#define SB_MIDI_VOL	1
39#define SB_CD_VOL	2
40#define SB_VOICE_VOL	3
41#define SB_OUTPUT_CLASS	4
42
43#define SB_MIC_VOL	5
44#define SB_LINE_IN_VOL	6
45#define	SB_RECORD_SOURCE 7
46#define SB_TREBLE	8
47#define SB_BASS		9
48#define SB_RECORD_CLASS	10
49
50#define SB_PCSPEAKER	11
51#define SB_INPUT_GAIN	12
52#define SB_OUTPUT_GAIN	13
53#define SB_AGC		14
54#define SB_INPUT_CLASS	15
55#define SB_EQUALIZATION_CLASS 16
56
57#define SB_NDEVS	17
58
59/*
60 * Software state, per SoundBlaster card.
61 * The soundblaster has multiple functionality, which we must demultiplex.
62 * One approach is to have one major device number for the soundblaster card,
63 * and use different minor numbers to indicate which hardware function
64 * we want.  This would make for one large driver.  Instead our approach
65 * is to partition the design into a set of drivers that share an underlying
66 * piece of hardware.  Most things are hard to share, for example, the audio
67 * and midi ports.  For audio, we might want to mix two processes' signals,
68 * and for midi we might want to merge streams (this is hard due to
69 * running status).  Moreover, we should be able to re-use the high-level
70 * modules with other kinds of hardware.  In this module, we only handle the
71 * most basic communications with the sb card.
72 */
73struct sbdsp_softc {
74	struct	device sc_dev;		/* base device */
75	struct	isadev sc_id;		/* ISA device */
76	isa_chipset_tag_t sc_ic;
77	bus_space_tag_t sc_iot;		/* tag */
78	bus_space_handle_t sc_ioh;	/* handle */
79	void	*sc_ih;			/* interrupt vectoring */
80
81	int	sc_iobase;		/* I/O port base address */
82	int	sc_irq;			/* interrupt */
83	int	sc_drq8;		/* DMA (8-bit) */
84	int	sc_drq16;		/* DMA (16-bit) */
85
86	struct	device *sc_isa;		/* pointer to ISA parent */
87
88	u_short	sc_open;		/* reference count of open calls */
89
90	u_char	gain[SB_NDEVS][2];	/* kept in input levels */
91#define SB_LEFT 0
92#define SB_RIGHT 1
93
94	u_int	out_port;		/* output port */
95	u_int	in_mask;		/* input ports */
96	u_int	in_port;		/* XXX needed for MI interface */
97	u_int	in_filter;		/* one of SB_TREBLE_EQ, SB_BASS_EQ, 0 */
98
99	u_int	spkr_state;		/* non-null is on */
100
101	u_int	sc_irate;		/* Sample rate for input */
102	u_int	sc_orate;		/* ...and output */
103	u_char	sc_itc;
104	u_char	sc_otc;
105
106	struct	sbmode *sc_imodep;
107	struct	sbmode *sc_omodep;
108	u_char	sc_ibmode;
109	u_char	sc_obmode;
110
111	u_long	sc_interrupts;		/* number of interrupts taken */
112	void	(*sc_intr)(void*);	/* dma completion intr handler */
113	void	(*sc_mintr)(void*, int);/* midi input intr handler */
114	void	*sc_arg;		/* arg for sc_intr() */
115
116	int	dmaflags;
117	caddr_t	dmaaddr;
118	vm_size_t	dmacnt;
119	int	dmachan;		/* active DMA channel */
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_mixer_model;
127#define SBM_NONE	0
128#define SBM_CT1335	1
129#define SBM_CT1345	2
130#define SBM_CT1745	3
131
132	u_int	sc_model;		/* DSP model */
133#define SB_UNK	-1
134#define SB_1	0			/* original SB */
135#define SB_20	1			/* SB 2 */
136#define SB_2x	2			/* SB 2, new version */
137#define SB_PRO	3			/* SB Pro */
138#define SB_JAZZ	4			/* Jazz 16 */
139#define SB_16	5			/* SB 16 */
140
141	u_int	sc_version;		/* DSP version */
142#define SBVER_MAJOR(v)	(((v)>>8) & 0xff)
143#define SBVER_MINOR(v)	((v)&0xff)
144};
145
146#define ISSBPRO(sc) ((sc)->sc_model == SB_PRO || (sc)->sc_model == SB_JAZZ)
147#define ISSBPROCLASS(sc) ((sc)->sc_model >= SB_PRO)
148#define ISSB16CLASS(sc) ((sc)->sc_model == SB_16)
149
150#ifdef _KERNEL
151int	sbdsp_open __P((struct sbdsp_softc *, dev_t, int));
152void	sbdsp_close __P((void *));
153
154int	sbdsp_probe __P((struct sbdsp_softc *));
155void	sbdsp_attach __P((struct sbdsp_softc *));
156
157int	sbdsp_set_in_gain __P((void *, u_int, u_char));
158int	sbdsp_set_in_gain_real __P((void *, u_int, u_char));
159int	sbdsp_get_in_gain __P((void *));
160int	sbdsp_set_out_gain __P((void *, u_int, u_char));
161int	sbdsp_set_out_gain_real __P((void *, u_int, u_char));
162int	sbdsp_get_out_gain __P((void *));
163int	sbdsp_set_monitor_gain __P((void *, u_int));
164int	sbdsp_get_monitor_gain __P((void *));
165int	sbdsp_query_encoding __P((void *, struct audio_encoding *));
166int	sbdsp_set_params __P((void *, int, struct audio_params *, struct audio_params *));
167int	sbdsp_round_blocksize __P((void *, int));
168int	sbdsp_set_out_port __P((void *, int));
169int	sbdsp_get_out_port __P((void *));
170int	sbdsp_set_in_port __P((void *, int));
171int	sbdsp_get_in_port __P((void *));
172int	sbdsp_get_avail_in_ports __P((void *));
173int	sbdsp_get_avail_out_ports __P((void *));
174int	sbdsp_speaker_ctl __P((void *, int));
175int	sbdsp_commit_settings __P((void *));
176
177int	sbdsp_dma_init_input __P((void *, void *, int));
178int	sbdsp_dma_init_output __P((void *, void *, int));
179int	sbdsp_dma_output __P((void *, void *, int, void (*)(void *), void*));
180int	sbdsp_dma_input __P((void *, void *, int, void (*)(void *), void*));
181
182int	sbdsp_haltdma __P((void *));
183int	sbdsp_contdma __P((void *));
184
185void	sbdsp_compress __P((int, u_char *, int));
186void	sbdsp_expand __P((int, u_char *, int));
187
188int	sbdsp_reset __P((struct sbdsp_softc *));
189void	sbdsp_spkron __P((struct sbdsp_softc *));
190void	sbdsp_spkroff __P((struct sbdsp_softc *));
191
192int	sbdsp_wdsp __P((struct sbdsp_softc *, int v));
193int	sbdsp_rdsp __P((struct sbdsp_softc *));
194
195int	sbdsp_intr __P((void *));
196
197int	sbdsp_set_sr __P((struct sbdsp_softc *, u_long *, int));
198int	sbdsp_setfd __P((void *, int));
199
200void	sbdsp_mix_write __P((struct sbdsp_softc *, int, int));
201int	sbdsp_mix_read __P((struct sbdsp_softc *, int));
202
203int	sbdsp_mixer_set_port __P((void *, mixer_ctrl_t *));
204int	sbdsp_mixer_get_port __P((void *, mixer_ctrl_t *));
205int	sbdsp_mixer_query_devinfo __P((void *, mixer_devinfo_t *));
206
207void 	*sb_malloc __P((void *, unsigned long, int, int));
208void	sb_free __P((void *, void *, int));
209unsigned long sb_round __P((void *, unsigned long));
210
211
212#endif
213