> Date: Fri, 16 Mar 2018 09:00:48 +0100
> From: Alexandre Ratchov <a...@caoua.org>
> 
> The allocm() functions are supposed to allocate memory and it's bad
> style to access the hardware there. The diff moves the DMA base
> pointers setup to the trigger_xxx() routines which start DMA. No
> behavior change.
> 
> OK?

Makes sense; ok kettenis@

> Index: envy.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/envy.c,v
> retrieving revision 1.70
> diff -u -p -u -p -r1.70 envy.c
> --- envy.c    28 Mar 2017 05:23:15 -0000      1.70
> +++ envy.c    15 Mar 2018 09:10:02 -0000
> @@ -1742,17 +1760,11 @@ void *
>  envy_allocm(void *self, int dir, size_t size, int type, int flags)
>  {
>       struct envy_softc *sc = (struct envy_softc *)self;
> -     int err, basereg, wait;
> +     int err, wait;
>       struct envy_buf *buf;
>       bus_addr_t dma_addr;
>  
> -     if (dir == AUMODE_RECORD) {
> -             buf = &sc->ibuf;
> -             basereg = ENVY_MT_RADDR;
> -     } else {
> -             buf = &sc->obuf;
> -             basereg = ENVY_MT_PADDR;
> -     }
> +     buf = (dir == AUMODE_RECORD) ? &sc->ibuf : &sc->obuf;
>       if (buf->addr != NULL) {
>               DPRINTF("%s: multiple alloc, dir = %d\n", DEVNAME(sc), dir);
>               return NULL;
> @@ -1789,7 +1801,6 @@ envy_allocm(void *self, int dir, size_t 
>               printf("%s: DMA address beyond 0x10000000\n", DEVNAME(sc));
>               goto err_unload;
>       }
> -     envy_mt_write_4(sc, basereg, dma_addr);
>       return buf->addr;
>   err_unload:
>       bus_dmamap_unload(sc->pci_dmat, buf->map);
> @@ -2051,6 +2062,7 @@ envy_trigger_output(void *self, void *st
>       }
>  #endif
>       mtx_enter(&audio_lock);
> +     envy_mt_write_4(sc, ENVY_MT_PADDR, sc->obuf.map->dm_segs[0].ds_addr);
>       envy_mt_write_2(sc, ENVY_MT_PBUFSZ, bufsz / 4 - 1);
>       envy_mt_write_2(sc, ENVY_MT_PBLKSZ(sc), blksz / 4 - 1);
>  
> @@ -2097,6 +2109,7 @@ envy_trigger_input(void *self, void *sta
>       }
>  #endif
>       mtx_enter(&audio_lock);
> +     envy_mt_write_4(sc, ENVY_MT_RADDR, sc->ibuf.map->dm_segs[0].ds_addr);
>       envy_mt_write_2(sc, ENVY_MT_RBUFSZ, bufsz / 4 - 1);
>       envy_mt_write_2(sc, ENVY_MT_RBLKSZ, blksz / 4 - 1);
>  
> 
> 

Reply via email to