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