Home | History | Annotate | Line # | Download | only in pci
emuxkivar.h revision 1.3.4.2
      1  1.3.4.2  he /*	$NetBSD: emuxkivar.h,v 1.3.4.2 2002/01/19 21:54:48 he Exp $	*/
      2  1.3.4.2  he 
      3  1.3.4.2  he /*-
      4  1.3.4.2  he  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5  1.3.4.2  he  * All rights reserved.
      6  1.3.4.2  he  *
      7  1.3.4.2  he  * This code is derived from software contributed to The NetBSD Foundation
      8  1.3.4.2  he  * by Yannick Montulet.
      9  1.3.4.2  he  *
     10  1.3.4.2  he  * Redistribution and use in source and binary forms, with or without
     11  1.3.4.2  he  * modification, are permitted provided that the following conditions
     12  1.3.4.2  he  * are met:
     13  1.3.4.2  he  * 1. Redistributions of source code must retain the above copyright
     14  1.3.4.2  he  *    notice, this list of conditions and the following disclaimer.
     15  1.3.4.2  he  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.3.4.2  he  *    notice, this list of conditions and the following disclaimer in the
     17  1.3.4.2  he  *    documentation and/or other materials provided with the distribution.
     18  1.3.4.2  he  * 3. All advertising materials mentioning features or use of this software
     19  1.3.4.2  he  *    must display the following acknowledgement:
     20  1.3.4.2  he  *	This product includes software developed by the NetBSD
     21  1.3.4.2  he  *	Foundation, Inc. and its contributors.
     22  1.3.4.2  he  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.3.4.2  he  *    contributors may be used to endorse or promote products derived
     24  1.3.4.2  he  *    from this software without specific prior written permission.
     25  1.3.4.2  he  *
     26  1.3.4.2  he  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.3.4.2  he  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.3.4.2  he  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.3.4.2  he  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.3.4.2  he  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.3.4.2  he  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.3.4.2  he  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.3.4.2  he  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.3.4.2  he  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.3.4.2  he  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.3.4.2  he  * POSSIBILITY OF SUCH DAMAGE.
     37  1.3.4.2  he  */
     38  1.3.4.2  he 
     39  1.3.4.2  he #ifndef _DEV_PCI_EMU10K1VAR_H_
     40  1.3.4.2  he #define _DEV_PCI_EMU10K1VAR_H_
     41  1.3.4.2  he 
     42  1.3.4.2  he #define	EMU_PCI_CBIO		0x10
     43  1.3.4.2  he 
     44  1.3.4.2  he /*
     45  1.3.4.2  he  * dma memory managment
     46  1.3.4.2  he  */
     47  1.3.4.2  he 
     48  1.3.4.2  he struct dmamem {
     49  1.3.4.2  he 	bus_dma_tag_t   dmat;
     50  1.3.4.2  he 	bus_size_t      size;
     51  1.3.4.2  he 	bus_size_t      align;
     52  1.3.4.2  he 	bus_size_t      bound;
     53  1.3.4.2  he 	bus_dma_segment_t *segs;
     54  1.3.4.2  he 	int             nsegs;
     55  1.3.4.2  he 	int             rsegs;
     56  1.3.4.2  he 	caddr_t         kaddr;
     57  1.3.4.2  he 	bus_dmamap_t    map;
     58  1.3.4.2  he };
     59  1.3.4.2  he 
     60  1.3.4.2  he #define	KERNADDR(ptr)		((void *)((ptr)->kaddr))
     61  1.3.4.2  he #define	DMASEGADDR(ptr, segno)	((ptr)->segs[segno].ds_addr)
     62  1.3.4.2  he #define	DMAADDR(ptr)		DMASEGADDR(ptr, 0)
     63  1.3.4.2  he #define DMASIZE(ptr)		((ptr)->size)
     64  1.3.4.2  he 
     65  1.3.4.2  he /*
     66  1.3.4.2  he  * Emu10k1 hardware limits
     67  1.3.4.2  he  */
     68  1.3.4.2  he 
     69  1.3.4.2  he #define	EMU_PTESIZE		4096
     70  1.3.4.2  he #define	EMU_MAXPTE ((EMU_CHAN_PSST_LOOPSTARTADDR_MASK + 1) /	\
     71  1.3.4.2  he 			EMU_PTESIZE)
     72  1.3.4.2  he #define EMU_NUMCHAN	64
     73  1.3.4.2  he #define EMU_NUMRECSRCS	3
     74  1.3.4.2  he 
     75  1.3.4.2  he #define	EMU_DMA_ALIGN	4096
     76  1.3.4.2  he #define	EMU_DMAMEM_NSEG	1
     77  1.3.4.2  he 
     78  1.3.4.2  he /*
     79  1.3.4.2  he  * Emu10k1 memory managment
     80  1.3.4.2  he  */
     81  1.3.4.2  he 
     82  1.3.4.2  he struct emuxki_mem {
     83  1.3.4.2  he 	LIST_ENTRY(emuxki_mem) next;
     84  1.3.4.2  he 	struct dmamem  *dmamem;
     85  1.3.4.2  he 	u_int16_t       ptbidx;
     86  1.3.4.2  he #define	EMU_RMEM		0xFFFF		/* recording memory */
     87  1.3.4.2  he };
     88  1.3.4.2  he 
     89  1.3.4.2  he /*
     90  1.3.4.2  he  * Emu10k1 play channel params
     91  1.3.4.2  he  */
     92  1.3.4.2  he 
     93  1.3.4.2  he struct emuxki_chanparms_fxsend {
     94  1.3.4.2  he 	struct {
     95  1.3.4.2  he 		u_int8_t        level, dest;
     96  1.3.4.2  he 	} a, b, c, d;
     97  1.3.4.2  he };
     98  1.3.4.2  he 
     99  1.3.4.2  he struct emuxki_chanparms_pitch {
    100  1.3.4.2  he 	u_int16_t       intial;	/* 4 bits of octave, 12 bits of fractional
    101  1.3.4.2  he 				 * octave */
    102  1.3.4.2  he 	u_int16_t       current;/* 0x4000 == unity pitch shift */
    103  1.3.4.2  he 	u_int16_t       target;	/* 0x4000 == unity pitch shift */
    104  1.3.4.2  he 	u_int8_t        envelope_amount;	/* Signed 2's complement, +/-
    105  1.3.4.2  he 						 * one octave peak extremes */
    106  1.3.4.2  he };
    107  1.3.4.2  he 
    108  1.3.4.2  he struct emuxki_chanparms_envelope {
    109  1.3.4.2  he 	u_int16_t       current_state;	/* 0x8000-n == 666*n usec delay */
    110  1.3.4.2  he 	u_int8_t        hold_time;	/* 127-n == n*(volume ? 88.2 :
    111  1.3.4.2  he 					 * 42)msec */
    112  1.3.4.2  he 	u_int8_t        attack_time;	/* 0 = infinite, 1 = (volume ? 11 :
    113  1.3.4.2  he 					 * 10.9) msec, 0x7f = 5.5msec */
    114  1.3.4.2  he 	u_int8_t        sustain_level;	/* 127 = full, 0 = off, 0.75dB
    115  1.3.4.2  he 					 * increments */
    116  1.3.4.2  he 	u_int8_t        decay_time;	/* 0 = 43.7msec, 1 = 21.8msec, 0x7f =
    117  1.3.4.2  he 					 * 22msec */
    118  1.3.4.2  he };
    119  1.3.4.2  he 
    120  1.3.4.2  he struct emuxki_chanparms_volume {
    121  1.3.4.2  he 	u_int16_t current, target;
    122  1.3.4.2  he 	struct emuxki_chanparms_envelope envelope;
    123  1.3.4.2  he };
    124  1.3.4.2  he 
    125  1.3.4.2  he struct emuxki_chanparms_filter {
    126  1.3.4.2  he 	u_int16_t       initial_cutoff_frequency;
    127  1.3.4.2  he 	/*
    128  1.3.4.2  he 	 * 6 most  significant bits are semitones, 2 least significant bits
    129  1.3.4.2  he 	 * are fractions
    130  1.3.4.2  he 	 */
    131  1.3.4.2  he 	u_int16_t       current_cutoff_frequency;
    132  1.3.4.2  he 	u_int16_t       target_cutoff_frequency;
    133  1.3.4.2  he 	u_int8_t        lowpass_resonance_height;
    134  1.3.4.2  he 	u_int8_t        interpolation_ROM;	/* 1 = full band, 7 = low
    135  1.3.4.2  he 						 * pass */
    136  1.3.4.2  he 	u_int8_t        envelope_amount;	/* Signed 2's complement, +/-
    137  1.3.4.2  he 						 * six octaves peak extremes */
    138  1.3.4.2  he 	u_int8_t        LFO_modulation_depth;	/* Signed 2's complement, +/-
    139  1.3.4.2  he 						 * three octave extremes */
    140  1.3.4.2  he };
    141  1.3.4.2  he 
    142  1.3.4.2  he struct emuxki_chanparms_loop {
    143  1.3.4.2  he 	u_int32_t       start;	/* index in the PTB (in samples) */
    144  1.3.4.2  he 	u_int32_t       end;	/* index in the PTB (in samples) */
    145  1.3.4.2  he };
    146  1.3.4.2  he 
    147  1.3.4.2  he struct emuxki_chanparms_modulation {
    148  1.3.4.2  he 	struct emuxki_chanparms_envelope envelope;
    149  1.3.4.2  he 	u_int16_t       LFO_state;	/* 0x8000-n = 666*n usec delay */
    150  1.3.4.2  he };
    151  1.3.4.2  he 
    152  1.3.4.2  he struct emuxki_chanparms_vibrato_LFO {
    153  1.3.4.2  he 	u_int16_t       state;		/* 0x8000-n == 666*n usec delay */
    154  1.3.4.2  he 	u_int8_t        modulation_depth;	/* Signed 2's complement, +/-
    155  1.3.4.2  he 						 * one octave extremes */
    156  1.3.4.2  he 	u_int8_t        vibrato_depth;	/* Signed 2's complement, +/- one
    157  1.3.4.2  he 					 * octave extremes */
    158  1.3.4.2  he 	u_int8_t        frequency;	/* 0.039Hz steps, maximum of 9.85 Hz */
    159  1.3.4.2  he };
    160  1.3.4.2  he 
    161  1.3.4.2  he struct emuxki_channel {
    162  1.3.4.2  he 	u_int8_t        num;	/* voice number */
    163  1.3.4.2  he 	struct emuxki_voice *voice;
    164  1.3.4.2  he 	struct emuxki_chanparms_fxsend fxsend;
    165  1.3.4.2  he 	struct emuxki_chanparms_pitch pitch;
    166  1.3.4.2  he 	u_int16_t       initial_attenuation;	/* 0.375dB steps */
    167  1.3.4.2  he 	struct emuxki_chanparms_volume volume;
    168  1.3.4.2  he 	struct emuxki_chanparms_filter filter;
    169  1.3.4.2  he 	struct emuxki_chanparms_loop loop;
    170  1.3.4.2  he 	struct emuxki_chanparms_modulation modulation;
    171  1.3.4.2  he 	struct emuxki_chanparms_vibrato_LFO vibrato_LFO;
    172  1.3.4.2  he 	u_int8_t        tremolo_depth;
    173  1.3.4.2  he };
    174  1.3.4.2  he 
    175  1.3.4.2  he /*
    176  1.3.4.2  he  * Voices, streams
    177  1.3.4.2  he  */
    178  1.3.4.2  he 
    179  1.3.4.2  he typedef enum {
    180  1.3.4.2  he 	EMU_RECSRC_MIC = 0,
    181  1.3.4.2  he 	EMU_RECSRC_ADC,
    182  1.3.4.2  he 	EMU_RECSRC_FX,
    183  1.3.4.2  he 	EMU_RECSRC_NOTSET
    184  1.3.4.2  he } emuxki_recsrc_t;
    185  1.3.4.2  he 
    186  1.3.4.2  he struct emuxki_voice {
    187  1.3.4.2  he 	struct emuxki_softc *sc;	/* our softc */
    188  1.3.4.2  he 
    189  1.3.4.2  he 	u_int8_t        use;
    190  1.3.4.2  he #define	EMU_VOICE_USE_PLAY		(1 << 0)
    191  1.3.4.2  he 	u_int8_t        state;
    192  1.3.4.2  he #define EMU_VOICE_STATE_STARTED	(1 << 0)
    193  1.3.4.2  he 	u_int8_t        stereo;
    194  1.3.4.2  he #define	EMU_VOICE_STEREO_NOTSET	0xFF
    195  1.3.4.2  he 	u_int8_t        b16;
    196  1.3.4.2  he 	u_int32_t       sample_rate;
    197  1.3.4.2  he 	union {
    198  1.3.4.2  he 		struct emuxki_channel *chan[2];
    199  1.3.4.2  he 		emuxki_recsrc_t source;
    200  1.3.4.2  he 	} dataloc;
    201  1.3.4.2  he 	struct emuxki_mem *buffer;
    202  1.3.4.2  he 	u_int16_t       blksize;/* in samples */
    203  1.3.4.2  he 	u_int16_t       trigblk;/* blk on which to trigger inth */
    204  1.3.4.2  he 	u_int16_t       blkmod;	/* Modulo value to wrap trigblk */
    205  1.3.4.2  he 	u_int16_t       timerate;
    206  1.3.4.2  he 	void            (*inth) (void *);
    207  1.3.4.2  he 	void           *inthparam;
    208  1.3.4.2  he 	LIST_ENTRY(emuxki_voice) next;
    209  1.3.4.2  he };
    210  1.3.4.2  he 
    211  1.3.4.2  he #if 0 /* Not yet */
    212  1.3.4.2  he /*
    213  1.3.4.2  he  * I intend this to be able to manage things like AC-3
    214  1.3.4.2  he  */
    215  1.3.4.2  he struct emuxki_stream {
    216  1.3.4.2  he 	struct emu10k1			*emu;
    217  1.3.4.2  he 	u_int8_t			nmono;
    218  1.3.4.2  he 	u_int8_t			nstereo;
    219  1.3.4.2  he 	struct emuxki_voice		*mono;
    220  1.3.4.2  he 	struct emuxki_voice		*stereo;
    221  1.3.4.2  he 	LIST_ENTRY(emuxki_stream)	next;
    222  1.3.4.2  he };
    223  1.3.4.2  he #endif /* Not yet */
    224  1.3.4.2  he 
    225  1.3.4.2  he struct emuxki_softc {
    226  1.3.4.2  he 	struct device   sc_dev;
    227  1.3.4.2  he 
    228  1.3.4.2  he 	/* Autoconfig parameters */
    229  1.3.4.2  he 	bus_space_tag_t 	sc_iot;
    230  1.3.4.2  he 	bus_space_handle_t	sc_ioh;
    231  1.3.4.2  he 	bus_addr_t		sc_iob;
    232  1.3.4.2  he 	bus_size_t		sc_ios;
    233  1.3.4.2  he 	pci_chipset_tag_t	sc_pc;		/* PCI tag */
    234  1.3.4.2  he 	bus_dma_tag_t		sc_dmat;
    235  1.3.4.2  he 	void			*sc_ih;		/* interrupt handler */
    236  1.3.4.2  he 
    237  1.3.4.2  he 	/* EMU10K1 device structures */
    238  1.3.4.2  he 	LIST_HEAD(, emuxki_mem) mem;
    239  1.3.4.2  he 
    240  1.3.4.2  he 	struct dmamem		*ptb;
    241  1.3.4.2  he 	struct dmamem		*silentpage;
    242  1.3.4.2  he 
    243  1.3.4.2  he 	struct emuxki_channel	*channel[EMU_NUMCHAN];
    244  1.3.4.2  he 	struct emuxki_voice	*recsrc[EMU_NUMRECSRCS];
    245  1.3.4.2  he 
    246  1.3.4.2  he 	LIST_HEAD(, emuxki_voice) voices;
    247  1.3.4.2  he 	/* LIST_HEAD(, emuxki_stream)	streams; */
    248  1.3.4.2  he 
    249  1.3.4.2  he 	u_int8_t		timerstate;
    250  1.3.4.2  he #define	EMU_TIMER_STATE_ENABLED	1
    251  1.3.4.2  he 
    252  1.3.4.2  he 	struct ac97_host_if	hostif;
    253  1.3.4.2  he 	struct ac97_codec_if	*codecif;
    254  1.3.4.2  he 	struct device		*sc_audev;
    255  1.3.4.2  he 
    256  1.3.4.2  he 	struct emuxki_voice	*pvoice, *rvoice, *lvoice;
    257  1.3.4.2  he };
    258  1.3.4.2  he 
    259  1.3.4.2  he #endif				/* !_DEV_PCI_EMU10K1VAR_H_ */
    260