sound.h revision 64442
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 64442 2000-08-09 01:22:09Z 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
4250724Scg#include <sys/filio.h>
4350724Scg#include <sys/sockio.h>
4450724Scg#include <sys/fcntl.h>
4550724Scg#include <sys/tty.h>
4650724Scg#include <sys/proc.h>
4750724Scg
4850724Scg#include <sys/kernel.h> /* for DATA_SET */
4950724Scg
5063469Scg#if __FreeBSD_version < 500000
5163469Scg#define MODULE_VERSION(mod, ver)
5263469Scg#define MODULE_DEPEND(mod, dep, min, pref, max)
5363469Scg#endif
5463469Scg
5550724Scg#include <sys/module.h>
5650724Scg#include <sys/conf.h>
5750724Scg#include <sys/file.h>
5850724Scg#include <sys/uio.h>
5950724Scg#include <sys/syslog.h>
6050724Scg#include <sys/errno.h>
6150724Scg#include <sys/malloc.h>
6250724Scg#include <sys/bus.h>
6363469Scg#if __FreeBSD_version > 500000
6460041Sphk#include <sys/bio.h>
6563469Scg#endif
6650724Scg#include <sys/buf.h>
6750724Scg#include <machine/clock.h>	/* for DELAY */
6850724Scg#include <machine/resource.h>
6950724Scg#include <machine/bus.h>
7050724Scg#include <sys/rman.h>
7150724Scg#include <sys/mman.h>
7250724Scg#include <sys/poll.h>
7350724Scg#include <sys/soundcard.h>
7450724Scg#include <isa/isavar.h>
7550724Scg#include <vm/vm.h>
7650724Scg#include <vm/pmap.h>
7750724Scg
7850724Scg#else
7950724Scgstruct isa_device { int dummy; };
8050724Scg#define d_open_t void
8150724Scg#define d_close_t void
8250724Scg#define d_read_t void
8350724Scg#define d_write_t void
8450724Scg#define d_ioctl_t void
8550724Scg#define d_select_t void
8655205Speter#endif /* _KERNEL */
8750724Scg
8850724Scg#endif	/* _OS_H_ */
8950724Scg
9053465Scg#include <dev/sound/pcm/datatypes.h>
9153465Scg#include <dev/sound/pcm/channel.h>
9253465Scg#include <dev/sound/pcm/mixer.h>
9353465Scg#include <dev/sound/pcm/dsp.h>
9450724Scg
9564442Scg#ifndef ISADMA_WRITE
9664442Scg#define ISADMA_WRITE B_WRITE
9764442Scg#define ISADMA_READ B_READ
9864442Scg#define ISADMA_RAW B_RAW
9964442Scg#endif
10064442Scg
10162483Scg#define PCM_MODVER	1
10262483Scg
10362483Scg#define PCM_MINVER	1
10462483Scg#define PCM_PREFVER	PCM_MODVER
10562483Scg#define PCM_MAXVER	1
10662483Scg
10750724Scg#define	MAGIC(unit) (0xa4d10de0 + unit)
10850724Scg
10950724Scg#define SD_F_SIMPLEX		0x00000001
11050724Scg#define SD_F_PRIO_RD		0x10000000
11150724Scg#define SD_F_PRIO_WR		0x20000000
11250724Scg#define SD_F_PRIO_SET		(SD_F_PRIO_RD | SD_F_PRIO_WR)
11350724Scg#define SD_F_DIR_SET		0x40000000
11450724Scg#define SD_F_TRANSIENT		0xf0000000
11550724Scg
11650724Scg/* many variables should be reduced to a range. Here define a macro */
11750724Scg#define RANGE(var, low, high) (var) = \
11850724Scg	(((var)<(low))? (low) : ((var)>(high))? (high) : (var))
11955204Scg/*
12055204Scg#define DSP_BUFFSIZE (65536 - 256)
12155204Scg*/
12255204Scg#define DSP_BUFFSIZE (8192)
12350724Scg/* the last 256 bytes are room for buggy soundcard to overflow. */
12450724Scg
12550724Scg/* make figuring out what a format is easier. got AFMT_STEREO already */
12650724Scg#define AFMT_16BIT (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE)
12750724Scg#define AFMT_SIGNED (AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)
12850724Scg#define AFMT_BIGENDIAN (AFMT_S16_BE | AFMT_U16_BE)
12950724Scg
13050724Scgint fkchan_setup(pcm_channel *c);
13150724Scg
13250724Scg/*
13350724Scg * Minor numbers for the sound driver.
13450724Scg *
13550724Scg * Unfortunately Creative called the codec chip of SB as a DSP. For this
13650724Scg * reason the /dev/dsp is reserved for digitized audio use. There is a
13750724Scg * device for true DSP processors but it will be called something else.
13850724Scg * In v3.0 it's /dev/sndproc but this could be a temporary solution.
13950724Scg */
14050724Scg
14150724Scg#define SND_DEV_CTL	0	/* Control port /dev/mixer */
14250724Scg#define SND_DEV_SEQ	1	/* Sequencer /dev/sequencer */
14350724Scg#define SND_DEV_MIDIN	2	/* Raw midi access */
14450724Scg#define SND_DEV_DSP	3	/* Digitized voice /dev/dsp */
14550724Scg#define SND_DEV_AUDIO	4	/* Sparc compatible /dev/audio */
14650724Scg#define SND_DEV_DSP16	5	/* Like /dev/dsp but 16 bits/sample */
14750724Scg#define SND_DEV_STATUS	6	/* /dev/sndstat */
14850724Scg				/* #7 not in use now. */
14950724Scg#define SND_DEV_SEQ2	8	/* /dev/sequencer, level 2 interface */
15050724Scg#define SND_DEV_SNDPROC 9	/* /dev/sndproc for programmable devices */
15150724Scg#define SND_DEV_PSS	SND_DEV_SNDPROC /* ? */
15251769Scg#define SND_DEV_NORESET	10
15350724Scg
15450724Scg#define DSP_DEFAULT_SPEED	8000
15550724Scg
15650724Scg#define ON		1
15750724Scg#define OFF		0
15850724Scg
15955205Speter#ifdef _KERNEL
16050724Scg
16150724Scg/*
16250724Scg * some macros for debugging purposes
16350724Scg * DDB/DEB to enable/disable debugging stuff
16450724Scg * BVDDB   to enable debugging when bootverbose
16550724Scg */
16650724Scg#define DDB(x)	x	/* XXX */
16750724Scg#define BVDDB(x) if (bootverbose) x
16850724Scg
16950724Scg#ifndef DEB
17050724Scg#define DEB(x)
17150724Scg#endif
17250724Scg
17350724Scgint pcm_addchan(device_t dev, int dir, pcm_channel *templ, void *devinfo);
17450724Scgint pcm_register(device_t dev, void *devinfo, int numplay, int numrec);
17550724Scgint pcm_setstatus(device_t dev, char *str);
17650724Scgu_int32_t pcm_getflags(device_t dev);
17750724Scgvoid pcm_setflags(device_t dev, u_int32_t val);
17858384Scgvoid *pcm_getdevinfo(device_t dev);
17954460Scgvoid pcm_setswap(device_t dev, pcm_swap_t *swap);
18050724Scg
18155205Speter#endif /* _KERNEL */
18250724Scg
18350724Scg/* usage of flags in device config entry (config file) */
18450724Scg#define DV_F_DRQ_MASK	0x00000007	/* mask for secondary drq */
18550724Scg#define	DV_F_DUAL_DMA	0x00000010	/* set to use secondary dma channel */
18650724Scg
18750724Scg/* ought to be made obsolete */
18850724Scg#define	DV_F_DEV_MASK	0x0000ff00	/* force device type/class */
18950724Scg#define	DV_F_DEV_SHIFT	8		/* force device type/class */
190