Lines Matching +full:pcm +full:- +full:interface +full:- +full:rate

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
33 #include <dev/sound/pcm/sound.h>
34 #include <dev/sound/pcm/ac97.h>
176 return (bus_space_read_1(fm801->st, fm801->sh, regno)); in fm801_rd()
178 return (bus_space_read_2(fm801->st, fm801->sh, regno)); in fm801_rd()
180 return (bus_space_read_4(fm801->st, fm801->sh, regno)); in fm801_rd()
192 bus_space_write_1(fm801->st, fm801->sh, regno, data); in fm801_wr()
195 bus_space_write_2(fm801->st, fm801->sh, regno, data); in fm801_wr()
198 bus_space_write_4(fm801->st, fm801->sh, regno, data); in fm801_wr()
203 /* -------------------------------------------------------------------- */
216 DPRINT("fm801 rdcd: 1 - DELAY\n"); in fm801_rdcd()
228 DPRINT("fm801 rdcd: 2 - DELAY\n"); in fm801_rdcd()
251 DPRINT("fm801 rdcd: 1 - DELAY\n"); in fm801_wrcd()
255 return -1; in fm801_wrcd()
264 DPRINT("fm801 wrcd: 2 - DELAY\n"); in fm801_wrcd()
268 return -1; in fm801_wrcd()
281 /* -------------------------------------------------------------------- */
295 fm801->play_flip++; in fm801_intr()
296 if(fm801->play_flip & 1) { in fm801_intr()
297 fm801_wr(fm801, FM_PLAY_DMABUF1, fm801->play_start,4); in fm801_intr()
299 fm801_wr(fm801, FM_PLAY_DMABUF2, fm801->play_nextblk,4); in fm801_intr()
300 chn_intr(fm801->pch.channel); in fm801_intr()
304 fm801->rec_flip++; in fm801_intr()
305 if(fm801->rec_flip & 1) { in fm801_intr()
306 fm801_wr(fm801, FM_REC_DMABUF1, fm801->rec_start,4); in fm801_intr()
308 fm801_wr(fm801, FM_REC_DMABUF2, fm801->rec_nextblk,4); in fm801_intr()
309 chn_intr(fm801->rch.channel); in fm801_intr()
326 /* -------------------------------------------------------------------- */
327 /* channel interface */
332 struct fm801_chinfo *ch = (dir == PCMDIR_PLAY)? &fm801->pch : &fm801->rch; in fm801ch_init()
335 ch->parent = fm801; in fm801ch_init()
336 ch->channel = c; in fm801ch_init()
337 ch->buffer = b; in fm801ch_init()
338 ch->dir = dir; in fm801ch_init()
339 if (sndbuf_alloc(ch->buffer, fm801->parent_dmat, 0, fm801->bufsz) != 0) in fm801ch_init()
348 struct fm801_info *fm801 = ch->parent; in fm801ch_setformat()
356 if(ch->dir == PCMDIR_PLAY) { in fm801ch_setformat()
357 fm801->play_fmt = in fm801ch_setformat()
359 fm801->play_fmt |= (format & AFMT_16BIT) ? FM_PLAY_16BIT : 0; in fm801ch_setformat()
363 if(ch->dir == PCMDIR_REC ) { in fm801ch_setformat()
364 fm801->rec_fmt = (AFMT_CHANNEL(format) > 1)? FM_REC_STEREO:0; in fm801ch_setformat()
365 fm801->rec_fmt |= (format & AFMT_16BIT) ? FM_PLAY_16BIT : 0; in fm801ch_setformat()
374 u_int32_t rate; member
387 /* anything above -> 48000 */
394 struct fm801_info *fm801 = ch->parent; in fm801ch_setspeed()
399 if(ch->dir == PCMDIR_PLAY) { in fm801ch_setspeed()
400 fm801->pch.spd = fm801_rates[i].rate; in fm801ch_setspeed()
401 fm801->play_shift = (i<<8); in fm801ch_setspeed()
402 fm801->play_shift &= FM_PLAY_RATE_MASK; in fm801ch_setspeed()
405 if(ch->dir == PCMDIR_REC ) { in fm801ch_setspeed()
406 fm801->rch.spd = fm801_rates[i].rate; in fm801ch_setspeed()
407 fm801->rec_shift = (i<<8); in fm801ch_setspeed()
408 fm801->rec_shift &= FM_REC_RATE_MASK; in fm801ch_setspeed()
411 ch->spd = fm801_rates[i].rate; in fm801ch_setspeed()
413 return fm801_rates[i].rate; in fm801ch_setspeed()
420 struct fm801_info *fm801 = ch->parent; in fm801ch_setblocksize()
424 * desired values in any case - otherwise sound playback in fm801ch_setblocksize()
427 if(ch->dir == PCMDIR_PLAY) in fm801ch_setblocksize()
428 fm801->play_blksize = blocksize; in fm801ch_setblocksize()
430 if(ch->dir == PCMDIR_REC) in fm801ch_setblocksize()
431 fm801->rec_blksize = blocksize; in fm801ch_setblocksize()
433 DPRINT("fm801ch_setblocksize %d (dir %d)\n",blocksize, ch->dir); in fm801ch_setblocksize()
442 struct fm801_info *fm801 = ch->parent; in fm801ch_trigger()
443 u_int32_t baseaddr = sndbuf_getbufaddr(ch->buffer); in fm801ch_trigger()
451 if (ch->dir == PCMDIR_PLAY) { in fm801ch_trigger()
453 fm801->play_start = baseaddr; in fm801ch_trigger()
454 fm801->play_nextblk = fm801->play_start + fm801->play_blksize; in fm801ch_trigger()
455 fm801->play_flip = 0; in fm801ch_trigger()
456 fm801_wr(fm801, FM_PLAY_DMALEN, fm801->play_blksize - 1, 2); in fm801ch_trigger()
457 fm801_wr(fm801, FM_PLAY_DMABUF1,fm801->play_start,4); in fm801ch_trigger()
458 fm801_wr(fm801, FM_PLAY_DMABUF2,fm801->play_nextblk,4); in fm801ch_trigger()
460 FM_PLAY_START | FM_PLAY_STOPNOW | fm801->play_fmt | fm801->play_shift, in fm801ch_trigger()
463 fm801->play_flip = 0; in fm801ch_trigger()
469 } else if(ch->dir == PCMDIR_REC) { in fm801ch_trigger()
471 fm801->rec_start = baseaddr; in fm801ch_trigger()
472 fm801->rec_nextblk = fm801->rec_start + fm801->rec_blksize; in fm801ch_trigger()
473 fm801->rec_flip = 0; in fm801ch_trigger()
474 fm801_wr(fm801, FM_REC_DMALEN, fm801->rec_blksize - 1, 2); in fm801ch_trigger()
475 fm801_wr(fm801, FM_REC_DMABUF1,fm801->rec_start,4); in fm801ch_trigger()
476 fm801_wr(fm801, FM_REC_DMABUF2,fm801->rec_nextblk,4); in fm801ch_trigger()
478 FM_REC_START | FM_REC_STOPNOW | fm801->rec_fmt | fm801->rec_shift, in fm801ch_trigger()
481 fm801->rec_flip = 0; in fm801ch_trigger()
497 struct fm801_info *fm801 = ch->parent; in fm801ch_getptr()
500 if (ch->dir == PCMDIR_PLAY) { in fm801ch_getptr()
502 (fm801->play_flip&1) ? in fm801ch_getptr()
503 FM_PLAY_DMABUF2:FM_PLAY_DMABUF1, 4) - fm801->play_start; in fm801ch_getptr()
506 if (ch->dir == PCMDIR_REC) { in fm801ch_getptr()
508 (fm801->rec_flip&1) ? in fm801ch_getptr()
509 FM_REC_DMABUF2:FM_REC_DMABUF1, 4) - fm801->rec_start; in fm801ch_getptr()
533 /* -------------------------------------------------------------------- */
579 fm801->type = pci_get_devid(dev); in fm801_pci_attach()
584 fm801->regid = PCIR_BAR(i); in fm801_pci_attach()
585 fm801->regtype = SYS_RES_MEMORY; in fm801_pci_attach()
586 fm801->reg = bus_alloc_resource_any(dev, fm801->regtype, in fm801_pci_attach()
587 &fm801->regid, RF_ACTIVE); in fm801_pci_attach()
588 if(!fm801->reg) in fm801_pci_attach()
590 fm801->regtype = SYS_RES_IOPORT; in fm801_pci_attach()
591 fm801->reg = bus_alloc_resource_any(dev, in fm801_pci_attach()
592 fm801->regtype, in fm801_pci_attach()
593 &fm801->regid, in fm801_pci_attach()
597 if(fm801->reg) { in fm801_pci_attach()
598 fm801->st = rman_get_bustag(fm801->reg); in fm801_pci_attach()
599 fm801->sh = rman_get_bushandle(fm801->reg); in fm801_pci_attach()
609 fm801->bufsz = pcm_getbuffersize(dev, 4096, FM801_DEFAULT_BUFSZ, 65536); in fm801_pci_attach()
616 if (mixer_init(dev, ac97_getmixerclass(), codec) == -1) goto oops; in fm801_pci_attach()
618 fm801->irqid = 0; in fm801_pci_attach()
619 fm801->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &fm801->irqid, in fm801_pci_attach()
621 if (!fm801->irq || in fm801_pci_attach()
622 snd_setup_intr(dev, fm801->irq, 0, fm801_intr, fm801, &fm801->ih)) { in fm801_pci_attach()
632 /*maxsize*/fm801->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff, in fm801_pci_attach()
634 &fm801->parent_dmat) != 0) { in fm801_pci_attach()
640 (fm801->regtype == SYS_RES_IOPORT)? "port" : "mem", in fm801_pci_attach()
641 rman_get_start(fm801->reg), rman_get_start(fm801->irq), in fm801_pci_attach()
651 fm801->radio = device_add_child(dev, "radio", DEVICE_UNIT_ANY); in fm801_pci_attach()
658 if (fm801->reg) bus_release_resource(dev, fm801->regtype, fm801->regid, fm801->reg); in fm801_pci_attach()
659 if (fm801->ih) bus_teardown_intr(dev, fm801->irq, fm801->ih); in fm801_pci_attach()
660 if (fm801->irq) bus_release_resource(dev, SYS_RES_IRQ, fm801->irqid, fm801->irq); in fm801_pci_attach()
661 if (fm801->parent_dmat) bus_dma_tag_destroy(fm801->parent_dmat); in fm801_pci_attach()
679 if (fm801->radio != NULL) { in fm801_pci_detach()
680 r = device_delete_child(dev, fm801->radio); in fm801_pci_detach()
683 fm801->radio = NULL; in fm801_pci_detach()
690 bus_release_resource(dev, fm801->regtype, fm801->regid, fm801->reg); in fm801_pci_detach()
691 bus_teardown_intr(dev, fm801->irq, fm801->ih); in fm801_pci_detach()
692 bus_release_resource(dev, SYS_RES_IRQ, fm801->irqid, fm801->irq); in fm801_pci_detach()
693 bus_dma_tag_destroy(fm801->parent_dmat); in fm801_pci_detach()
726 return (fm801->reg); in fm801_alloc_resource()
738 /* Device interface */
746 /* Bus interface */
756 "pcm",