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