Lines Matching +full:bitclock +full:- +full:inversion
1 /*-
83 {"simple-audio-card", 1},
149 sc = ausoc_chan->sc; in audio_soc_chan_setformat()
151 return AUDIO_DAI_SET_CHANFORMAT(sc->cpu_dev, format); in audio_soc_chan_setformat()
164 sc = ausoc_chan->sc; in audio_soc_chan_setspeed()
166 if (sc->link_mclk_fs) { in audio_soc_chan_setspeed()
167 rate = speed * sc->link_mclk_fs; in audio_soc_chan_setspeed()
168 if (AUDIO_DAI_SET_SYSCLK(sc->cpu_dev, rate, AUDIO_DAI_CLOCK_IN)) in audio_soc_chan_setspeed()
169 device_printf(sc->dev, "failed to set sysclk for CPU node\n"); in audio_soc_chan_setspeed()
171 if (AUDIO_DAI_SET_SYSCLK(sc->codec_dev, rate, AUDIO_DAI_CLOCK_OUT)) in audio_soc_chan_setspeed()
172 device_printf(sc->dev, "failed to set sysclk for codec node\n"); in audio_soc_chan_setspeed()
174 SLIST_FOREACH(aux_node, &sc->aux_devs, link) { in audio_soc_chan_setspeed()
175 if (AUDIO_DAI_SET_SYSCLK(aux_node->dev, rate, AUDIO_DAI_CLOCK_OUT)) in audio_soc_chan_setspeed()
176 device_printf(sc->dev, "failed to set sysclk for aux node\n"); in audio_soc_chan_setspeed()
183 speed = AUDIO_DAI_SET_CHANSPEED(sc->cpu_dev, speed); in audio_soc_chan_setspeed()
184 AUDIO_DAI_SET_CHANSPEED(sc->codec_dev, speed); in audio_soc_chan_setspeed()
185 SLIST_FOREACH(aux_node, &sc->aux_devs, link) { in audio_soc_chan_setspeed()
186 AUDIO_DAI_SET_CHANSPEED(aux_node->dev, speed); in audio_soc_chan_setspeed()
199 sc = ausoc_chan->sc; in audio_soc_chan_getptr()
201 return AUDIO_DAI_GET_PTR(sc->cpu_dev, ausoc_chan->dir); in audio_soc_chan_getptr()
219 ausoc_chan->dir = dir; in audio_soc_chan_init()
220 ausoc_chan->buf = b; in audio_soc_chan_init()
221 ausoc_chan->pcm = c; in audio_soc_chan_init()
234 sc = ausoc_chan->sc; in audio_soc_chan_trigger()
235 AUDIO_DAI_TRIGGER(sc->codec_dev, go, ausoc_chan->dir); in audio_soc_chan_trigger()
236 SLIST_FOREACH(aux_node, &sc->aux_devs, link) { in audio_soc_chan_trigger()
237 AUDIO_DAI_TRIGGER(aux_node->dev, go, ausoc_chan->dir); in audio_soc_chan_trigger()
240 return AUDIO_DAI_TRIGGER(sc->cpu_dev, go, ausoc_chan->dir); in audio_soc_chan_trigger()
252 buffer = sndbuf_getbuf(ausoc_chan->buf); in audio_soc_chan_free()
266 sc = ausoc_chan->sc; in audio_soc_chan_getcaps()
268 return AUDIO_DAI_GET_CAPS(sc->cpu_dev); in audio_soc_chan_getcaps()
291 channel_intr_required = AUDIO_DAI_INTR(sc->cpu_dev, sc->play_channel.buf, sc->rec_channel.buf); in audio_soc_intr()
293 chn_intr(sc->play_channel.pcm); in audio_soc_intr()
295 chn_intr(sc->rec_channel.pcm); in audio_soc_intr()
305 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) { in audio_soc_probe()
306 device_set_desc(dev, "simple-audio-card"); in audio_soc_probe()
325 config_intrhook_disestablish(&sc->init_hook); in audio_soc_init()
327 node = ofw_bus_get_node(sc->dev); in audio_soc_init()
328 /* TODO: handle multi-link nodes */ in audio_soc_init()
329 child = ofw_bus_find_child(node, "simple-audio-card,cpu"); in audio_soc_init()
331 device_printf(sc->dev, "cpu node is missing\n"); in audio_soc_init()
334 if ((OF_getencprop(child, "sound-dai", &xref, sizeof(xref))) <= 0) { in audio_soc_init()
335 device_printf(sc->dev, "missing sound-dai property in cpu node\n"); in audio_soc_init()
340 device_printf(sc->dev, "no driver attached to cpu node\n"); in audio_soc_init()
343 sc->cpu_dev = daidev; in audio_soc_init()
345 child = ofw_bus_find_child(node, "simple-audio-card,codec"); in audio_soc_init()
347 device_printf(sc->dev, "codec node is missing\n"); in audio_soc_init()
350 if ((OF_getencprop(child, "sound-dai", &xref, sizeof(xref))) <= 0) { in audio_soc_init()
351 device_printf(sc->dev, "missing sound-dai property in codec node\n"); in audio_soc_init()
356 device_printf(sc->dev, "no driver attached to codec node\n"); in audio_soc_init()
359 sc->codec_dev = daidev; in audio_soc_init()
363 ncells = OF_getencprop_alloc_multi(node, "simple-audio-card,aux-devs", sizeof(*aux_devs), in audio_soc_init()
369 device_printf(sc->dev, "warning: no driver attached to aux node\n"); in audio_soc_init()
372 device_printf(sc->dev, "failed to allocate aux node struct\n"); in audio_soc_init()
375 aux_node->dev = auxdev; in audio_soc_init()
376 SLIST_INSERT_HEAD(&sc->aux_devs, aux_node, link); in audio_soc_init()
382 if (AUDIO_DAI_INIT(sc->cpu_dev, sc->format)) { in audio_soc_init()
383 device_printf(sc->dev, "failed to initialize cpu node\n"); in audio_soc_init()
388 if (AUDIO_DAI_INIT(sc->codec_dev, audio_soc_reverse_clocks(sc->format))) { in audio_soc_init()
389 device_printf(sc->dev, "failed to initialize codec node\n"); in audio_soc_init()
393 SLIST_FOREACH(aux_node, &sc->aux_devs, link) { in audio_soc_init()
394 if (AUDIO_DAI_INIT(aux_node->dev, audio_soc_reverse_clocks(sc->format))) { in audio_soc_init()
395 device_printf(sc->dev, "failed to initialize aux node\n"); in audio_soc_init()
400 pcm_init(sc->dev, sc); in audio_soc_init()
402 sc->play_channel.sc = sc; in audio_soc_init()
403 sc->rec_channel.sc = sc; in audio_soc_init()
405 pcm_addchan(sc->dev, PCMDIR_PLAY, &audio_soc_chan_class, &sc->play_channel); in audio_soc_init()
406 pcm_addchan(sc->dev, PCMDIR_REC, &audio_soc_chan_class, &sc->rec_channel); in audio_soc_init()
408 if (pcm_register(sc->dev, "at simplebus")) { in audio_soc_init()
409 device_printf(sc->dev, "failed to register PCM\n"); in audio_soc_init()
413 AUDIO_DAI_SETUP_INTR(sc->cpu_dev, audio_soc_intr, sc); in audio_soc_init()
414 AUDIO_DAI_SETUP_MIXER(sc->codec_dev, sc->dev); in audio_soc_init()
415 SLIST_FOREACH(aux_node, &sc->aux_devs, link) { in audio_soc_init()
416 AUDIO_DAI_SETUP_MIXER(aux_node->dev, sc->dev); in audio_soc_init()
433 sc->dev = dev; in audio_soc_attach()
437 if (ret == -1) in audio_soc_attach()
440 sc->name = strdup(name, M_DEVBUF); in audio_soc_attach()
441 device_set_desc(dev, sc->name); in audio_soc_attach()
443 if (ret != -1) in audio_soc_attach()
446 SLIST_INIT(&sc->aux_devs); in audio_soc_attach()
448 ret = OF_getprop(node, "simple-audio-card,format", tmp, sizeof(tmp)); in audio_soc_attach()
461 if (OF_getencprop(node, "simple-audio-card,mclk-fs", in audio_soc_attach()
462 &sc->link_mclk_fs, sizeof(sc->link_mclk_fs)) <= 0) in audio_soc_attach()
463 sc->link_mclk_fs = 0; in audio_soc_attach()
468 cpu_child = ofw_bus_find_child(node, "simple-audio-card,cpu"); in audio_soc_attach()
470 if ((OF_getencprop(node, "simple-audio-card,frame-master", &xref, sizeof(xref))) > 0) in audio_soc_attach()
473 if ((OF_getencprop(node, "simple-audio-card,bitclock-master", &xref, sizeof(xref))) > 0) in audio_soc_attach()
484 bool bitclock_inversion = OF_hasprop(node, "simple-audio-card,bitclock-inversion"); in audio_soc_attach()
485 bool frame_inversion = OF_hasprop(node, "simple-audio-card,frame-inversion"); in audio_soc_attach()
494 sc->format = AUDIO_DAI_FORMAT(fmt, pol, clk); in audio_soc_attach()
496 sc->init_hook.ich_func = audio_soc_init; in audio_soc_attach()
497 sc->init_hook.ich_arg = sc; in audio_soc_attach()
498 if (config_intrhook_establish(&sc->init_hook) != 0) in audio_soc_attach()
511 if (sc->name) in audio_soc_detach()
512 free(sc->name, M_DEVBUF); in audio_soc_detach()
514 while ((aux = SLIST_FIRST(&sc->aux_devs)) != NULL) { in audio_soc_detach()
515 SLIST_REMOVE_HEAD(&sc->aux_devs, link); in audio_soc_detach()