Home | History | Annotate | Line # | Download | only in dev
aucc.c revision 1.18
      1  1.18  augustss /*	$NetBSD: aucc.c,v 1.18 1997/08/24 22:31:23 augustss Exp $	*/
      2   1.1        is #undef AUDIO_DEBUG
      3   1.1        is /*
      4   1.1        is  * Copyright (c) 1997 Stephan Thesing
      5   1.1        is  * All rights reserved.
      6   1.1        is  *
      7   1.1        is  * Redistribution and use in source and binary forms, with or without
      8   1.1        is  * modification, are permitted provided that the following conditions
      9   1.1        is  * are met:
     10   1.1        is  * 1. Redistributions of source code must retain the above copyright
     11   1.1        is  *    notice, this list of conditions and the following disclaimer.
     12   1.1        is  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1        is  *    notice, this list of conditions and the following disclaimer in the
     14   1.1        is  *    documentation and/or other materials provided with the distribution.
     15   1.1        is  * 3. All advertising materials mentioning features or use of this software
     16   1.1        is  *    must display the following acknowledgement:
     17   1.1        is  *      This product includes software developed by Stephan Thesing.
     18   1.1        is  * 4. The name of the author may not be used to endorse or promote products
     19   1.1        is  *    derived from this software without specific prior written permission
     20   1.1        is  *
     21   1.1        is  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22   1.1        is  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23   1.1        is  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24   1.1        is  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25   1.1        is  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26   1.1        is  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27   1.1        is  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28   1.1        is  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29   1.1        is  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30   1.1        is  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31   1.1        is  */
     32   1.1        is 
     33   1.1        is #include "aucc.h"
     34   1.1        is #if NAUCC > 0
     35   1.5        is 
     36   1.1        is #include <sys/param.h>
     37   1.1        is #include <sys/systm.h>
     38   1.1        is #include <sys/errno.h>
     39   1.1        is #include <sys/ioctl.h>
     40   1.1        is #include <sys/device.h>
     41   1.1        is #include <sys/proc.h>
     42   1.1        is #include <machine/cpu.h>
     43   1.1        is 
     44   1.1        is #include <sys/audioio.h>
     45   1.1        is #include <dev/audio_if.h>
     46   1.1        is #include <amiga/amiga/cc.h>
     47   1.1        is #include <amiga/amiga/custom.h>
     48   1.1        is #include <amiga/amiga/device.h>
     49   1.1        is #include <amiga/dev/auccvar.h>
     50   1.1        is 
     51   1.7        is 
     52   1.7        is #ifdef LEV6_DEFER
     53   1.7        is #define AUCC_MAXINT 3
     54   1.7        is #define AUCC_ALLINTF (INTF_AUD0|INTF_AUD1|INTF_AUD2)
     55   1.7        is #else
     56   1.7        is #define AUCC_MAXINT 4
     57   1.7        is #define AUCC_ALLINTF (INTF_AUD0|INTF_AUD1|INTF_AUD2|INTF_AUD3)
     58   1.7        is #endif
     59   1.7        is /* this unconditionally; we may use AUD3 as slave channel with LEV6_DEFER */
     60   1.7        is #define AUCC_ALLDMAF (DMAF_AUD0|DMAF_AUD1|DMAF_AUD2|DMAF_AUD3)
     61   1.7        is 
     62   1.1        is #ifdef AUDIO_DEBUG
     63   1.1        is /*extern printf __P((const char *,...));*/
     64   1.1        is int     auccdebug = 1;
     65   1.1        is #define DPRINTF(x)      if (auccdebug) printf x
     66   1.1        is #else
     67   1.1        is #define DPRINTF(x)
     68   1.1        is #endif
     69   1.1        is 
     70   1.1        is #ifdef splaudio
     71   1.1        is #undef splaudio
     72   1.1        is #endif
     73   1.1        is 
     74   1.1        is #define splaudio() spl4();
     75   1.1        is 
     76   1.1        is /* clock frequency.. */
     77   1.1        is extern int eclockfreq;
     78   1.1        is 
     79   1.1        is 
     80   1.1        is /* hw audio ch */
     81   1.1        is extern struct audio_channel channel[4];
     82   1.1        is 
     83   1.1        is 
     84   1.1        is /*
     85   1.1        is  * Software state.
     86   1.1        is  */
     87   1.1        is struct aucc_softc {
     88   1.1        is 	struct	device sc_dev;		/* base device */
     89   1.1        is 
     90   1.1        is 	int	sc_open;		/* single use device */
     91   1.1        is 	aucc_data_t sc_channel[4];	/* per channel freq, ... */
     92   1.1        is 	u_int	sc_encoding;		/* encoding AUDIO_ENCODING_.*/
     93   1.1        is 	int	sc_channels;		/* # of channels used */
     94   1.1        is 
     95   1.1        is 	int	sc_intrcnt;		/* interrupt count */
     96   1.1        is 	int	sc_channelmask;  	/* which channels are used ? */
     97   1.1        is };
     98   1.1        is 
     99   1.1        is /* interrupt interfaces */
    100   1.1        is void aucc_inthdl __P((int));
    101   1.1        is 
    102   1.1        is /* forward declarations */
    103   1.1        is static int init_aucc __P((struct aucc_softc *));
    104   1.1        is static u_int freqtoper  __P((u_int));
    105   1.1        is static u_int pertofreq  __P((u_int));
    106   1.1        is 
    107   1.1        is /* autoconfiguration driver */
    108   1.1        is void	auccattach __P((struct device *, struct device *, void *));
    109   1.1        is int	auccmatch __P((struct device *, struct cfdata *, void *));
    110   1.1        is 
    111   1.1        is struct cfattach aucc_ca = {
    112   1.1        is 	sizeof(struct aucc_softc),
    113   1.1        is 	auccmatch,
    114   1.1        is 	auccattach
    115   1.1        is };
    116   1.1        is 
    117   1.1        is struct	cfdriver aucc_cd = {
    118   1.1        is 	NULL, "aucc", DV_DULL, NULL, 0
    119   1.1        is };
    120   1.1        is 
    121   1.1        is struct audio_device aucc_device = {
    122   1.1        is 	"Amiga-audio",
    123   1.1        is 	"x",
    124   1.1        is 	"aucc"
    125   1.1        is };
    126   1.1        is 
    127   1.1        is 
    128   1.1        is struct aucc_softc *aucc=NULL;
    129   1.1        is 
    130   1.1        is 
    131   1.1        is unsigned char ulaw_to_lin[] = {
    132   1.2        is 	0x82, 0x86, 0x8a, 0x8e, 0x92, 0x96, 0x9a, 0x9e,
    133   1.2        is 	0xa2, 0xa6, 0xaa, 0xae, 0xb2, 0xb6, 0xba, 0xbe,
    134   1.2        is 	0xc1, 0xc3, 0xc5, 0xc7, 0xc9, 0xcb, 0xcd, 0xcf,
    135   1.2        is 	0xd1, 0xd3, 0xd5, 0xd7, 0xd9, 0xdb, 0xdd, 0xdf,
    136   1.2        is 	0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
    137   1.2        is 	0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0,
    138   1.2        is 	0xf0, 0xf1, 0xf1, 0xf2, 0xf2, 0xf3, 0xf3, 0xf4,
    139   1.2        is 	0xf4, 0xf5, 0xf5, 0xf6, 0xf6, 0xf7, 0xf7, 0xf8,
    140   1.2        is 	0xf8, 0xf8, 0xf9, 0xf9, 0xf9, 0xf9, 0xfa, 0xfa,
    141   1.2        is 	0xfa, 0xfa, 0xfb, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc,
    142   1.2        is 	0xfc, 0xfc, 0xfc, 0xfc, 0xfd, 0xfd, 0xfd, 0xfd,
    143   1.2        is 	0xfd, 0xfd, 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xfe,
    144   1.2        is 	0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
    145   1.2        is 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    146   1.2        is 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
    147   1.2        is 	0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
    148   1.2        is 	0x7d, 0x79, 0x75, 0x71, 0x6d, 0x69, 0x65, 0x61,
    149   1.2        is 	0x5d, 0x59, 0x55, 0x51, 0x4d, 0x49, 0x45, 0x41,
    150   1.2        is 	0x3e, 0x3c, 0x3a, 0x38, 0x36, 0x34, 0x32, 0x30,
    151   1.2        is 	0x2e, 0x2c, 0x2a, 0x28, 0x26, 0x24, 0x22, 0x20,
    152   1.2        is 	0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18, 0x17,
    153   1.2        is 	0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f,
    154   1.2        is 	0x0f, 0x0e, 0x0e, 0x0d, 0x0d, 0x0c, 0x0c, 0x0b,
    155   1.2        is 	0x0b, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x07,
    156   1.2        is 	0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05,
    157   1.2        is 	0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03,
    158   1.2        is 	0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02,
    159   1.2        is 	0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01,
    160   1.2        is 	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
    161   1.2        is 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    162   1.2        is 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    163   1.2        is 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    164   1.1        is };
    165   1.1        is 
    166   1.1        is /*
    167   1.1        is  * Define our interface to the higher level audio driver.
    168   1.1        is  */
    169  1.16  augustss int	aucc_open __P((void *, int));
    170   1.1        is void	aucc_close __P((void *));
    171   1.1        is int	aucc_set_out_sr __P((void *, u_long));
    172   1.1        is int	aucc_query_encoding __P((void *, struct audio_encoding *));
    173   1.1        is int	aucc_round_blocksize __P((void *, int));
    174   1.1        is int	aucc_set_out_port __P((void *, int));
    175   1.1        is int	aucc_get_out_port __P((void *));
    176   1.1        is int	aucc_set_in_port __P((void *, int));
    177   1.1        is int	aucc_get_in_port __P((void *));
    178   1.1        is int	aucc_commit_settings __P((void *));
    179   1.1        is int	aucc_start_output __P((void *, void *, int, void (*)(void *),
    180   1.1        is 				  void *));
    181   1.1        is int	aucc_start_input __P((void *, void *, int, void (*)(void *),
    182   1.1        is 				 void *));
    183   1.1        is int	aucc_halt_output __P((void *));
    184   1.1        is int	aucc_halt_input __P((void *));
    185   1.1        is int	aucc_cont_output __P((void *));
    186   1.1        is int	aucc_cont_input __P((void *));
    187   1.1        is int	aucc_getdev __P((void *, struct audio_device *));
    188   1.1        is int	aucc_set_port __P((void *, mixer_ctrl_t *));
    189   1.1        is int	aucc_get_port __P((void *, mixer_ctrl_t *));
    190   1.1        is int	aucc_query_devinfo __P((void *, mixer_devinfo_t *));
    191   1.8        is void	aucc_encode __P((int, int, int, u_char *, u_short **));
    192  1.18  augustss int	aucc_set_params __P((void *, int, int,
    193  1.18  augustss 	    struct audio_params *, struct audio_params *));
    194  1.16  augustss int	aucc_get_props __P((void *));
    195   1.1        is 
    196   1.1        is struct audio_hw_if sa_hw_if = {
    197   1.1        is 	aucc_open,
    198   1.1        is 	aucc_close,
    199   1.1        is 	NULL,
    200   1.1        is 	aucc_query_encoding,
    201   1.1        is 	aucc_set_params,
    202   1.1        is 	aucc_round_blocksize,
    203   1.1        is 	aucc_set_out_port,
    204   1.1        is 	aucc_get_out_port,
    205   1.1        is 	aucc_set_in_port,
    206   1.1        is 	aucc_get_in_port,
    207   1.1        is 	aucc_commit_settings,
    208  1.14  augustss 	NULL,
    209  1.14  augustss 	NULL,
    210   1.1        is 	aucc_start_output,
    211   1.1        is 	aucc_start_input,
    212   1.1        is 	aucc_halt_output,
    213   1.1        is 	aucc_halt_input,
    214   1.1        is 	aucc_cont_output,
    215   1.1        is 	aucc_cont_input,
    216   1.1        is 	NULL,
    217   1.1        is 	aucc_getdev,
    218  1.13  augustss 	NULL,
    219   1.1        is 	aucc_set_port,
    220   1.1        is 	aucc_get_port,
    221   1.1        is 	aucc_query_devinfo,
    222  1.14  augustss 	NULL,
    223  1.14  augustss 	NULL,
    224  1.14  augustss 	NULL,
    225  1.15  augustss 	NULL,
    226  1.16  augustss 	aucc_get_props,
    227   1.1        is };
    228   1.1        is 
    229   1.1        is /* autoconfig routines */
    230   1.1        is 
    231   1.1        is int
    232   1.1        is auccmatch(pdp, cfp, aux)
    233   1.1        is 	struct device *pdp;
    234   1.1        is 	struct cfdata *cfp;
    235   1.1        is 	void *aux;
    236   1.1        is {
    237   1.1        is 	if (matchname((char *)aux, "aucc") &&
    238   1.1        is #ifdef DRACO
    239   1.1        is 	    !is_draco() &&
    240   1.1        is #endif
    241   1.1        is 	    (cfp->cf_unit == 0))
    242   1.1        is 		return 1;
    243   1.1        is 
    244   1.1        is 	return 0;
    245   1.1        is }
    246   1.1        is 
    247   1.1        is /*
    248   1.1        is  * Audio chip found.
    249   1.1        is  */
    250   1.1        is void
    251   1.1        is auccattach(parent, self, args)
    252   1.1        is 	struct device *parent, *self;
    253   1.1        is 	void *args;
    254   1.1        is {
    255   1.1        is 	register struct aucc_softc *sc = (struct aucc_softc *)self;
    256   1.1        is 	register int i;
    257   1.1        is 
    258   1.1        is 	printf("\n");
    259   1.1        is 
    260   1.1        is 	if((i=init_aucc(sc))) {
    261   1.1        is 		printf("audio: no chipmem\n");
    262   1.1        is 		return;
    263   1.1        is 	}
    264   1.1        is 
    265  1.17  augustss 	audio_attach_mi(&sa_hw_if, 0, sc, &sc->sc_dev);
    266   1.1        is }
    267   1.1        is 
    268   1.1        is 
    269   1.1        is static int
    270   1.1        is init_aucc(sc)
    271   1.1        is 	struct aucc_softc *sc;
    272   1.1        is {
    273   1.1        is 	register int i, err=0;
    274   1.1        is 
    275   1.1        is 	/* init values per channel */
    276   1.1        is  	for (i=0;i<4;i++) {
    277   1.1        is 		sc->sc_channel[i].nd_freq=8000;
    278   1.1        is 		sc->sc_channel[i].nd_per=freqtoper(8000);
    279   1.1        is 		sc->sc_channel[i].nd_busy=0;
    280   1.1        is 		sc->sc_channel[i].nd_dma=alloc_chipmem(AUDIO_BUF_SIZE*2);
    281   1.1        is 		if (sc->sc_channel[i].nd_dma==NULL)
    282   1.1        is 			err=1;
    283   1.1        is 	 	sc->sc_channel[i].nd_dmalength=0;
    284   1.1        is 		sc->sc_channel[i].nd_volume=64;
    285   1.1        is 		sc->sc_channel[i].nd_intr=NULL;
    286   1.1        is 		sc->sc_channel[i].nd_intrdata=NULL;
    287   1.8        is 		sc->sc_channel[i].nd_doublebuf=0;
    288   1.1        is 		DPRINTF(("dma buffer for channel %d is %p\n", i,
    289   1.1        is 		    sc->sc_channel[i].nd_dma));
    290   1.1        is 
    291   1.1        is 	}
    292   1.1        is 
    293   1.1        is 	if (err) {
    294   1.1        is 		for(i=0;i<4;i++)
    295   1.1        is 			if (sc->sc_channel[i].nd_dma)
    296   1.1        is 				free_chipmem(sc->sc_channel[i].nd_dma);
    297   1.1        is 	}
    298   1.1        is 
    299   1.8        is 	sc->sc_channels=1;
    300   1.1        is 	sc->sc_channelmask=0xf;
    301   1.1        is 
    302   1.2        is 	/* clear interrupts and dma: */
    303   1.7        is 	custom.intena = AUCC_ALLINTF;
    304   1.7        is 	custom.dmacon = AUCC_ALLDMAF;;
    305   1.1        is 
    306   1.1        is 	sc->sc_encoding=AUDIO_ENCODING_ULAW;
    307   1.1        is 
    308   1.1        is 	return err;
    309   1.1        is 
    310   1.1        is }
    311   1.1        is 
    312   1.1        is int
    313  1.16  augustss aucc_open(addr, flags)
    314  1.16  augustss 	void *addr;
    315   1.1        is 	int flags;
    316   1.1        is {
    317  1.16  augustss 	struct aucc_softc *sc = addr;
    318  1.16  augustss 	int i;
    319   1.1        is 
    320  1.16  augustss 	DPRINTF(("sa_open: unit %p\n",sc));
    321   1.1        is 
    322   1.1        is 	if (sc->sc_open)
    323   1.1        is 		return (EBUSY);
    324   1.1        is 	sc->sc_open = 1;
    325   1.7        is 	for (i=0;i<AUCC_MAXINT;i++) {
    326   1.1        is 		sc->sc_channel[i].nd_intr=NULL;
    327   1.1        is 		sc->sc_channel[i].nd_intrdata=NULL;
    328   1.1        is 	}
    329   1.1        is 	aucc=sc;
    330   1.1        is 	sc->sc_channelmask=0xf;
    331   1.1        is 
    332   1.1        is 	DPRINTF(("saopen: ok -> sc=0x%p\n",sc));
    333   1.1        is 
    334   1.1        is 	return (0);
    335   1.1        is }
    336   1.1        is 
    337   1.1        is void
    338   1.1        is aucc_close(addr)
    339   1.1        is 	void *addr;
    340   1.1        is {
    341   1.1        is 	register struct aucc_softc *sc = addr;
    342   1.1        is 
    343   1.1        is 	DPRINTF(("sa_close: sc=0x%p\n", sc));
    344   1.1        is 	/*
    345   1.1        is 	 * halt i/o, clear open flag, and done.
    346   1.1        is 	 */
    347   1.1        is 	aucc_halt_output(sc);
    348   1.1        is 	sc->sc_open = 0;
    349   1.1        is 
    350   1.1        is 	DPRINTF(("sa_close: closed.\n"));
    351   1.1        is }
    352   1.1        is 
    353   1.1        is int
    354   1.1        is aucc_set_out_sr(addr, sr)
    355   1.1        is 	void *addr;
    356   1.1        is 	u_long sr;
    357   1.1        is {
    358   1.1        is 	struct aucc_softc *sc=addr;
    359   1.1        is 	u_long per;
    360   1.1        is 	register int i;
    361   1.1        is 
    362   1.1        is 	per=freqtoper(sr);
    363   1.1        is 	if (per>0xffff)
    364   1.1        is 		return EINVAL;
    365   1.1        is 	sr=pertofreq(per);
    366   1.1        is 
    367   1.1        is 	for (i=0;i<4;i++) {
    368   1.1        is 		sc->sc_channel[i].nd_freq=sr;
    369   1.1        is 		sc->sc_channel[i].nd_per=per;
    370   1.1        is 	}
    371   1.1        is 
    372   1.1        is 	return(0);
    373   1.1        is }
    374   1.1        is 
    375   1.1        is int
    376   1.1        is aucc_query_encoding(addr, fp)
    377   1.1        is 	void *addr;
    378   1.1        is 	struct audio_encoding *fp;
    379   1.1        is {
    380   1.1        is 	switch (fp->index) {
    381   1.1        is 	case 0:
    382   1.1        is 		strcpy(fp->name, AudioElinear);
    383  1.11  augustss 		fp->encoding = AUDIO_ENCODING_SLINEAR;
    384   1.1        is 		fp->precision = 8;
    385   1.1        is 		fp->flags = 0;
    386   1.1        is 		break;
    387   1.1        is 	case 1:
    388   1.1        is 		strcpy(fp->name, AudioEmulaw);
    389   1.1        is 		fp->encoding = AUDIO_ENCODING_ULAW;
    390   1.1        is 		fp->precision = 8;
    391   1.1        is 		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
    392   1.1        is 		break;
    393   1.1        is 
    394   1.3        is 	case 2:
    395   1.3        is 		strcpy(fp->name, AudioEulinear);
    396   1.3        is 		fp->encoding = AUDIO_ENCODING_ULINEAR;
    397   1.3        is 		fp->precision = 8;
    398   1.3        is 		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
    399   1.3        is 		break;
    400   1.3        is 
    401   1.1        is 	default:
    402   1.1        is 		return(EINVAL);
    403   1.1        is 		/*NOTREACHED*/
    404   1.1        is 	}
    405   1.1        is 	return(0);
    406   1.1        is }
    407   1.1        is 
    408   1.1        is int
    409  1.18  augustss aucc_set_params(addr, setmode, usemode, p, r)
    410   1.1        is 	void *addr;
    411  1.18  augustss 	int setmode, usemode;
    412  1.18  augustss 	struct  audio_params *p, *r;
    413   1.1        is {
    414  1.18  augustss 	struct aucc_softc *sc = addr;
    415   1.8        is 
    416  1.18  augustss 	/* if (setmode & AUMODE_RECORD)
    417   1.8        is 		return 0 ENXIO*/;
    418   1.8        is 
    419   1.9        is #ifdef AUCCDEBUG
    420  1.18  augustss 	printf("aucc_set_params(setmode 0x%x, usemode 0x%x, enc %d, bits %d, chn %d, sr %ld)\n",
    421  1.18  augustss 	    setmode, usemode, p->encoding, p->precision, p->channels, p->sample_rate);
    422   1.9        is #endif
    423   1.4        is 
    424   1.1        is 	switch (p->encoding) {
    425   1.1        is 	case AUDIO_ENCODING_ULAW:
    426  1.11  augustss 	case AUDIO_ENCODING_SLINEAR:
    427  1.11  augustss 	case AUDIO_ENCODING_SLINEAR_BE:
    428  1.11  augustss 	case AUDIO_ENCODING_SLINEAR_LE:
    429   1.8        is 	case AUDIO_ENCODING_ULINEAR_BE:
    430   1.8        is 	case AUDIO_ENCODING_ULINEAR_LE:
    431   1.1        is 		break;
    432   1.8        is 
    433   1.1        is 	default:
    434   1.1        is 		return EINVAL;
    435   1.1        is 		/* NOTREADCHED */
    436   1.1        is 	}
    437   1.1        is 
    438   1.1        is 	if (p->precision != 8)
    439   1.1        is 		return EINVAL;
    440   1.1        is 
    441   1.1        is 	if ((p->channels<1) || (p->channels>4))
    442   1.1        is 		return(EINVAL);
    443   1.1        is 
    444   1.8        is 	sc->sc_channels = p->channels;
    445   1.8        is 	sc->sc_encoding = p->encoding;
    446   1.8        is 
    447   1.8        is 	return aucc_set_out_sr(addr, p->sample_rate);
    448   1.1        is }
    449   1.1        is 
    450   1.1        is int
    451   1.1        is aucc_round_blocksize(addr, blk)
    452   1.1        is 	void *addr;
    453   1.1        is 	int blk;
    454   1.1        is {
    455   1.1        is 
    456   1.1        is 
    457   1.1        is 	return blk>AUDIO_BUF_SIZE?AUDIO_BUF_SIZE:blk; /* round up to even size */
    458   1.1        is }
    459   1.1        is 
    460   1.1        is int
    461   1.1        is aucc_set_out_port(addr, port) /* can set channels  */
    462   1.1        is 	void *addr;
    463   1.1        is 	int port;
    464   1.1        is {
    465   1.1        is 	register struct aucc_softc *sc = addr;
    466   1.1        is 
    467   1.1        is 	/* port is mask for channels 0..3 */
    468   1.1        is 	if ((port<0)||(port>15))
    469   1.1        is 		return EINVAL;
    470   1.1        is 
    471   1.1        is 	sc->sc_channelmask=port;
    472   1.1        is 
    473   1.1        is 	return(0);
    474   1.1        is }
    475   1.1        is 
    476   1.1        is int
    477   1.1        is aucc_get_out_port(addr)
    478   1.1        is 	void *addr;
    479   1.1        is {
    480   1.1        is 	register struct aucc_softc *sc = addr;
    481   1.1        is 
    482   1.1        is 	return sc->sc_channelmask;
    483   1.1        is }
    484   1.1        is 
    485   1.1        is int
    486   1.1        is aucc_set_in_port(addr, port)
    487   1.1        is 	void *addr;
    488   1.1        is 	int port;
    489   1.1        is {
    490   1.1        is 	return(EINVAL); /* no input possible */
    491   1.1        is 
    492   1.1        is }
    493   1.1        is 
    494   1.1        is int
    495   1.1        is aucc_get_in_port(addr)
    496   1.1        is 	void *addr;
    497   1.1        is {
    498   1.1        is 	return(0);
    499   1.1        is }
    500   1.1        is 
    501   1.1        is int
    502   1.1        is aucc_commit_settings(addr)
    503   1.1        is 	void *addr;
    504   1.1        is {
    505   1.1        is 	register struct aucc_softc *sc = addr;
    506   1.1        is 	register int i;
    507   1.1        is 
    508   1.1        is 	DPRINTF(("sa_commit.\n"));
    509   1.1        is 
    510   1.1        is 	for (i=0;i<4;i++) {
    511   1.1        is 		custom.aud[i].vol=sc->sc_channel[i].nd_volume;
    512   1.1        is 		custom.aud[i].per=sc->sc_channel[i].nd_per;
    513   1.1        is 	}
    514   1.1        is 
    515   1.1        is 	DPRINTF(("commit done\n"));
    516   1.1        is 
    517   1.1        is 	return(0);
    518   1.1        is }
    519   1.1        is 
    520   1.1        is static int masks[4] = {1,3,7,15}; /* masks for n first channels */
    521   1.1        is static int masks2[4] = {1,2,4,8};
    522   1.1        is 
    523   1.1        is int
    524   1.1        is aucc_start_output(addr, p, cc, intr, arg)
    525   1.1        is 	void *addr;
    526   1.1        is 	void *p;
    527   1.1        is 	int cc;
    528   1.1        is 	void (*intr) __P((void *));
    529   1.1        is 	void *arg;
    530   1.1        is {
    531   1.8        is 	struct aucc_softc *sc;
    532   1.8        is 	int mask;
    533   1.8        is 	int i,j,k;
    534   1.8        is 	u_short *dmap[4];
    535   1.8        is 	u_char *pp;
    536   1.8        is 
    537   1.1        is 
    538   1.8        is 	sc = addr;
    539   1.8        is 	mask = sc->sc_channelmask;
    540   1.1        is 
    541   1.8        is 	dmap[0] = dmap[1] = dmap[2] = dmap[3] = NULL;
    542   1.1        is 
    543   1.1        is 	DPRINTF(("sa_start_output: cc=%d %p (%p)\n", cc, intr, arg));
    544   1.1        is 
    545  1.10        is 	if (sc->sc_channels > 1)
    546  1.10        is 		mask &=masks[sc->sc_channels-1];
    547  1.10        is 		/* we use first sc_channels channels */
    548   1.1        is 	if (mask==0) /* active and used channels are disjoint */
    549   1.1        is 		return EINVAL;
    550   1.1        is 
    551   1.1        is 	for (i=0;i<4;i++) { /* channels available ? */
    552   1.1        is 		if ((masks2[i]&mask)&&(sc->sc_channel[i].nd_busy))
    553   1.1        is 			return EBUSY; /* channel is busy */
    554   1.1        is 		if (channel[i].isaudio==-1)
    555   1.1        is 			return EBUSY; /* system uses them */
    556   1.1        is 	}
    557   1.1        is 
    558   1.1        is 	/* enable interrupt on 1st channel */
    559   1.8        is 	for (i=j=0;i<AUCC_MAXINT;i++) {
    560   1.1        is 		if (masks2[i]&mask) {
    561   1.1        is 			DPRINTF(("first channel is %d\n",i));
    562   1.1        is 			j=i;
    563   1.1        is 			sc->sc_channel[i].nd_intr=intr;
    564   1.1        is 			sc->sc_channel[i].nd_intrdata=arg;
    565   1.1        is 			break;
    566   1.1        is 		}
    567   1.1        is 	}
    568   1.1        is 
    569   1.8        is 	DPRINTF(("dmap is %p %p %p %p, mask=0x%x\n", dmap[0], dmap[1],
    570   1.8        is 		dmap[2], dmap[3], mask));
    571   1.8        is 
    572   1.8        is 	/* disable ints, dma for channels, until all parameters set */
    573   1.8        is 	/* XXX dont disable DMA! custom.dmacon=mask;*/
    574   1.8        is 	custom.intreq=mask<<INTB_AUD0;
    575   1.8        is 	custom.intena=mask<<INTB_AUD0;
    576   1.1        is 
    577   1.1        is 	/* copy data to dma buffer */
    578   1.1        is 
    579   1.1        is 
    580   1.1        is 	pp=(u_char *)p;
    581   1.1        is 
    582   1.8        is 	if (sc->sc_channels == 1) {
    583   1.8        is 		dmap[0] =
    584   1.8        is 		dmap[1] =
    585   1.8        is 		dmap[2] =
    586   1.8        is 		dmap[3] = sc->sc_channel[j].nd_dma;
    587   1.8        is 	} else {
    588   1.8        is 		for (k=0; k<4; k++) {
    589   1.8        is 			if (masks2[k+j]&mask)
    590   1.8        is 				dmap[k]=sc->sc_channel[k+j].nd_dma;
    591   1.8        is 		}
    592   1.8        is 	}
    593   1.8        is 
    594   1.8        is 	sc->sc_channel[j].nd_doublebuf ^= 1;
    595   1.8        is 	if (sc->sc_channel[j].nd_doublebuf) {
    596   1.8        is 		dmap[0] += AUDIO_BUF_SIZE/sizeof(u_short);
    597   1.8        is 		dmap[1] += AUDIO_BUF_SIZE/sizeof(u_short);
    598   1.8        is 		dmap[2] += AUDIO_BUF_SIZE/sizeof(u_short);
    599   1.8        is 		dmap[3] += AUDIO_BUF_SIZE/sizeof(u_short);
    600   1.8        is 	}
    601   1.1        is 
    602   1.8        is 	aucc_encode(sc->sc_encoding, sc->sc_channels, cc, pp, dmap);
    603   1.1        is 
    604   1.1        is 	/* dma buffers: we use same buffer 4 all channels */
    605   1.1        is 	/* write dma location and length */
    606   1.8        is 	for (i=k=0; i<4; i++) {
    607   1.8        is 		if (masks2[i] & mask) {
    608   1.1        is 			DPRINTF(("turning channel %d on\n",i));
    609   1.1        is 			/*  sc->sc_channel[i].nd_busy=1;*/
    610   1.1        is 			channel[i].isaudio=1;
    611   1.1        is 			channel[i].play_count=1;
    612   1.1        is 			channel[i].handler=NULL;
    613   1.1        is 			custom.aud[i].per=sc->sc_channel[i].nd_per;
    614   1.1        is 			custom.aud[i].vol=sc->sc_channel[i].nd_volume;
    615   1.8        is 			custom.aud[i].lc = PREP_DMA_MEM(dmap[k++]);
    616   1.9        is 			custom.aud[i].len=cc/(sc->sc_channels*2);
    617   1.1        is 			sc->sc_channel[i].nd_mask=mask;
    618   1.1        is 			DPRINTF(("per is %d, vol is %d, len is %d\n",\
    619   1.8        is 			    sc->sc_channel[i].nd_per,
    620   1.8        is 			    sc->sc_channel[i].nd_volume, cc>>1));
    621   1.1        is 
    622   1.1        is 		}
    623   1.1        is 	}
    624   1.1        is 
    625   1.1        is 	channel[j].handler=aucc_inthdl;
    626   1.1        is 
    627   1.1        is 	/* enable ints */
    628   1.7        is 	custom.intena=INTF_SETCLR|INTF_INTEN| (masks2[j]<<INTB_AUD0);
    629   1.1        is 
    630   1.7        is 	DPRINTF(("enabled ints: 0x%x\n",(masks2[j]<<INTB_AUD0)));
    631   1.1        is 
    632   1.1        is 	/* enable dma */
    633   1.1        is 	custom.dmacon=DMAF_SETCLR|DMAF_MASTER|mask;
    634   1.1        is 
    635   1.1        is 	DPRINTF(("enabled dma, mask=0x%x\n",mask));
    636   1.1        is 
    637   1.1        is 	return(0);
    638   1.1        is }
    639   1.1        is 
    640   1.1        is /* ARGSUSED */
    641   1.1        is int
    642   1.1        is aucc_start_input(addr, p, cc, intr, arg)
    643   1.1        is 	void *addr;
    644   1.1        is 	void *p;
    645   1.1        is 	int cc;
    646   1.1        is 	void (*intr) __P((void *));
    647   1.1        is 	void *arg;
    648   1.1        is {
    649   1.1        is 
    650   1.1        is 	return ENXIO; /* no input */
    651   1.1        is }
    652   1.1        is 
    653   1.1        is int
    654   1.1        is aucc_halt_output(addr)
    655   1.1        is 	void *addr;
    656   1.1        is {
    657   1.1        is 	register struct aucc_softc *sc = addr;
    658   1.1        is 	register int i;
    659   1.1        is 
    660   1.1        is 	/* XXX only halt, if input is also halted ?? */
    661   1.1        is 	/* stop dma, etc */
    662   1.7        is 	custom.intena = AUCC_ALLINTF;
    663   1.7        is 	custom.dmacon = AUCC_ALLDMAF;
    664   1.1        is 	/* mark every busy unit idle */
    665   1.1        is 	for (i=0;i<4;i++) {
    666   1.1        is 		sc->sc_channel[i].nd_busy=sc->sc_channel[i].nd_mask=0;
    667   1.1        is 		channel[i].isaudio=0;
    668   1.1        is 		channel[i].play_count=0;
    669   1.1        is 	}
    670   1.1        is 
    671   1.1        is 	return(0);
    672   1.1        is }
    673   1.1        is 
    674   1.1        is int
    675   1.1        is aucc_halt_input(addr)
    676   1.1        is 	void *addr;
    677   1.1        is {
    678   1.1        is 	/* no input */
    679   1.1        is 
    680   1.1        is 	return ENXIO;
    681   1.1        is }
    682   1.1        is 
    683   1.1        is int
    684   1.1        is aucc_cont_output(addr)
    685   1.1        is 	void *addr;
    686   1.1        is {
    687   1.1        is 	DPRINTF(("aucc_cont_output: never called, what should it do?!\n"));
    688   1.1        is 	/* reenable DMA XXX */
    689   1.1        is 	return ENXIO;
    690   1.1        is }
    691   1.1        is 
    692   1.1        is int
    693   1.1        is aucc_cont_input(addr)
    694   1.1        is 	void *addr;
    695   1.1        is {
    696   1.1        is 	DPRINTF(("aucc_cont_input: never called, what should it do?!\n"));
    697   1.1        is 	return(0);
    698   1.1        is }
    699   1.1        is 
    700   1.1        is int
    701   1.1        is aucc_getdev(addr, retp)
    702   1.1        is         void *addr;
    703   1.1        is         struct audio_device *retp;
    704   1.1        is {
    705   1.1        is         *retp = aucc_device;
    706   1.1        is         return 0;
    707   1.1        is }
    708   1.1        is 
    709   1.1        is int
    710   1.1        is aucc_set_port(addr, cp)
    711   1.1        is 	void *addr;
    712   1.1        is 	mixer_ctrl_t *cp;
    713   1.1        is {
    714   1.1        is 	register struct aucc_softc *sc = addr;
    715   1.1        is 	register int i,j;
    716   1.1        is 
    717   1.1        is 	DPRINTF(("aucc_set_port: port=%d", cp->dev));
    718   1.1        is 
    719   1.1        is 	switch (cp->type) {
    720   1.1        is 	case AUDIO_MIXER_SET:
    721   1.1        is 		if (cp->dev!=AUCC_CHANNELS)
    722   1.1        is 			return EINVAL;
    723   1.1        is 		i=cp->un.mask;
    724   1.1        is 		if ((i<1)||(i>15))
    725   1.1        is 			return EINVAL;
    726   1.1        is 		sc->sc_channelmask=i;
    727   1.1        is 		break;
    728   1.1        is 
    729   1.1        is 	case AUDIO_MIXER_VALUE:
    730   1.1        is 		i=cp->un.value.num_channels;
    731   1.1        is 		if ((i<1)||(i>4))
    732   1.1        is 			return EINVAL;
    733   1.1        is 
    734  1.10        is #ifdef __XXXwhatsthat
    735   1.1        is 		if (cp->dev!=AUCC_VOLUME)
    736   1.1        is 			return EINVAL;
    737  1.10        is #endif
    738   1.1        is 
    739   1.1        is 		/* set volume for channel 0..i-1 */
    740  1.10        is 		if (i>1)
    741  1.10        is 			for (j=0;j<i;j++)
    742  1.10        is 	 			sc->sc_channel[j].nd_volume =
    743  1.10        is 				    cp->un.value.level[j]>>2;
    744  1.10        is 		else if (sc->sc_channels > 1)
    745  1.10        is 			for (j=0; j<sc->sc_channels; j++)
    746  1.10        is 	 			sc->sc_channel[j].nd_volume =
    747  1.10        is 				    cp->un.value.level[0]>>2;
    748  1.10        is 		else
    749  1.10        is 			for (j=0; j<4; j++)
    750  1.10        is 	 			sc->sc_channel[j].nd_volume =
    751  1.10        is 				    cp->un.value.level[0]>>2;
    752  1.10        is 		break;
    753   1.1        is 
    754   1.1        is 	default:
    755   1.1        is 		return EINVAL;
    756   1.1        is 		break;
    757   1.1        is 	}
    758   1.1        is 	return 0;
    759   1.1        is }
    760   1.1        is 
    761   1.1        is 
    762   1.1        is int
    763   1.1        is aucc_get_port(addr, cp)
    764   1.1        is 	void *addr;
    765   1.1        is 	mixer_ctrl_t *cp;
    766   1.1        is {
    767   1.1        is 	register struct aucc_softc *sc = addr;
    768   1.1        is 	register int i,j;
    769   1.1        is 
    770   1.1        is 	DPRINTF(("aucc_get_port: port=%d", cp->dev));
    771   1.1        is 
    772   1.1        is 	switch (cp->type) {
    773   1.1        is 	case AUDIO_MIXER_SET:
    774   1.1        is 		if (cp->dev!=AUCC_CHANNELS)
    775   1.1        is 			return EINVAL;
    776   1.1        is 		cp->un.mask=sc->sc_channelmask;
    777   1.1        is 		break;
    778   1.1        is 
    779   1.1        is 	case AUDIO_MIXER_VALUE:
    780   1.1        is 		i = cp->un.value.num_channels;
    781   1.1        is 		if ((i<1)||(i>4))
    782   1.1        is 			return EINVAL;
    783   1.1        is 
    784   1.1        is 		for (j=0;j<i;j++)
    785  1.10        is 			cp->un.value.level[j] =
    786  1.10        is 			    (sc->sc_channel[j].nd_volume<<2) +
    787  1.10        is 			    (sc->sc_channel[j].nd_volume>>4);
    788   1.1        is 		break;
    789   1.1        is 
    790   1.1        is 	default:
    791   1.1        is 		return EINVAL;
    792   1.1        is 	}
    793   1.1        is 	return 0;
    794   1.1        is }
    795   1.1        is 
    796  1.16  augustss 
    797  1.16  augustss int
    798  1.16  augustss aucc_get_props(addr)
    799  1.16  augustss 	void *addr;
    800  1.16  augustss {
    801  1.16  augustss 	return 0;
    802  1.16  augustss }
    803   1.1        is 
    804   1.1        is int
    805   1.1        is aucc_query_devinfo(addr, dip)
    806   1.1        is 	void *addr;
    807   1.1        is 	register mixer_devinfo_t *dip;
    808   1.1        is {
    809   1.1        is 	register int i;
    810   1.1        is 
    811   1.1        is 	switch(dip->index) {
    812   1.1        is 	case AUCC_CHANNELS:
    813   1.1        is 		dip->type = AUDIO_MIXER_SET;
    814   1.1        is 		dip->mixer_class = AUCC_OUTPUT_CLASS;
    815   1.1        is 		dip->prev = dip->next = AUDIO_MIXER_LAST;
    816   1.1        is                 strcpy(dip->label.name, AudioNspeaker);
    817   1.1        is 		for (i=0;i<16;i++) {
    818   1.1        is 			sprintf(dip->un.s.member[i].label.name,
    819   1.1        is 			    "channelmask%d", i);
    820   1.1        is 			dip->un.s.member[i].mask = i;
    821   1.1        is 		}
    822   1.1        is 		dip->un.s.num_mem = 16;
    823   1.1        is 		break;
    824   1.1        is 
    825   1.1        is 	case AUCC_VOLUME:
    826   1.1        is 		dip->type = AUDIO_MIXER_VALUE;
    827   1.1        is 		dip->mixer_class = AUCC_OUTPUT_CLASS;
    828   1.1        is 		dip->prev = dip->next = AUDIO_MIXER_LAST;
    829   1.1        is 		strcpy(dip->label.name, AudioNspeaker);
    830   1.1        is 		dip->un.v.num_channels = 4;
    831   1.1        is 		strcpy(dip->un.v.units.name, AudioNvolume);
    832   1.1        is 		break;
    833   1.1        is 
    834   1.1        is 	case AUCC_OUTPUT_CLASS:
    835   1.1        is 		dip->type = AUDIO_MIXER_CLASS;
    836   1.1        is 		dip->mixer_class = AUCC_OUTPUT_CLASS;
    837   1.1        is 		dip->next = dip->prev = AUDIO_MIXER_LAST;
    838   1.1        is 		strcpy(dip->label.name, AudioCOutputs);
    839   1.1        is 		break;
    840   1.1        is 	default:
    841   1.1        is 		return ENXIO;
    842   1.1        is 		/*NOTREACHED*/
    843   1.1        is 	}
    844   1.1        is 
    845   1.1        is 	DPRINTF(("AUDIO_MIXER_DEVINFO: name=%s\n", dip->label.name));
    846   1.1        is 
    847   1.1        is 	return(0);
    848   1.1        is }
    849   1.1        is 
    850   1.1        is 
    851   1.1        is /* audio int handler */
    852   1.1        is void
    853   1.1        is aucc_inthdl(int ch)
    854   1.1        is {
    855   1.1        is 	register int i;
    856   1.1        is 	register int mask=aucc->sc_channel[ch].nd_mask;
    857   1.1        is 
    858   1.1        is 	/* for all channels in this maskgroup:
    859   1.1        is 	   disable dma, int
    860   1.1        is 	   mark idle */
    861   1.1        is 	DPRINTF(("inthandler called, channel %d, mask 0x%x\n",ch,mask));
    862   1.1        is 
    863   1.7        is 	custom.intreq=mask<<INTB_AUD0; /* clear request */
    864   1.1        is 	/* XXX: maybe we can leave ints and/or DMA on, if another sample has to be played?*/
    865   1.7        is 	custom.intena=mask<<INTB_AUD0;
    866   1.1        is 	/*
    867   1.1        is 	 * XXX custom.dmacon=mask; NO!!!
    868   1.1        is 	 */
    869   1.1        is 	for (i=0;i<4;i++) {
    870   1.1        is 		if (masks2[i]&&mask) {
    871   1.1        is 			DPRINTF(("marking channel %d idle\n",i));
    872   1.1        is 			aucc->sc_channel[i].nd_busy=0;
    873   1.1        is 			aucc->sc_channel[i].nd_mask=0;
    874   1.1        is 			channel[i].isaudio=channel[i].play_count=0;
    875   1.1        is 		}
    876   1.1        is 	}
    877   1.1        is 
    878   1.1        is 	/* call handler */
    879   1.1        is 	if (aucc->sc_channel[ch].nd_intr) {
    880   1.1        is 		DPRINTF(("calling %p\n",aucc->sc_channel[ch].nd_intr));
    881   1.1        is 		(*(aucc->sc_channel[ch].nd_intr))(aucc->sc_channel[ch].nd_intrdata);
    882   1.1        is 	}
    883   1.1        is 	else DPRINTF(("zero int handler\n"));
    884   1.1        is 	DPRINTF(("ints done\n"));
    885   1.1        is }
    886   1.1        is 
    887   1.1        is 
    888   1.1        is 
    889   1.1        is 
    890   1.1        is /* transform frequency to period, adjust bounds */
    891   1.1        is static u_int
    892   1.1        is freqtoper(u_int freq)
    893   1.1        is {
    894   1.1        is 	u_int per=eclockfreq*5/freq;
    895   1.1        is 
    896   1.1        is 	if (per<124)
    897   1.1        is 		per=124; /* must have at least 124 ticks between samples */
    898   1.1        is 
    899   1.1        is 	return per;
    900   1.1        is }
    901   1.1        is 
    902   1.1        is /* transform period to frequency */
    903   1.1        is static u_int
    904   1.1        is pertofreq(u_int per)
    905   1.1        is {
    906   1.1        is 	u_int freq=eclockfreq*5/per;
    907   1.1        is 
    908   1.1        is 
    909   1.1        is 	return freq;
    910   1.1        is }
    911   1.1        is 
    912   1.1        is 
    913   1.1        is 
    914   1.1        is void
    915   1.8        is aucc_encode(enc, channels, i, p, dmap)
    916   1.8        is 	int enc, channels, i;
    917   1.1        is 	u_char *p;
    918   1.8        is 	u_short **dmap;
    919   1.1        is {
    920   1.8        is 	char *q, *r, *s, *t;
    921   1.8        is 	int off;
    922   1.8        is 	u_char *tab;
    923   1.8        is 
    924   1.9        is #ifdef AUCCDEBUG
    925   1.8        is 	static int debctl = 6;
    926   1.9        is #endif
    927   1.1        is 
    928   1.8        is 	off = 0;
    929   1.8        is 	tab = NULL;
    930   1.1        is 
    931   1.9        is #ifdef AUCCDEBUG
    932   1.8        is 	if (--debctl >= 0)
    933   1.8        is 		printf("Enc: enc %d, chan %d, dmap %p %p %p %p\n",
    934   1.8        is 		    enc, channels, dmap[0], dmap[1], dmap[2], dmap[3]);
    935   1.9        is #endif
    936   1.1        is 
    937   1.1        is 	switch (enc) {
    938   1.1        is 	case AUDIO_ENCODING_ULAW:
    939   1.1        is 		tab=ulaw_to_lin;
    940   1.1        is 		break;
    941   1.8        is 	case AUDIO_ENCODING_ULINEAR_BE:
    942   1.8        is 	case AUDIO_ENCODING_ULINEAR_LE:
    943   1.1        is 		off=-128;
    944   1.8        is 		break;
    945  1.11  augustss 	case AUDIO_ENCODING_SLINEAR_BE:
    946  1.11  augustss 	case AUDIO_ENCODING_SLINEAR_LE:
    947   1.1        is 		break;
    948   1.1        is 	default:
    949   1.1        is 		return;
    950   1.1        is 	}
    951   1.1        is 
    952   1.8        is 	q = (char *)dmap[0];
    953   1.8        is 	r = (char *)dmap[1];
    954   1.8        is 	s = (char *)dmap[2];
    955   1.8        is 	t = (char *)dmap[3];
    956   1.8        is 
    957   1.1        is 	if (tab)
    958   1.9        is 		while (i) {
    959   1.8        is 			switch (channels) {
    960   1.8        is 			case 4: *t++ = tab[*p++];
    961   1.8        is 			case 3: *s++ = tab[*p++];
    962   1.8        is 			case 2: *r++ = tab[*p++];
    963   1.8        is 			case 1: *q++ = tab[*p++];
    964   1.8        is 			}
    965   1.9        is 			i -= channels;
    966   1.8        is 		}
    967   1.1        is 	else
    968   1.9        is 		while (i) {
    969   1.8        is 			switch (channels) {
    970   1.8        is 			case 4: *t++ = *p++ + off;
    971   1.8        is 			case 3: *s++ = *p++ + off;
    972   1.8        is 			case 2: *r++ = *p++ + off;
    973   1.8        is 			case 1: *q++ = *p++ + off;
    974   1.8        is 			}
    975   1.9        is 			i -= channels;
    976   1.8        is 		}
    977   1.1        is 
    978   1.1        is }
    979   1.1        is 
    980   1.1        is #endif /* NAUCC > 0 */
    981