Lines Matching +full:pcm +full:- +full:interface +full:- +full:rate
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause AND BSD-3-Clause
27 /*-
80 #include <dev/sound/pcm/sound.h>
109 /* Device interface. */
116 "pcm",
128 /* Device interface. */
137 int detect_active; /* for extint-gpio */
138 int level; /* for extint-gpio */
139 struct i2s_softc *i2s; /* for extint-gpio */
195 sc->aoa.sc_dev = self; in i2s_attach()
196 sc->node = ofw_bus_get_node(self); in i2s_attach()
198 port = of_find_firstchild_byname(sc->node, "i2s-a"); in i2s_attach()
199 if (port == -1) in i2s_attach()
201 sc->soundnode = of_find_firstchild_byname(port, "sound"); in i2s_attach()
202 if (sc->soundnode == -1) in i2s_attach()
205 mtx_init(&sc->port_mtx, "port_mtx", NULL, MTX_DEF); in i2s_attach()
209 sc->reg = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE); in i2s_attach()
210 if (sc->reg == NULL) in i2s_attach()
215 sc->aoa.sc_odma = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, in i2s_attach()
217 if (sc->aoa.sc_odma == NULL) in i2s_attach()
220 /* Establish the DBDMA channel edge-triggered interrupt. */ in i2s_attach()
246 i2s_delayed_attach->ich_func = i2s_postattach; in i2s_attach()
247 i2s_delayed_attach->ich_arg = sc; in i2s_attach()
280 {"headphone-mute", HEADPHONE_MUTE},
281 {"lineout-mute", LINEOUT_MUTE},
282 {"amp-mute", AMP_MUTE},
283 {"headphone-detect", HEADPHONE_DETECT},
284 {"lineout-detect", LINEOUT_DETECT},
285 {"line-output-detect", LINEOUT_DETECT},
286 {"audio-hw-reset", AUDIO_HW_RESET},
287 {"hw-reset", AUDIO_HW_RESET},
302 sc->level = sc->detect_active; in aoagpio_int()
304 sc->level = !(sc->detect_active); in aoagpio_int()
306 if (sc->i2s) in aoagpio_int()
307 i2s_cint(sc->i2s); in aoagpio_int()
320 if (node == 0 || node == -1) in aoagpio_probe()
324 if (OF_getprop(node, "audio-gpio", bname, sizeof(bname)) > 2) in aoagpio_probe()
330 for (m = gpio_controls; m->name != NULL; m++) { in aoagpio_probe()
331 if (strcmp(name, m->name) == 0) { in aoagpio_probe()
333 gpio_ctrls[m->ctrl] = sc; in aoagpio_probe()
334 sc->dev = gpio; in aoagpio_probe()
335 sc->ctrl = m->ctrl; in aoagpio_probe()
336 sc->level = 0; in aoagpio_probe()
337 sc->detect_active = 0; in aoagpio_probe()
338 sc->i2s = NULL; in aoagpio_probe()
340 OF_getprop(node, "audio-gpio-active-state", in aoagpio_probe()
341 &sc->detect_active, sizeof(sc->detect_active)); in aoagpio_probe()
343 if ((1 << m->ctrl) & GPIO_CTRL_EXTINT_SET) in aoagpio_probe()
346 device_set_desc(gpio, m->name); in aoagpio_probe()
365 if ((1 << sc->ctrl) & GPIO_CTRL_EXTINT_SET) { in aoagpio_attach()
394 #define I2S_INT_CLKSTOPPEND 0x01000000 /* clock-stop interrupt pending */
437 'rate' is the frame rate.
443 i2s_setup(struct i2s_softc *sc, u_int rate, u_int wordsize, u_int sclk_fs) in i2s_setup() argument
461 mclk = rate * MCLK_FS; in i2s_setup()
486 x = (mdiv / 2) - 1; in i2s_setup()
499 x = (sdiv / 2) - 1; in i2s_setup()
533 x = bus_read_4(sc->reg, I2S_WORDSIZE); in i2s_setup()
535 bus_write_4(sc->reg, I2S_WORDSIZE, wordformat); in i2s_setup()
537 x = bus_read_4(sc->reg, I2S_FORMAT); in i2s_setup()
550 bus_space_write_4(sc->sc_tag, sc->sc_bsh, I2S_INT, in i2s_setup()
555 for (timo = 1000; timo > 0; timo--) { in i2s_setup()
556 if (bus_space_read_4(sc->sc_tag, sc->sc_bsh, in i2s_setup()
565 sc->sc_dev.dv_xname); in i2s_setup()
568 bus_space_write_4(sc->sc_tag, sc->sc_bsh, I2S_FORMAT, reg); in i2s_setup()
584 for (n = OF_child(node); n != -1; n = OF_peer(n)) { in of_find_firstchild_byname()
592 return (-1); in of_find_firstchild_byname()
603 return (macgpio_read(sc->dev) & GPIO_DATA); in gpio_read()
619 macgpio_write(sc->dev, reg); in gpio_write()
628 gpio_ctrls[HEADPHONE_DETECT]->level) in i2s_cint()
632 gpio_ctrls[LINEOUT_DETECT]->level) in i2s_cint()
698 if (mask == sc->output_mask) in MUTE_CONTROL()
701 mtx_lock(&sc->port_mtx); in MUTE_CONTROL()
723 sc->output_mask = mask; in MUTE_CONTROL()
725 mtx_unlock(&sc->port_mtx); in MUTE_CONTROL()
735 self = sc->aoa.sc_dev; in i2s_postattach()
750 gpio_ctrls[i]->i2s = sc; in i2s_postattach()