1 /* $NetBSD: emuxkivar.h,v 1.11 2008/04/28 20:23:54 martin Exp $ */
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _DEV_PCI_EMU10K1VAR_H_
33 #define _DEV_PCI_EMU10K1VAR_H_
35 #define EMU_PCI_CBIO 0x10
36 #define EMU_SUBSYS_APS 0x40011102
39 * DMA memory management
47 bus_dma_segment_t
*segs
;
54 #define KERNADDR(ptr) ((void *)((ptr)->kaddr))
55 #define DMASEGADDR(ptr, segno) ((ptr)->segs[segno].ds_addr)
56 #define DMAADDR(ptr) DMASEGADDR(ptr, 0)
57 #define DMASIZE(ptr) ((ptr)->size)
60 * Emu10k1 hardware limits
63 #define EMU_PTESIZE 4096
64 #define EMU_MAXPTE ((EMU_CHAN_PSST_LOOPSTARTADDR_MASK + 1) / \
66 #define EMU_NUMCHAN 64
67 #define EMU_NUMRECSRCS 3
69 #define EMU_DMA_ALIGN 4096
70 #define EMU_DMAMEM_NSEG 1
73 * Emu10k1 memory management
77 LIST_ENTRY(emuxki_mem
) next
;
78 struct dmamem
*dmamem
;
80 #define EMU_RMEM 0xFFFF /* recording memory */
84 * Emu10k1 play channel params
87 struct emuxki_chanparms_fxsend
{
90 } a
, b
, c
, d
, e
, f
, g
, h
;
93 struct emuxki_chanparms_pitch
{
94 uint16_t initial
;/* 4 bits of octave, 12 bits of fractional
96 uint16_t current
;/* 0x4000 == unity pitch shift */
97 uint16_t target
; /* 0x4000 == unity pitch shift */
98 uint8_t envelope_amount
; /* Signed 2's complement, +/-
99 * one octave peak extremes */
102 struct emuxki_chanparms_envelope
{
103 uint16_t current_state
; /* 0x8000-n == 666*n usec delay */
104 uint8_t hold_time
; /* 127-n == n*(volume ? 88.2 :
106 uint8_t attack_time
; /* 0 = infinite, 1 = (volume ? 11 :
107 * 10.9) msec, 0x7f = 5.5msec */
108 uint8_t sustain_level
; /* 127 = full, 0 = off, 0.75dB
110 uint8_t decay_time
; /* 0 = 43.7msec, 1 = 21.8msec, 0x7f =
114 struct emuxki_chanparms_volume
{
115 uint16_t current
, target
;
116 struct emuxki_chanparms_envelope envelope
;
119 struct emuxki_chanparms_filter
{
120 uint16_t initial_cutoff_frequency
;
122 * 6 most significant bits are semitones, 2 least significant bits
125 uint16_t current_cutoff_frequency
;
126 uint16_t target_cutoff_frequency
;
127 uint8_t lowpass_resonance_height
;
128 uint8_t interpolation_ROM
; /* 1 = full band, 7 = low
130 uint8_t envelope_amount
; /* Signed 2's complement, +/-
131 * six octaves peak extremes */
132 uint8_t LFO_modulation_depth
; /* Signed 2's complement, +/-
133 * three octave extremes */
136 struct emuxki_chanparms_loop
{
137 uint32_t start
; /* index in the PTB (in samples) */
138 uint32_t end
; /* index in the PTB (in samples) */
141 struct emuxki_chanparms_modulation
{
142 struct emuxki_chanparms_envelope envelope
;
143 uint16_t LFO_state
; /* 0x8000-n = 666*n usec delay */
146 struct emuxki_chanparms_vibrato_LFO
{
147 uint16_t state
; /* 0x8000-n == 666*n usec delay */
148 uint8_t modulation_depth
; /* Signed 2's complement, +/-
149 * one octave extremes */
150 uint8_t vibrato_depth
; /* Signed 2's complement, +/- one
152 uint8_t frequency
; /* 0.039Hz steps, maximum of 9.85 Hz */
155 struct emuxki_channel
{
156 uint8_t num
; /* voice number */
157 struct emuxki_voice
*voice
;
158 struct emuxki_chanparms_fxsend fxsend
;
159 struct emuxki_chanparms_pitch pitch
;
160 uint16_t initial_attenuation
; /* 0.375dB steps */
161 struct emuxki_chanparms_volume volume
;
162 struct emuxki_chanparms_filter filter
;
163 struct emuxki_chanparms_loop loop
;
164 struct emuxki_chanparms_modulation modulation
;
165 struct emuxki_chanparms_vibrato_LFO vibrato_LFO
;
166 uint8_t tremolo_depth
;
180 struct emuxki_voice
{
181 struct emuxki_softc
*sc
; /* our softc */
184 #define EMU_VOICE_USE_PLAY (1 << 0)
186 #define EMU_VOICE_STATE_STARTED (1 << 0)
188 #define EMU_VOICE_STEREO_NOTSET 0xFF
190 uint32_t sample_rate
;
192 struct emuxki_channel
*chan
[2];
193 emuxki_recsrc_t source
;
195 struct emuxki_mem
*buffer
;
196 uint16_t blksize
;/* in samples */
197 uint16_t trigblk
;/* blk on which to trigger inth */
198 uint16_t blkmod
; /* Modulo value to wrap trigblk */
200 void (*inth
)(void *);
202 LIST_ENTRY(emuxki_voice
) next
;
207 * I intend this to be able to manage things like AC-3
209 struct emuxki_stream
{
213 struct emuxki_voice
*mono
;
214 struct emuxki_voice
*stereo
;
215 LIST_ENTRY(emuxki_stream
) next
;
219 struct emuxki_softc
{
221 audio_device_t sc_audv
;
223 EMUXKI_SBLIVE
= 0x00, EMUXKI_AUDIGY
= 0x01,
224 EMUXKI_AUDIGY2
= 0x02, EMUXKI_LIVE_5_1
= 0x04,
228 /* Autoconfig parameters */
229 bus_space_tag_t sc_iot
;
230 bus_space_handle_t sc_ioh
;
233 pci_chipset_tag_t sc_pc
; /* PCI tag */
234 bus_dma_tag_t sc_dmat
;
235 void *sc_ih
; /* interrupt handler */
237 /* EMU10K1 device structures */
238 LIST_HEAD(, emuxki_mem
) mem
;
241 struct dmamem
*silentpage
;
243 struct emuxki_channel
*channel
[EMU_NUMCHAN
];
244 struct emuxki_voice
*recsrc
[EMU_NUMRECSRCS
];
246 LIST_HEAD(, emuxki_voice
) voices
;
247 /* LIST_HEAD(, emuxki_stream) streams; */
250 #define EMU_TIMER_STATE_ENABLED 1
252 struct ac97_host_if hostif
;
253 struct ac97_codec_if
*codecif
;
256 struct emuxki_voice
*pvoice
, *rvoice
, *lvoice
;
259 #endif /* !_DEV_PCI_EMU10K1VAR_H_ */