sound.h revision 50724
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 * 2750724Scg * $Id$ 2850724Scg */ 2950724Scg 3050724Scg#ifdef KERNEL 3150724Scg#include "pcm.h" 3250724Scg#else 3350724Scg#error why? 3450724Scg#define NPCM 1 3550724Scg#endif 3650724Scg#if NPCM > 0 3750724Scg 3850724Scg/* 3950724Scg * first, include kernel header files. 4050724Scg */ 4150724Scg 4250724Scg#ifndef _OS_H_ 4350724Scg#define _OS_H_ 4450724Scg 4550724Scg#ifdef KERNEL 4650724Scg#include <sys/param.h> 4750724Scg#include <sys/systm.h> 4850724Scg#include <sys/ioccom.h> 4950724Scg 5050724Scg#include <sys/filio.h> 5150724Scg#include <sys/sockio.h> 5250724Scg#include <sys/fcntl.h> 5350724Scg#include <sys/tty.h> 5450724Scg#include <sys/proc.h> 5550724Scg 5650724Scg#include <sys/kernel.h> /* for DATA_SET */ 5750724Scg 5850724Scg#include <sys/module.h> 5950724Scg#include <sys/conf.h> 6050724Scg#include <sys/file.h> 6150724Scg#include <sys/uio.h> 6250724Scg#include <sys/syslog.h> 6350724Scg#include <sys/errno.h> 6450724Scg#include <sys/malloc.h> 6550724Scg#include <sys/bus.h> 6650724Scg#include <sys/buf.h> 6750724Scg#include <machine/clock.h> /* for DELAY */ 6850724Scg#include <machine/resource.h> 6950724Scg#include <machine/bus_memio.h> 7050724Scg#include <machine/bus_pio.h> 7150724Scg#include <machine/bus.h> 7250724Scg#include <sys/rman.h> 7350724Scg#include <sys/mman.h> 7450724Scg#include <sys/poll.h> 7550724Scg#include <sys/soundcard.h> 7650724Scg#include <isa/isavar.h> 7750724Scg#include <vm/vm.h> 7850724Scg#include <vm/pmap.h> 7950724Scg 8050724Scg#else 8150724Scgstruct isa_device { int dummy; }; 8250724Scg#define d_open_t void 8350724Scg#define d_close_t void 8450724Scg#define d_read_t void 8550724Scg#define d_write_t void 8650724Scg#define d_ioctl_t void 8750724Scg#define d_select_t void 8850724Scg#endif /* KERNEL */ 8950724Scg 9050724Scg#endif /* _OS_H_ */ 9150724Scg 9250724Scg#include <dev/pcm/datatypes.h> 9350724Scg#include <dev/pcm/channel.h> 9450724Scg#include <dev/pcm/mixer.h> 9550724Scg#include <dev/pcm/dsp.h> 9650724Scg 9750724Scg#define MAGIC(unit) (0xa4d10de0 + unit) 9850724Scg 9950724Scg#define SD_F_SIMPLEX 0x00000001 10050724Scg#define SD_F_EVILSB16 0x00000002 10150724Scg#define SD_F_PRIO_RD 0x10000000 10250724Scg#define SD_F_PRIO_WR 0x20000000 10350724Scg#define SD_F_PRIO_SET (SD_F_PRIO_RD | SD_F_PRIO_WR) 10450724Scg#define SD_F_DIR_SET 0x40000000 10550724Scg#define SD_F_TRANSIENT 0xf0000000 10650724Scg 10750724Scg/* many variables should be reduced to a range. Here define a macro */ 10850724Scg#define RANGE(var, low, high) (var) = \ 10950724Scg (((var)<(low))? (low) : ((var)>(high))? (high) : (var)) 11050724Scg 11150724Scg#define DSP_BUFFSIZE (65536 - 256) /* XXX */ 11250724Scg/* the last 256 bytes are room for buggy soundcard to overflow. */ 11350724Scg 11450724Scg/* make figuring out what a format is easier. got AFMT_STEREO already */ 11550724Scg#define AFMT_16BIT (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE) 11650724Scg#define AFMT_SIGNED (AFMT_S16_LE | AFMT_S16_BE | AFMT_S8) 11750724Scg#define AFMT_BIGENDIAN (AFMT_S16_BE | AFMT_U16_BE) 11850724Scg 11950724Scgint fkchan_setup(pcm_channel *c); 12050724Scg 12150724Scg#ifdef KERNEL 12250724Scg#include "pnp.h" 12350724Scg#endif /* KERNEL */ 12450724Scg 12550724Scg/* 12650724Scg * Minor numbers for the sound driver. 12750724Scg * 12850724Scg * Unfortunately Creative called the codec chip of SB as a DSP. For this 12950724Scg * reason the /dev/dsp is reserved for digitized audio use. There is a 13050724Scg * device for true DSP processors but it will be called something else. 13150724Scg * In v3.0 it's /dev/sndproc but this could be a temporary solution. 13250724Scg */ 13350724Scg 13450724Scg#define SND_DEV_CTL 0 /* Control port /dev/mixer */ 13550724Scg#define SND_DEV_SEQ 1 /* Sequencer /dev/sequencer */ 13650724Scg#define SND_DEV_MIDIN 2 /* Raw midi access */ 13750724Scg#define SND_DEV_DSP 3 /* Digitized voice /dev/dsp */ 13850724Scg#define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */ 13950724Scg#define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */ 14050724Scg#define SND_DEV_STATUS 6 /* /dev/sndstat */ 14150724Scg /* #7 not in use now. */ 14250724Scg#define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */ 14350724Scg#define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */ 14450724Scg#define SND_DEV_PSS SND_DEV_SNDPROC /* ? */ 14550724Scg 14650724Scg#define DSP_DEFAULT_SPEED 8000 14750724Scg 14850724Scg#define ON 1 14950724Scg#define OFF 0 15050724Scg 15150724Scg#ifdef KERNEL 15250724Scg 15350724Scg/* 15450724Scg * some macros for debugging purposes 15550724Scg * DDB/DEB to enable/disable debugging stuff 15650724Scg * BVDDB to enable debugging when bootverbose 15750724Scg */ 15850724Scg#define DDB(x) x /* XXX */ 15950724Scg#define BVDDB(x) if (bootverbose) x 16050724Scg 16150724Scg#ifndef DEB 16250724Scg#define DEB(x) 16350724Scg#endif 16450724Scg 16550724Scgint pcm_addchan(device_t dev, int dir, pcm_channel *templ, void *devinfo); 16650724Scgint pcm_register(device_t dev, void *devinfo, int numplay, int numrec); 16750724Scgint pcm_setstatus(device_t dev, char *str); 16850724Scgu_int32_t pcm_getflags(device_t dev); 16950724Scgvoid pcm_setflags(device_t dev, u_int32_t val); 17050724Scg 17150724Scg#endif /* KERNEL */ 17250724Scg 17350724Scg/* usage of flags in device config entry (config file) */ 17450724Scg#define DV_F_DRQ_MASK 0x00000007 /* mask for secondary drq */ 17550724Scg#define DV_F_DUAL_DMA 0x00000010 /* set to use secondary dma channel */ 17650724Scg 17750724Scg/* ought to be made obsolete */ 17850724Scg#define DV_F_DEV_MASK 0x0000ff00 /* force device type/class */ 17950724Scg#define DV_F_DEV_SHIFT 8 /* force device type/class */ 18050724Scg 18150724Scg#endif 182