Home | History | Annotate | Line # | Download | only in ic
interwavevar.h revision 1.3
      1 #ifndef INTERWAVEVAR_H
      2 #define INTERWAVEVAR_H
      3 
      4 /*	$NetBSD: interwavevar.h,v 1.3 1997/10/19 07:42:11 augustss Exp $	*/
      5 
      6 /*
      7  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      8  * All rights reserved.
      9  *
     10  * Author: Kari Mettinen
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *        This product includes software developed by the NetBSD
     23  *        Foundation, Inc. and its contributors.
     24  * 4. Neither the name of The NetBSD Foundation nor the names of its
     25  *    contributors may be used to endorse or promote products derived
     26  *    from this software without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     29  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     31  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     32  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     38  * POSSIBILITY OF SUCH DAMAGE.
     39  */
     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 	struct	device *sc_isa;
     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 	int	sc_recdrq;
    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 	int	playfirst;
    120 	u_short	silence;
    121 
    122 	u_long	sc_last_dmasize;
    123 	u_long	sc_last_playsize;
    124 	u_long	sc_last_played;
    125 	u_long	sc_play_pos;	/* position of next free byte in buffer */
    126 	u_long	sc_play_start;	/* address of start of the buffer */
    127 	u_long	sc_play_end;	/* end */
    128 
    129 	void	(*sc_playintr)__P((void *));
    130 	void	*sc_playarg;
    131 	void	*sc_playdma_bp;
    132 	int	sc_playdma_cnt;
    133 
    134 	int	play_encoding;
    135 	int	play_channels;
    136 	int	play_precision;
    137 	int	sc_playlastcc;
    138 
    139 	int	sc_fillcount;
    140 	int	bytesout;
    141 	int	bytesin;
    142 
    143 	int	sc_playbuf_available;
    144 	int	sc_recbuf_available;
    145 
    146 	int	rec_encoding;
    147 	int	rec_channels;
    148 	int	rec_precision;
    149 	int	sc_reclastcc;
    150 
    151 	u_char	recfmtbits;
    152 	u_char	playfmtbits;
    153 	u_char	sc_recsrcbits;
    154 	int	(*sc_ih)__P((void *));
    155 	iw_port_info_t sc_mic;
    156 	iw_port_info_t sc_aux1;
    157 	iw_port_info_t sc_aux2;
    158 	iw_port_info_t sc_linein;
    159 	iw_port_info_t sc_lineout;
    160 	iw_port_info_t sc_rec;
    161 	iw_port_info_t sc_dac;
    162 	iw_port_info_t sc_loopback;
    163 	iw_port_info_t sc_monoin;
    164 	volatile u_short flags;		/* InterWave stat flags */
    165 
    166 	bus_space_handle_t dir_h;	/* dummy handle for direct access*/
    167 	int	codec_index;		/* Base Port for Codec */
    168 	bus_space_handle_t codec_index_h;
    169 	isa_chipset_tag_t sc_codec_ic;
    170 	int	pcdrar;		      	/* Base Port for Ext Device */
    171 	int	p2xr;			/* Compatibility Base Port */
    172 	bus_space_handle_t p2xr_h;
    173 	isa_chipset_tag_t sc_p2xr_ic;
    174 	int	p3xr;			/* MIDI and Synth Base Port */
    175 	bus_space_handle_t p3xr_h;
    176 	isa_chipset_tag_t sc_p3xr_ic;
    177 	int	p401ar;		      	/* Gen Purpose Reg. 1 address */
    178 	int	p201ar;		      	/* Game Ctrl normally at 0x201 */
    179 	int	pataar;		      	/* Base Address for ATAPI I/O Space */
    180 
    181 	int	p388ar;		      	/* Base Port for AdLib. It should bbe 388h */
    182 	int	pnprdp;		      	/* PNP read data port */
    183 	int	igidxr;		      	/* Gen Index Reg at P3XR+0x03 */
    184 	int	i16dp;		       	/* 16-bit data port at P3XR+0x04  */
    185 	int	i8dp;			/* 8-bit data port at P3XR+0x05 */
    186 	int	svsr;			/* Synth Voice Select at P3XR+0x02 */
    187 	int	cdatap;		      	/* Codec Indexed Data Port at PCODAR+0x01 */
    188 	int	csr1r;		       	/* Codec Stat Reg 1 at PCODAR+0x02 */
    189 	int	cxdr;			/* Play or Record Data Reg at PCODAR+0x03 */
    190 	int	gmxr;			/* GMCR or GMSR at P3XR+0x00 */
    191 	int	gmxdr;		       	/* GMTDR or GMRDR at P3XR+0x01 */
    192 	int	lmbdr;		       	/* LMBDR at P3XR+0x07 */
    193 	u_char	csn;			/* Card Select Number */
    194 	u_char	cmode;		       	/* Codec Operation Mode */
    195 	int	dma1_chan;		/* DMA channel 1 (local DMA & codec rec) */
    196 	int	dma2_chan;		/* DMA channel 2 (codec play) */
    197 	int	ext_chan;		/* Ext Dev DMA channel */
    198 	u_char	voices;		      	/* Number of active voices */
    199 	u_long	vendor;		     	/* Vendor ID and Product Identifier */
    200 	long	free_mem;		/* Address of First Free LM Block */
    201 	long	reserved_mem;	       	/* Amount of LM reserved by app. */
    202 	u_char	smode;		       	/* Synth Mode */
    203 	long	size_mem;		/* Total LM in bytes */
    204 	struct	cfdriver *iw_cd;
    205 	struct	audio_hw_if *iw_hw_if;
    206 };
    207 
    208 void	iwattach __P((struct iw_softc *));
    209 
    210 int     iwopen __P((struct iw_softc *, int));       /* open hardware */
    211 void    iwclose __P((void *));	  	/* close hardware */
    212 
    213 	/* Encoding. */
    214 	/* XXX should we have separate in/out? */
    215 int     iw_query_encoding __P((void *, struct audio_encoding *));
    216 int     iw_set_params __P((void *, int, int, struct audio_params *,  struct audio_params *));
    217 
    218 	/* Hardware may have some say in the blocksize to choose */
    219 int     iw_round_blocksize __P((void *, int));
    220 
    221 int     iw_commit_settings __P((void *));
    222 
    223 	/* Software en/decode functions, set if SW coding required by HW */
    224 void    iw_sw_encode __P((void *, int, u_char *, int));
    225 void    iw_sw_decode __P((void *, int, u_char *, int));
    226 
    227 	/* Start input/output routines. These usually control DMA. */
    228 int     iw_start_output __P((void *, void *, int,
    229 				    void (*)(void *), void *));
    230 int     iw_start_input __P((void *, void *, int,
    231 			           void (*)(void *), void *));
    232 
    233 int     iw_init_input __P((void *,void *,int));
    234 int     iw_init_output __P((void *,void *,int));
    235 int     iw_halt_output __P((void *));
    236 int     iw_halt_input __P((void *));
    237 
    238 int     iw_speaker_ctl __P((void *, int));
    239 int     iw_getdev __P((void *, struct audio_device *));
    240 int     iw_setfd __P((void *, int));
    241 
    242         /* Mixer (in/out ports) */
    243 int     iw_set_port __P((void *, mixer_ctrl_t *));
    244 int     iw_get_port __P((void *, mixer_ctrl_t *));
    245 
    246 int     iw_query_devinfo __P((void *, mixer_devinfo_t *));
    247 
    248 void *  iw_malloc __P((void *, u_long, int, int));
    249 void    iw_free __P((void *,void *,int));
    250 u_long	iw_round __P((void *, u_long));
    251 int     iw_mappage __P((void *, void *, int, int));
    252 int     iw_get_props __P((void *));
    253 
    254 #endif /* INTERWAVEVAR_H */
    255