29#ifdef HAVE_KERNEL_OPTION_HEADERS
44#define TDX_PCI_ID 0x20001023
45#define TNX_PCI_ID 0x20011023
46#define ALI_PCI_ID 0x545110b9
47#define SPA_PCI_ID 0x70181039
49#define TR_DEFAULT_BUFSZ 0x1000
51#define ALI_BUFSZ 0x10000
53#define TR_TIMEOUT_CDC 0xffff
57#define ALI_MAXPLAYCH 1
64#define TR_MAXADDR ((1U << 30) - 1)
65#define ALI_MAXADDR ((1U << 31) - 1)
97 bus_space_handle_t
sh;
151 return bus_space_read_1(tr->
st, tr->
sh,
regno);
153 return bus_space_read_2(tr->
st, tr->
sh,
regno);
155 return bus_space_read_4(tr->
st, tr->
sh,
regno);
207 printf(
"!!! tr_rdcd defaulted !!!\n");
216 u_int32_t chk1, chk2;
219 j =
tr_rd(tr, treg, 4);
221 chk1 =
tr_rd(tr, 0xc8, 4);
222 chk2 =
tr_rd(tr, 0xc8, 4);
225 chk2 =
tr_rd(tr, 0xc8, 4);
232 j=
tr_rd(tr, treg, 4);
235 if (i == 0) printf(
"codec timeout during read of register %x\n",
regno);
260 printf(
"!!! tr_wrcd defaulted !!!");
275 j =
tr_rd(tr, treg, 4);
277 u_int32_t chk1, chk2;
278 chk1 =
tr_rd(tr, 0xc8, 4);
279 chk2 =
tr_rd(tr, 0xc8, 4);
282 chk2 =
tr_rd(tr, 0xc8, 4);
287 j=
tr_rd(tr, treg, 4);
296 if (i==0) printf(
"codec timeout writing %x, data %x\n",
regno,
data);
297 return (i > 0)? 0 : -1;
301 KOBJMETHOD(ac97_read,
tr_rdcd),
302 KOBJMETHOD(ac97_write,
tr_wrcd),
317 bank = (ch->
index & 0x20) ? 1 : 0;
329 bank = (ch->
index & 0x20) ? 1 : 0;
342 bank = (ch->
index & 0x20) ? 1 : 0;
365 i |= ch->
index & 0x3f;
375 bank = (ch->
index & 0x20) ? 1 : 0;
386 bank = (ch->
index & 0x20) ? 1 : 0;
397 ch->
gvsel &= 0x00000001;
398 ch->
fmc &= 0x00000003;
399 ch->
fms &= 0x0000000f;
400 ch->
ctrl &= 0x0000000f;
401 ch->
pan &= 0x0000007f;
402 ch->
rvol &= 0x0000007f;
403 ch->
cvol &= 0x0000007f;
404 ch->
vol &= 0x000000ff;
405 ch->
ec &= 0x00000fff;
406 ch->
alpha &= 0x00000fff;
407 ch->
delta &= 0x0000ffff;
415 cr[4]=(ch->
gvsel<<31) | (ch->
pan<<24) | (ch->
vol<<16) | (ch->
ctrl<<12) | (ch->
ec);
421 ch->
cso &= 0x0000ffff;
422 ch->
eso &= 0x0000ffff;
427 ch->
cso &= 0x00ffffff;
428 ch->
eso &= 0x00ffffff;
429 cr[0]=((ch->
delta & 0xff)<<24) | (ch->
cso);
430 cr[2]=((ch->
delta>>8)<<24) | (ch->
eso);
431 cr[3]|=(ch->
alpha<<20) | (ch->
fms<<16) | (ch->
fmc<<14);
457 ch->
fmc= (cr[3] & 0x0000c000) >> 14;
458 ch->
rvol= (cr[3] & 0x00003f80) >> 7;
459 ch->
cvol= (cr[3] & 0x0000007f);
460 ch->
gvsel= (cr[4] & 0x80000000) >> 31;
461 ch->
pan= (cr[4] & 0x7f000000) >> 24;
462 ch->
vol= (cr[4] & 0x00ff0000) >> 16;
463 ch->
ctrl= (cr[4] & 0x0000f000) >> 12;
464 ch->
ec= (cr[4] & 0x00000fff);
469 ch->
cso= (cr[0] & 0xffff0000) >> 16;
470 ch->
alpha= (cr[0] & 0x0000fff0) >> 4;
471 ch->
fms= (cr[0] & 0x0000000f);
472 ch->
eso= (cr[2] & 0xffff0000) >> 16;
473 ch->
delta= (cr[2] & 0x0000ffff);
476 ch->
cso= (cr[0] & 0x00ffffff);
477 ch->
eso= (cr[2] & 0x00ffffff);
478 ch->
delta= ((cr[2] & 0xff000000) >> 16) | ((cr[0] & 0xff000000) >> 24);
479 ch->
alpha= (cr[3] & 0xfff00000) >> 20;
480 ch->
fms= (cr[3] & 0x000f0000) >> 16;
535 return (ch->
delta * 48000) >> 12;
639 i = 0x18 | (bits << 4);
656 return (48000 << 12) / ch->
delta;
743 while (chnum < tr->hwchns) {
751 if (chnum < tr->playchns) {
762 }
while (chnum & 31);
805 switch (pci_get_devid(
dev)) {
807 device_set_desc(
dev,
"SiS 7018");
808 return BUS_PROBE_DEFAULT;
810 device_set_desc(
dev,
"Acer Labs M5451");
811 return BUS_PROBE_DEFAULT;
813 device_set_desc(
dev,
"Trident 4DWave DX");
814 return BUS_PROBE_DEFAULT;
816 device_set_desc(
dev,
"Trident 4DWave NX");
817 return BUS_PROBE_DEFAULT;
832 tr = malloc(
sizeof(*tr), M_DEVBUF, M_WAITOK | M_ZERO);
834 tr->
rev = pci_get_revid(
dev);
837 if (resource_int_value(device_get_name(
dev), device_get_unit(
dev),
856 pci_enable_busmaster(
dev);
863 tr->
st = rman_get_bustag(tr->
reg);
864 tr->
sh = rman_get_bushandle(tr->
reg);
866 device_printf(
dev,
"unable to map register space\n");
871 device_printf(
dev,
"unable to initialize the card\n");
877 if (codec == NULL)
goto bad;
881 tr->
irq = bus_alloc_resource_any(
dev, SYS_RES_IRQ, &tr->
irqid,
882 RF_ACTIVE | RF_SHAREABLE);
884 device_printf(
dev,
"unable to map interrupt\n");
909 if (bus_dma_tag_create(bus_get_dma_tag(
dev),
918 device_printf(
dev,
"unable to create dma tag\n");
922 snprintf(
status, 64,
"at io 0x%jx irq %jd %s",
928 for (i = 0; i < dacn; i++)
937 if (tr->
ih) bus_teardown_intr(
dev, tr->
irq, tr->
ih);
938 if (tr->
irq) bus_release_resource(
dev, SYS_RES_IRQ, tr->
irqid, tr->
irq);
957 bus_teardown_intr(
dev, tr->
irq, tr->
ih);
958 bus_release_resource(
dev, SYS_RES_IRQ, tr->
irqid, tr->
irq);
974 for (i = 0; i < tr->
playchns; i++) {
998 device_printf(
dev,
"unable to initialize the card\n");
1003 device_printf(
dev,
"unable to initialize the mixer\n");
1007 for (i = 0; i < tr->
playchns; i++) {
kobj_class_t ac97_getmixerclass(void)
void ac97_destroy(struct ac97_info *codec)
#define AC97_CREATE(dev, devinfo, cls)
int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags, unsigned int size)
bus_addr_t sndbuf_getbufaddr(struct snd_dbuf *buf)
unsigned int sndbuf_getalign(struct snd_dbuf *b)
unsigned int sndbuf_getsize(struct snd_dbuf *b)
int sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz)
unsigned int sndbuf_runsz(struct snd_dbuf *b)
void chn_intr(struct pcm_channel *c)
#define PCMTRIG_COMMON(x)
int mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
int mixer_reinit(device_t dev)
void * snd_mtxcreate(const char *desc, const char *type)
void * pcm_getdevinfo(device_t dev)
int pcm_setstatus(device_t dev, char *str)
void snd_mtxfree(void *m)
int pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo)
int pcm_unregister(device_t dev)
int pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
int snd_setup_intr(device_t dev, struct resource *res, int flags, driver_intr_t hand, void *param, void **cookiep)
unsigned int pcm_getbuffersize(device_t dev, unsigned int minbufsz, unsigned int deflt, unsigned int maxbufsz)
#define SND_FORMAT(f, c, e)
struct pcm_channel * channel
struct tr_rchinfo recchinfo
struct tr_chinfo chinfo[TR_MAXPLAYCH]
bus_dma_tag_t parent_dmat
struct pcm_channel * channel
static u_int32_t trrchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
static u_int32_t tr_playfmt[]
static struct pcmchan_caps * trrchan_getcaps(kobj_t obj, void *data)
static int tr_pci_resume(device_t dev)
static void tr_wr(struct tr_info *tr, int regno, u_int32_t data, int size)
static int tr_wrcd(kobj_t obj, void *devinfo, int regno, u_int32_t data)
static u_int32_t trrchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
MODULE_VERSION(snd_t4dwave, 1)
static void * trpchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
static void tr_stopch(struct tr_chinfo *ch)
static u_int32_t tr_recfmt[]
static int trpchan_trigger(kobj_t obj, void *data, int go)
static kobj_method_t trrchan_methods[]
static int tr_pci_detach(device_t dev)
static struct pcmchan_caps * trpchan_getcaps(kobj_t obj, void *data)
static u_int32_t trpchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
SND_DECLARE_FILE("$FreeBSD$")
DRIVER_MODULE(snd_t4dwave, pci, tr_driver, pcm_devclass, 0, 0)
static u_int32_t trpchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
static u_int32_t trpchan_getptr(kobj_t obj, void *data)
static int trrchan_trigger(kobj_t obj, void *data, int go)
static kobj_method_t trpchan_methods[]
static int trrchan_setformat(kobj_t obj, void *data, u_int32_t format)
static int trpchan_setformat(kobj_t obj, void *data, u_int32_t format)
static void tr_enaint(struct tr_chinfo *ch, int enable)
static struct pcmchan_caps tr_playcaps
static device_method_t tr_methods[]
static int tr_init(struct tr_info *tr)
static void tr_wrch(struct tr_chinfo *ch)
static int tr_pci_probe(device_t dev)
static kobj_method_t tr_ac97_methods[]
static void * trrchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
static u_int32_t tr_rd(struct tr_info *tr, int regno, int size)
static void tr_clrint(struct tr_chinfo *ch)
MODULE_DEPEND(snd_t4dwave, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
static int tr_rdcd(kobj_t obj, void *devinfo, int regno)
static void tr_startch(struct tr_chinfo *ch)
static int tr_pci_suspend(device_t dev)
static driver_t tr_driver
static int tr_pci_attach(device_t dev)
static u_int32_t tr_fmttobits(u_int32_t fmt)
static void tr_selch(struct tr_chinfo *ch)
static u_int32_t trrchan_getptr(kobj_t obj, void *data)
static struct pcmchan_caps tr_reccaps
static void tr_intr(void *p)
static void tr_rdch(struct tr_chinfo *ch)