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