sound.h revision 65486
150724Scg/*
250724Scg * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
350724Scg * Copyright by Hannu Savolainen 1995
450724Scg * All rights reserved.
550724Scg *
650724Scg * Redistribution and use in source and binary forms, with or without
750724Scg * modification, are permitted provided that the following conditions
850724Scg * are met:
950724Scg * 1. Redistributions of source code must retain the above copyright
1050724Scg *    notice, this list of conditions and the following disclaimer.
1150724Scg * 2. Redistributions in binary form must reproduce the above copyright
1250724Scg *    notice, this list of conditions and the following disclaimer in the
1350724Scg *    documentation and/or other materials provided with the distribution.
1450724Scg *
1550724Scg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1650724Scg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1750724Scg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1850724Scg * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1950724Scg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2050724Scg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2150724Scg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2250724Scg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2350724Scg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2450724Scg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2550724Scg * SUCH DAMAGE.
2650724Scg *
2750733Speter * $FreeBSD: head/sys/dev/sound/pcm/sound.h 65486 2000-09-05 20:56:31Z cg $
2850724Scg */
2950724Scg
3050724Scg/*
3150724Scg * first, include kernel header files.
3250724Scg */
3350724Scg
3450724Scg#ifndef _OS_H_
3550724Scg#define _OS_H_
3650724Scg
3755205Speter#ifdef _KERNEL
3850724Scg#include <sys/param.h>
3950724Scg#include <sys/systm.h>
4050724Scg#include <sys/ioccom.h>
4150724Scg#include <sys/filio.h>
4250724Scg#include <sys/sockio.h>
4350724Scg#include <sys/fcntl.h>
4450724Scg#include <sys/tty.h>
4550724Scg#include <sys/proc.h>
4650724Scg#include <sys/kernel.h> /* for DATA_SET */
4750724Scg#include <sys/module.h>
4850724Scg#include <sys/conf.h>
4950724Scg#include <sys/file.h>
5050724Scg#include <sys/uio.h>
5150724Scg#include <sys/syslog.h>
5250724Scg#include <sys/errno.h>
5350724Scg#include <sys/malloc.h>
5450724Scg#include <sys/bus.h>
5563469Scg#if __FreeBSD_version > 500000
5660041Sphk#include <sys/bio.h>
5763469Scg#endif
5850724Scg#include <sys/buf.h>
5950724Scg#include <machine/clock.h>	/* for DELAY */
6050724Scg#include <machine/resource.h>
6150724Scg#include <machine/bus.h>
6250724Scg#include <sys/rman.h>
6350724Scg#include <sys/mman.h>
6450724Scg#include <sys/poll.h>
6550724Scg#include <sys/soundcard.h>
6650724Scg#include <isa/isavar.h>
6750724Scg#include <vm/vm.h>
6850724Scg#include <vm/pmap.h>
6950724Scg
7050724Scg#else
7150724Scgstruct isa_device { int dummy; };
7250724Scg#define d_open_t void
7350724Scg#define d_close_t void
7450724Scg#define d_read_t void
7550724Scg#define d_write_t void
7650724Scg#define d_ioctl_t void
7750724Scg#define d_select_t void
7855205Speter#endif /* _KERNEL */
7950724Scg
8050724Scg#endif	/* _OS_H_ */
8150724Scg
8253465Scg#include <dev/sound/pcm/datatypes.h>
8353465Scg#include <dev/sound/pcm/channel.h>
8464881Scg#include <dev/sound/pcm/feeder.h>
8553465Scg#include <dev/sound/pcm/mixer.h>
8653465Scg#include <dev/sound/pcm/dsp.h>
8750724Scg
8864442Scg#ifndef ISADMA_WRITE
8964442Scg#define ISADMA_WRITE B_WRITE
9064442Scg#define ISADMA_READ B_READ
9164442Scg#define ISADMA_RAW B_RAW
9264442Scg#endif
9364442Scg
9462483Scg#define PCM_MODVER	1
9562483Scg
9662483Scg#define PCM_MINVER	1
9762483Scg#define PCM_PREFVER	PCM_MODVER
9862483Scg#define PCM_MAXVER	1
9962483Scg
10050724Scg#define	MAGIC(unit) (0xa4d10de0 + unit)
10150724Scg
10250724Scg#define SD_F_SIMPLEX		0x00000001
10350724Scg#define SD_F_PRIO_RD		0x10000000
10450724Scg#define SD_F_PRIO_WR		0x20000000
10550724Scg#define SD_F_PRIO_SET		(SD_F_PRIO_RD | SD_F_PRIO_WR)
10650724Scg#define SD_F_DIR_SET		0x40000000
10750724Scg#define SD_F_TRANSIENT		0xf0000000
10850724Scg
10950724Scg/* many variables should be reduced to a range. Here define a macro */
11050724Scg#define RANGE(var, low, high) (var) = \
11150724Scg	(((var)<(low))? (low) : ((var)>(high))? (high) : (var))
11255204Scg#define DSP_BUFFSIZE (8192)
11350724Scg
11450724Scg/* make figuring out what a format is easier. got AFMT_STEREO already */
11565486Scg#define AFMT_32BIT (AFMT_S32_LE | AFMT_S32_BE | AFMT_U32_LE | AFMT_U32_BE)
11650724Scg#define AFMT_16BIT (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE)
11750724Scg#define AFMT_SIGNED (AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)
11850724Scg#define AFMT_BIGENDIAN (AFMT_S16_BE | AFMT_U16_BE)
11950724Scg
12050724Scgint fkchan_setup(pcm_channel *c);
12150724Scg
12250724Scg/*
12350724Scg * Minor numbers for the sound driver.
12450724Scg *
12550724Scg * Unfortunately Creative called the codec chip of SB as a DSP. For this
12650724Scg * reason the /dev/dsp is reserved for digitized audio use. There is a
12750724Scg * device for true DSP processors but it will be called something else.
12850724Scg * In v3.0 it's /dev/sndproc but this could be a temporary solution.
12950724Scg */
13050724Scg
13150724Scg#define SND_DEV_CTL	0	/* Control port /dev/mixer */
13250724Scg#define SND_DEV_SEQ	1	/* Sequencer /dev/sequencer */
13350724Scg#define SND_DEV_MIDIN	2	/* Raw midi access */
13450724Scg#define SND_DEV_DSP	3	/* Digitized voice /dev/dsp */
13550724Scg#define SND_DEV_AUDIO	4	/* Sparc compatible /dev/audio */
13650724Scg#define SND_DEV_DSP16	5	/* Like /dev/dsp but 16 bits/sample */
13750724Scg#define SND_DEV_STATUS	6	/* /dev/sndstat */
13850724Scg				/* #7 not in use now. */
13950724Scg#define SND_DEV_SEQ2	8	/* /dev/sequencer, level 2 interface */
14050724Scg#define SND_DEV_SNDPROC 9	/* /dev/sndproc for programmable devices */
14150724Scg#define SND_DEV_PSS	SND_DEV_SNDPROC /* ? */
14251769Scg#define SND_DEV_NORESET	10
14350724Scg
14450724Scg#define DSP_DEFAULT_SPEED	8000
14550724Scg
14650724Scg#define ON		1
14750724Scg#define OFF		0
14850724Scg
14955205Speter#ifdef _KERNEL
15050724Scg
15150724Scg/*
15250724Scg * some macros for debugging purposes
15350724Scg * DDB/DEB to enable/disable debugging stuff
15450724Scg * BVDDB   to enable debugging when bootverbose
15550724Scg */
15650724Scg#define DDB(x)	x	/* XXX */
15750724Scg#define BVDDB(x) if (bootverbose) x
15850724Scg
15950724Scg#ifndef DEB
16050724Scg#define DEB(x)
16150724Scg#endif
16250724Scg
16350724Scgint pcm_addchan(device_t dev, int dir, pcm_channel *templ, void *devinfo);
16450724Scgint pcm_register(device_t dev, void *devinfo, int numplay, int numrec);
16565340Scgint pcm_unregister(device_t dev);
16650724Scgint pcm_setstatus(device_t dev, char *str);
16750724Scgu_int32_t pcm_getflags(device_t dev);
16850724Scgvoid pcm_setflags(device_t dev, u_int32_t val);
16958384Scgvoid *pcm_getdevinfo(device_t dev);
17054460Scgvoid pcm_setswap(device_t dev, pcm_swap_t *swap);
17150724Scg
17255205Speter#endif /* _KERNEL */
17350724Scg
17450724Scg/* usage of flags in device config entry (config file) */
17550724Scg#define DV_F_DRQ_MASK	0x00000007	/* mask for secondary drq */
17650724Scg#define	DV_F_DUAL_DMA	0x00000010	/* set to use secondary dma channel */
17750724Scg
17850724Scg/* ought to be made obsolete */
17950724Scg#define	DV_F_DEV_MASK	0x0000ff00	/* force device type/class */
18050724Scg#define	DV_F_DEV_SHIFT	8		/* force device type/class */
181