Lines Matching +full:- +full:32000
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2012-2016 Ruslan Bukin <br@bsdpad.com>
5 * Copyright (c) 2023-2024 Florian Walpen <dev@submerge.ch>
122 snd_mtxlock(sc->lock); in hdspe_intr()
126 if ((err = device_get_children(sc->dev, &devlist, &devcount)) != 0) in hdspe_intr()
131 if (scp->ih != NULL) in hdspe_intr()
132 scp->ih(scp); in hdspe_intr()
139 snd_mtxunlock(sc->lock); in hdspe_intr()
146 device_printf(sc->dev, "hdspe_dmapsetmap()\n"); in hdspe_dmapsetmap()
155 sc->csid = PCIR_BAR(0); in hdspe_alloc_resources()
156 sc->cs = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, in hdspe_alloc_resources()
157 &sc->csid, RF_ACTIVE); in hdspe_alloc_resources()
159 if (!sc->cs) { in hdspe_alloc_resources()
160 device_printf(sc->dev, "Unable to map SYS_RES_MEMORY.\n"); in hdspe_alloc_resources()
164 sc->cst = rman_get_bustag(sc->cs); in hdspe_alloc_resources()
165 sc->csh = rman_get_bushandle(sc->cs); in hdspe_alloc_resources()
168 sc->irqid = 0; in hdspe_alloc_resources()
169 sc->irq = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, &sc->irqid, in hdspe_alloc_resources()
172 if (!sc->irq || in hdspe_alloc_resources()
173 bus_setup_intr(sc->dev, sc->irq, INTR_MPSAFE | INTR_TYPE_AV, in hdspe_alloc_resources()
174 NULL, hdspe_intr, sc, &sc->ih)) { in hdspe_alloc_resources()
175 device_printf(sc->dev, "Unable to alloc interrupt resource.\n"); in hdspe_alloc_resources()
180 if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(sc->dev), in hdspe_alloc_resources()
193 /*dmatag*/&sc->dmat) != 0) { in hdspe_alloc_resources()
194 device_printf(sc->dev, "Unable to create dma tag.\n"); in hdspe_alloc_resources()
198 sc->bufsize = HDSPE_DMASEGSIZE; in hdspe_alloc_resources()
201 if (bus_dmamem_alloc(sc->dmat, (void **)&sc->pbuf, BUS_DMA_WAITOK, in hdspe_alloc_resources()
202 &sc->pmap)) { in hdspe_alloc_resources()
203 device_printf(sc->dev, "Can't alloc pbuf.\n"); in hdspe_alloc_resources()
207 if (bus_dmamap_load(sc->dmat, sc->pmap, sc->pbuf, sc->bufsize, in hdspe_alloc_resources()
209 device_printf(sc->dev, "Can't load pbuf.\n"); in hdspe_alloc_resources()
214 if (bus_dmamem_alloc(sc->dmat, (void **)&sc->rbuf, BUS_DMA_WAITOK, in hdspe_alloc_resources()
215 &sc->rmap)) { in hdspe_alloc_resources()
216 device_printf(sc->dev, "Can't alloc rbuf.\n"); in hdspe_alloc_resources()
220 if (bus_dmamap_load(sc->dmat, sc->rmap, sc->rbuf, sc->bufsize, in hdspe_alloc_resources()
222 device_printf(sc->dev, "Can't load rbuf.\n"); in hdspe_alloc_resources()
226 bzero(sc->pbuf, sc->bufsize); in hdspe_alloc_resources()
227 bzero(sc->rbuf, sc->bufsize); in hdspe_alloc_resources()
238 paddr = vtophys(sc->pbuf); in hdspe_map_dmabuf()
239 raddr = vtophys(sc->rbuf); in hdspe_map_dmabuf()
252 struct sc_info *sc = oidp->oid_arg1; in hdspe_sysctl_sample_rate()
256 speed = sc->force_speed; in hdspe_sysctl_sample_rate()
260 if (error != 0 || req->newptr == NULL) in hdspe_sysctl_sample_rate()
263 /* Speed from 32000 to 192000, 0 falls back to pcm speed setting. */ in hdspe_sysctl_sample_rate()
264 sc->force_speed = 0; in hdspe_sysctl_sample_rate()
272 if (speed < ((32000 + 44100) / 2) * multiplier) in hdspe_sysctl_sample_rate()
273 sc->force_speed = 32000 * multiplier; in hdspe_sysctl_sample_rate()
275 sc->force_speed = 44100 * multiplier; in hdspe_sysctl_sample_rate()
277 sc->force_speed = 48000 * multiplier; in hdspe_sysctl_sample_rate()
287 struct sc_info *sc = oidp->oid_arg1; in hdspe_sysctl_period()
291 period = sc->force_period; in hdspe_sysctl_period()
295 if (error != 0 || req->newptr == NULL) in hdspe_sysctl_period()
299 sc->force_period = 0; in hdspe_sysctl_period()
301 sc->force_period = 32; in hdspe_sysctl_period()
302 while (sc->force_period < period && sc->force_period < 4096) in hdspe_sysctl_period()
303 sc->force_period <<= 1; in hdspe_sysctl_period()
318 sc = oidp->oid_arg1; in hdspe_sysctl_clock_preference()
321 if (sc->type == HDSPE_AIO) in hdspe_sysctl_clock_preference()
323 else if (sc->type == HDSPE_RAYDAT) in hdspe_sysctl_clock_preference()
329 setting = sc->settings_register & HDSPE_SETTING_CLOCK_MASK; in hdspe_sysctl_clock_preference()
330 for (clock = clock_table; clock->name != NULL; ++clock) { in hdspe_sysctl_clock_preference()
331 if (clock->setting == setting) in hdspe_sysctl_clock_preference()
334 if (clock->name != NULL) in hdspe_sysctl_clock_preference()
335 strlcpy(buf, clock->name, sizeof(buf)); in hdspe_sysctl_clock_preference()
339 if (error != 0 || req->newptr == NULL) in hdspe_sysctl_clock_preference()
343 for (clock = clock_table; clock->name != NULL; ++clock) { in hdspe_sysctl_clock_preference()
344 if (strncasecmp(buf, clock->name, sizeof(buf)) == 0) in hdspe_sysctl_clock_preference()
349 if (clock->name != NULL) { in hdspe_sysctl_clock_preference()
350 setting = clock->setting & HDSPE_SETTING_CLOCK_MASK; in hdspe_sysctl_clock_preference()
351 snd_mtxlock(sc->lock); in hdspe_sysctl_clock_preference()
352 sc->settings_register &= ~HDSPE_SETTING_CLOCK_MASK; in hdspe_sysctl_clock_preference()
353 sc->settings_register |= setting; in hdspe_sysctl_clock_preference()
354 hdspe_write_4(sc, HDSPE_SETTINGS_REG, sc->settings_register); in hdspe_sysctl_clock_preference()
355 snd_mtxunlock(sc->lock); in hdspe_sysctl_clock_preference()
368 sc = oidp->oid_arg1; in hdspe_sysctl_clock_source()
371 if (sc->type == HDSPE_AIO) in hdspe_sysctl_clock_source()
373 else if (sc->type == HDSPE_RAYDAT) in hdspe_sysctl_clock_source()
379 snd_mtxlock(sc->lock); in hdspe_sysctl_clock_source()
382 snd_mtxunlock(sc->lock); in hdspe_sysctl_clock_source()
385 for (clock = clock_table; clock->name != NULL; ++clock) { in hdspe_sysctl_clock_source()
387 if (sc->settings_register & HDSPE_SETTING_MASTER) { in hdspe_sysctl_clock_source()
388 if (clock->setting & HDSPE_SETTING_MASTER) in hdspe_sysctl_clock_source()
390 } else if (clock->status == status) in hdspe_sysctl_clock_source()
395 if (clock->name != NULL) in hdspe_sysctl_clock_source()
396 strlcpy(buf, clock->name, sizeof(buf)); in hdspe_sysctl_clock_source()
408 sc = oidp->oid_arg1; in hdspe_sysctl_clock_list()
412 if (sc->type == HDSPE_AIO) in hdspe_sysctl_clock_list()
414 else if (sc->type == HDSPE_RAYDAT) in hdspe_sysctl_clock_list()
421 for (clock = clock_table; clock->name != NULL; ++clock) { in hdspe_sysctl_clock_list()
423 n += strlcpy(buf + n, ",", sizeof(buf) - n); in hdspe_sysctl_clock_list()
424 n += strlcpy(buf + n, clock->name, sizeof(buf) - n); in hdspe_sysctl_clock_list()
439 sc = oidp->oid_arg1; in hdspe_sysctl_sync_status()
443 if (sc->type == HDSPE_AIO) in hdspe_sysctl_sync_status()
445 else if (sc->type == HDSPE_RAYDAT) in hdspe_sysctl_sync_status()
451 snd_mtxlock(sc->lock); in hdspe_sysctl_sync_status()
453 snd_mtxunlock(sc->lock); in hdspe_sysctl_sync_status()
456 for (clock = clock_table; clock->name != NULL; ++clock) { in hdspe_sysctl_sync_status()
457 if (clock->sync_bit != 0) { in hdspe_sysctl_sync_status()
459 n += strlcpy(buf + n, ",", sizeof(buf) - n); in hdspe_sysctl_sync_status()
461 if ((clock->sync_bit & status) != 0) in hdspe_sysctl_sync_status()
463 else if ((clock->lock_bit & status) != 0) in hdspe_sysctl_sync_status()
465 n += snprintf(buf + n, sizeof(buf) - n, "%s(%s)", in hdspe_sysctl_sync_status()
466 clock->name, state); in hdspe_sysctl_sync_status()
500 sc->period = 32; in hdspe_init()
507 sc->force_period = 256; in hdspe_init()
508 sc->ctrl_register = hdspe_encode_latency(7); in hdspe_init()
511 sc->speed = HDSPE_SPEED_DEFAULT; in hdspe_init()
512 sc->force_speed = 0; in hdspe_init()
513 sc->ctrl_register &= ~HDSPE_FREQ_MASK; in hdspe_init()
514 sc->ctrl_register |= HDSPE_FREQ_MASK_DEFAULT; in hdspe_init()
515 hdspe_write_4(sc, HDSPE_CONTROL_REG, sc->ctrl_register); in hdspe_init()
517 switch (sc->type) { in hdspe_init()
527 period /= sc->speed; in hdspe_init()
531 sc->settings_register = 0; in hdspe_init()
532 hdspe_write_4(sc, HDSPE_SETTINGS_REG, sc->settings_register); in hdspe_init()
551 sc->lock = snd_mtxcreate(device_get_nameunit(dev), in hdspe_attach()
553 sc->dev = dev; in hdspe_attach()
559 sc->type = HDSPE_AIO; in hdspe_attach()
563 sc->type = HDSPE_RAYDAT; in hdspe_attach()
582 scp->hc = &chan_map[i]; in hdspe_attach()
583 scp->sc = sc; in hdspe_attach()
584 scp->dev = device_add_child(dev, "pcm", DEVICE_UNIT_ANY); in hdspe_attach()
585 device_set_ivars(scp->dev, scp); in hdspe_attach()
624 "Force sample rate (32000, 44100, 48000, ... 192000)"); in hdspe_attach()
639 bus_dmamap_unload(sc->dmat, sc->rmap); in hdspe_dmafree()
640 bus_dmamap_unload(sc->dmat, sc->pmap); in hdspe_dmafree()
641 bus_dmamem_free(sc->dmat, sc->rbuf, sc->rmap); in hdspe_dmafree()
642 bus_dmamem_free(sc->dmat, sc->pbuf, sc->pmap); in hdspe_dmafree()
643 sc->rbuf = sc->pbuf = NULL; in hdspe_dmafree()
664 if (sc->ih) in hdspe_detach()
665 bus_teardown_intr(dev, sc->irq, sc->ih); in hdspe_detach()
666 if (sc->dmat) in hdspe_detach()
667 bus_dma_tag_destroy(sc->dmat); in hdspe_detach()
668 if (sc->irq) in hdspe_detach()
669 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); in hdspe_detach()
670 if (sc->cs) in hdspe_detach()
671 bus_release_resource(dev, SYS_RES_MEMORY, PCIR_BAR(0), sc->cs); in hdspe_detach()
672 if (sc->lock) in hdspe_detach()
673 snd_mtxfree(sc->lock); in hdspe_detach()