Home | History | Annotate | Line # | Download | only in ic
      1 /*	$NetBSD: interwavevar.h,v 1.20 2020/02/29 05:51:11 isaki Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997, 1999, 2008 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 	device_t sc_dev;
     79 	bus_space_tag_t sc_iot;		/* bus cookie	  */
     80 	isa_chipset_tag_t sc_ic;
     81 	kmutex_t sc_lock;
     82 	kmutex_t sc_intr_lock;
     83 
     84 	int	vers;
     85 	int	revision;
     86 	int	sc_fullduplex;
     87 	int	sc_irate;
     88 	int	sc_orate;
     89 	u_long	sc_dma_flags;
     90 	int	sc_irq;
     91 	int	sc_midi_irq;
     92 
     93 	void	(*sc_recintr)(void *);
     94 	void	*sc_recarg;
     95 	void	*sc_recdma_bp;
     96 	int	sc_playdrq;
     97 	bus_size_t sc_play_maxsize;
     98 	int	sc_recdrq;
     99 	bus_size_t sc_rec_maxsize;
    100 	int	sc_recdma_cnt;
    101 	int	sc_playing;
    102 	int	sc_maxdma;
    103 
    104 	u_long	outfifo;
    105 	u_long	infifo;
    106 
    107 	int	fifosize;
    108 	u_short	silence;
    109 
    110 	u_long	sc_last_dmasize;
    111 	u_long	sc_last_playsize;
    112 	u_long	sc_last_played;
    113 	u_long	sc_play_pos;	/* position of next free byte in buffer */
    114 	u_long	sc_play_start;	/* address of start of the buffer */
    115 	u_long	sc_play_end;	/* end */
    116 
    117 	void	(*sc_playintr)(void *);
    118 	void	*sc_playarg;
    119 	void	*sc_playdma_bp;
    120 	int	sc_playdma_cnt;
    121 
    122 	int	play_encoding;
    123 	int	play_channels;
    124 	int	play_precision;
    125 	int	sc_playlastcc;
    126 
    127 	int	sc_fillcount;
    128 	int	bytesout;
    129 	int	bytesin;
    130 
    131 	int	sc_playbuf_available;
    132 	int	sc_recbuf_available;
    133 
    134 	int	rec_encoding;
    135 	int	rec_channels;
    136 	int	rec_precision;
    137 	int	sc_reclastcc;
    138 
    139 	u_char	recfmtbits;
    140 	u_char	playfmtbits;
    141 	u_char	sc_recsrcbits;
    142 	int	(*sc_ih)(void *);
    143 	iw_port_info_t sc_mic;
    144 	iw_port_info_t sc_aux1;
    145 	iw_port_info_t sc_aux2;
    146 	iw_port_info_t sc_linein;
    147 	iw_port_info_t sc_lineout;
    148 	iw_port_info_t sc_rec;
    149 	iw_port_info_t sc_dac;
    150 	iw_port_info_t sc_loopback;
    151 	iw_port_info_t sc_monoin;
    152 	volatile u_short flags;		/* InterWave stat flags */
    153 
    154 	bus_space_handle_t dir_h;	/* dummy handle for direct access*/
    155 	int	codec_index;		/* Base Port for Codec */
    156 	bus_space_handle_t codec_index_h;
    157 	isa_chipset_tag_t sc_codec_ic;
    158 	int	pcdrar;			/* Base Port for Ext Device */
    159 	int	p2xr;			/* Compatibility Base Port */
    160 	bus_space_handle_t p2xr_h;
    161 	isa_chipset_tag_t sc_p2xr_ic;
    162 	int	p3xr;			/* MIDI and Synth Base Port */
    163 	bus_space_handle_t p3xr_h;
    164 	isa_chipset_tag_t sc_p3xr_ic;
    165 	int	p401ar;			/* Gen Purpose Reg. 1 address */
    166 	int	p201ar;			/* Game Ctrl normally at 0x201 */
    167 	int	pataar;			/* Base Address for ATAPI I/O Space */
    168 
    169 	int	p388ar;			/* Base Port for AdLib. It should bbe 388h */
    170 	int	pnprdp;			/* PNP read data port */
    171 	int	igidxr;			/* Gen Index Reg at P3XR+0x03 */
    172 	int	i16dp;			/* 16-bit data port at P3XR+0x04  */
    173 	int	i8dp;			/* 8-bit data port at P3XR+0x05 */
    174 	int	svsr;			/* Synth Voice Select at P3XR+0x02 */
    175 	int	cdatap;			/* Codec Indexed Data Port at PCODAR+0x01 */
    176 	int	csr1r;			/* Codec Stat Reg 1 at PCODAR+0x02 */
    177 	int	cxdr;			/* Play or Record Data Reg at PCODAR+0x03 */
    178 	int	gmxr;			/* GMCR or GMSR at P3XR+0x00 */
    179 	int	gmxdr;			/* GMTDR or GMRDR at P3XR+0x01 */
    180 	int	lmbdr;			/* LMBDR at P3XR+0x07 */
    181 	u_char	csn;			/* Card Select Number */
    182 	u_char	cmode;			/* Codec Operation Mode */
    183 	int	dma1_chan;		/* DMA channel 1 (local DMA & codec rec) */
    184 	int	dma2_chan;		/* DMA channel 2 (codec play) */
    185 	int	ext_chan;		/* Ext Dev DMA channel */
    186 	u_char	voices;			/* Number of active voices */
    187 	u_long	vendor;			/* Vendor ID and Product Identifier */
    188 	long	free_mem;		/* Address of First Free LM Block */
    189 	long	reserved_mem;		/* Amount of LM reserved by app. */
    190 	u_char	smode;			/* Synth Mode */
    191 	long	size_mem;		/* Total LM in bytes */
    192 	struct	cfdriver *iw_cd;
    193 	const struct audio_hw_if *iw_hw_if;
    194 };
    195 
    196 void	iwattach(struct iw_softc *);
    197 
    198 int	iwopen(struct iw_softc *, int);	/* open hardware */
    199 void	iwclose(void *);		/* close hardware */
    200 
    201 	/* Format. */
    202 int	iw_query_format(void *, audio_format_query_t *);
    203 int	iw_audio_set_format(void *, int,
    204 	    const audio_params_t *, const audio_params_t *,
    205 	    audio_filter_reg_t *, audio_filter_reg_t *);
    206 
    207 int	iw_commit_settings(void *);
    208 
    209 	/* Software en/decode functions, set if SW coding required by HW */
    210 void	iw_sw_encode(void *, int, u_char *, int);
    211 void	iw_sw_decode(void *, int, u_char *, int);
    212 
    213 	/* Start input/output routines. These usually control DMA. */
    214 int	iw_start_output(void *, void *, int, void (*)(void *), void *);
    215 int	iw_start_input(void *, void *, int, void (*)(void *), void *);
    216 
    217 int	iw_init_input(void *, void *, int);
    218 int	iw_init_output(void *, void *, int);
    219 int	iw_halt_output(void *);
    220 int	iw_halt_input(void *);
    221 
    222 int	iw_speaker_ctl(void *, int);
    223 int	iw_getdev(void *, struct audio_device *);
    224 
    225 	/* Mixer (in/out ports) */
    226 int	iw_set_port(void *, mixer_ctrl_t *);
    227 int	iw_get_port(void *, mixer_ctrl_t *);
    228 
    229 int	iw_query_devinfo(void *, mixer_devinfo_t *);
    230 
    231 struct malloc_type;
    232 void *	iw_malloc(void *, int, size_t);
    233 void	iw_free(void *, void *, size_t);
    234 size_t	iw_round_buffersize(void *, int, size_t);
    235 int	iw_get_props(void *);
    236 void	iw_get_locks(void *, kmutex_t **, kmutex_t **);
    237 
    238 #endif /* INTERWAVEVAR_H */
    239