35#include <machine/bus.h>
42#include <sys/sysctl.h>
48#include <machine/clock.h>
50#ifdef HAVE_KERNEL_OPTION_HEADERS
64#define HAS_AC97 0x0004
66#define IS_EMU10K1 0x0008
67#define IS_EMU10K2 0x0010
68#define IS_CA0102 0x0020
69#define IS_CA0108 0x0040
70#define IS_UNKNOWN 0x0080
72#define BROKEN_DIGITAL 0x0100
73#define DIGITAL_ONLY 0x0200
75#define IS_CARDBUS 0x0400
79#define SPDIF_MODE_PCM 1
80#define SPDIF_MODE_AC3 2
99#define GPR(i) (sc->gpr_base+(i))
100#define INP(i) (sc->input_base+(i))
101#define OUTP(i) (sc->output_base+(i))
103#define FX2(i) (sc->efxc_base+(i))
104#define DSP_CONST(i) (sc->dsp_zero+(i))
106#define COND_NORMALIZED DSP_CONST(0x1)
107#define COND_BORROW DSP_CONST(0x2)
108#define COND_MINUS DSP_CONST(0x3)
109#define COND_LESS_ZERO DSP_CONST(0x4)
110#define COND_EQ_ZERO DSP_CONST(0x5)
111#define COND_SATURATION DSP_CONST(0x6)
112#define COND_NEQ_ZERO DSP_CONST(0x8)
114#define DSP_ACCUM DSP_CONST(0x16)
115#define DSP_CCR DSP_CONST(0x17)
118#define IN_AC97_L 0x00
119#define IN_AC97_R 0x01
120#define IN_AC97 IN_AC97_L
121#define IN_SPDIF_CD_L 0x02
122#define IN_SPDIF_CD_R 0x03
123#define IN_SPDIF_CD IN_SPDIF_CD_L
124#define IN_ZOOM_L 0x04
125#define IN_ZOOM_R 0x05
126#define IN_ZOOM IN_ZOOM_L
127#define IN_TOSLINK_L 0x06
128#define IN_TOSLINK_R 0x07
129#define IN_TOSLINK IN_TOSLINK_L
130#define IN_LINE1_L 0x08
131#define IN_LINE1_R 0x09
132#define IN_LINE1 IN_LINE1_L
133#define IN_COAX_SPDIF_L 0x0a
134#define IN_COAX_SPDIF_R 0x0b
135#define IN_COAX_SPDIF IN_COAX_SPDIF_L
136#define IN_LINE2_L 0x0c
137#define IN_LINE2_R 0x0d
138#define IN_LINE2 IN_LINE2_L
143#define OUT_AC97_L 0x00
144#define OUT_AC97_R 0x01
145#define OUT_AC97 OUT_AC97_L
146#define OUT_A_FRONT OUT_AC97
147#define OUT_TOSLINK_L 0x02
148#define OUT_TOSLINK_R 0x03
149#define OUT_TOSLINK OUT_TOSLINK_L
150#define OUT_D_CENTER 0x04
151#define OUT_D_SUB 0x05
152#define OUT_HEADPHONE_L 0x06
153#define OUT_HEADPHONE_R 0x07
154#define OUT_HEADPHONE OUT_HEADPHONE_L
155#define OUT_REAR_L 0x08
156#define OUT_REAR_R 0x09
157#define OUT_REAR OUT_REAR_L
158#define OUT_ADC_REC_L 0x0a
159#define OUT_ADC_REC_R 0x0b
160#define OUT_ADC_REC OUT_ADC_REC_L
161#define OUT_MIC_CAP 0x0c
164#define OUT_A_CENTER 0x11
165#define OUT_A_SUB 0x12
168#define A_IN_AC97_L 0x00
169#define A_IN_AC97_R 0x01
170#define A_IN_AC97 A_IN_AC97_L
171#define A_IN_SPDIF_CD_L 0x02
172#define A_IN_SPDIF_CD_R 0x03
173#define A_IN_SPDIF_CD A_IN_SPDIF_CD_L
174#define A_IN_O_SPDIF_L 0x04
175#define A_IN_O_SPDIF_R 0x05
176#define A_IN_O_SPDIF A_IN_O_SPDIF_L
177#define A_IN_LINE2_L 0x08
178#define A_IN_LINE2_R 0x09
179#define A_IN_LINE2 A_IN_LINE2_L
180#define A_IN_R_SPDIF_L 0x0a
181#define A_IN_R_SPDIF_R 0x0b
182#define A_IN_R_SPDIF A_IN_R_SPDIF_L
183#define A_IN_AUX2_L 0x0c
184#define A_IN_AUX2_R 0x0d
185#define A_IN_AUX2 A_IN_AUX2_L
188#define A_OUT_D_FRONT_L 0x00
189#define A_OUT_D_FRONT_R 0x01
190#define A_OUT_D_FRONT A_OUT_D_FRONT_L
191#define A_OUT_D_CENTER 0x02
192#define A_OUT_D_SUB 0x03
193#define A_OUT_D_SIDE_L 0x04
194#define A_OUT_D_SIDE_R 0x05
195#define A_OUT_D_SIDE A_OUT_D_SIDE_L
196#define A_OUT_D_REAR_L 0x06
197#define A_OUT_D_REAR_R 0x07
198#define A_OUT_D_REAR A_OUT_D_REAR_L
201#define A_OUT_HPHONE_L 0x04
202#define A_OUT_HPHONE_R 0x05
203#define A_OUT_HPHONE A_OUT_HPHONE_L
205#define A_OUT_A_FRONT_L 0x08
206#define A_OUT_A_FRONT_R 0x09
207#define A_OUT_A_FRONT A_OUT_A_FRONT_L
208#define A_OUT_A_CENTER 0x0a
209#define A_OUT_A_SUB 0x0b
210#define A_OUT_A_SIDE_L 0x0c
211#define A_OUT_A_SIDE_R 0x0d
212#define A_OUT_A_SIDE A_OUT_A_SIDE_L
213#define A_OUT_A_REAR_L 0x0e
214#define A_OUT_A_REAR_R 0x0f
215#define A_OUT_A_REAR A_OUT_A_REAR_L
216#define A_OUT_AC97_L 0x10
217#define A_OUT_AC97_R 0x11
218#define A_OUT_AC97 A_OUT_AC97_L
219#define A_OUT_ADC_REC_L 0x16
220#define A_OUT_ADC_REC_R 0x17
221#define A_OUT_ADC_REC A_OUT_ADC_REC_L
223#define EMU_DATA2 0x24
225#define EMU_INTE2 0x2c
227#define EMU_INTE3 0x3c
229#define EMU_A2_SRCSel 0x60
230#define EMU_A2_SRCMULTI_ENABLE 0x6e
232#define EMU_A_I2S_CAPTURE_96000 0x00000400
234#define EMU_A2_MIXER_I2S_ENABLE 0x7B
235#define EMU_A2_MIXER_SPDIF_ENABLE 0x7A
253#define EMU_MAX_GPR 512
254#define EMU_MAX_IRQ_CONSUMERS 32
277 uint32_t pte_start, pte_size;
278 bus_dmamap_t buf_map;
323 bus_space_handle_t
sh;
379 struct sysctl_ctx_list *
ctx;
383static void emu_setmap(
void *arg, bus_dma_segment_t * segs,
int nseg,
int error);
384static void*
emu_malloc(
struct emu_mem *mem, uint32_t sz, bus_addr_t * addr, bus_dmamap_t *map);
385static void emu_free(
struct emu_mem *mem,
void *dmabuf, bus_dmamap_t map);
386static void*
emu_memalloc(
struct emu_mem *mem, uint32_t sz, bus_addr_t * addr,
const char * owner);
414static void emu_addefxop(
struct emu_sc_info *sc,
unsigned int op,
unsigned int z,
unsigned int w,
unsigned int x,
unsigned int y, uint32_t * pc);
421static int emu_read_ivar(device_t bus __unused, device_t
dev,
int ivar_index, uintptr_t * result);
423 int ivar_index, uintptr_t
value __unused);
428static int emu_modevent(module_t mod __unused,
int cmd,
void *
data __unused);
430#ifdef SND_EMU10KX_DEBUG
432#define EMU_MTX_DEBUG() do { \
433 if (mtx_owned(&sc->rw)) { \
434 printf("RW owned in %s line %d for %s\n", __func__, \
435 __LINE__ , device_get_nameunit(sc->dev)); \
436 printf("rw lock owned: %d\n", mtx_owned(&sc->rw)); \
437 printf("rw lock: value %x thread %x\n", \
438 ((&sc->rw)->mtx_lock & ~MTX_FLAGMASK), \
439 (uintptr_t)curthread); \
440 printf("rw lock: recursed %d\n", mtx_recursed(&sc->rw));\
441 db_show_mtx(&sc->rw); \
445#define EMU_MTX_DEBUG() do { \
449#define EMU_RWLOCK() do { \
451 mtx_lock(&(sc->rw)); \
454#define EMU_RWUNLOCK() do { \
455 mtx_unlock(&(sc->rw)); \
471 {0xffff, 0xffff, 0xffff, 0xffff,
"BADCRD",
"Not a compatible card", 0},
475 {0x1102, 0x0002, 0x1102, 0x002f,
"CT????",
"SBLive! mainboard implementation",
HAS_AC97 |
IS_EMU10K1},
484 {0x1102, 0x0002, 0x1102, 0x8025,
"CT????",
"SBLive! Mainboard Implementation",
HAS_AC97 |
IS_EMU10K1},
487 {0x1102, 0x0002, 0x1102, 0x8028,
"CT4760",
"SBLive! OEM version",
HAS_AC97 |
IS_EMU10K1},
501 {0x1102, 0x0002, 0x1102, 0x0000,
"SB????",
"SBLive! (Unknown model)",
HAS_AC97 |
IS_EMU10K1},
514 {0x1102, 0x0004, 0x1102, 0x1002,
"SB????",
"Audigy 2 Platinum",
HAS_51 |
IS_CA0102},
515 {0x1102, 0x0004, 0x1102, 0x1005,
"SB????",
"Audigy 2 Platinum EX",
HAS_51 |
IS_CA0102},
551 {0x1102, 0x0002, 0x1102, 0x4001,
"EMUAPS",
"E-mu APS", 0},
552 {0x1102, 0x0002, 0x1102, 0x4002,
"EMUAPS",
"E-mu APS", 0},
553 {0x1102, 0x0004, 0x1102, 0x4001,
"EMU???",
"E-mu 1212m [4001]", 0},
555 {0x1102, 0x8064, 0x0000, 0x0000,
"SB0100",
"SBLive! 5.1 OEM", 0},
556 {0x1102, 0x0006, 0x0000, 0x0000,
"SB0200",
"DELL OEM SBLive! Value", 0},
557 {0x1102, 0x0007, 0x0000, 0x0000,
"SB0310",
"Audigy LS", 0},
568 unsigned int thiscard;
575 for (i = 1; i < nitems(
emu_cards); i++) {
614 KASSERT(sc != NULL, (
"emu_rd: NULL sc"));
617 return (bus_space_read_1(sc->
st, sc->
sh,
regno));
619 return (bus_space_read_2(sc->
st, sc->
sh,
regno));
621 return (bus_space_read_4(sc->
st, sc->
sh,
regno));
630 KASSERT(sc != NULL, (
"emu_rd: NULL sc"));
665 if (
reg & 0xff000000) {
689 if (
reg & 0xff000000) {
756 KASSERT(
regno !=
EMU_PTR, (
"emu_wr: attempt to write to EMU_PTR"));
757 KASSERT(
regno !=
EMU_A2_PTR, (
"emu_wr: attempt to write to EMU_A2_PTR"));
767 KASSERT(
regno !=
EMU_DATA, (
"emu_rd: attempt to read DATA"));
792 device_printf(sc->
dev,
"Audigy IR MIDI events enabled.\n");
802 device_printf(sc->
dev,
"SB Live! IR MIDI events enabled.\n");
819 if (sc->
timer[i] == 0) {
822 mtx_unlock(&sc->
lock);
825 mtx_unlock(&sc->
lock);
838 RANGE(delay, 16, 1024);
842 sc->
timer[timer] = delay;
849 mtx_unlock(&sc->
lock);
868 if ((
go == 1) && (sc->
timer[timer] < 0))
870 if ((
go == 0) && (sc->
timer[timer] > 0))
877 if (sc->
timer[i] > 0)
889 x &= ~EMU_INTE_INTERTIMERENB;
892 mtx_unlock(&sc->
lock);
907 if (sc->
timer[timer] != 0)
908 sc->
timer[timer] = 0;
909 mtx_unlock(&sc->
lock);
933 mtx_unlock(&sc->
lock);
935 device_printf(sc->
dev,
"ihandle %d registered\n", i);
939 mtx_unlock(&sc->
lock);
941 device_printf(sc->
dev,
"ihandle not registered\n");
955 mtx_unlock(&sc->
lock);
960 x &= ~sc->ihandler[hnumber].inte_mask;
974 mtx_unlock(&sc->
lock);
1000 device_printf(sc->
dev,
"Unhandled interrupt: %08x\n", stat & (~ack));
1011 device_printf(sc->
dev,
"EMU_IPR2: %08x\n", stat);
1025 device_printf(sc->
dev,
"EMU_IPR3: %08x\n", stat);
1043emu_setmap(
void *arg, bus_dma_segment_t * segs,
int nseg,
int error)
1045 bus_addr_t *phys = (bus_addr_t *) arg;
1047 *phys =
error ? 0 : (bus_addr_t) segs->ds_addr;
1050 printf(
"emu10kx: setmap (%lx, %lx), nseg=%d, error=%d\n",
1051 (
unsigned long)segs->ds_addr, (
unsigned long)segs->ds_len,
1064 if ((
error = bus_dmamem_alloc(
mem->
dmat, &dmabuf, BUS_DMA_NOWAIT, map))) {
1066 device_printf(
mem->
card->
dev,
"emu_malloc: failed to alloc DMA map: %d\n",
error);
1071 device_printf(
mem->
card->
dev,
"emu_malloc: failed to load DMA memory: %d\n",
error);
1072 bus_dmamem_free(
mem->
dmat, dmabuf, *map);
1081 bus_dmamap_unload(
mem->
dmat, map);
1082 bus_dmamem_free(
mem->
dmat, dmabuf, map);
1097 device_printf(mem->
card->
dev,
"emu_memalloc: memory request tool large\n");
1106 if (mem->
bmap[idx >> 3] & (1 << (idx & 7)))
1113 device_printf(mem->
card->
dev,
"emu_memalloc: no free space in bitmap\n");
1116 blk = malloc(
sizeof(*blk), M_DEVBUF, M_NOWAIT);
1119 device_printf(mem->
card->
dev,
"emu_memalloc: buffer allocation failed\n");
1122 bzero(blk,
sizeof(*blk));
1123 membuf =
emu_malloc(mem, sz, &blk->buf_addr, &blk->buf_map);
1124 *
addr = blk->buf_addr;
1125 if (membuf == NULL) {
1127 device_printf(mem->
card->
dev,
"emu_memalloc: can't setup HW memory\n");
1128 free(blk, M_DEVBUF);
1132 blk->pte_start =
start;
1133 blk->pte_size =
blksz;
1134 strncpy(blk->owner, owner, 15);
1135 blk->owner[15] =
'\0';
1138 mem->
bmap[idx >> 3] |= 1 << (idx & 7);
1139 tmp = (uint32_t) (blk->buf_addr + ofs);
1143 SLIST_INSERT_HEAD(&mem->blocks, blk, link);
1154 SLIST_FOREACH(i, &mem->blocks, link) {
1155 if (i->buf == membuf)
1160 SLIST_REMOVE(&mem->blocks, blk,
emu_memblk, link);
1161 emu_free(mem, membuf, blk->buf_map);
1163 for (idx = blk->pte_start; idx < blk->pte_start + blk->pte_size; idx++) {
1164 mem->
bmap[idx >> 3] &= ~(1 << (idx & 7));
1167 free(blk, M_DEVBUF);
1177 SLIST_FOREACH(i, &mem->blocks, link) {
1178 if (i->buf == membuf)
1183 return (blk->pte_start);
1189 static uint32_t logMagTable[128] = {
1190 0x00000, 0x02dfc, 0x05b9e, 0x088e6, 0x0b5d6, 0x0e26f, 0x10eb3, 0x13aa2,
1191 0x1663f, 0x1918a, 0x1bc84, 0x1e72e, 0x2118b, 0x23b9a, 0x2655d, 0x28ed5,
1192 0x2b803, 0x2e0e8, 0x30985, 0x331db, 0x359eb, 0x381b6, 0x3a93d, 0x3d081,
1193 0x3f782, 0x41e42, 0x444c1, 0x46b01, 0x49101, 0x4b6c4, 0x4dc49, 0x50191,
1194 0x5269e, 0x54b6f, 0x57006, 0x59463, 0x5b888, 0x5dc74, 0x60029, 0x623a7,
1195 0x646ee, 0x66a00, 0x68cdd, 0x6af86, 0x6d1fa, 0x6f43c, 0x7164b, 0x73829,
1196 0x759d4, 0x77b4f, 0x79c9a, 0x7bdb5, 0x7dea1, 0x7ff5e, 0x81fed, 0x8404e,
1197 0x86082, 0x88089, 0x8a064, 0x8c014, 0x8df98, 0x8fef1, 0x91e20, 0x93d26,
1198 0x95c01, 0x97ab4, 0x9993e, 0x9b79f, 0x9d5d9, 0x9f3ec, 0xa11d8, 0xa2f9d,
1199 0xa4d3c, 0xa6ab5, 0xa8808, 0xaa537, 0xac241, 0xadf26, 0xafbe7, 0xb1885,
1200 0xb3500, 0xb5157, 0xb6d8c, 0xb899f, 0xba58f, 0xbc15e, 0xbdd0c, 0xbf899,
1201 0xc1404, 0xc2f50, 0xc4a7b, 0xc6587, 0xc8073, 0xc9b3f, 0xcb5ed, 0xcd07c,
1202 0xceaec, 0xd053f, 0xd1f73, 0xd398a, 0xd5384, 0xd6d60, 0xd8720, 0xda0c3,
1203 0xdba4a, 0xdd3b4, 0xded03, 0xe0636, 0xe1f4e, 0xe384a, 0xe512c, 0xe69f3,
1204 0xe829f, 0xe9b31, 0xeb3a9, 0xecc08, 0xee44c, 0xefc78, 0xf148a, 0xf2c83,
1205 0xf4463, 0xf5c2a, 0xf73da, 0xf8b71, 0xfa2f0, 0xfba57, 0xfd1a7, 0xfe8df
1207 static char logSlopeTable[128] = {
1208 0x5c, 0x5c, 0x5b, 0x5a, 0x5a, 0x59, 0x58, 0x58,
1209 0x57, 0x56, 0x56, 0x55, 0x55, 0x54, 0x53, 0x53,
1210 0x52, 0x52, 0x51, 0x51, 0x50, 0x50, 0x4f, 0x4f,
1211 0x4e, 0x4d, 0x4d, 0x4d, 0x4c, 0x4c, 0x4b, 0x4b,
1212 0x4a, 0x4a, 0x49, 0x49, 0x48, 0x48, 0x47, 0x47,
1213 0x47, 0x46, 0x46, 0x45, 0x45, 0x45, 0x44, 0x44,
1214 0x43, 0x43, 0x43, 0x42, 0x42, 0x42, 0x41, 0x41,
1215 0x41, 0x40, 0x40, 0x40, 0x3f, 0x3f, 0x3f, 0x3e,
1216 0x3e, 0x3e, 0x3d, 0x3d, 0x3d, 0x3c, 0x3c, 0x3c,
1217 0x3b, 0x3b, 0x3b, 0x3b, 0x3a, 0x3a, 0x3a, 0x39,
1218 0x39, 0x39, 0x39, 0x38, 0x38, 0x38, 0x38, 0x37,
1219 0x37, 0x37, 0x37, 0x36, 0x36, 0x36, 0x36, 0x35,
1220 0x35, 0x35, 0x35, 0x34, 0x34, 0x34, 0x34, 0x34,
1221 0x33, 0x33, 0x33, 0x33, 0x32, 0x32, 0x32, 0x32,
1222 0x32, 0x31, 0x31, 0x31, 0x31, 0x31, 0x30, 0x30,
1223 0x30, 0x30, 0x30, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f
1230 for (i = 31; i > 0; i--) {
1231 if (
rate & 0x80000000) {
1232 return (((uint32_t) (i - 15) << 20) +
1233 logMagTable[0x7f & (
rate >> 24)] +
1234 (0x7f & (
rate >> 17)) *
1235 logSlopeTable[0x7f & (
rate >> 24)]);
1257 mtx_lock(&sc->
lock);
1263 mtx_unlock(&sc->
lock);
1272 mtx_lock(&sc->
lock);
1273 for (i = 0; i <
NUM_G; i++) {
1281 if (v->
slave != NULL)
1285 mtx_unlock(&sc->
lock);
1293 bus_addr_t tmp_addr;
1298 device_printf(sc->
dev,
"emu_memalloc returns NULL in enu_vinit\n");
1306 device_printf(sc->
dev,
"emu_memstart returns (-1) in enu_vinit\n");
1310 m->end =
m->start + sz;
1342 if (v->
slave != NULL) {
1349 if (v->
slave != NULL)
1359 for (i = 0; i < 8; i++) {
1364 for (i = 0; i < 8; i++) {
1379 s = (v->
stereo ? 1 : 0) + (v->
b16 ? 1 : 0);
1382 v->
ea = v->
end >> s;
1459 uint32_t pitch_target, initial_pitch;
1460 uint32_t cra, cs, ccis;
1466 ccis = v->
stereo ? 28 : 30;
1467 ccis *= v->
b16 ? 1 : 2;
1468 sample = v->
b16 ? 0x00000000 : 0x80808080;
1469 for (i = 0; i < cs; i++)
1504 s = (v->
b16 ? 1 : 0) + (v->
stereo ? 1 : 0);
1506 return (ptr & ~0x0000001f);
1517emu_addefxop(
struct emu_sc_info *sc,
unsigned int op,
unsigned int z,
unsigned int w,
unsigned int x,
unsigned int y, uint32_t * pc)
1520 device_printf(sc->
dev,
"DSP CODE OVERRUN: attept to write past code_size (pc=%d)\n", (*pc));
1540 err = sysctl_handle_int(oidp, &new_vol, 0,
req);
1542 if (err ||
req->newptr == NULL)
1544 if (new_vol < 0 || new_vol > 100)
1555 char sysctl_name[32];
1563 if (mix_name != NULL) {
1569 snprintf(sysctl_name, 32,
"_%s", mix_name);
1570 SYSCTL_ADD_PROC(sc->
ctx,
1571 SYSCTL_CHILDREN(sc->
root), OID_AUTO, sysctl_name,
1572 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, mix_id,
1589 err = sysctl_handle_int(oidp, &new_val, 0,
req);
1591 if (err ||
req->newptr == NULL)
1593 if (new_val < 0 || new_val > 1)
1611 SYSCTL_ADD_PROC(sc->
ctx, SYSCTL_CHILDREN(sc->
root), OID_AUTO,
1612 "_digital", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,
1614 "Enable digital output");
1623#define EFX_CACHE(CACHE_IDX) do { \
1624 sc->cache_gpr[CACHE_IDX] = emu_rm_gpr_alloc(sc->rm, 1); \
1625 emu_addefxop(sc, ACC3, \
1626 GPR(sc->cache_gpr[CACHE_IDX]), \
1634#define EFX_ROUTE(TITLE, INP_NR, IN_GPR_IDX, OUT_CACHE_IDX, DEF) do { \
1635 sc->mixer_gpr[IN_GPR_IDX] = emu_addefxmixer(sc, TITLE, IN_GPR_IDX, DEF); \
1636 sc->mixer_volcache[IN_GPR_IDX] = DEF; \
1637 emu_addefxop(sc, MACS, \
1638 GPR(sc->cache_gpr[OUT_CACHE_IDX]), \
1639 GPR(sc->cache_gpr[OUT_CACHE_IDX]), \
1641 GPR(sc->mixer_gpr[IN_GPR_IDX]), \
1646#define EFX_OUTPUT(TITLE, OUT_CACHE_IDX, OUT_GPR_IDX, OUTP_NR, DEF) do { \
1647 sc->mixer_gpr[OUT_GPR_IDX] = emu_addefxmixer(sc, TITLE, OUT_GPR_IDX, DEF); \
1648 sc->mixer_volcache[OUT_GPR_IDX] = DEF; \
1649 emu_addefxop(sc, MACS, \
1652 GPR(sc->cache_gpr[OUT_CACHE_IDX]), \
1653 GPR(sc->mixer_gpr[OUT_GPR_IDX]), \
1658#define EFX_OUTPUTD(OUT_CACHE_IDX, OUT_GPR_IDX, OUTP_NR) do { \
1659 emu_addefxop(sc, MACS, \
1662 GPR(sc->cache_gpr[OUT_CACHE_IDX]), \
1663 GPR(sc->mixer_gpr[OUT_GPR_IDX]), \
1668#define EFX_SKIP(OPCOUNT, FLAG_GPR) do { \
1669 emu_addefxop(sc, MACS, \
1671 GPR(sc->mute_gpr[FLAG_GPR]), \
1675 emu_addefxop(sc, SKIP, \
1683#define EFX_COPY(TO, FROM) do { \
1684 emu_addefxop(sc, ACC3, \
1733 for (i = 0; i < 16 ; i++) {
1925 for(i = (sc->
has_51 ? 2 : 0); i < 2; i++)
1929 for(i = 0; i < 4; i++)
1933 for(i = 0; i < 9; i++)
2146 for(i = 0; i < 16; i++)
2150 for(i = 0; i < 16; i++)
2181 .d_name =
"emu10kx",
2182 .d_version = D_VERSION,
2186emu10kx_open(
struct cdev *i_dev,
int flags __unused,
int mode __unused,
struct thread *td __unused)
2191 sc = i_dev->si_drv1;
2199 if (sbuf_new(&sc->
emu10kx_sbuf, NULL, 4096, 0) == NULL) {
2219 sc = i_dev->si_drv1;
2239 sc = i_dev->si_drv1;
2259 sbuf_printf(s,
"FreeBSD EMU10Kx Audio Driver\n");
2260 sbuf_printf(s,
"\nHardware resource usage:\n");
2261 sbuf_printf(s,
"DSP General Purpose Registers: %d used, %d total\n", sc->
rm->
num_used, sc->
rm->
num_gprs);
2263 sbuf_printf(s,
"Card supports");
2265 sbuf_printf(s,
" AC97 codec");
2267 sbuf_printf(s,
" NO AC97 codec");
2271 sbuf_printf(s,
" and 7.1 output");
2273 sbuf_printf(s,
" and 5.1 output");
2276 sbuf_printf(s,
", SBLive! DSP code");
2278 sbuf_printf(s,
", Audigy DSP code");
2280 sbuf_printf(s,
", Audigy DSP code with Audigy2 hacks");
2282 sbuf_printf(s,
", Audigy DSP code with Audigy2Value hacks");
2283 sbuf_printf(s,
"\n");
2285 sbuf_printf(s,
"Digital mode unsupported\n");
2286 sbuf_printf(s,
"\nInstalled devices:\n");
2288 if (sc->
pcm[i] != NULL)
2289 if (device_is_attached(sc->
pcm[i])) {
2290 sbuf_printf(s,
"%s on %s\n", device_get_desc(sc->
pcm[i]), device_get_nameunit(sc->
pcm[i]));
2292 if (sc->
midi[0] != NULL)
2293 if (device_is_attached(sc->
midi[0])) {
2294 sbuf_printf(s,
"EMU10Kx MIDI Interface\n");
2295 sbuf_printf(s,
"\tOn-card connector on %s\n", device_get_nameunit(sc->
midi[0]));
2297 if (sc->
midi[1] != NULL)
2298 if (device_is_attached(sc->
midi[1])) {
2299 sbuf_printf(s,
"\tOn-Drive connector on %s\n", device_get_nameunit(sc->
midi[1]));
2301 if (sc->
midi[0] != NULL)
2302 if (device_is_attached(sc->
midi[0])) {
2303 sbuf_printf(s,
"\tIR receiver MIDI events %s\n", sc->
enable_ir ?
"enabled" :
"disabled");
2305 sbuf_printf(s,
"Card is in %s mode\n", (sc->
mode ==
MODE_ANALOG) ?
"analog" :
"digital");
2308 return (sbuf_len(s));
2317 mtx_init(&sc->
emu10kx_lock, device_get_nameunit(sc->
dev),
"kxdevlock", 0);
2318 unit = device_get_unit(sc->
dev);
2321 if (sc->
cdev != NULL) {
2322 sc->
cdev->si_drv1 = sc;
2337 destroy_dev(sc->
cdev);
2352 rm = malloc(
sizeof(
struct emu_rm), M_DEVBUF, M_NOWAIT | M_ZERO);
2360 mtx_init(&(rm->
gpr_lock), device_get_nameunit(sc->
dev),
"gpr alloc", MTX_DEF);
2380 device_printf(sc->
dev,
"rm: gpr %d not free before uninit\n", i);
2402 for (i = 1; i <
count; i++)
2413 for (j = 1; j <
count; j++) {
2417 if (allocated_gpr == i)
2423 for (i = 1; i <
count; i++)
2428 allocated_gpr = (-1);
2429 if (allocated_gpr >= 0)
2432 return (allocated_gpr);
2465 device_printf(sc->
dev,
"Digital mode is reported as broken on this card.\n");
2518 device_printf(sc->
dev,
"AC3 mode does not work and disabled\n");
2536#define L2L_POINTS 10
2599 device_printf(sc->
dev,
"Zero gpr write access\n");
2613 RANGE(volume, 0, 100);
2623 if ((mixer_idx <
NUM_MIXERS) && (mixer_idx >= 0))
2697 if (bus_dma_tag_create( bus_get_dma_tag(sc->
dev),
2705 device_printf(sc->
dev,
"unable to create dma tag\n");
2706 bus_dma_tag_destroy(sc->
mem.
dmat);
2711 SLIST_INIT(&sc->
mem.blocks);
2727 for (ch = 0; ch <
NUM_G; ch++) {
2736 for (ch = 0; ch <
NUM_G; ch++) {
2792 spdif_sr &= 0xfffff1ff;
2816 device_printf(sc->
dev,
"Audigy card initialized in analog mode.\n");
2823 device_printf(sc->
dev,
"Card Configuration ( 0x%08x )\n", tmp);
2824 device_printf(sc->
dev,
"Card Configuration ( & 0xff000000 ) : %s%s%s%s%s%s%s%s\n",
2825 (tmp & 0x80000000 ?
"[Legacy MPIC] " :
""),
2826 (tmp & 0x40000000 ?
"[0x40] " :
""),
2827 (tmp & 0x20000000 ?
"[0x20] " :
""),
2828 (tmp & 0x10000000 ?
"[0x10] " :
""),
2829 (tmp & 0x08000000 ?
"[0x08] " :
""),
2830 (tmp & 0x04000000 ?
"[0x04] " :
""),
2831 (tmp & 0x02000000 ?
"[0x02] " :
""),
2832 (tmp & 0x01000000 ?
"[0x01]" :
" "));
2833 device_printf(sc->
dev,
"Card Configuration ( & 0x00ff0000 ) : %s%s%s%s%s%s%s%s\n",
2834 (tmp & 0x00800000 ?
"[0x80] " :
""),
2835 (tmp & 0x00400000 ?
"[0x40] " :
""),
2836 (tmp & 0x00200000 ?
"[Legacy INT] " :
""),
2837 (tmp & 0x00100000 ?
"[0x10] " :
""),
2838 (tmp & 0x00080000 ?
"[0x08] " :
""),
2839 (tmp & 0x00040000 ?
"[Codec4] " :
""),
2840 (tmp & 0x00020000 ?
"[Codec2] " :
""),
2841 (tmp & 0x00010000 ?
"[I2S Codec]" :
" "));
2842 device_printf(sc->
dev,
"Card Configuration ( & 0x0000ff00 ) : %s%s%s%s%s%s%s%s\n",
2843 (tmp & 0x00008000 ?
"[0x80] " :
""),
2844 (tmp & 0x00004000 ?
"[GPINPUT0] " :
""),
2845 (tmp & 0x00002000 ?
"[GPINPUT1] " :
""),
2846 (tmp & 0x00001000 ?
"[GPOUT0] " :
""),
2847 (tmp & 0x00000800 ?
"[GPOUT1] " :
""),
2848 (tmp & 0x00000400 ?
"[GPOUT2] " :
""),
2849 (tmp & 0x00000200 ?
"[Joystick] " :
""),
2850 (tmp & 0x00000100 ?
"[0x01]" :
" "));
2851 device_printf(sc->
dev,
"Card Configuration ( & 0x000000ff ) : %s%s%s%s%s%s%s%s\n",
2852 (tmp & 0x00000080 ?
"[0x80] " :
""),
2853 (tmp & 0x00000040 ?
"[0x40] " :
""),
2854 (tmp & 0x00000020 ?
"[0x20] " :
""),
2855 (tmp & 0x00000010 ?
"[AUTOMUTE] " :
""),
2856 (tmp & 0x00000008 ?
"[LOCKSOUNDCACHE] " :
""),
2857 (tmp & 0x00000004 ?
"[LOCKTANKCACHE] " :
""),
2858 (tmp & 0x00000002 ?
"[MUTEBUTTONENABLE] " :
""),
2859 (tmp & 0x00000001 ?
"[AUDIOENABLE]" :
" "));
2863 device_printf(sc->
dev,
"Audigy Card Configuration ( 0x%04x )\n", tmp);
2864 device_printf(sc->
dev,
"Audigy Card Configuration ( & 0xff00 )");
2865 printf(
" : %s%s%s%s%s%s%s%s\n",
2866 (tmp & 0x8000 ?
"[Rear Speakers] " :
""),
2867 (tmp & 0x4000 ?
"[Front Speakers] " :
""),
2868 (tmp & 0x2000 ?
"[0x20] " :
""),
2869 (tmp & 0x1000 ?
"[0x10] " :
""),
2870 (tmp & 0x0800 ?
"[0x08] " :
""),
2871 (tmp & 0x0400 ?
"[0x04] " :
""),
2872 (tmp & 0x0200 ?
"[0x02] " :
""),
2873 (tmp & 0x0100 ?
"[AudigyDrive Phones]" :
" "));
2874 device_printf(sc->
dev,
"Audigy Card Configuration ( & 0x00ff )");
2875 printf(
" : %s%s%s%s%s%s%s%s\n",
2876 (tmp & 0x0080 ?
"[0x80] " :
""),
2877 (tmp & 0x0040 ?
"[Mute AnalogOut] " :
""),
2878 (tmp & 0x0020 ?
"[0x20] " :
""),
2879 (tmp & 0x0010 ?
"[0x10] " :
""),
2880 (tmp & 0x0008 ?
"[0x08] " :
""),
2881 (tmp & 0x0004 ?
"[GPOUT0] " :
""),
2882 (tmp & 0x0002 ?
"[GPOUT1] " :
""),
2883 (tmp & 0x0001 ?
"[GPOUT2]" :
" "));
2896 for (ch = 0; ch <
NUM_G; ch++)
2898 for (ch = 0; ch <
NUM_G; ch++) {
2926 if (!SLIST_EMPTY(&sc->
mem.blocks))
2927 device_printf(sc->
dev,
"warning: memblock list not empty\n");
2929 SLIST_FOREACH(blk, &sc->
mem.blocks, link)
2931 device_printf(sc->
dev,
"lost %d for %s\n", blk->pte_size, blk->owner);
2950 switch (ivar_index) {
2952 *result =
func->func;
2955 if (
func->varinfo == NULL)
2977 int ivar_index, uintptr_t
value __unused)
2980 switch (ivar_index) {
2993 unsigned int thiscard = 0;
3004 s = sbuf_new(NULL, NULL, 4096, 0);
3010 device_set_desc_copy(
dev, sbuf_data(s));
3014 return (BUS_PROBE_DEFAULT);
3032 sc = device_get_softc(
dev);
3033 unit = device_get_unit(
dev);
3037 sc->
ctx = device_get_sysctl_ctx(
dev);
3038 if (sc->
ctx == NULL)
3040 sc->
root = device_get_sysctl_tree(
dev);
3041 if (sc->
root == NULL)
3044 if (resource_int_value(
"emu10kx", unit,
"multichannel_disabled", &(sc->
mch_disabled)))
3046 SYSCTL_ADD_INT(device_get_sysctl_ctx(
dev),
3047 SYSCTL_CHILDREN(device_get_sysctl_tree(
dev)),
3048 OID_AUTO,
"multichannel_disabled", CTLFLAG_RD, &(sc->
mch_disabled), 0,
"Multichannel playback setting");
3050 if (resource_int_value(
"emu10kx", unit,
"multichannel_recording", &(sc->
mch_rec)))
3052 SYSCTL_ADD_INT(device_get_sysctl_ctx(
dev),
3053 SYSCTL_CHILDREN(device_get_sysctl_tree(
dev)),
3054 OID_AUTO,
"multichannel_recording", CTLFLAG_RD, &(sc->
mch_rec), 0,
"Multichannel recording setting");
3056 if (resource_int_value(
"emu10kx", unit,
"debug", &(sc->
dbg_level)))
3058 SYSCTL_ADD_INT(device_get_sysctl_ctx(
dev),
3059 SYSCTL_CHILDREN(device_get_sysctl_tree(
dev)),
3060 OID_AUTO,
"debug", CTLFLAG_RW, &(sc->
dbg_level), 0,
"Debug level");
3063 mtx_init(&sc->
lock, device_get_nameunit(
dev),
"bridge conf", MTX_DEF);
3064 mtx_init(&sc->
rw, device_get_nameunit(
dev),
"exclusive io", MTX_DEF);
3066 sc->
type = pci_get_devid(
dev);
3067 sc->
rev = pci_get_revid(
dev);
3080 if (device_flags &
HAS_51)
3082 if (device_flags &
HAS_71) {
3103 device_printf(sc->
dev,
"Unable to detect HW chipset\n");
3167 pci_enable_busmaster(
dev);
3170 sc->
reg = bus_alloc_resource_any(
dev, SYS_RES_IOPORT, &i, RF_ACTIVE);
3171 if (sc->
reg == NULL) {
3172 device_printf(
dev,
"unable to map register space\n");
3175 sc->
st = rman_get_bustag(sc->
reg);
3176 sc->
sh = rman_get_bushandle(sc->
reg);
3182 sc->
irq = bus_alloc_resource_any(
dev, SYS_RES_IRQ, &i, RF_ACTIVE | RF_SHAREABLE);
3183 if ((sc->
irq == NULL) || bus_setup_intr(
dev, sc->
irq, INTR_MPSAFE | INTR_TYPE_AV,
3186 device_printf(
dev,
"unable to map interrupt\n");
3190 device_printf(
dev,
"unable to create resource manager\n");
3195 device_printf(
dev,
"unable to initialize CardBus interface\n");
3199 device_printf(
dev,
"unable to initialize the card\n");
3203 device_printf(
dev,
"unable to create control device\n");
3206 snprintf(
status, 255,
"rev %d at io 0x%jx irq %jd", sc->
rev, rman_get_start(sc->
reg), rman_get_start(sc->
irq));
3209 for (i = 0; i <
NUM_G; i++) {
3232 pcminfo = malloc(
sizeof(
struct emu_pcminfo), M_DEVBUF, M_NOWAIT | M_ZERO);
3233 if (pcminfo == NULL) {
3241 func->varinfo = pcminfo;
3252 pcminfo = malloc(
sizeof(
struct emu_pcminfo), M_DEVBUF, M_NOWAIT | M_ZERO);
3253 if (pcminfo == NULL) {
3261 func->varinfo = pcminfo;
3271 pcminfo = malloc(
sizeof(
struct emu_pcminfo), M_DEVBUF, M_NOWAIT | M_ZERO);
3272 if (pcminfo == NULL) {
3280 func->varinfo = pcminfo;
3289 pcminfo = malloc(
sizeof(
struct emu_pcminfo), M_DEVBUF, M_NOWAIT | M_ZERO);
3290 if (pcminfo == NULL) {
3298 func->varinfo = pcminfo;
3309 pcminfo = malloc(
sizeof(
struct emu_pcminfo), M_DEVBUF, M_NOWAIT | M_ZERO);
3310 if (pcminfo == NULL) {
3318 func->varinfo = pcminfo;
3330 pcminfo = malloc(
sizeof(
struct emu_pcminfo), M_DEVBUF, M_NOWAIT | M_ZERO);
3331 if (pcminfo == NULL) {
3339 func->varinfo = pcminfo;
3344 for (i = 0; i < 2; i++)
3356 midiinfo = malloc(
sizeof(
struct emu_midiinfo), M_DEVBUF, M_NOWAIT | M_ZERO);
3357 if (midiinfo == NULL) {
3361 midiinfo->
card = sc;
3367 midiinfo->
port = MUDATA;
3371 func->varinfo = midiinfo;
3372 sc->
midi[0] = device_add_child(
dev,
"midi", -1);
3373 device_set_ivars(sc->
midi[0],
func);
3382 midiinfo = malloc(
sizeof(
struct emu_midiinfo), M_DEVBUF, M_NOWAIT | M_ZERO);
3383 if (midiinfo == NULL) {
3387 midiinfo->
card = sc;
3393 func->varinfo = midiinfo;
3394 sc->
midi[1] = device_add_child(
dev,
"midi", -1);
3395 device_set_ivars(sc->
midi[1],
func);
3398 return (bus_generic_attach(
dev));
3409 bus_teardown_intr(
dev, sc->
irq, sc->
ih);
3411 bus_release_resource(
dev, SYS_RES_IRQ, 0, sc->
irq);
3412 mtx_destroy(&sc->
rw);
3413 mtx_destroy(&sc->
lock);
3423 device_t *childlist;
3426 sc = device_get_softc(
dev);
3429 if (sc->
pcm[i] != NULL) {
3430 func = device_get_ivars(sc->
pcm[i]);
3432 device_set_ivars(sc->
pcm[i], NULL);
3436 r = device_delete_child(
dev, sc->
pcm[i]);
3441 if (sc->
midi[0] != NULL) {
3442 func = device_get_ivars(sc->
midi[0]);
3444 device_set_ivars(sc->
midi[0], NULL);
3448 r = device_delete_child(
dev, sc->
midi[0]);
3452 if (sc->
midi[1] != NULL) {
3453 func = device_get_ivars(sc->
midi[1]);
3455 device_set_ivars(sc->
midi[1], NULL);
3459 r = device_delete_child(
dev, sc->
midi[1]);
3463 if (device_get_children(
dev, &childlist, &devcount) == 0)
3464 for (i = 0; i < devcount - 1; i++) {
3465 device_printf(
dev,
"removing stale child %d (unit %d)\n", i, device_get_unit(childlist[i]));
3466 func = device_get_ivars(childlist[i]);
3468 device_set_ivars(childlist[i], NULL);
3472 device_delete_child(
dev, childlist[i]);
3474 if (childlist != NULL)
3475 free(childlist, M_TEMP);
3486 bus_dma_tag_destroy(sc->
mem.
dmat);
3490 bus_teardown_intr(
dev, sc->
irq, sc->
ih);
3491 bus_release_resource(
dev, SYS_RES_IRQ, 0, sc->
irq);
3492 mtx_destroy(&sc->
rw);
3493 mtx_destroy(&sc->
lock);
3495 return (bus_generic_detach(
dev));
int sndbuf_setup(struct snd_dbuf *b, void *buf, unsigned int size)
SLIST_HEAD(pcm_synclist, pcmchan_syncgroup) snd_pcm_syncgroups
struct pcmchan_matrix * m
uint32_t emu_rd(struct emu_sc_info *sc, unsigned int regno, unsigned int size)
int emu_timer_clear(struct emu_sc_info *sc, int timer)
static int emu_rm_gpr_alloc(struct emu_rm *rm, int count)
static int log2lin(int log_t)
#define EMU_A_I2S_CAPTURE_96000
void emu_vroute(struct emu_sc_info *sc, struct emu_route *rt, struct emu_voice *v)
#define EFX_ROUTE(TITLE, INP_NR, IN_GPR_IDX, OUT_CACHE_IDX, DEF)
int emu_timer_set(struct emu_sc_info *sc, int timer, int delay)
int emu_vinit(struct emu_sc_info *sc, struct emu_voice *m, struct emu_voice *s, uint32_t sz, struct snd_dbuf *b)
void emumix_set_volume(struct emu_sc_info *sc, int mixer_idx, int volume)
void emu_vsetup(struct emu_voice *v, int fmt, int spd)
void emu_vwrite(struct emu_sc_info *sc, struct emu_voice *v)
static driver_t emu_driver
uint32_t emu_rdptr(struct emu_sc_info *sc, unsigned int chn, unsigned int reg)
void emu_wr_p16vptr(struct emu_sc_info *sc, uint16_t chn, uint16_t reg, uint32_t data)
static void emu_initefx(struct emu_sc_info *sc)
static void emu_addefxop(struct emu_sc_info *sc, unsigned int op, unsigned int z, unsigned int w, unsigned int x, unsigned int y, uint32_t *pc)
DRIVER_MODULE(snd_emu10kx, pci, emu_driver, emu_devclass, emu_modevent, NULL)
static void emu_wr_cbptr(struct emu_sc_info *sc, uint32_t data)
static int emu_init(struct emu_sc_info *sc)
static d_read_t emu10kx_read
static int emu_modevent(module_t mod __unused, int cmd, void *data __unused)
#define EMU_MAX_IRQ_CONSUMERS
static int emu_read_ivar(device_t bus __unused, device_t dev, int ivar_index, uintptr_t *result)
static int emu_pci_detach(device_t dev)
struct emu_voice * emu_valloc(struct emu_sc_info *sc)
static int emu_write_ivar(device_t bus __unused, device_t dev __unused, int ivar_index, uintptr_t value __unused)
int emu_intr_register(struct emu_sc_info *sc, uint32_t inte_mask, uint32_t intr_mask, uint32_t(*func)(void *softc, uint32_t irq), void *isc)
void emu_vfree(struct emu_sc_info *sc, struct emu_voice *v)
int emu_timer_enable(struct emu_sc_info *sc, int timer, int go)
static int emu10kx_dev_init(struct emu_sc_info *sc)
int emumix_get_volume(struct emu_sc_info *sc, int mixer_idx)
static int l2l_f[L2L_POINTS]
static int emu_addefxmixer(struct emu_sc_info *sc, const char *mix_name, const int mix_id, uint32_t defvolume)
static void emu_vstop(struct emu_sc_info *sc, char channel, int enable)
void emu_wr(struct emu_sc_info *sc, unsigned int regno, uint32_t data, unsigned int size)
static d_close_t emu10kx_close
static void emumix_set_mode(struct emu_sc_info *sc, int mode)
static int emu_pci_attach(device_t dev)
static int emu_rm_uninit(struct emu_sc_info *sc)
MODULE_VERSION(snd_emu10kx, SND_EMU10KX_PREFVER)
#define EMU_A2_MIXER_I2S_ENABLE
static int sysctl_emu_digitalswitch_control(SYSCTL_HANDLER_ARGS)
static void emumix_set_gpr(struct emu_sc_info *sc, unsigned gpr, int32_t val)
static void emu_intr(void *p)
void emu_enable_ir(struct emu_sc_info *sc)
static void emumix_set_fxvol(struct emu_sc_info *sc, unsigned gpr, int32_t vol)
static int emu_memfree(struct emu_mem *mem, void *membuf)
static int emu_cardbus_init(struct emu_sc_info *sc)
bus_dma_tag_t emu_gettag(struct emu_sc_info *sc)
int emu_intr_unregister(struct emu_sc_info *sc, int hnumber)
#define EFX_COPY(TO, FROM)
#define EFX_SKIP(OPCOUNT, FLAG_GPR)
static struct emu_hwinfo emu_cards[]
static int emu_memstart(struct emu_mem *mem, void *membuf)
static struct cdevsw emu10kx_cdevsw
void emu_wrptr(struct emu_sc_info *sc, unsigned int chn, unsigned int reg, uint32_t data)
#define EFX_OUTPUT(TITLE, OUT_CACHE_IDX, OUT_GPR_IDX, OUTP_NR, DEF)
static uint32_t emu_rd_nolock(struct emu_sc_info *sc, unsigned int regno, unsigned int size)
#define EFX_OUTPUTD(OUT_CACHE_IDX, OUT_GPR_IDX, OUTP_NR)
#define EMU_A2_SRCMULTI_ENABLE
static void * emu_malloc(struct emu_mem *mem, uint32_t sz, bus_addr_t *addr, bus_dmamap_t *map)
static void emu_setmap(void *arg, bus_dma_segment_t *segs, int nseg, int error)
static int l2l_df[L2L_POINTS]
#define EMU_A2_MIXER_SPDIF_ENABLE
static void emu_wrefx(struct emu_sc_info *sc, unsigned int pc, unsigned int data)
static devclass_t emu_devclass
static int emu_uninit(struct emu_sc_info *sc)
uint32_t emu_rd_p16vptr(struct emu_sc_info *sc, uint16_t chn, uint16_t reg)
static struct emu_hwinfo emu_bad_cards[]
static void emu_digitalswitch(struct emu_sc_info *sc)
static int emu10kx_prepare(struct emu_sc_info *sc, struct sbuf *s)
static int emu_pci_probe(device_t dev)
static uint32_t emu_rate_to_linearpitch(uint32_t rate)
static uint32_t emu_rate_to_pitch(uint32_t rate)
void emu_vtrigger(struct emu_sc_info *sc, struct emu_voice *v, int go)
static int emu10kx_dev_uninit(struct emu_sc_info *sc)
int emu_timer_create(struct emu_sc_info *sc)
static void * emu_memalloc(struct emu_mem *mem, uint32_t sz, bus_addr_t *addr, const char *owner)
static void emu_free(struct emu_mem *mem, void *dmabuf, bus_dmamap_t map)
static int emu_rm_init(struct emu_sc_info *sc)
static unsigned int emu_getcard(device_t dev)
static void emu_wr_nolock(struct emu_sc_info *sc, unsigned int regno, uint32_t data, unsigned int size)
int emu_vpos(struct emu_sc_info *sc, struct emu_voice *v)
static int sysctl_emu_mixer_control(SYSCTL_HANDLER_ARGS)
static device_method_t emu_methods[]
static void emumix_set_spdif_mode(struct emu_sc_info *sc, int mode)
#define EFX_CACHE(CACHE_IDX)
static d_open_t emu10kx_open
#define EMU_A_IOCFG_GPOUT2
#define EMU_AC97SLOT_REAR_LEFT
#define EMU_AC97SLOT_REAR_RIGHT
#define M_MASTER_SUBWOOFER
#define EMU_A_IOCFG_DISABLE_ANALOG
#define EMU_VAR_ISEMU10K1
#define SND_EMU10KX_PREFVER
#define EMU_VAR_MCH_DISABLED
#define EMU_CHAN_CCR_READADDRESS
#define EMU_MICROCODEBASE
#define EMU_HCFG_JOYENABLE
#define EMU_INTE_PCIERRENABLE
#define EMU_A_FXGPREGBASE
#define EMU_SPCS_EMPHASIS_NONE
#define EMU_SPCS_CLKACCY_1000PPM
#define EMU_CHAN_CPF_PITCH
#define EMU_PTR_CHNO_MASK
#define EMU_CHAN_PEFE_FILTERAMOUNT
#define EMU_SPCS_SOURCENUM_UNSPEC
#define EMU_HCFG_LOCKTANKCACHE_MASK
#define EMU_CHAN_PEFE_PITCHAMOUNT
#define EMU_DBG_SINGLE_STEP
#define EMU_CHAN_PTRX_PITCHTARGET
#define EMU_CHAN_VTFT_FILTERTARGET_MASK
#define EMU_PTR_ADDR_MASK
#define EMU_A_SPDIF_48000
#define EMU_SPCS_GENERATIONSTATUS
#define EMU_CHAN_CCCA_CURRADDR
#define EMU_AC97SLOT_CENTER
#define EMU_HCFG_MUTEBUTTONENABLE
#define EMU_CHAN_MAP_PTI_MASK
#define EMU_A_PTR_ADDR_MASK
#define EMU_A_IOCFG_GPOUT1
#define EMU_HCFG_LOCKSOUNDCACHE
#define EMU_CHAN_CCR_CACHEINVALIDSIZE
#define EMU_INTE_INTERTIMERENB
#define EMU_INTE_SAMPLERATER
#define EMU_CHAN_DCYSUSM_DECAYTIME_MASK
#define EMU_HCFG_AUTOMUTE
#define EMU_CHAN_ATKHLDV_ATTACKTIME_MASK
#define EMU_A_CHAN_SENDAMOUNTS
#define EMU_CHAN_CPF_STEREO_MASK
#define EMU_SPCS_COPYRIGHT
#define EMU_SPCS_SAMPLERATE_48
#define EMU_A_SPDIF_SAMPLERATE
#define EMU_A_DBG_SINGLE_STEP
#define EMU_SPCS_CHANNELNUM_LEFT
#define EMU_RECBS_BUFSIZE_NONE
#define EMU_CHAN_CVCF_CURRFILTER_MASK
#define EMU_HCFG_AUDIOENABLE
#define EMU_A_MICROCODEBASE
#define EMU_CHAN_ATKHLDV_HOLDTIME_MASK
#define EMU_HCFG_CODECFMT_I2S
#define EMU_CHAN_CCCA_8BITSELECT
#define RANGE(var, low, high)
uint32_t(* irq_func)(void *softc, uint32_t irq)
u_int8_t bmap[EMUMAXPAGES/8]
bus_addr_t silent_page_addr
bus_addr_t ptb_pages_addr
struct emu_sc_info * card
struct emu_sc_info * card
struct emu_sc_info * card
struct emu_sc_info * card
signed int allocmap[EMU_MAX_GPR]
int timer[EMU_MAX_IRQ_CONSUMERS]
int mixer_gpr[NUM_MIXERS]
int mixer_volcache[NUM_MIXERS]
struct sysctl_ctx_list * ctx
unsigned int routing_code_start
uint32_t irq_mask[EMU_MAX_IRQ_CONSUMERS]
struct emu_voice voice[NUM_G]
unsigned int opcode_shift
unsigned int high_operand_shift
unsigned int routing_code_end
struct emu_intr_handler ihandler[EMU_MAX_IRQ_CONSUMERS]
int cache_gpr[NUM_CACHES]
unsigned int address_mask