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;
196 sc->node = ofw_bus_get_node(self);
198 port = of_find_firstchild_byname(sc->node, "i2s-a");
199 if (port == -1)
201 sc->soundnode = of_find_firstchild_byname(port, "sound");
202 if (sc->soundnode == -1)
205 mtx_init(&sc->port_mtx, "port_mtx", NULL, MTX_DEF);
209 sc->reg = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE);
210 if (sc->reg == NULL)
215 sc->aoa.sc_odma = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid,
217 if (sc->aoa.sc_odma == NULL)
220 /* Establish the DBDMA channel edge-triggered interrupt. */
246 i2s_delayed_attach->ich_func = i2s_postattach;
247 i2s_delayed_attach->ich_arg = sc;
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;
304 sc->level = !(sc->detect_active);
306 if (sc->i2s)
307 i2s_cint(sc->i2s);
320 if (node == 0 || node == -1)
324 if (OF_getprop(node, "audio-gpio", bname, sizeof(bname)) > 2)
330 for (m = gpio_controls; m->name != NULL; m++) {
331 if (strcmp(name, m->name) == 0) {
333 gpio_ctrls[m->ctrl] = sc;
334 sc->dev = gpio;
335 sc->ctrl = m->ctrl;
336 sc->level = 0;
337 sc->detect_active = 0;
338 sc->i2s = NULL;
340 OF_getprop(node, "audio-gpio-active-state",
341 &sc->detect_active, sizeof(sc->detect_active));
343 if ((1 << m->ctrl) & GPIO_CTRL_EXTINT_SET)
346 device_set_desc(gpio, m->name);
365 if ((1 << sc->ctrl) & GPIO_CTRL_EXTINT_SET) {
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)
461 mclk = rate * MCLK_FS;
486 x = (mdiv / 2) - 1;
499 x = (sdiv / 2) - 1;
533 x = bus_read_4(sc->reg, I2S_WORDSIZE);
535 bus_write_4(sc->reg, I2S_WORDSIZE, wordformat);
537 x = bus_read_4(sc->reg, I2S_FORMAT);
550 bus_space_write_4(sc->sc_tag, sc->sc_bsh, I2S_INT,
555 for (timo = 1000; timo > 0; timo--) {
556 if (bus_space_read_4(sc->sc_tag, sc->sc_bsh,
565 sc->sc_dev.dv_xname);
568 bus_space_write_4(sc->sc_tag, sc->sc_bsh, I2S_FORMAT, reg);
584 for (n = OF_child(node); n != -1; n = OF_peer(n)) {
592 return (-1);
603 return (macgpio_read(sc->dev) & GPIO_DATA);
619 macgpio_write(sc->dev, reg);
628 gpio_ctrls[HEADPHONE_DETECT]->level)
632 gpio_ctrls[LINEOUT_DETECT]->level)
698 if (mask == sc->output_mask)
701 mtx_lock(&sc->port_mtx);
723 sc->output_mask = mask;
725 mtx_unlock(&sc->port_mtx);
735 self = sc->aoa.sc_dev;
750 gpio_ctrls[i]->i2s = sc;