sound.h revision 55204
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: head/sys/dev/sound/pcm/sound.h 55204 1999-12-29 03:46:54Z cg $
28 */
29
30#ifdef KERNEL
31#include "pcm.h"
32#else
33#error why?
34#define NPCM 1
35#endif
36#if NPCM > 0
37
38/*
39 * first, include kernel header files.
40 */
41
42#ifndef _OS_H_
43#define _OS_H_
44
45#ifdef KERNEL
46#include <sys/param.h>
47#include <sys/systm.h>
48#include <sys/ioccom.h>
49
50#include <sys/filio.h>
51#include <sys/sockio.h>
52#include <sys/fcntl.h>
53#include <sys/tty.h>
54#include <sys/proc.h>
55
56#include <sys/kernel.h> /* for DATA_SET */
57
58#include <sys/module.h>
59#include <sys/conf.h>
60#include <sys/file.h>
61#include <sys/uio.h>
62#include <sys/syslog.h>
63#include <sys/errno.h>
64#include <sys/malloc.h>
65#include <sys/bus.h>
66#include <sys/buf.h>
67#include <machine/clock.h>	/* for DELAY */
68#include <machine/resource.h>
69#include <machine/bus_memio.h>
70#include <machine/bus_pio.h>
71#include <machine/bus.h>
72#include <sys/rman.h>
73#include <sys/mman.h>
74#include <sys/poll.h>
75#include <sys/soundcard.h>
76#include <isa/isavar.h>
77#include <vm/vm.h>
78#include <vm/pmap.h>
79
80#else
81struct isa_device { int dummy; };
82#define d_open_t void
83#define d_close_t void
84#define d_read_t void
85#define d_write_t void
86#define d_ioctl_t void
87#define d_select_t void
88#endif /* KERNEL */
89
90#endif	/* _OS_H_ */
91
92#include <dev/sound/pcm/datatypes.h>
93#include <dev/sound/pcm/channel.h>
94#include <dev/sound/pcm/mixer.h>
95#include <dev/sound/pcm/dsp.h>
96
97#define	MAGIC(unit) (0xa4d10de0 + unit)
98
99#define SD_F_SIMPLEX		0x00000001
100#define SD_F_PRIO_RD		0x10000000
101#define SD_F_PRIO_WR		0x20000000
102#define SD_F_PRIO_SET		(SD_F_PRIO_RD | SD_F_PRIO_WR)
103#define SD_F_DIR_SET		0x40000000
104#define SD_F_TRANSIENT		0xf0000000
105
106/* many variables should be reduced to a range. Here define a macro */
107#define RANGE(var, low, high) (var) = \
108	(((var)<(low))? (low) : ((var)>(high))? (high) : (var))
109/*
110#define DSP_BUFFSIZE (65536 - 256)
111*/
112#define DSP_BUFFSIZE (8192)
113/* the last 256 bytes are room for buggy soundcard to overflow. */
114
115/* make figuring out what a format is easier. got AFMT_STEREO already */
116#define AFMT_16BIT (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE)
117#define AFMT_SIGNED (AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)
118#define AFMT_BIGENDIAN (AFMT_S16_BE | AFMT_U16_BE)
119
120int fkchan_setup(pcm_channel *c);
121
122/*
123 * Minor numbers for the sound driver.
124 *
125 * Unfortunately Creative called the codec chip of SB as a DSP. For this
126 * reason the /dev/dsp is reserved for digitized audio use. There is a
127 * device for true DSP processors but it will be called something else.
128 * In v3.0 it's /dev/sndproc but this could be a temporary solution.
129 */
130
131#define SND_DEV_CTL	0	/* Control port /dev/mixer */
132#define SND_DEV_SEQ	1	/* Sequencer /dev/sequencer */
133#define SND_DEV_MIDIN	2	/* Raw midi access */
134#define SND_DEV_DSP	3	/* Digitized voice /dev/dsp */
135#define SND_DEV_AUDIO	4	/* Sparc compatible /dev/audio */
136#define SND_DEV_DSP16	5	/* Like /dev/dsp but 16 bits/sample */
137#define SND_DEV_STATUS	6	/* /dev/sndstat */
138				/* #7 not in use now. */
139#define SND_DEV_SEQ2	8	/* /dev/sequencer, level 2 interface */
140#define SND_DEV_SNDPROC 9	/* /dev/sndproc for programmable devices */
141#define SND_DEV_PSS	SND_DEV_SNDPROC /* ? */
142#define SND_DEV_NORESET	10
143
144#define DSP_DEFAULT_SPEED	8000
145
146#define ON		1
147#define OFF		0
148
149#ifdef KERNEL
150
151/*
152 * some macros for debugging purposes
153 * DDB/DEB to enable/disable debugging stuff
154 * BVDDB   to enable debugging when bootverbose
155 */
156#define DDB(x)	x	/* XXX */
157#define BVDDB(x) if (bootverbose) x
158
159#ifndef DEB
160#define DEB(x)
161#endif
162
163int pcm_addchan(device_t dev, int dir, pcm_channel *templ, void *devinfo);
164int pcm_register(device_t dev, void *devinfo, int numplay, int numrec);
165int pcm_setstatus(device_t dev, char *str);
166u_int32_t pcm_getflags(device_t dev);
167void pcm_setflags(device_t dev, u_int32_t val);
168void pcm_setswap(device_t dev, pcm_swap_t *swap);
169
170#endif /* KERNEL */
171
172/* usage of flags in device config entry (config file) */
173#define DV_F_DRQ_MASK	0x00000007	/* mask for secondary drq */
174#define	DV_F_DUAL_DMA	0x00000010	/* set to use secondary dma channel */
175
176/* ought to be made obsolete */
177#define	DV_F_DEV_MASK	0x0000ff00	/* force device type/class */
178#define	DV_F_DEV_SHIFT	8		/* force device type/class */
179
180#endif
181