Lines Matching +full:dac +full:- +full:mode +full:- +full:mask

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
47 /* ------------------------------------------------------------------------- */
59 /* ------------------------------------------------------------------------- */
115 /* ------------------------------------------------------------------------- */
123 return bus_space_read_1(sc->enh_st, sc->enh_sh, reg); in sv_direct_get()
130 bus_space_write_1(sc->enh_st, sc->enh_sh, reg, val); in _sv_direct_set()
134 …device_printf(sc->dev, "sv_direct_set register 0x%02x %d != %d from line %d\n", reg, n, val, line); in _sv_direct_set()
144 bus_space_write_1(sc->enh_st, sc->enh_sh, SV_CM_INDEX, reg); in sv_indirect_get()
145 return bus_space_read_1(sc->enh_st, sc->enh_sh, SV_CM_DATA); in sv_indirect_get()
156 bus_space_write_1(sc->enh_st, sc->enh_sh, SV_CM_INDEX, reg); in _sv_indirect_set()
157 bus_space_write_1(sc->enh_st, sc->enh_sh, SV_CM_DATA, val); in _sv_indirect_set()
164 device_printf(sc->dev, "sv_indirect_set register 0x%02x %d != %d line %d\n", reg, n, val, line); in _sv_indirect_set()
171 u_int32_t base, u_int32_t count, u_int8_t mode) in sv_dma_set_config() argument
175 bus_space_write_1(st, sh, SV_DMA_MODE, mode); in sv_dma_set_config()
177 DEB(printf("base 0x%08x count %5d mode 0x%02x\n", in sv_dma_set_config()
178 base, count, mode)); in sv_dma_set_config()
187 /* ------------------------------------------------------------------------- */
195 ch = (dir == PCMDIR_PLAY) ? &sc->pch : &sc->rch; in svchan_init()
197 ch->parent = sc; in svchan_init()
198 ch->channel = c; in svchan_init()
199 ch->dir = dir; in svchan_init()
201 if (sndbuf_alloc(b, sc->parent_dmat, 0, sc->bufsz) != 0) { in svchan_init()
205 ch->buffer = b; in svchan_init()
206 ch->fmt = SND_FORMAT(AFMT_U8, 1, 0); in svchan_init()
207 ch->spd = DSP_DEFAULT_SPEED; in svchan_init()
208 ch->dma_active = ch->dma_was_active = 0; in svchan_init()
223 struct sc_info *sc = ch->parent; in svchan_setblocksize()
226 RANGE(blocksize, SV_MIN_BLKSZ, sc->bufsz / SV_INTR_PER_BUFFER); in svchan_setblocksize()
227 sndbuf_resize(ch->buffer, SV_INTR_PER_BUFFER, blocksize); in svchan_setblocksize()
238 ch->fmt = (AFMT_CHANNEL(format) > 1) ? SV_AFMT_STEREO : SV_AFMT_MONO; in svchan_setformat()
239 ch->fmt |= (format & AFMT_16BIT) ? SV_AFMT_S16 : SV_AFMT_U8; in svchan_setformat()
248 ch->spd = speed; in svchan_setspeed()
252 /* ------------------------------------------------------------------------- */
282 ms = (m > 3) ? (m - 1) : 3; in sv_set_recspeed()
287 err = f_actual - f_out; in sv_set_recspeed()
289 err = f_out - f_actual; in sv_set_recspeed()
293 best_m = m - 2; in sv_set_recspeed()
294 best_n = n - 2; in sv_set_recspeed()
305 DEB(printf("svrchan_setspeed: %d -> PLLM 0x%02x PLLNR 0x%08x\n", in sv_set_recspeed()
316 struct sc_info *sc = ch->parent; in svrchan_trigger()
323 sv_set_recspeed(sc, ch->spd); in svrchan_trigger()
327 v |= SV_AFMT_DMAC(ch->fmt); in svrchan_trigger()
331 count = sndbuf_getsize(ch->buffer) / 2; /* DMAC uses words */ in svrchan_trigger()
332 sv_dma_set_config(sc->dmac_st, sc->dmac_sh, in svrchan_trigger()
333 sndbuf_getbufaddr(ch->buffer), in svrchan_trigger()
334 count - 1, in svrchan_trigger()
336 count = count / SV_INTR_PER_BUFFER - 1; in svrchan_trigger()
343 ch->dma_active = 1; in svrchan_trigger()
349 ch->dma_active = 0; in svrchan_trigger()
360 struct sc_info *sc = ch->parent; in svrchan_getptr()
363 sz = sndbuf_getsize(ch->buffer); in svrchan_getptr()
365 remain = (sv_dma_get_count(sc->dmac_st, sc->dmac_sh) + 1) * 2; in svrchan_getptr()
366 return sz - remain; in svrchan_getptr()
381 /* ------------------------------------------------------------------------- */
388 struct sc_info *sc = ch->parent; in svpchan_trigger()
395 speed = (ch->spd * 65536) / 48000; in svpchan_trigger()
403 v |= SV_AFMT_DMAA(ch->fmt); in svpchan_trigger()
407 count = sndbuf_getsize(ch->buffer); in svpchan_trigger()
408 sv_dma_set_config(sc->dmaa_st, sc->dmaa_sh, in svpchan_trigger()
409 sndbuf_getbufaddr(ch->buffer), in svpchan_trigger()
410 count - 1, in svpchan_trigger()
412 count = count / SV_INTR_PER_BUFFER - 1; in svpchan_trigger()
420 ch->dma_active = 1; in svpchan_trigger()
426 ch->dma_active = 0; in svpchan_trigger()
437 struct sc_info *sc = ch->parent; in svpchan_getptr()
440 sz = sndbuf_getsize(ch->buffer); in svpchan_getptr()
442 remain = sv_dma_get_count(sc->dmaa_st, sc->dmaa_sh) + 1; in svpchan_getptr()
443 return (sz - remain); in svpchan_getptr()
458 /* ------------------------------------------------------------------------- */
488 g = mt[dev].max - g; in sv_channel_gain()
546 sv_mix_setrecsrc(struct snd_mixer *m, u_int32_t mask) in sv_mix_setrecsrc() argument
553 if ((1 << i) & mask) { in sv_mix_setrecsrc()
557 DEB(printf("sv_mix_setrecsrc: mask 0x%08x adc_input 0x%02x\n", mask, v)); in sv_mix_setrecsrc()
559 return mask; in sv_mix_setrecsrc()
570 /* ------------------------------------------------------------------------- */
614 /* Set in enhanced mode */ in sv_init()
628 /* Disable loopback - binds ADC and DAC rates */ in sv_init()
637 sc->rev = sv_indirect_get(sc, SV_REG_REVISION); in sv_init()
647 sc->rch.dma_was_active = sc->rch.dma_active; in sv_suspend()
648 svrchan_trigger(NULL, &sc->rch, PCMTRIG_ABORT); in sv_suspend()
650 sc->pch.dma_was_active = sc->pch.dma_active; in sv_suspend()
651 svrchan_trigger(NULL, &sc->pch, PCMTRIG_ABORT); in sv_suspend()
666 if (sv_init(sc) == -1) { in sv_resume()
671 if (mixer_reinit(dev) == -1) { in sv_resume()
676 if (sc->rch.dma_was_active) { in sv_resume()
677 svrchan_trigger(0, &sc->rch, PCMTRIG_START); in sv_resume()
680 if (sc->pch.dma_was_active) { in sv_resume()
681 svpchan_trigger(0, &sc->pch, PCMTRIG_START); in sv_resume()
687 /* ------------------------------------------------------------------------- */
698 chn_intr(sc->pch.channel); in sv_intr()
701 chn_intr(sc->rch.channel); in sv_intr()
730 sc->dev = dev; in sv_attach()
735 device_printf(dev, "chip is in D%d power mode " in sv_attach()
736 "-- setting to D0\n", pci_get_powerstate(dev)); in sv_attach()
739 sc->enh_rid = SV_PCI_ENHANCED; in sv_attach()
740 sc->enh_type = SYS_RES_IOPORT; in sv_attach()
741 sc->enh_reg = bus_alloc_resource_any(dev, sc->enh_type, in sv_attach()
742 &sc->enh_rid, RF_ACTIVE); in sv_attach()
743 if (sc->enh_reg == NULL) { in sv_attach()
747 sc->enh_st = rman_get_bustag(sc->enh_reg); in sv_attach()
748 sc->enh_sh = rman_get_bushandle(sc->enh_reg); in sv_attach()
760 sc->irqid = 0; in sv_attach()
761 sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irqid, in sv_attach()
763 if (!sc->irq || in sv_attach()
764 snd_setup_intr(dev, sc->irq, 0, sv_intr, sc, &sc->ih)) { in sv_attach()
769 sc->bufsz = pcm_getbuffersize(dev, 4096, SV_DEFAULT_BUFSZ, 65536); in sv_attach()
775 /*maxsize*/sc->bufsz, /*nsegments*/1, in sv_attach()
778 &sc->parent_dmat) != 0) { in sv_attach()
814 if ((mu - ml >= 0x800) || in sv_attach()
815 ((mu - ml) % 0x200)) { in sv_attach()
825 /* Add resources to list of pci resources for this device - from here on in sv_attach()
830 /* Cache resource short-cuts for dma_a */ in sv_attach()
831 sc->dmaa_rid = SV_PCI_DMAA; in sv_attach()
832 sc->dmaa_type = SYS_RES_IOPORT; in sv_attach()
833 sc->dmaa_reg = bus_alloc_resource_any(dev, sc->dmaa_type, in sv_attach()
834 &sc->dmaa_rid, RF_ACTIVE); in sv_attach()
835 if (sc->dmaa_reg == NULL) { in sv_attach()
839 sc->dmaa_st = rman_get_bustag(sc->dmaa_reg); in sv_attach()
840 sc->dmaa_sh = rman_get_bushandle(sc->dmaa_reg); in sv_attach()
848 /* Cache resource short-cuts for dma_c */ in sv_attach()
849 sc->dmac_rid = SV_PCI_DMAC; in sv_attach()
850 sc->dmac_type = SYS_RES_IOPORT; in sv_attach()
851 sc->dmac_reg = bus_alloc_resource_any(dev, sc->dmac_type, in sv_attach()
852 &sc->dmac_rid, RF_ACTIVE); in sv_attach()
853 if (sc->dmac_reg == NULL) { in sv_attach()
857 sc->dmac_st = rman_get_bustag(sc->dmac_reg); in sv_attach()
858 sc->dmac_sh = rman_get_bushandle(sc->dmac_reg); in sv_attach()
867 printf("Sonicvibes: revision %d.\n", sc->rev); in sv_attach()
874 rman_get_start(sc->enh_reg), rman_get_start(sc->irq), in sv_attach()
886 if (sc->parent_dmat) in sv_attach()
887 bus_dma_tag_destroy(sc->parent_dmat); in sv_attach()
888 if (sc->ih) in sv_attach()
889 bus_teardown_intr(dev, sc->irq, sc->ih); in sv_attach()
890 if (sc->irq) in sv_attach()
891 bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq); in sv_attach()
892 if (sc->enh_reg) in sv_attach()
893 bus_release_resource(dev, sc->enh_type, sc->enh_rid, sc->enh_reg); in sv_attach()
894 if (sc->dmaa_reg) in sv_attach()
895 bus_release_resource(dev, sc->dmaa_type, sc->dmaa_rid, sc->dmaa_reg); in sv_attach()
896 if (sc->dmac_reg) in sv_attach()
897 bus_release_resource(dev, sc->dmac_type, sc->dmac_rid, sc->dmac_reg); in sv_attach()
913 bus_dma_tag_destroy(sc->parent_dmat); in sv_detach()
914 bus_teardown_intr(dev, sc->irq, sc->ih); in sv_detach()
915 bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq); in sv_detach()
916 bus_release_resource(dev, sc->enh_type, sc->enh_rid, sc->enh_reg); in sv_detach()
917 bus_release_resource(dev, sc->dmaa_type, sc->dmaa_rid, sc->dmaa_reg); in sv_detach()
918 bus_release_resource(dev, sc->dmac_type, sc->dmac_rid, sc->dmac_reg); in sv_detach()