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 *
| 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 74763 2001-03-24 23:10:29Z cg $
| 27 * $FreeBSD: head/sys/dev/sound/pcm/sound.h 77269 2001-05-27 17:22:00Z cg $
|
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 <sys/sysctl.h> 67#include <isa/isavar.h> 68#include <sys/kobj.h> 69#include <vm/vm.h> 70#include <vm/pmap.h> 71 72#if __FreeBSD_version > 500000 73#define USING_MUTEX 74#define USING_DEVFS 75#endif 76#define SND_DYNSYSCTL 77 78#else 79struct isa_device { int dummy; }; 80#define d_open_t void 81#define d_close_t void 82#define d_read_t void 83#define d_write_t void 84#define d_ioctl_t void 85#define d_select_t void 86#endif /* _KERNEL */ 87 88#endif /* _OS_H_ */ 89 90struct pcm_channel; 91struct pcm_feeder; 92struct snd_dbuf; 93struct snd_mixer; 94 95#include <dev/sound/pcm/buffer.h> 96#include <dev/sound/pcm/channel.h> 97#include <dev/sound/pcm/feeder.h> 98#include <dev/sound/pcm/mixer.h> 99#include <dev/sound/pcm/dsp.h> 100
| 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 <sys/sysctl.h> 67#include <isa/isavar.h> 68#include <sys/kobj.h> 69#include <vm/vm.h> 70#include <vm/pmap.h> 71 72#if __FreeBSD_version > 500000 73#define USING_MUTEX 74#define USING_DEVFS 75#endif 76#define SND_DYNSYSCTL 77 78#else 79struct isa_device { int dummy; }; 80#define d_open_t void 81#define d_close_t void 82#define d_read_t void 83#define d_write_t void 84#define d_ioctl_t void 85#define d_select_t void 86#endif /* _KERNEL */ 87 88#endif /* _OS_H_ */ 89 90struct pcm_channel; 91struct pcm_feeder; 92struct snd_dbuf; 93struct snd_mixer; 94 95#include <dev/sound/pcm/buffer.h> 96#include <dev/sound/pcm/channel.h> 97#include <dev/sound/pcm/feeder.h> 98#include <dev/sound/pcm/mixer.h> 99#include <dev/sound/pcm/dsp.h> 100
|
| 101struct snddev_channel { 102 SLIST_ENTRY(snddev_channel) link; 103 struct pcm_channel *channel; 104}; 105
|
101#define SND_STATUSLEN 64 102/* descriptor of audio device */ 103struct snddev_info {
| 106#define SND_STATUSLEN 64 107/* descriptor of audio device */ 108struct snddev_info {
|
104 struct pcm_channel *play, *rec, **aplay, **arec, *fakechan; 105 int *ref; 106 unsigned playcount, reccount, chancount, maxchans;
| 109 SLIST_HEAD(, snddev_channel) channels; 110 struct pcm_channel **aplay, **arec, *fakechan; 111 unsigned chancount, maxchans;
|
107 struct snd_mixer *mixer; 108 unsigned flags; 109 void *devinfo; 110 device_t dev; 111 char status[SND_STATUSLEN]; 112 struct sysctl_ctx_list sysctl_tree; 113 struct sysctl_oid *sysctl_tree_top; 114 struct mtx mutex; 115}; 116 117#ifndef ISADMA_WRITE 118#define ISADMA_WRITE B_WRITE 119#define ISADMA_READ B_READ 120#define ISADMA_RAW B_RAW 121#endif 122 123#define PCM_MODVER 1 124 125#define PCM_MINVER 1 126#define PCM_PREFVER PCM_MODVER 127#define PCM_MAXVER 1 128 129#define MAGIC(unit) (0xa4d10de0 + unit) 130 131#define SD_F_SIMPLEX 0x00000001 132#define SD_F_PRIO_RD 0x10000000 133#define SD_F_PRIO_WR 0x20000000 134#define SD_F_PRIO_SET (SD_F_PRIO_RD | SD_F_PRIO_WR) 135#define SD_F_DIR_SET 0x40000000 136#define SD_F_TRANSIENT 0xf0000000 137 138/* many variables should be reduced to a range. Here define a macro */ 139#define RANGE(var, low, high) (var) = \ 140 (((var)<(low))? (low) : ((var)>(high))? (high) : (var)) 141#define DSP_BUFFSIZE (8192) 142 143/* make figuring out what a format is easier. got AFMT_STEREO already */ 144#define AFMT_32BIT (AFMT_S32_LE | AFMT_S32_BE | AFMT_U32_LE | AFMT_U32_BE) 145#define AFMT_16BIT (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE) 146#define AFMT_8BIT (AFMT_U8 | AFMT_S8) 147#define AFMT_SIGNED (AFMT_S16_LE | AFMT_S16_BE | AFMT_S8) 148#define AFMT_BIGENDIAN (AFMT_S16_BE | AFMT_U16_BE) 149 150struct pcm_channel *fkchan_setup(device_t dev); 151int fkchan_kill(struct pcm_channel *c); 152 153/* 154 * Minor numbers for the sound driver. 155 * 156 * Unfortunately Creative called the codec chip of SB as a DSP. For this 157 * reason the /dev/dsp is reserved for digitized audio use. There is a 158 * device for true DSP processors but it will be called something else. 159 * In v3.0 it's /dev/sndproc but this could be a temporary solution. 160 */ 161 162#define SND_DEV_CTL 0 /* Control port /dev/mixer */ 163#define SND_DEV_SEQ 1 /* Sequencer /dev/sequencer */ 164#define SND_DEV_MIDIN 2 /* Raw midi access */ 165#define SND_DEV_DSP 3 /* Digitized voice /dev/dsp */ 166#define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */ 167#define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */ 168#define SND_DEV_STATUS 6 /* /dev/sndstat */ 169 /* #7 not in use now. */ 170#define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */ 171#define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */ 172#define SND_DEV_PSS SND_DEV_SNDPROC /* ? */ 173#define SND_DEV_NORESET 10 174 175#define DSP_DEFAULT_SPEED 8000 176 177#define ON 1 178#define OFF 0 179 180#ifdef _KERNEL 181 182/* 183 * some macros for debugging purposes 184 * DDB/DEB to enable/disable debugging stuff 185 * BVDDB to enable debugging when bootverbose 186 */ 187#define DDB(x) x /* XXX */ 188#define BVDDB(x) if (bootverbose) x 189 190#ifndef DEB 191#define DEB(x) 192#endif 193 194SYSCTL_DECL(_hw_snd); 195
| 112 struct snd_mixer *mixer; 113 unsigned flags; 114 void *devinfo; 115 device_t dev; 116 char status[SND_STATUSLEN]; 117 struct sysctl_ctx_list sysctl_tree; 118 struct sysctl_oid *sysctl_tree_top; 119 struct mtx mutex; 120}; 121 122#ifndef ISADMA_WRITE 123#define ISADMA_WRITE B_WRITE 124#define ISADMA_READ B_READ 125#define ISADMA_RAW B_RAW 126#endif 127 128#define PCM_MODVER 1 129 130#define PCM_MINVER 1 131#define PCM_PREFVER PCM_MODVER 132#define PCM_MAXVER 1 133 134#define MAGIC(unit) (0xa4d10de0 + unit) 135 136#define SD_F_SIMPLEX 0x00000001 137#define SD_F_PRIO_RD 0x10000000 138#define SD_F_PRIO_WR 0x20000000 139#define SD_F_PRIO_SET (SD_F_PRIO_RD | SD_F_PRIO_WR) 140#define SD_F_DIR_SET 0x40000000 141#define SD_F_TRANSIENT 0xf0000000 142 143/* many variables should be reduced to a range. Here define a macro */ 144#define RANGE(var, low, high) (var) = \ 145 (((var)<(low))? (low) : ((var)>(high))? (high) : (var)) 146#define DSP_BUFFSIZE (8192) 147 148/* make figuring out what a format is easier. got AFMT_STEREO already */ 149#define AFMT_32BIT (AFMT_S32_LE | AFMT_S32_BE | AFMT_U32_LE | AFMT_U32_BE) 150#define AFMT_16BIT (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE) 151#define AFMT_8BIT (AFMT_U8 | AFMT_S8) 152#define AFMT_SIGNED (AFMT_S16_LE | AFMT_S16_BE | AFMT_S8) 153#define AFMT_BIGENDIAN (AFMT_S16_BE | AFMT_U16_BE) 154 155struct pcm_channel *fkchan_setup(device_t dev); 156int fkchan_kill(struct pcm_channel *c); 157 158/* 159 * Minor numbers for the sound driver. 160 * 161 * Unfortunately Creative called the codec chip of SB as a DSP. For this 162 * reason the /dev/dsp is reserved for digitized audio use. There is a 163 * device for true DSP processors but it will be called something else. 164 * In v3.0 it's /dev/sndproc but this could be a temporary solution. 165 */ 166 167#define SND_DEV_CTL 0 /* Control port /dev/mixer */ 168#define SND_DEV_SEQ 1 /* Sequencer /dev/sequencer */ 169#define SND_DEV_MIDIN 2 /* Raw midi access */ 170#define SND_DEV_DSP 3 /* Digitized voice /dev/dsp */ 171#define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */ 172#define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */ 173#define SND_DEV_STATUS 6 /* /dev/sndstat */ 174 /* #7 not in use now. */ 175#define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */ 176#define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */ 177#define SND_DEV_PSS SND_DEV_SNDPROC /* ? */ 178#define SND_DEV_NORESET 10 179 180#define DSP_DEFAULT_SPEED 8000 181 182#define ON 1 183#define OFF 0 184 185#ifdef _KERNEL 186 187/* 188 * some macros for debugging purposes 189 * DDB/DEB to enable/disable debugging stuff 190 * BVDDB to enable debugging when bootverbose 191 */ 192#define DDB(x) x /* XXX */ 193#define BVDDB(x) if (bootverbose) x 194 195#ifndef DEB 196#define DEB(x) 197#endif 198 199SYSCTL_DECL(_hw_snd); 200
|
| 201struct pcm_channel *pcm_chnalloc(struct snddev_info *d, int direction); 202int pcm_chnfree(struct pcm_channel *c); 203int pcm_chnref(struct pcm_channel *c, int ref); 204 205struct pcm_channel *pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, int dir, void *devinfo); 206int pcm_chn_destroy(struct pcm_channel *ch); 207int pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch); 208int pcm_chn_remove(struct snddev_info *d, struct pcm_channel *ch); 209
|
196int pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo); 197int pcm_register(device_t dev, void *devinfo, int numplay, int numrec); 198int pcm_unregister(device_t dev); 199int pcm_setstatus(device_t dev, char *str); 200u_int32_t pcm_getflags(device_t dev); 201void pcm_setflags(device_t dev, u_int32_t val); 202void *pcm_getdevinfo(device_t dev); 203 204int snd_setup_intr(device_t dev, struct resource *res, int flags, 205 driver_intr_t hand, void *param, void **cookiep); 206 207void *snd_mtxcreate(const char *desc); 208void snd_mtxfree(void *m); 209void snd_mtxassert(void *m); 210void snd_mtxlock(void *m); 211void snd_mtxunlock(void *m); 212 213#endif /* _KERNEL */ 214 215/* usage of flags in device config entry (config file) */ 216#define DV_F_DRQ_MASK 0x00000007 /* mask for secondary drq */ 217#define DV_F_DUAL_DMA 0x00000010 /* set to use secondary dma channel */ 218 219/* ought to be made obsolete */ 220#define DV_F_DEV_MASK 0x0000ff00 /* force device type/class */ 221#define DV_F_DEV_SHIFT 8 /* force device type/class */
| 210int pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo); 211int pcm_register(device_t dev, void *devinfo, int numplay, int numrec); 212int pcm_unregister(device_t dev); 213int pcm_setstatus(device_t dev, char *str); 214u_int32_t pcm_getflags(device_t dev); 215void pcm_setflags(device_t dev, u_int32_t val); 216void *pcm_getdevinfo(device_t dev); 217 218int snd_setup_intr(device_t dev, struct resource *res, int flags, 219 driver_intr_t hand, void *param, void **cookiep); 220 221void *snd_mtxcreate(const char *desc); 222void snd_mtxfree(void *m); 223void snd_mtxassert(void *m); 224void snd_mtxlock(void *m); 225void snd_mtxunlock(void *m); 226 227#endif /* _KERNEL */ 228 229/* usage of flags in device config entry (config file) */ 230#define DV_F_DRQ_MASK 0x00000007 /* mask for secondary drq */ 231#define DV_F_DUAL_DMA 0x00000010 /* set to use secondary dma channel */ 232 233/* ought to be made obsolete */ 234#define DV_F_DEV_MASK 0x0000ff00 /* force device type/class */ 235#define DV_F_DEV_SHIFT 8 /* force device type/class */
|