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