Lines Matching refs:tr
145 tr_rd(struct tr_info *tr, int regno, int size) in tr_rd() argument
149 return bus_space_read_1(tr->st, tr->sh, regno); in tr_rd()
151 return bus_space_read_2(tr->st, tr->sh, regno); in tr_rd()
153 return bus_space_read_4(tr->st, tr->sh, regno); in tr_rd()
160 tr_wr(struct tr_info *tr, int regno, u_int32_t data, int size) in tr_wr() argument
164 bus_space_write_1(tr->st, tr->sh, regno, data); in tr_wr()
167 bus_space_write_2(tr->st, tr->sh, regno, data); in tr_wr()
170 bus_space_write_4(tr->st, tr->sh, regno, data); in tr_wr()
181 struct tr_info *tr = (struct tr_info *)devinfo; in tr_rdcd() local
184 switch (tr->type) { in tr_rdcd()
190 if (tr->rev > 0x01) in tr_rdcd()
212 snd_mtxlock(tr->lock); in tr_rdcd()
213 if (tr->type == ALI_PCI_ID) { in tr_rdcd()
217 j = tr_rd(tr, treg, 4); in tr_rdcd()
219 chk1 = tr_rd(tr, 0xc8, 4); in tr_rdcd()
220 chk2 = tr_rd(tr, 0xc8, 4); in tr_rdcd()
223 chk2 = tr_rd(tr, 0xc8, 4); in tr_rdcd()
226 if (tr->type != ALI_PCI_ID || i > 0) { in tr_rdcd()
227 tr_wr(tr, treg, regno | trw, 4); in tr_rdcd()
230 j=tr_rd(tr, treg, 4); in tr_rdcd()
232 snd_mtxunlock(tr->lock); in tr_rdcd()
240 struct tr_info *tr = (struct tr_info *)devinfo; in tr_wrcd() local
243 switch (tr->type) { in tr_wrcd()
269 snd_mtxlock(tr->lock); in tr_wrcd()
270 if (tr->type == ALI_PCI_ID) { in tr_wrcd()
273 j = tr_rd(tr, treg, 4); in tr_wrcd()
276 chk1 = tr_rd(tr, 0xc8, 4); in tr_wrcd()
277 chk2 = tr_rd(tr, 0xc8, 4); in tr_wrcd()
280 chk2 = tr_rd(tr, 0xc8, 4); in tr_wrcd()
283 if (tr->type != ALI_PCI_ID || i > 0) { in tr_wrcd()
285 j=tr_rd(tr, treg, 4); in tr_wrcd()
286 if (tr->type == ALI_PCI_ID && tr->rev > 0x01) in tr_wrcd()
288 tr_wr(tr, treg, (data << TR_CDC_DATA) | regno | trw, 4); in tr_wrcd()
293 snd_mtxunlock(tr->lock); in tr_wrcd()
312 struct tr_info *tr = ch->parent;
317 return tr_rd(tr, bank? TR_REG_ADDRINTB : TR_REG_ADDRINTA, 4) & (1 << chan);
324 struct tr_info *tr = ch->parent; in tr_clrint() local
329 tr_wr(tr, bank? TR_REG_ADDRINTB : TR_REG_ADDRINTA, 1 << chan, 4); in tr_clrint()
335 struct tr_info *tr = ch->parent; in tr_enaint() local
339 snd_mtxlock(tr->lock); in tr_enaint()
344 i = tr_rd(tr, reg, 4); in tr_enaint()
349 tr_wr(tr, reg, i, 4); in tr_enaint()
350 snd_mtxunlock(tr->lock); in tr_enaint()
358 struct tr_info *tr = ch->parent; in tr_selch() local
361 i = tr_rd(tr, TR_REG_CIR, 4); in tr_selch()
364 tr_wr(tr, TR_REG_CIR, i, 4); in tr_selch()
370 struct tr_info *tr = ch->parent; in tr_startch() local
375 tr_wr(tr, bank? TR_REG_STARTB : TR_REG_STARTA, 1 << chan, 4); in tr_startch()
381 struct tr_info *tr = ch->parent; in tr_stopch() local
386 tr_wr(tr, bank? TR_REG_STOPB : TR_REG_STOPA, 1 << chan, 4); in tr_stopch()
392 struct tr_info *tr = ch->parent; in tr_wrch() local
406 if (tr->type == ALI_PCI_ID) in tr_wrch()
415 switch (tr->type) { in tr_wrch()
432 snd_mtxlock(tr->lock); in tr_wrch()
435 tr_wr(tr, TR_REG_CHNBASE+(i<<2), cr[i], 4); in tr_wrch()
436 snd_mtxunlock(tr->lock); in tr_wrch()
442 struct tr_info *tr = ch->parent; in tr_rdch() local
445 snd_mtxlock(tr->lock); in tr_rdch()
448 cr[i]=tr_rd(tr, TR_REG_CHNBASE+(i<<2), 4); in tr_rdch()
449 snd_mtxunlock(tr->lock); in tr_rdch()
451 if (tr->type == ALI_PCI_ID) in tr_rdch()
463 switch(tr->type) { in tr_rdch()
502 struct tr_info *tr = devinfo; in trpchan_init() local
506 ch = &tr->chinfo[tr->playchns]; in trpchan_init()
507 ch->index = tr->playchns++; in trpchan_init()
509 ch->parent = tr; in trpchan_init()
511 if (sndbuf_alloc(ch->buffer, tr->parent_dmat, 0, tr->bufsz) != 0) in trpchan_init()
611 struct tr_info *tr = devinfo; in trrchan_init() local
615 ch = &tr->recchinfo; in trrchan_init()
617 ch->parent = tr; in trrchan_init()
619 if (sndbuf_alloc(ch->buffer, tr->parent_dmat, 0, tr->bufsz) != 0) in trrchan_init()
629 struct tr_info *tr = ch->parent; in trrchan_setformat() local
635 tr_wr(tr, TR_REG_SBBL, i | (i << 16), 4); in trrchan_setformat()
638 tr_wr(tr, TR_REG_SBCTRL, i, 1); in trrchan_setformat()
647 struct tr_info *tr = ch->parent; in trrchan_setspeed() local
651 tr_wr(tr, TR_REG_SBDELTA, ch->delta, 2); in trrchan_setspeed()
671 struct tr_info *tr = ch->parent; in trrchan_trigger() local
679 tr_wr(tr, TR_REG_DMAR15, 0, 1); in trrchan_trigger()
680 i = tr_rd(tr, TR_REG_DMAR11, 1) & 0x03; in trrchan_trigger()
681 tr_wr(tr, TR_REG_DMAR11, i | 0x54, 1); in trrchan_trigger()
683 tr_wr(tr, TR_REG_DMAR0, sndbuf_getbufaddr(ch->buffer), 4); in trrchan_trigger()
685 i = tr_rd(tr, TR_REG_DMAR4, 4) & ~0x00ffffff; in trrchan_trigger()
686 tr_wr(tr, TR_REG_DMAR4, i | (sndbuf_runsz(ch->buffer) - 1), 4); in trrchan_trigger()
688 tr_wr(tr, TR_REG_SBCTRL, tr_rd(tr, TR_REG_SBCTRL, 1) | 1, 1); in trrchan_trigger()
691 tr_wr(tr, TR_REG_SBCTRL, tr_rd(tr, TR_REG_SBCTRL, 1) & ~7, 1); in trrchan_trigger()
703 struct tr_info *tr = ch->parent; in trrchan_getptr() local
706 return tr_rd(tr, TR_REG_DMAR0, 4) - sndbuf_getbufaddr(ch->buffer); in trrchan_getptr()
733 struct tr_info *tr = (struct tr_info *)p; in tr_intr() local
738 intsrc = tr_rd(tr, TR_REG_MISCINT, 4); in tr_intr()
741 while (chnum < tr->hwchns) { in tr_intr()
743 active = tr_rd(tr, (chnum < 32)? TR_REG_ADDRINTA : TR_REG_ADDRINTB, 4); in tr_intr()
744 bufhalf = tr_rd(tr, (chnum < 32)? TR_REG_CSPF_A : TR_REG_CSPF_B, 4); in tr_intr()
749 if (chnum < tr->playchns) { in tr_intr()
750 ch = &tr->chinfo[chnum]; in tr_intr()
764 tr_wr(tr, (chnum <= 32)? TR_REG_ADDRINTA : TR_REG_ADDRINTB, active, 4); in tr_intr()
768 chn_intr(tr->recchinfo.channel); in tr_intr()
769 tr_rd(tr, TR_REG_SBR9, 1); in tr_intr()
770 tr_rd(tr, TR_REG_SBR10, 1); in tr_intr()
781 tr_init(struct tr_info *tr) in tr_init() argument
783 switch (tr->type) { in tr_init()
785 tr_wr(tr, SPA_REG_GPIO, 0, 4); in tr_init()
786 tr_wr(tr, SPA_REG_CODECST, SPA_RST_OFF, 4); in tr_init()
789 tr_wr(tr, TDX_REG_CODECST, TDX_CDC_ON, 4); in tr_init()
792 tr_wr(tr, TNX_REG_CODECST, TNX_CDC_ON, 4); in tr_init()
796 tr_wr(tr, TR_REG_CIR, TR_CIR_MIDENA | TR_CIR_ADDRENA, 4); in tr_init()
824 struct tr_info *tr; in tr_pci_attach() local
830 tr = malloc(sizeof(*tr), M_DEVBUF, M_WAITOK | M_ZERO); in tr_pci_attach()
831 tr->type = pci_get_devid(dev); in tr_pci_attach()
832 tr->rev = pci_get_revid(dev); in tr_pci_attach()
833 tr->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_t4dwave softc"); in tr_pci_attach()
844 switch (tr->type) { in tr_pci_attach()
856 tr->regid = PCIR_BAR(0); in tr_pci_attach()
857 tr->regtype = SYS_RES_IOPORT; in tr_pci_attach()
858 tr->reg = bus_alloc_resource_any(dev, tr->regtype, &tr->regid, in tr_pci_attach()
860 if (tr->reg) { in tr_pci_attach()
861 tr->st = rman_get_bustag(tr->reg); in tr_pci_attach()
862 tr->sh = rman_get_bushandle(tr->reg); in tr_pci_attach()
868 if (tr_init(tr) == -1) { in tr_pci_attach()
872 tr->playchns = 0; in tr_pci_attach()
874 codec = AC97_CREATE(dev, tr, tr_ac97); in tr_pci_attach()
878 tr->irqid = 0; in tr_pci_attach()
879 tr->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &tr->irqid, in tr_pci_attach()
881 if (!tr->irq || snd_setup_intr(dev, tr->irq, 0, tr_intr, tr, &tr->ih)) { in tr_pci_attach()
886 if (tr->type == ALI_PCI_ID) { in tr_pci_attach()
898 tr->hwchns = ALI_MAXHWCH; in tr_pci_attach()
899 tr->bufsz = ALI_BUFSZ; in tr_pci_attach()
902 tr->hwchns = TR_MAXHWCH; in tr_pci_attach()
903 tr->bufsz = pcm_getbuffersize(dev, 4096, TR_DEFAULT_BUFSZ, in tr_pci_attach()
913 /*maxsize*/tr->bufsz, /*nsegments*/1, /*maxsegz*/tr->bufsz, in tr_pci_attach()
915 &tr->parent_dmat) != 0) { in tr_pci_attach()
921 rman_get_start(tr->reg), rman_get_start(tr->irq), in tr_pci_attach()
924 pcm_init(dev, tr); in tr_pci_attach()
925 pcm_addchan(dev, PCMDIR_REC, &trrchan_class, tr); in tr_pci_attach()
927 pcm_addchan(dev, PCMDIR_PLAY, &trpchan_class, tr); in tr_pci_attach()
935 if (tr->reg) bus_release_resource(dev, tr->regtype, tr->regid, tr->reg); in tr_pci_attach()
936 if (tr->ih) bus_teardown_intr(dev, tr->irq, tr->ih); in tr_pci_attach()
937 if (tr->irq) bus_release_resource(dev, SYS_RES_IRQ, tr->irqid, tr->irq); in tr_pci_attach()
938 if (tr->parent_dmat) bus_dma_tag_destroy(tr->parent_dmat); in tr_pci_attach()
939 if (tr->lock) snd_mtxfree(tr->lock); in tr_pci_attach()
940 free(tr, M_DEVBUF); in tr_pci_attach()
948 struct tr_info *tr; in tr_pci_detach() local
954 tr = pcm_getdevinfo(dev); in tr_pci_detach()
955 bus_release_resource(dev, tr->regtype, tr->regid, tr->reg); in tr_pci_detach()
956 bus_teardown_intr(dev, tr->irq, tr->ih); in tr_pci_detach()
957 bus_release_resource(dev, SYS_RES_IRQ, tr->irqid, tr->irq); in tr_pci_detach()
958 bus_dma_tag_destroy(tr->parent_dmat); in tr_pci_detach()
959 snd_mtxfree(tr->lock); in tr_pci_detach()
960 free(tr, M_DEVBUF); in tr_pci_detach()
969 struct tr_info *tr; in tr_pci_suspend() local
971 tr = pcm_getdevinfo(dev); in tr_pci_suspend()
973 for (i = 0; i < tr->playchns; i++) { in tr_pci_suspend()
974 tr->chinfo[i].was_active = tr->chinfo[i].active; in tr_pci_suspend()
975 if (tr->chinfo[i].active) { in tr_pci_suspend()
976 trpchan_trigger(NULL, &tr->chinfo[i], PCMTRIG_STOP); in tr_pci_suspend()
980 tr->recchinfo.was_active = tr->recchinfo.active; in tr_pci_suspend()
981 if (tr->recchinfo.active) { in tr_pci_suspend()
982 trrchan_trigger(NULL, &tr->recchinfo, PCMTRIG_STOP); in tr_pci_suspend()
992 struct tr_info *tr; in tr_pci_resume() local
994 tr = pcm_getdevinfo(dev); in tr_pci_resume()
996 if (tr_init(tr) == -1) { in tr_pci_resume()
1006 for (i = 0; i < tr->playchns; i++) { in tr_pci_resume()
1007 if (tr->chinfo[i].was_active) { in tr_pci_resume()
1008 trpchan_trigger(NULL, &tr->chinfo[i], PCMTRIG_START); in tr_pci_resume()
1012 if (tr->recchinfo.was_active) { in tr_pci_resume()
1013 trrchan_trigger(NULL, &tr->recchinfo, PCMTRIG_START); in tr_pci_resume()