Module Name: src Committed By: jmcneill Date: Sun Nov 20 13:47:07 UTC 2011
Modified Files: src/sys/arch/arm/xscale [jmcneill-audiomp3]: pxa2x0_ac97.c pxa2x0_dmac.c pxa2x0_dmac.h pxa2x0_i2s.c pxa2x0_i2s.h pxa2x0_mci.c src/sys/arch/zaurus/dev [jmcneill-audiomp3]: zaudio.c Log Message: port zaudio to audiomp api changes for real this time To generate a diff of this commit: cvs rdiff -u -r1.9.4.1 -r1.9.4.2 src/sys/arch/arm/xscale/pxa2x0_ac97.c cvs rdiff -u -r1.8 -r1.8.4.1 src/sys/arch/arm/xscale/pxa2x0_dmac.c cvs rdiff -u -r1.3 -r1.3.84.1 src/sys/arch/arm/xscale/pxa2x0_dmac.h cvs rdiff -u -r1.9 -r1.9.4.1 src/sys/arch/arm/xscale/pxa2x0_i2s.c cvs rdiff -u -r1.2 -r1.2.4.1 src/sys/arch/arm/xscale/pxa2x0_i2s.h cvs rdiff -u -r1.8 -r1.8.6.1 src/sys/arch/arm/xscale/pxa2x0_mci.c cvs rdiff -u -r1.15.4.1 -r1.15.4.2 src/sys/arch/zaurus/dev/zaudio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/xscale/pxa2x0_ac97.c diff -u src/sys/arch/arm/xscale/pxa2x0_ac97.c:1.9.4.1 src/sys/arch/arm/xscale/pxa2x0_ac97.c:1.9.4.2 --- src/sys/arch/arm/xscale/pxa2x0_ac97.c:1.9.4.1 Sun Nov 20 13:13:43 2011 +++ src/sys/arch/arm/xscale/pxa2x0_ac97.c Sun Nov 20 13:47:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pxa2x0_ac97.c,v 1.9.4.1 2011/11/20 13:13:43 mrg Exp $ */ +/* $NetBSD: pxa2x0_ac97.c,v 1.9.4.2 2011/11/20 13:47:07 jmcneill Exp $ */ /* * Copyright (c) 2003, 2005 Wasabi Systems, Inc. @@ -679,28 +679,28 @@ acu_malloc(void *arg, int direction, siz return (NULL); /* XXX */ - if ((ad->ad_dx = pxa2x0_dmac_allocate_xfer(M_NOWAIT)) == NULL) + if ((ad->ad_dx = pxa2x0_dmac_allocate_xfer()) == NULL) goto error; ad->ad_size = size; error = bus_dmamem_alloc(sc->sc_dmat, size, 16, 0, ad->ad_segs, - ACU_N_SEGS, &ad->ad_nsegs, BUS_DMA_NOWAIT); + ACU_N_SEGS, &ad->ad_nsegs, BUS_DMA_WAITOK); if (error) goto free_xfer; error = bus_dmamem_map(sc->sc_dmat, ad->ad_segs, ad->ad_nsegs, size, - &ad->ad_addr, BUS_DMA_NOWAIT | BUS_DMA_COHERENT | BUS_DMA_NOCACHE); + &ad->ad_addr, BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_NOCACHE); if (error) goto free_dmamem; error = bus_dmamap_create(sc->sc_dmat, size, 1, size, 0, - BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &ad->ad_map); + BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW, &ad->ad_map); if (error) goto unmap_dmamem; error = bus_dmamap_load(sc->sc_dmat, ad->ad_map, ad->ad_addr, size, - NULL, BUS_DMA_NOWAIT); + NULL, BUS_DMA_WAITOK); if (error) { bus_dmamap_destroy(sc->sc_dmat, ad->ad_map); unmap_dmamem: bus_dmamem_unmap(sc->sc_dmat, ad->ad_addr, size); Index: src/sys/arch/arm/xscale/pxa2x0_dmac.c diff -u src/sys/arch/arm/xscale/pxa2x0_dmac.c:1.8 src/sys/arch/arm/xscale/pxa2x0_dmac.c:1.8.4.1 --- src/sys/arch/arm/xscale/pxa2x0_dmac.c:1.8 Fri Jul 1 20:32:51 2011 +++ src/sys/arch/arm/xscale/pxa2x0_dmac.c Sun Nov 20 13:47:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pxa2x0_dmac.c,v 1.8 2011/07/01 20:32:51 dyoung Exp $ */ +/* $NetBSD: pxa2x0_dmac.c,v 1.8.4.1 2011/11/20 13:47:07 jmcneill Exp $ */ /* * Copyright (c) 2003, 2005 Wasabi Systems, Inc. @@ -41,7 +41,7 @@ #include <sys/systm.h> #include <sys/device.h> #include <sys/kernel.h> -#include <sys/malloc.h> +#include <sys/kmem.h> #include <sys/queue.h> #include <uvm/uvm_param.h> /* For PAGE_SIZE */ @@ -741,11 +741,11 @@ dmac_dmover_done(struct dmac_xfer *dx, i #endif struct dmac_xfer * -pxa2x0_dmac_allocate_xfer(int flags) +pxa2x0_dmac_allocate_xfer(void) { struct dmac_xfer_state *dxs; - dxs = malloc(sizeof(struct dmac_xfer_state), M_DEVBUF, flags); + dxs = kmem_alloc(sizeof(*dxs), KM_SLEEP); return ((struct dmac_xfer *)dxs); } @@ -753,12 +753,13 @@ pxa2x0_dmac_allocate_xfer(int flags) void pxa2x0_dmac_free_xfer(struct dmac_xfer *dx) { + struct dmac_xfer_state *dxs = (struct dmac_xfer_state *)dx; /* * XXX: Should verify the DMAC is not actively using this * structure before freeing... */ - free(dx, M_DEVBUF); + kmem_free(dxs, sizeof(*dxs)); } static inline int Index: src/sys/arch/arm/xscale/pxa2x0_dmac.h diff -u src/sys/arch/arm/xscale/pxa2x0_dmac.h:1.3 src/sys/arch/arm/xscale/pxa2x0_dmac.h:1.3.84.1 --- src/sys/arch/arm/xscale/pxa2x0_dmac.h:1.3 Wed Feb 21 22:59:39 2007 +++ src/sys/arch/arm/xscale/pxa2x0_dmac.h Sun Nov 20 13:47:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pxa2x0_dmac.h,v 1.3 2007/02/21 22:59:39 thorpej Exp $ */ +/* $NetBSD: pxa2x0_dmac.h,v 1.3.84.1 2011/11/20 13:47:07 jmcneill Exp $ */ /* * Copyright (c) 2003, 2005 Wasabi Systems, Inc. @@ -147,7 +147,7 @@ struct dmac_xfer { #define DMAC_DESC_DST 1 }; -extern struct dmac_xfer *pxa2x0_dmac_allocate_xfer(int); +extern struct dmac_xfer *pxa2x0_dmac_allocate_xfer(void); extern void pxa2x0_dmac_free_xfer(struct dmac_xfer *); extern int pxa2x0_dmac_start_xfer(struct dmac_xfer *); extern void pxa2x0_dmac_abort_xfer(struct dmac_xfer *); Index: src/sys/arch/arm/xscale/pxa2x0_i2s.c diff -u src/sys/arch/arm/xscale/pxa2x0_i2s.c:1.9 src/sys/arch/arm/xscale/pxa2x0_i2s.c:1.9.4.1 --- src/sys/arch/arm/xscale/pxa2x0_i2s.c:1.9 Fri Jul 1 20:32:51 2011 +++ src/sys/arch/arm/xscale/pxa2x0_i2s.c Sun Nov 20 13:47:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pxa2x0_i2s.c,v 1.9 2011/07/01 20:32:51 dyoung Exp $ */ +/* $NetBSD: pxa2x0_i2s.c,v 1.9.4.1 2011/11/20 13:47:07 jmcneill Exp $ */ /* $OpenBSD: pxa2x0_i2s.c,v 1.7 2006/04/04 11:45:40 pascoe Exp $ */ /* @@ -18,13 +18,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pxa2x0_i2s.c,v 1.9 2011/07/01 20:32:51 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pxa2x0_i2s.c,v 1.9.4.1 2011/11/20 13:47:07 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> #include <sys/device.h> -#include <sys/malloc.h> - +#include <sys/kmem.h> #include <sys/bus.h> #include <arm/xscale/pxa2x0reg.h> @@ -67,6 +66,8 @@ pxa2x0_i2s_attach_sub(struct pxa2x0_i2s_ { int rv; + KASSERT(sc->sc_intr_lock != NULL); + rv = bus_space_map(sc->sc_iot, PXA2X0_I2S_BASE, PXA2X0_I2S_SIZE, 0, &sc->sc_ioh); if (rv) { @@ -191,19 +192,18 @@ pxa2x0_i2s_setspeed(struct pxa2x0_i2s_so } void * -pxa2x0_i2s_allocm(void *hdl, int direction, size_t size, - struct malloc_type *type, int flags) +pxa2x0_i2s_allocm(void *hdl, int direction, size_t size) { struct pxa2x0_i2s_softc *sc = hdl; struct pxa2x0_i2s_dma *p; struct dmac_xfer *dx; int error; - p = malloc(sizeof(*p), type, flags); + p = kmem_alloc(sizeof(*p), KM_SLEEP); if (p == NULL) return NULL; - dx = pxa2x0_dmac_allocate_xfer(M_NOWAIT); + dx = pxa2x0_dmac_allocate_xfer(); if (dx == NULL) { goto fail_alloc; } @@ -211,22 +211,22 @@ pxa2x0_i2s_allocm(void *hdl, int directi p->size = size; if ((error = bus_dmamem_alloc(sc->sc_dmat, size, NBPG, 0, p->segs, - I2S_N_SEGS, &p->nsegs, BUS_DMA_NOWAIT)) != 0) { + I2S_N_SEGS, &p->nsegs, BUS_DMA_WAITOK)) != 0) { goto fail_xfer; } if ((error = bus_dmamem_map(sc->sc_dmat, p->segs, p->nsegs, size, - &p->addr, BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) { + &p->addr, BUS_DMA_WAITOK | BUS_DMA_COHERENT)) != 0) { goto fail_map; } if ((error = bus_dmamap_create(sc->sc_dmat, size, 1, size, 0, - BUS_DMA_NOWAIT, &p->map)) != 0) { + BUS_DMA_WAITOK, &p->map)) != 0) { goto fail_create; } if ((error = bus_dmamap_load(sc->sc_dmat, p->map, p->addr, size, NULL, - BUS_DMA_NOWAIT)) != 0) { + BUS_DMA_WAITOK)) != 0) { goto fail_load; } @@ -249,12 +249,12 @@ fail_map: fail_xfer: pxa2x0_dmac_free_xfer(dx); fail_alloc: - free(p, type); + kmem_free(p, sizeof(*p)); return NULL; } void -pxa2x0_i2s_freem(void *hdl, void *ptr, struct malloc_type *type) +pxa2x0_i2s_freem(void *hdl, void *ptr, size_t size) { struct pxa2x0_i2s_softc *sc = hdl; struct pxa2x0_i2s_dma **pp, *p; @@ -270,7 +270,7 @@ pxa2x0_i2s_freem(void *hdl, void *ptr, s bus_dmamem_free(sc->sc_dmat, p->segs, p->nsegs); *pp = p->next; - free(p, type); + kmem_free(p, sizeof(*p)); return; } } @@ -321,14 +321,13 @@ int pxa2x0_i2s_halt_output(void *hdl) { struct pxa2x0_i2s_softc *sc = hdl; - int s; - s = splaudio(); + mutex_spin_enter(sc->sc_intr_lock); if (sc->sc_txdma) { pxa2x0_dmac_abort_xfer(sc->sc_txdma->dx); sc->sc_txdma = NULL; } - splx(s); + mutex_spin_exit(sc->sc_intr_lock); return 0; } @@ -337,14 +336,13 @@ int pxa2x0_i2s_halt_input(void *hdl) { struct pxa2x0_i2s_softc *sc = hdl; - int s; - s = splaudio(); + mutex_spin_enter(sc->sc_intr_lock); if (sc->sc_rxdma) { pxa2x0_dmac_abort_xfer(sc->sc_rxdma->dx); sc->sc_rxdma = NULL; } - splx(s); + mutex_spin_exit(sc->sc_intr_lock); return 0; } @@ -453,7 +451,6 @@ static void pxa2x0_i2s_dmac_ointr(struct dmac_xfer *dx, int status) { struct pxa2x0_i2s_softc *sc = dx->dx_cookie; - int s; if (sc->sc_txdma == NULL) { panic("pxa2x_i2s_dmac_ointr: bad TX DMA descriptor!"); @@ -468,16 +465,15 @@ pxa2x0_i2s_dmac_ointr(struct dmac_xfer * "non-zero completion status %d\n", status); } - s = splaudio(); + mutex_spin_enter(sc->sc_intr_lock); (sc->sc_txfunc)(sc->sc_txarg); - splx(s); + mutex_spin_exit(sc->sc_intr_lock); } static void pxa2x0_i2s_dmac_iintr(struct dmac_xfer *dx, int status) { struct pxa2x0_i2s_softc *sc = dx->dx_cookie; - int s; if (sc->sc_rxdma == NULL) { panic("pxa2x_i2s_dmac_iintr: bad RX DMA descriptor!"); @@ -493,7 +489,7 @@ pxa2x0_i2s_dmac_iintr(struct dmac_xfer * } - s = splaudio(); + mutex_spin_enter(sc->sc_intr_lock); (sc->sc_rxfunc)(sc->sc_rxarg); - splx(s); + mutex_spin_exit(sc->sc_intr_lock); } Index: src/sys/arch/arm/xscale/pxa2x0_i2s.h diff -u src/sys/arch/arm/xscale/pxa2x0_i2s.h:1.2 src/sys/arch/arm/xscale/pxa2x0_i2s.h:1.2.4.1 --- src/sys/arch/arm/xscale/pxa2x0_i2s.h:1.2 Fri Jul 1 20:32:51 2011 +++ src/sys/arch/arm/xscale/pxa2x0_i2s.h Sun Nov 20 13:47:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pxa2x0_i2s.h,v 1.2 2011/07/01 20:32:51 dyoung Exp $ */ +/* $NetBSD: pxa2x0_i2s.h,v 1.2.4.1 2011/11/20 13:47:07 jmcneill Exp $ */ /* $OpenBSD: pxa2x0_i2s.h,v 1.3 2006/04/04 11:45:40 pascoe Exp $ */ /* @@ -27,6 +27,7 @@ struct audio_params; struct pxa2x0_i2s_softc { struct device sc_dev; + kmutex_t *sc_intr_lock; bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; @@ -61,8 +62,8 @@ void pxa2x0_i2s_write(struct pxa2x0_i2s_ void pxa2x0_i2s_setspeed(struct pxa2x0_i2s_softc *, u_int *); -void * pxa2x0_i2s_allocm(void *, int, size_t, struct malloc_type *, int); -void pxa2x0_i2s_freem(void *, void *, struct malloc_type *); +void * pxa2x0_i2s_allocm(void *, int, size_t); +void pxa2x0_i2s_freem(void *, void *, size_t); paddr_t pxa2x0_i2s_mappage(void *, void *, off_t, int); int pxa2x0_i2s_round_blocksize(void *, int, int, const struct audio_params *); size_t pxa2x0_i2s_round_buffersize(void *, int, size_t); Index: src/sys/arch/arm/xscale/pxa2x0_mci.c diff -u src/sys/arch/arm/xscale/pxa2x0_mci.c:1.8 src/sys/arch/arm/xscale/pxa2x0_mci.c:1.8.6.1 --- src/sys/arch/arm/xscale/pxa2x0_mci.c:1.8 Sat Feb 5 15:29:16 2011 +++ src/sys/arch/arm/xscale/pxa2x0_mci.c Sun Nov 20 13:47:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pxa2x0_mci.c,v 1.8 2011/02/05 15:29:16 nonaka Exp $ */ +/* $NetBSD: pxa2x0_mci.c,v 1.8.6.1 2011/11/20 13:47:07 jmcneill Exp $ */ /* $OpenBSD: pxa2x0_mmc.c,v 1.5 2009/02/23 18:09:55 miod Exp $ */ /* @@ -54,7 +54,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pxa2x0_mci.c,v 1.8 2011/02/05 15:29:16 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pxa2x0_mci.c,v 1.8.6.1 2011/11/20 13:47:07 jmcneill Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -253,7 +253,7 @@ pxamci_attach_sub(device_t self, struct sc->sc_rxdr.ds_addr = PXA2X0_MMC_BASE + MMC_RXFIFO; sc->sc_rxdr.ds_len = 1; - sc->sc_rxdx = pxa2x0_dmac_allocate_xfer(M_NOWAIT); + sc->sc_rxdx = pxa2x0_dmac_allocate_xfer(); if (sc->sc_rxdx == NULL) { aprint_error_dev(sc->sc_dev, "couldn't alloc rx dma xfer\n"); @@ -274,7 +274,7 @@ pxamci_attach_sub(device_t self, struct sc->sc_txdr.ds_addr = PXA2X0_MMC_BASE + MMC_TXFIFO; sc->sc_txdr.ds_len = 1; - sc->sc_txdx = pxa2x0_dmac_allocate_xfer(M_NOWAIT); + sc->sc_txdx = pxa2x0_dmac_allocate_xfer(); if (sc->sc_txdx == NULL) { aprint_error_dev(sc->sc_dev, "couldn't alloc tx dma xfer\n"); Index: src/sys/arch/zaurus/dev/zaudio.c diff -u src/sys/arch/zaurus/dev/zaudio.c:1.15.4.1 src/sys/arch/zaurus/dev/zaudio.c:1.15.4.2 --- src/sys/arch/zaurus/dev/zaudio.c:1.15.4.1 Sun Nov 20 13:30:46 2011 +++ src/sys/arch/zaurus/dev/zaudio.c Sun Nov 20 13:47:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: zaudio.c,v 1.15.4.1 2011/11/20 13:30:46 jmcneill Exp $ */ +/* $NetBSD: zaudio.c,v 1.15.4.2 2011/11/20 13:47:07 jmcneill Exp $ */ /* $OpenBSD: zaurus_audio.c,v 1.8 2005/08/18 13:23:02 robert Exp $ */ /* @@ -51,7 +51,7 @@ #include "opt_zaudio.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: zaudio.c,v 1.15.4.1 2011/11/20 13:30:46 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: zaudio.c,v 1.15.4.2 2011/11/20 13:47:07 jmcneill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -215,8 +215,8 @@ static int zaudio_getdev(void *, struct static int zaudio_set_port(void *, struct mixer_ctrl *); static int zaudio_get_port(void *, struct mixer_ctrl *); static int zaudio_query_devinfo(void *, struct mixer_devinfo *); -static void *zaudio_allocm(void *, int, size_t, struct malloc_type *, int); -static void zaudio_freem(void *, void *, struct malloc_type *); +static void *zaudio_allocm(void *, int, size_t); +static void zaudio_freem(void *, void *, size_t); static size_t zaudio_round_buffersize(void *, int, size_t); static paddr_t zaudio_mappage(void *, void *, off_t, int); static int zaudio_get_props(void *); @@ -351,6 +351,7 @@ zaudio_attach(device_t parent, device_t sc->sc_i2s.sc_iot = &pxa2x0_bs_tag; sc->sc_i2s.sc_dmat = &pxa2x0_bus_dma_tag; sc->sc_i2s.sc_size = PXA2X0_I2S_SIZE; + sc->sc_i2s.sc_intr_lock = &sc->sc_intr_lock; if (pxa2x0_i2s_attach_sub(&sc->sc_i2s)) { aprint_error_dev(self, "unable to attach I2S\n"); goto fail_i2s; @@ -894,9 +895,7 @@ zaudio_halt_output(void *hdl) struct zaudio_softc *sc = hdl; int rv; - mutex_spin_enter(&sc->sc_intr_lock); rv = pxa2x0_i2s_halt_output(&sc->sc_i2s); - mutex_spin_exit(&sc->sc_intr_lock); if (!sc->sc_recording) zaudio_standby(sc); sc->sc_playing = 0; @@ -910,9 +909,7 @@ zaudio_halt_input(void *hdl) struct zaudio_softc *sc = hdl; int rv; - mutex_spin_enter(&sc->sc_intr_lock); rv = pxa2x0_i2s_halt_input(&sc->sc_i2s); - mutex_spin_exit(&sc->sc_intr_lock); if (!sc->sc_playing) zaudio_standby(sc); sc->sc_recording = 0; @@ -1227,20 +1224,19 @@ mute: } static void * -zaudio_allocm(void *hdl, int direction, size_t size, struct malloc_type *type, - int flags) +zaudio_allocm(void *hdl, int direction, size_t size) { struct zaudio_softc *sc = hdl; - return pxa2x0_i2s_allocm(&sc->sc_i2s, direction, size, type, flags); + return pxa2x0_i2s_allocm(&sc->sc_i2s, direction, size); } static void -zaudio_freem(void *hdl, void *ptr, struct malloc_type *type) +zaudio_freem(void *hdl, void *ptr, size_t size) { struct zaudio_softc *sc = hdl; - return pxa2x0_i2s_freem(&sc->sc_i2s, ptr, type); + return pxa2x0_i2s_freem(&sc->sc_i2s, ptr, size); } static size_t @@ -1280,10 +1276,7 @@ zaudio_start_output(void *hdl, void *blo } /* Start DMA via I2S */ - mutex_spin_enter(&sc->sc_intr_lock); rv = pxa2x0_i2s_start_output(&sc->sc_i2s, block, bsize, intr, intrarg); - mutex_spin_exit(&sc->sc_intr_lock); - if (rv) { if (!sc->sc_recording) zaudio_standby(sc); @@ -1307,10 +1300,7 @@ zaudio_start_input(void *hdl, void *bloc } /* Start DMA via I2S */ - mutex_spin_enter(&sc->sc_intr_lock); rv = pxa2x0_i2s_start_input(&sc->sc_i2s, block, bsize, intr, intrarg); - mutex_spin_exit(&sc->sc_intr_lock); - if (rv) { if (!sc->sc_playing) zaudio_standby(sc);