MCPcopy Create free account
hub / github.com/F-Stack/f-stack / a10codec_chan_init

Function a10codec_chan_init

freebsd/arm/allwinner/a10_codec.c:811–869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

809}
810
811static void *
812a10codec_chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b,
813 struct pcm_channel *c, int dir)
814{
815 struct a10codec_info *sc = devinfo;
816 struct a10codec_chinfo *ch = dir == PCMDIR_PLAY ? &sc->play : &sc->rec;
817 phandle_t xref;
818 pcell_t *cells;
819 int ncells, error;
820
821 error = ofw_bus_parse_xref_list_alloc(ofw_bus_get_node(sc->dev),
822 "dmas", "#dma-cells", dir == PCMDIR_PLAY ? 1 : 0,
823 &xref, &ncells, &cells);
824 if (error != 0) {
825 device_printf(sc->dev, "cannot parse 'dmas' property\n");
826 return (NULL);
827 }
828 OF_prop_free(cells);
829
830 ch->parent = sc;
831 ch->channel = c;
832 ch->buffer = b;
833 ch->dir = dir;
834 ch->fifo = rman_get_start(sc->res[0]) +
835 (dir == PCMDIR_REC ? AC_ADC_RXDATA(sc) : AC_DAC_TXDATA(sc));
836
837 ch->dmac = OF_device_from_xref(xref);
838 if (ch->dmac == NULL) {
839 device_printf(sc->dev, "cannot find DMA controller\n");
840 device_printf(sc->dev, "xref = 0x%x\n", (u_int)xref);
841 return (NULL);
842 }
843 ch->dmachan = SUNXI_DMA_ALLOC(ch->dmac, false, a10codec_dmaintr, ch);
844 if (ch->dmachan == NULL) {
845 device_printf(sc->dev, "cannot allocate DMA channel\n");
846 return (NULL);
847 }
848
849 error = bus_dmamem_alloc(sc->dmat, &ch->dmaaddr,
850 BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &ch->dmamap);
851 if (error != 0) {
852 device_printf(sc->dev, "cannot allocate channel buffer\n");
853 return (NULL);
854 }
855 error = bus_dmamap_load(sc->dmat, ch->dmamap, ch->dmaaddr,
856 sc->dmasize, a10codec_dmamap_cb, ch, BUS_DMA_NOWAIT);
857 if (error != 0) {
858 device_printf(sc->dev, "cannot load DMA map\n");
859 return (NULL);
860 }
861 memset(ch->dmaaddr, 0, sc->dmasize);
862
863 if (sndbuf_setup(ch->buffer, ch->dmaaddr, sc->dmasize) != 0) {
864 device_printf(sc->dev, "cannot setup sndbuf\n");
865 return (NULL);
866 }
867
868 return (ch);

Callers

nothing calls this directly

Calls 5

device_printfFunction · 0.85
rman_get_startFunction · 0.85
bus_dmamap_loadFunction · 0.85
memsetFunction · 0.85
bus_dmamem_allocFunction · 0.50

Tested by

no test coverage detected