1 /* $NetBSD: interwavevar.h,v 1.8 2000/06/26 04:56:18 simonb 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_playlocked; 102 int sc_reclocked; 103 int sc_irq; 104 int sc_midi_irq; 105 106 void (*sc_recintr)__P((void *)); 107 void *sc_recarg; 108 void *sc_recdma_bp; 109 int sc_playdrq; 110 bus_size_t sc_play_maxsize; 111 int sc_recdrq; 112 bus_size_t sc_rec_maxsize; 113 int sc_recdma_cnt; 114 int sc_playing; 115 int sc_maxdma; 116 117 u_long outfifo; 118 u_long infifo; 119 120 int fifosize; 121 int playfirst; 122 u_short silence; 123 124 u_long sc_last_dmasize; 125 u_long sc_last_playsize; 126 u_long sc_last_played; 127 u_long sc_play_pos; /* position of next free byte in buffer */ 128 u_long sc_play_start; /* address of start of the buffer */ 129 u_long sc_play_end; /* end */ 130 131 void (*sc_playintr)__P((void *)); 132 void *sc_playarg; 133 void *sc_playdma_bp; 134 int sc_playdma_cnt; 135 136 int play_encoding; 137 int play_channels; 138 int play_precision; 139 int sc_playlastcc; 140 141 int sc_fillcount; 142 int bytesout; 143 int bytesin; 144 145 int sc_playbuf_available; 146 int sc_recbuf_available; 147 148 int rec_encoding; 149 int rec_channels; 150 int rec_precision; 151 int sc_reclastcc; 152 153 u_char recfmtbits; 154 u_char playfmtbits; 155 u_char sc_recsrcbits; 156 int (*sc_ih)__P((void *)); 157 iw_port_info_t sc_mic; 158 iw_port_info_t sc_aux1; 159 iw_port_info_t sc_aux2; 160 iw_port_info_t sc_linein; 161 iw_port_info_t sc_lineout; 162 iw_port_info_t sc_rec; 163 iw_port_info_t sc_dac; 164 iw_port_info_t sc_loopback; 165 iw_port_info_t sc_monoin; 166 volatile u_short flags; /* InterWave stat flags */ 167 168 bus_space_handle_t dir_h; /* dummy handle for direct access*/ 169 int codec_index; /* Base Port for Codec */ 170 bus_space_handle_t codec_index_h; 171 isa_chipset_tag_t sc_codec_ic; 172 int pcdrar; /* Base Port for Ext Device */ 173 int p2xr; /* Compatibility Base Port */ 174 bus_space_handle_t p2xr_h; 175 isa_chipset_tag_t sc_p2xr_ic; 176 int p3xr; /* MIDI and Synth Base Port */ 177 bus_space_handle_t p3xr_h; 178 isa_chipset_tag_t sc_p3xr_ic; 179 int p401ar; /* Gen Purpose Reg. 1 address */ 180 int p201ar; /* Game Ctrl normally at 0x201 */ 181 int pataar; /* Base Address for ATAPI I/O Space */ 182 183 int p388ar; /* Base Port for AdLib. It should bbe 388h */ 184 int pnprdp; /* PNP read data port */ 185 int igidxr; /* Gen Index Reg at P3XR+0x03 */ 186 int i16dp; /* 16-bit data port at P3XR+0x04 */ 187 int i8dp; /* 8-bit data port at P3XR+0x05 */ 188 int svsr; /* Synth Voice Select at P3XR+0x02 */ 189 int cdatap; /* Codec Indexed Data Port at PCODAR+0x01 */ 190 int csr1r; /* Codec Stat Reg 1 at PCODAR+0x02 */ 191 int cxdr; /* Play or Record Data Reg at PCODAR+0x03 */ 192 int gmxr; /* GMCR or GMSR at P3XR+0x00 */ 193 int gmxdr; /* GMTDR or GMRDR at P3XR+0x01 */ 194 int lmbdr; /* LMBDR at P3XR+0x07 */ 195 u_char csn; /* Card Select Number */ 196 u_char cmode; /* Codec Operation Mode */ 197 int dma1_chan; /* DMA channel 1 (local DMA & codec rec) */ 198 int dma2_chan; /* DMA channel 2 (codec play) */ 199 int ext_chan; /* Ext Dev DMA channel */ 200 u_char voices; /* Number of active voices */ 201 u_long vendor; /* Vendor ID and Product Identifier */ 202 long free_mem; /* Address of First Free LM Block */ 203 long reserved_mem; /* Amount of LM reserved by app. */ 204 u_char smode; /* Synth Mode */ 205 long size_mem; /* Total LM in bytes */ 206 struct cfdriver *iw_cd; 207 struct audio_hw_if *iw_hw_if; 208 }; 209 210 void iwattach __P((struct iw_softc *)); 211 212 int iwopen __P((struct iw_softc *, int)); /* open hardware */ 213 void iwclose __P((void *)); /* close hardware */ 214 215 /* Encoding. */ 216 /* XXX should we have separate in/out? */ 217 int iw_query_encoding __P((void *, struct audio_encoding *)); 218 int iw_set_params __P((void *, int, int, struct audio_params *, struct audio_params *)); 219 220 /* Hardware may have some say in the blocksize to choose */ 221 int iw_round_blocksize __P((void *, int)); 222 223 int iw_commit_settings __P((void *)); 224 225 /* Software en/decode functions, set if SW coding required by HW */ 226 void iw_sw_encode __P((void *, int, u_char *, int)); 227 void iw_sw_decode __P((void *, int, u_char *, int)); 228 229 /* Start input/output routines. These usually control DMA. */ 230 int iw_start_output __P((void *, void *, int, 231 void (*)(void *), void *)); 232 int iw_start_input __P((void *, void *, int, 233 void (*)(void *), void *)); 234 235 int iw_init_input __P((void *,void *,int)); 236 int iw_init_output __P((void *,void *,int)); 237 int iw_halt_output __P((void *)); 238 int iw_halt_input __P((void *)); 239 240 int iw_speaker_ctl __P((void *, int)); 241 int iw_getdev __P((void *, struct audio_device *)); 242 int iw_setfd __P((void *, int)); 243 244 /* Mixer (in/out ports) */ 245 int iw_set_port __P((void *, mixer_ctrl_t *)); 246 int iw_get_port __P((void *, mixer_ctrl_t *)); 247 248 int iw_query_devinfo __P((void *, mixer_devinfo_t *)); 249 250 void * iw_malloc __P((void *, int, size_t, int, int)); 251 void iw_free __P((void *,void *,int)); 252 size_t iw_round_buffersize __P((void *, int, size_t)); 253 paddr_t iw_mappage __P((void *, void *, off_t, int)); 254 int iw_get_props __P((void *)); 255 256 #endif /* INTERWAVEVAR_H */ 257