interwavevar.h revision 1.10 1 /* $NetBSD: interwavevar.h,v 1.10 2004/07/09 01:13:53 mycroft Exp $ */
2
3 /*
4 * Copyright (c) 1997, 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Author: Kari Mettinen
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the NetBSD
20 * Foundation, Inc. and its contributors.
21 * 4. Neither the name of The NetBSD Foundation nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38 #ifndef INTERWAVEVAR_H
39 #define INTERWAVEVAR_H
40
41 typedef struct iw_voice_info {
42 u_char bank; /* lower 2 bits select one of 4 4M bank for voice data */
43 u_long start; /* voice data start address */
44 u_long end;
45 #define SACI_IRQ 0x80
46 #define SACI_BACKWARDS 0x40
47 #define SACI_IRQ_ENABLE 0x20
48 #define SACI_BOUNCE 0x10
49 #define SACI_LOOP 0x08
50 #define SACI_16BIT 0x04
51 #define SACI_STOP_1 0x02
52 #define SACI_STOP_0 0x01
53 u_char format; /* SACI , voice direction, format */
54 u_char volume;
55 #define SVCI_VOLUME_IRQ 0x80
56 #define SVCI_DIRECTION 0x40
57 #define SVCI_IRQ_ENABLE 0x20
58 #define SVCI_BOUNCE 0x10
59 #define SVCI_LOOP 0x08
60 #define SVCI_PCM 0x04 /* for playback continue over voice end */
61 #define SVCI_STOP_1 0x02
62 #define SVCI_STOP_0 0x01
63 u_char volume_control;
64 u_short left_offset; /* usually fully left */
65 u_short right_offset;
66 u_char effect_acc;
67 #define SMSI_ROM 0x80
68 #define SMSI_ULAW 0x40
69 #define SMSI_OFFSET_ON 0x20
70 #define SMSI_ALT_EFF 0x10
71 #define SMSI_OFF 0x02
72 #define SMSI_EFFECT 0x01
73 u_char mode;
74
75 } iw_voice_info_t;
76
77 typedef struct iw_port_info {
78 char off;
79 char pad[3];
80 int voll;
81 int volr;
82 } iw_port_info_t;
83
84 struct iw_softc {
85 struct device sc_dev;
86 bus_space_tag_t sc_iot; /* bus cookie */
87 isa_chipset_tag_t sc_ic;
88
89 int vers;
90 int revision;
91 int sc_fullduplex;
92 int sc_open;
93 int sc_flags;
94 int sc_mode;
95 #define IW_OPEN 1
96 #define IW_READ 2
97 #define IW_WRITE 4
98 int sc_irate;
99 int sc_orate;
100 u_long sc_dma_flags;
101 int sc_irq;
102 int sc_midi_irq;
103
104 void (*sc_recintr)__P((void *));
105 void *sc_recarg;
106 void *sc_recdma_bp;
107 int sc_playdrq;
108 bus_size_t sc_play_maxsize;
109 int sc_recdrq;
110 bus_size_t sc_rec_maxsize;
111 int sc_recdma_cnt;
112 int sc_playing;
113 int sc_maxdma;
114
115 u_long outfifo;
116 u_long infifo;
117
118 int fifosize;
119 u_short silence;
120
121 u_long sc_last_dmasize;
122 u_long sc_last_playsize;
123 u_long sc_last_played;
124 u_long sc_play_pos; /* position of next free byte in buffer */
125 u_long sc_play_start; /* address of start of the buffer */
126 u_long sc_play_end; /* end */
127
128 void (*sc_playintr)__P((void *));
129 void *sc_playarg;
130 void *sc_playdma_bp;
131 int sc_playdma_cnt;
132
133 int play_encoding;
134 int play_channels;
135 int play_precision;
136 int sc_playlastcc;
137
138 int sc_fillcount;
139 int bytesout;
140 int bytesin;
141
142 int sc_playbuf_available;
143 int sc_recbuf_available;
144
145 int rec_encoding;
146 int rec_channels;
147 int rec_precision;
148 int sc_reclastcc;
149
150 u_char recfmtbits;
151 u_char playfmtbits;
152 u_char sc_recsrcbits;
153 int (*sc_ih)__P((void *));
154 iw_port_info_t sc_mic;
155 iw_port_info_t sc_aux1;
156 iw_port_info_t sc_aux2;
157 iw_port_info_t sc_linein;
158 iw_port_info_t sc_lineout;
159 iw_port_info_t sc_rec;
160 iw_port_info_t sc_dac;
161 iw_port_info_t sc_loopback;
162 iw_port_info_t sc_monoin;
163 volatile u_short flags; /* InterWave stat flags */
164
165 bus_space_handle_t dir_h; /* dummy handle for direct access*/
166 int codec_index; /* Base Port for Codec */
167 bus_space_handle_t codec_index_h;
168 isa_chipset_tag_t sc_codec_ic;
169 int pcdrar; /* Base Port for Ext Device */
170 int p2xr; /* Compatibility Base Port */
171 bus_space_handle_t p2xr_h;
172 isa_chipset_tag_t sc_p2xr_ic;
173 int p3xr; /* MIDI and Synth Base Port */
174 bus_space_handle_t p3xr_h;
175 isa_chipset_tag_t sc_p3xr_ic;
176 int p401ar; /* Gen Purpose Reg. 1 address */
177 int p201ar; /* Game Ctrl normally at 0x201 */
178 int pataar; /* Base Address for ATAPI I/O Space */
179
180 int p388ar; /* Base Port for AdLib. It should bbe 388h */
181 int pnprdp; /* PNP read data port */
182 int igidxr; /* Gen Index Reg at P3XR+0x03 */
183 int i16dp; /* 16-bit data port at P3XR+0x04 */
184 int i8dp; /* 8-bit data port at P3XR+0x05 */
185 int svsr; /* Synth Voice Select at P3XR+0x02 */
186 int cdatap; /* Codec Indexed Data Port at PCODAR+0x01 */
187 int csr1r; /* Codec Stat Reg 1 at PCODAR+0x02 */
188 int cxdr; /* Play or Record Data Reg at PCODAR+0x03 */
189 int gmxr; /* GMCR or GMSR at P3XR+0x00 */
190 int gmxdr; /* GMTDR or GMRDR at P3XR+0x01 */
191 int lmbdr; /* LMBDR at P3XR+0x07 */
192 u_char csn; /* Card Select Number */
193 u_char cmode; /* Codec Operation Mode */
194 int dma1_chan; /* DMA channel 1 (local DMA & codec rec) */
195 int dma2_chan; /* DMA channel 2 (codec play) */
196 int ext_chan; /* Ext Dev DMA channel */
197 u_char voices; /* Number of active voices */
198 u_long vendor; /* Vendor ID and Product Identifier */
199 long free_mem; /* Address of First Free LM Block */
200 long reserved_mem; /* Amount of LM reserved by app. */
201 u_char smode; /* Synth Mode */
202 long size_mem; /* Total LM in bytes */
203 struct cfdriver *iw_cd;
204 struct audio_hw_if *iw_hw_if;
205 };
206
207 void iwattach __P((struct iw_softc *));
208
209 int iwopen __P((struct iw_softc *, int)); /* open hardware */
210 void iwclose __P((void *)); /* close hardware */
211
212 /* Encoding. */
213 /* XXX should we have separate in/out? */
214 int iw_query_encoding __P((void *, struct audio_encoding *));
215 int iw_set_params __P((void *, int, int, struct audio_params *, struct audio_params *));
216
217 /* Hardware may have some say in the blocksize to choose */
218 int iw_round_blocksize __P((void *, int));
219
220 int iw_commit_settings __P((void *));
221
222 /* Software en/decode functions, set if SW coding required by HW */
223 void iw_sw_encode __P((void *, int, u_char *, int));
224 void iw_sw_decode __P((void *, int, u_char *, int));
225
226 /* Start input/output routines. These usually control DMA. */
227 int iw_start_output __P((void *, void *, int,
228 void (*)(void *), void *));
229 int iw_start_input __P((void *, void *, int,
230 void (*)(void *), void *));
231
232 int iw_init_input __P((void *,void *,int));
233 int iw_init_output __P((void *,void *,int));
234 int iw_halt_output __P((void *));
235 int iw_halt_input __P((void *));
236
237 int iw_speaker_ctl __P((void *, int));
238 int iw_getdev __P((void *, struct audio_device *));
239 int iw_setfd __P((void *, int));
240
241 /* Mixer (in/out ports) */
242 int iw_set_port __P((void *, mixer_ctrl_t *));
243 int iw_get_port __P((void *, mixer_ctrl_t *));
244
245 int iw_query_devinfo __P((void *, mixer_devinfo_t *));
246
247 struct malloc_type;
248 void * iw_malloc __P((void *, int, size_t, struct malloc_type *, int));
249 void iw_free __P((void *,void *,struct malloc_type *));
250 size_t iw_round_buffersize __P((void *, int, size_t));
251 paddr_t iw_mappage __P((void *, void *, off_t, int));
252 int iw_get_props __P((void *));
253
254 #endif /* INTERWAVEVAR_H */
255