xref: /freebsd/sys/dev/sound/pcm/sound.h (revision 77a0943ded95b9e6438f7db70c4a28e4d93946d4)
1 /*
2  * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
3  * Copyright by Hannu Savolainen 1995
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * $FreeBSD$
28  */
29 
30 /*
31  * first, include kernel header files.
32  */
33 
34 #ifndef _OS_H_
35 #define _OS_H_
36 
37 #ifdef _KERNEL
38 #include <sys/param.h>
39 #include <sys/systm.h>
40 #include <sys/ioccom.h>
41 #include <sys/filio.h>
42 #include <sys/sockio.h>
43 #include <sys/fcntl.h>
44 #include <sys/tty.h>
45 #include <sys/proc.h>
46 #include <sys/kernel.h> /* for DATA_SET */
47 #include <sys/module.h>
48 #include <sys/conf.h>
49 #include <sys/file.h>
50 #include <sys/uio.h>
51 #include <sys/syslog.h>
52 #include <sys/errno.h>
53 #include <sys/malloc.h>
54 #include <sys/bus.h>
55 #if __FreeBSD_version > 500000
56 #include <sys/bio.h>
57 #endif
58 #include <sys/buf.h>
59 #include <machine/clock.h>	/* for DELAY */
60 #include <machine/resource.h>
61 #include <machine/bus.h>
62 #include <sys/rman.h>
63 #include <sys/mman.h>
64 #include <sys/poll.h>
65 #include <sys/soundcard.h>
66 #include <isa/isavar.h>
67 #include <vm/vm.h>
68 #include <vm/pmap.h>
69 
70 #else
71 struct isa_device { int dummy; };
72 #define d_open_t void
73 #define d_close_t void
74 #define d_read_t void
75 #define d_write_t void
76 #define d_ioctl_t void
77 #define d_select_t void
78 #endif /* _KERNEL */
79 
80 #endif	/* _OS_H_ */
81 
82 #include <dev/sound/pcm/datatypes.h>
83 #include <dev/sound/pcm/channel.h>
84 #include <dev/sound/pcm/feeder.h>
85 #include <dev/sound/pcm/mixer.h>
86 #include <dev/sound/pcm/dsp.h>
87 
88 #ifndef ISADMA_WRITE
89 #define ISADMA_WRITE B_WRITE
90 #define ISADMA_READ B_READ
91 #define ISADMA_RAW B_RAW
92 #endif
93 
94 #define PCM_MODVER	1
95 
96 #define PCM_MINVER	1
97 #define PCM_PREFVER	PCM_MODVER
98 #define PCM_MAXVER	1
99 
100 #define	MAGIC(unit) (0xa4d10de0 + unit)
101 
102 #define SD_F_SIMPLEX		0x00000001
103 #define SD_F_PRIO_RD		0x10000000
104 #define SD_F_PRIO_WR		0x20000000
105 #define SD_F_PRIO_SET		(SD_F_PRIO_RD | SD_F_PRIO_WR)
106 #define SD_F_DIR_SET		0x40000000
107 #define SD_F_TRANSIENT		0xf0000000
108 
109 /* many variables should be reduced to a range. Here define a macro */
110 #define RANGE(var, low, high) (var) = \
111 	(((var)<(low))? (low) : ((var)>(high))? (high) : (var))
112 #define DSP_BUFFSIZE (8192)
113 
114 /* make figuring out what a format is easier. got AFMT_STEREO already */
115 #define AFMT_32BIT (AFMT_S32_LE | AFMT_S32_BE | AFMT_U32_LE | AFMT_U32_BE)
116 #define AFMT_16BIT (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE)
117 #define AFMT_8BIT (AFMT_U8 | AFMT_S8)
118 #define AFMT_SIGNED (AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)
119 #define AFMT_BIGENDIAN (AFMT_S16_BE | AFMT_U16_BE)
120 
121 int fkchan_setup(pcm_channel *c);
122 
123 /*
124  * Minor numbers for the sound driver.
125  *
126  * Unfortunately Creative called the codec chip of SB as a DSP. For this
127  * reason the /dev/dsp is reserved for digitized audio use. There is a
128  * device for true DSP processors but it will be called something else.
129  * In v3.0 it's /dev/sndproc but this could be a temporary solution.
130  */
131 
132 #define SND_DEV_CTL	0	/* Control port /dev/mixer */
133 #define SND_DEV_SEQ	1	/* Sequencer /dev/sequencer */
134 #define SND_DEV_MIDIN	2	/* Raw midi access */
135 #define SND_DEV_DSP	3	/* Digitized voice /dev/dsp */
136 #define SND_DEV_AUDIO	4	/* Sparc compatible /dev/audio */
137 #define SND_DEV_DSP16	5	/* Like /dev/dsp but 16 bits/sample */
138 #define SND_DEV_STATUS	6	/* /dev/sndstat */
139 				/* #7 not in use now. */
140 #define SND_DEV_SEQ2	8	/* /dev/sequencer, level 2 interface */
141 #define SND_DEV_SNDPROC 9	/* /dev/sndproc for programmable devices */
142 #define SND_DEV_PSS	SND_DEV_SNDPROC /* ? */
143 #define SND_DEV_NORESET	10
144 
145 #define DSP_DEFAULT_SPEED	8000
146 
147 #define ON		1
148 #define OFF		0
149 
150 #ifdef _KERNEL
151 
152 /*
153  * some macros for debugging purposes
154  * DDB/DEB to enable/disable debugging stuff
155  * BVDDB   to enable debugging when bootverbose
156  */
157 #define DDB(x)	x	/* XXX */
158 #define BVDDB(x) if (bootverbose) x
159 
160 #ifndef DEB
161 #define DEB(x)
162 #endif
163 
164 int pcm_addchan(device_t dev, int dir, pcm_channel *templ, void *devinfo);
165 int pcm_register(device_t dev, void *devinfo, int numplay, int numrec);
166 int pcm_unregister(device_t dev);
167 int pcm_setstatus(device_t dev, char *str);
168 u_int32_t pcm_getflags(device_t dev);
169 void pcm_setflags(device_t dev, u_int32_t val);
170 void *pcm_getdevinfo(device_t dev);
171 void pcm_setswap(device_t dev, pcm_swap_t *swap);
172 
173 #endif /* _KERNEL */
174 
175 /* usage of flags in device config entry (config file) */
176 #define DV_F_DRQ_MASK	0x00000007	/* mask for secondary drq */
177 #define	DV_F_DUAL_DMA	0x00000010	/* set to use secondary dma channel */
178 
179 /* ought to be made obsolete */
180 #define	DV_F_DEV_MASK	0x0000ff00	/* force device type/class */
181 #define	DV_F_DEV_SHIFT	8		/* force device type/class */
182