1993-10-23 10:55:52 +00:00
|
|
|
/*
|
|
|
|
* sound/386bsd/soundcard.c
|
1995-07-28 21:40:49 +00:00
|
|
|
*
|
1997-10-31 17:25:35 +00:00
|
|
|
* Soundcard driver for 386BSD.
|
1995-07-28 21:40:49 +00:00
|
|
|
*
|
1993-10-29 03:44:07 +00:00
|
|
|
* Copyright by Hannu Savolainen 1993
|
1997-10-31 17:25:35 +00:00
|
|
|
*
|
1993-10-29 03:44:07 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
1997-10-31 17:25:35 +00:00
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer. 2.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
|
|
|
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
1993-10-29 03:44:07 +00:00
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1997-10-31 17:25:35 +00:00
|
|
|
*
|
1993-10-23 10:55:52 +00:00
|
|
|
*/
|
|
|
|
|
1996-09-10 08:32:01 +00:00
|
|
|
#include <i386/isa/sound/sound_config.h>
|
1997-10-31 17:25:35 +00:00
|
|
|
|
|
|
|
#if NSND > 0 /* from "snd.h" */
|
1995-12-06 23:52:35 +00:00
|
|
|
#include <vm/vm.h>
|
1997-10-31 17:25:35 +00:00
|
|
|
#include <vm/pmap.h>
|
|
|
|
#include <sys/mman.h>
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
#include <i386/isa/isa_device.h>
|
the second set of changes in a move towards getting devices to be
totally dynamic. (the first was about 7 weeeks ago)
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:43:45 +00:00
|
|
|
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
/*
|
|
|
|
** Register definitions for DMA controller 1 (channels 0..3):
|
|
|
|
*/
|
|
|
|
#define DMA1_CHN(c) (IO_DMA1 + 1*(2*(c))) /* addr reg for channel c */
|
|
|
|
#define DMA1_SMSK (IO_DMA1 + 1*10) /* single mask register */
|
|
|
|
#define DMA1_MODE (IO_DMA1 + 1*11) /* mode register */
|
|
|
|
#define DMA1_FFC (IO_DMA1 + 1*12) /* clear first/last FF */
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Register definitions for DMA controller 2 (channels 4..7):
|
|
|
|
*/
|
|
|
|
#define DMA2_CHN(c) (IO_DMA2 + 2*(2*(c))) /* addr reg for channel c */
|
|
|
|
#define DMA2_SMSK (IO_DMA2 + 2*10) /* single mask register */
|
|
|
|
#define DMA2_MODE (IO_DMA2 + 2*11) /* mode register */
|
|
|
|
#define DMA2_FFC (IO_DMA2 + 2*12) /* clear first/last FF */
|
|
|
|
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
#define FIX_RETURN(ret) {if ((ret)<0) return -(ret); else return 0;}
|
|
|
|
|
|
|
|
static int soundcards_installed = 0; /* Number of installed soundcards */
|
1993-10-23 10:55:52 +00:00
|
|
|
static int soundcard_configured = 0;
|
|
|
|
|
|
|
|
static struct fileinfo files[SND_NDEVS];
|
1997-10-31 17:25:35 +00:00
|
|
|
struct selinfo selinfo[SND_NDEVS >> 4];
|
1996-03-28 14:31:42 +00:00
|
|
|
|
1997-11-10 18:31:35 +00:00
|
|
|
int
|
|
|
|
MIDIbuf_poll (int dev, struct fileinfo *file, int events, select_table * wait);
|
|
|
|
|
|
|
|
int
|
|
|
|
audio_poll(int dev, struct fileinfo * file, int events, select_table * wait);
|
|
|
|
|
|
|
|
int
|
|
|
|
sequencer_poll (int dev, struct fileinfo *file, int events, select_table * wait);
|
1996-03-28 14:31:42 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
void sndintr __P((int unit));
|
|
|
|
int sndprobe __P((struct isa_device *));
|
|
|
|
int sndattach __P((struct isa_device *));
|
|
|
|
int sndmmap __P((dev_t dev, int offset, int nprot ));
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
static d_open_t sndopen;
|
|
|
|
static d_close_t sndclose;
|
|
|
|
static d_ioctl_t sndioctl;
|
|
|
|
static d_read_t sndread;
|
|
|
|
static d_write_t sndwrite;
|
|
|
|
static d_poll_t sndpoll;
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
static char driver_name[] = "snd";
|
1995-12-08 11:19:42 +00:00
|
|
|
|
|
|
|
#define CDEV_MAJOR 30
|
1997-10-31 17:25:35 +00:00
|
|
|
static struct cdevsw snd_cdevsw = {
|
|
|
|
sndopen, sndclose, sndread, sndwrite,
|
|
|
|
sndioctl, nxstop, nxreset, nxdevtotty,
|
|
|
|
sndpoll, sndmmap, nxstrategy, driver_name,
|
|
|
|
NULL, -1,
|
|
|
|
};
|
Reorganize how sound devices are configured. Use a snd controller
with individual devices for each type of sound card:
opl, sb, sbxvi, sbmidi, pas, mpu, gus, gusxvi, gusmax, mss, uart
EXCLUDE_* options are no longer required to be included in the config file.
They are automatically determined by local.h depending on the devices
included.
Move #includes in local.h to os.h so files are included in the proper
order to avoid warnings.
soundcard.c now has additional code to reflect the device driver
routines needed.
Define new EXCLUDE_SB16MIDI for use in sb16_midi.c and dev_table.h.
#ifndef EXCLUDE_SEQUENCER or EXCLUDE_AUDIO have been added to
soundcard.c and sound_switch.c where appropriate.
Probe outputs changed to reflect new device names.
Readme.freebsd not needed. Update sound.doc with new config instructions.
Reviewed by: wollman
1995-03-12 23:34:12 +00:00
|
|
|
|
1995-09-01 19:09:11 +00:00
|
|
|
|
1995-07-28 21:40:49 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
|
|
|
|
static void sound_mem_init(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* for each "device XXX" entry in the config file, we have
|
|
|
|
* a struct isa_driver which is linked into isa_devtab_null[]
|
|
|
|
*
|
|
|
|
* XXX It is a bit stupid to call the generic routine so many times and
|
|
|
|
* switch then to the specific one, but the alternative way would be
|
|
|
|
* to replicate some code in the probe/attach routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct isa_driver opldriver = {sndprobe, sndattach, "opl"};
|
|
|
|
struct isa_driver trixdriver = {sndprobe, sndattach, "trix"};
|
|
|
|
struct isa_driver trixsbdriver = {sndprobe, sndattach, "trixsb"};
|
|
|
|
struct isa_driver sbdriver = {sndprobe, sndattach, "sb"};
|
|
|
|
struct isa_driver sbxvidriver = {sndprobe, sndattach, "sbxvi"};
|
|
|
|
struct isa_driver sbmididriver = {sndprobe, sndattach, "sbmidi"};
|
|
|
|
struct isa_driver awedriver = {sndprobe, sndattach, "awe"};
|
|
|
|
struct isa_driver pasdriver = {sndprobe, sndattach, "pas"};
|
|
|
|
struct isa_driver mpudriver = {sndprobe, sndattach, "mpu"};
|
|
|
|
struct isa_driver gusdriver = {sndprobe, sndattach, "gus"};
|
|
|
|
struct isa_driver gusxvidriver = {sndprobe, sndattach, "gusxvi"};
|
|
|
|
struct isa_driver gusmaxdriver = {sndprobe, sndattach, "gusmax"};
|
|
|
|
struct isa_driver uartdriver = {sndprobe, sndattach, "uart"};
|
|
|
|
struct isa_driver mssdriver = {sndprobe, sndattach, "mss"};
|
1997-12-12 14:08:50 +00:00
|
|
|
struct isa_driver cssdriver = {sndprobe, sndattach, "css"};
|
1997-11-10 18:31:35 +00:00
|
|
|
struct isa_driver sscapedriver = {sndprobe, sndattach, "sscape"};
|
|
|
|
struct isa_driver sscape_mssdriver = {sndprobe, sndattach, "sscape_mss"};
|
1997-10-31 17:25:35 +00:00
|
|
|
|
|
|
|
short ipri_to_irq(u_short ipri);
|
|
|
|
|
|
|
|
u_long
|
1994-04-23 04:16:53 +00:00
|
|
|
get_time(void)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
struct timeval timecopy;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
x = splclock();
|
|
|
|
timecopy = time;
|
|
|
|
splx(x);
|
|
|
|
return timecopy.tv_usec / (1000000 / hz) +
|
|
|
|
(u_long) timecopy.tv_sec * hz;
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
int
|
|
|
|
sndmmap( dev_t dev, int offset, int nprot )
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
int unit;
|
|
|
|
struct dma_buffparms * dmap;
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
dev = minor(dev) >> 4;
|
|
|
|
if (dev > 0 ) return (-1);
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
dmap = audio_devs[dev]->dmap_out;
|
|
|
|
|
|
|
|
if (nprot & PROT_EXEC)
|
|
|
|
return( -1 );
|
|
|
|
dmap->mapping_flags |= DMA_MAP_MAPPED ;
|
|
|
|
return( i386_btop(vtophys(dmap->raw_buf) + offset) );
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1997-10-31 17:25:35 +00:00
|
|
|
sndread(dev_t dev, struct uio * buf, int flag)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
int count = buf->uio_resid;
|
|
|
|
|
|
|
|
dev = minor(dev);
|
|
|
|
FIX_RETURN(sound_read_sw(dev, &files[dev], buf, count));
|
|
|
|
}
|
|
|
|
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
static int
|
|
|
|
sndwrite(dev_t dev, struct uio * buf, int flag)
|
|
|
|
{
|
|
|
|
int count = buf->uio_resid;
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
dev = minor(dev);
|
|
|
|
FIX_RETURN(sound_write_sw(dev, &files[dev], buf, count));
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1997-10-31 17:25:35 +00:00
|
|
|
sndopen(dev_t dev, int flags, int mode, struct proc * p)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
int retval;
|
|
|
|
struct fileinfo tmp_file;
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
dev = minor(dev);
|
|
|
|
if (!soundcard_configured && dev) {
|
|
|
|
printf("SoundCard Error: soundcard system has not been configured\n");
|
|
|
|
return ENODEV ;
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
1997-10-31 17:25:35 +00:00
|
|
|
tmp_file.mode = 0;
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
if (flags & FREAD && flags & FWRITE)
|
|
|
|
tmp_file.mode = OPEN_READWRITE;
|
|
|
|
else if (flags & FREAD)
|
|
|
|
tmp_file.mode = OPEN_READ;
|
|
|
|
else if (flags & FWRITE)
|
|
|
|
tmp_file.mode = OPEN_WRITE;
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
selinfo[dev >> 4].si_pid = 0;
|
|
|
|
selinfo[dev >> 4].si_flags = 0;
|
|
|
|
if ((retval = sound_open_sw(dev, &tmp_file)) < 0)
|
|
|
|
FIX_RETURN(retval);
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
bcopy((char *) &tmp_file, (char *) &files[dev], sizeof(tmp_file));
|
1995-03-05 04:01:29 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
FIX_RETURN(retval);
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1997-10-31 17:25:35 +00:00
|
|
|
sndclose(dev_t dev, int flags, int mode, struct proc * p)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
dev = minor(dev);
|
|
|
|
sound_release_sw(dev, &files[dev]);
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
return 0 ;
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
1995-12-08 11:19:42 +00:00
|
|
|
static int
|
1997-10-31 17:25:35 +00:00
|
|
|
sndioctl(dev_t dev, int cmd, caddr_t arg, int mode, struct proc * p)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
dev = minor(dev);
|
|
|
|
FIX_RETURN(sound_ioctl_sw(dev, &files[dev], cmd, arg));
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
int
|
|
|
|
sndpoll(dev_t dev, int events, struct proc * p)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
dev = minor(dev);
|
|
|
|
dev = minor(dev);
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
/* printf ("snd_select(dev=%d, rw=%d, pid=%d)\n", dev, rw, p->p_pid); */
|
1997-11-10 18:31:35 +00:00
|
|
|
#ifdef ALLOW_POLL
|
1997-10-31 17:25:35 +00:00
|
|
|
switch (dev & 0x0f) {
|
1997-11-10 18:31:35 +00:00
|
|
|
#ifdef CONFIG_SEQUENCER
|
1995-07-28 21:40:49 +00:00
|
|
|
case SND_DEV_SEQ:
|
|
|
|
case SND_DEV_SEQ2:
|
1997-10-31 17:25:35 +00:00
|
|
|
return sequencer_poll(dev, &files[dev], events, p);
|
|
|
|
break;
|
1995-07-28 21:40:49 +00:00
|
|
|
#endif
|
|
|
|
|
1997-11-10 18:31:35 +00:00
|
|
|
#ifdef CONFIG_MIDI
|
1995-07-28 21:40:49 +00:00
|
|
|
case SND_DEV_MIDIN:
|
1997-10-31 17:25:35 +00:00
|
|
|
return MIDIbuf_poll(dev, &files[dev], events, p);
|
|
|
|
break;
|
1995-07-28 21:40:49 +00:00
|
|
|
#endif
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
#ifdef CONFIG_AUDIO
|
1995-07-28 21:40:49 +00:00
|
|
|
case SND_DEV_DSP:
|
|
|
|
case SND_DEV_DSP16:
|
|
|
|
case SND_DEV_AUDIO:
|
1997-10-31 17:25:35 +00:00
|
|
|
|
|
|
|
return audio_poll(dev, &files[dev], events, p);
|
|
|
|
break;
|
1995-07-28 21:40:49 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
default:
|
1997-10-31 17:25:35 +00:00
|
|
|
return 0;
|
1995-07-28 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
1997-11-10 18:31:35 +00:00
|
|
|
#endif /* ALLOW_POLL */
|
1997-10-31 17:25:35 +00:00
|
|
|
DEB(printf("sound_ioctl(dev=%d, cmd=0x%x, arg=0x%x)\n", dev, cmd, arg));
|
1995-07-28 21:40:49 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
return 0 ;
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
/* XXX this should become ffs(ipri), perhaps -1 lr 970705 */
|
|
|
|
short
|
|
|
|
ipri_to_irq(u_short ipri)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
/*
|
|
|
|
* Converts the ipri (bitmask) to the corresponding irq number
|
|
|
|
*/
|
|
|
|
int irq;
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
for (irq = 0; irq < 16; irq++)
|
|
|
|
if (ipri == (1 << irq))
|
|
|
|
return irq;
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
return -1; /* Invalid argument */
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
Reorganize how sound devices are configured. Use a snd controller
with individual devices for each type of sound card:
opl, sb, sbxvi, sbmidi, pas, mpu, gus, gusxvi, gusmax, mss, uart
EXCLUDE_* options are no longer required to be included in the config file.
They are automatically determined by local.h depending on the devices
included.
Move #includes in local.h to os.h so files are included in the proper
order to avoid warnings.
soundcard.c now has additional code to reflect the device driver
routines needed.
Define new EXCLUDE_SB16MIDI for use in sb16_midi.c and dev_table.h.
#ifndef EXCLUDE_SEQUENCER or EXCLUDE_AUDIO have been added to
soundcard.c and sound_switch.c where appropriate.
Probe outputs changed to reflect new device names.
Readme.freebsd not needed. Update sound.doc with new config instructions.
Reviewed by: wollman
1995-03-12 23:34:12 +00:00
|
|
|
static int
|
1997-10-31 17:25:35 +00:00
|
|
|
driver_to_voxunit(struct isa_driver * driver)
|
Reorganize how sound devices are configured. Use a snd controller
with individual devices for each type of sound card:
opl, sb, sbxvi, sbmidi, pas, mpu, gus, gusxvi, gusmax, mss, uart
EXCLUDE_* options are no longer required to be included in the config file.
They are automatically determined by local.h depending on the devices
included.
Move #includes in local.h to os.h so files are included in the proper
order to avoid warnings.
soundcard.c now has additional code to reflect the device driver
routines needed.
Define new EXCLUDE_SB16MIDI for use in sb16_midi.c and dev_table.h.
#ifndef EXCLUDE_SEQUENCER or EXCLUDE_AUDIO have been added to
soundcard.c and sound_switch.c where appropriate.
Probe outputs changed to reflect new device names.
Readme.freebsd not needed. Update sound.doc with new config instructions.
Reviewed by: wollman
1995-03-12 23:34:12 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
/*
|
|
|
|
* converts a sound driver pointer into the equivalent VoxWare device
|
|
|
|
* unit number
|
|
|
|
*/
|
|
|
|
if (driver == &opldriver)
|
|
|
|
return (SNDCARD_ADLIB);
|
|
|
|
else if (driver == &sbdriver)
|
|
|
|
return (SNDCARD_SB);
|
|
|
|
else if (driver == &pasdriver)
|
|
|
|
return (SNDCARD_PAS);
|
|
|
|
else if (driver == &gusdriver)
|
|
|
|
return (SNDCARD_GUS);
|
|
|
|
else if (driver == &mpudriver)
|
|
|
|
return (SNDCARD_MPU401);
|
|
|
|
else if (driver == &sbxvidriver)
|
|
|
|
return (SNDCARD_SB16);
|
|
|
|
else if (driver == &sbmididriver)
|
|
|
|
return (SNDCARD_SB16MIDI);
|
|
|
|
else if(driver == &awedriver)
|
|
|
|
return(SNDCARD_AWE32);
|
|
|
|
else if (driver == &uartdriver)
|
|
|
|
return (SNDCARD_UART6850);
|
|
|
|
else if (driver == &gusdriver)
|
|
|
|
return (SNDCARD_GUS16);
|
|
|
|
else if (driver == &mssdriver)
|
|
|
|
return (SNDCARD_MSS);
|
1997-12-12 14:08:50 +00:00
|
|
|
else if (driver == &cssdriver)
|
|
|
|
return (SNDCARD_CS4232);
|
1997-11-10 18:31:35 +00:00
|
|
|
else if (driver == &sscapedriver)
|
|
|
|
return(SNDCARD_SSCAPE);
|
|
|
|
else if (driver == &sscape_mssdriver)
|
|
|
|
return(SNDCARD_SSCAPE_MSS);
|
1997-10-31 17:25:35 +00:00
|
|
|
else if (driver == &trixdriver)
|
|
|
|
return (SNDCARD_TRXPRO);
|
|
|
|
else if (driver == &trixsbdriver)
|
|
|
|
return (SNDCARD_TRXPRO_SB);
|
|
|
|
else
|
|
|
|
return (0);
|
Reorganize how sound devices are configured. Use a snd controller
with individual devices for each type of sound card:
opl, sb, sbxvi, sbmidi, pas, mpu, gus, gusxvi, gusmax, mss, uart
EXCLUDE_* options are no longer required to be included in the config file.
They are automatically determined by local.h depending on the devices
included.
Move #includes in local.h to os.h so files are included in the proper
order to avoid warnings.
soundcard.c now has additional code to reflect the device driver
routines needed.
Define new EXCLUDE_SB16MIDI for use in sb16_midi.c and dev_table.h.
#ifndef EXCLUDE_SEQUENCER or EXCLUDE_AUDIO have been added to
soundcard.c and sound_switch.c where appropriate.
Probe outputs changed to reflect new device names.
Readme.freebsd not needed. Update sound.doc with new config instructions.
Reviewed by: wollman
1995-03-12 23:34:12 +00:00
|
|
|
}
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
/*
|
|
|
|
* very dirty: tmp_osp is allocated in sndprobe, and used at the next
|
|
|
|
* call in sndattach
|
|
|
|
*/
|
|
|
|
|
|
|
|
static sound_os_info *temp_osp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sndprobe is called for each isa_device. From here, a voxware unit
|
|
|
|
* number is determined, and the appropriate probe routine is selected.
|
|
|
|
* The parameters from the config line are passed to the hw_config struct.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
sndprobe(struct isa_device * dev)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
struct address_info hw_config;
|
|
|
|
int unit;
|
|
|
|
|
|
|
|
temp_osp = (sound_os_info *)malloc(sizeof(sound_os_info),
|
|
|
|
M_DEVBUF, M_NOWAIT);
|
|
|
|
if (!temp_osp)
|
|
|
|
panic("SOUND: Cannot allocate memory\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get config info from the kernel config. These may be overridden
|
|
|
|
* by the local autoconfiguration routines though (e.g. pnp stuff).
|
|
|
|
*/
|
|
|
|
|
|
|
|
hw_config.io_base = dev->id_iobase;
|
|
|
|
hw_config.irq = ipri_to_irq(dev->id_irq);
|
|
|
|
hw_config.dma = dev->id_drq;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* misuse the flags field for read dma. Note that, to use 0 as
|
|
|
|
* read dma channel, one of the high bits should be set. lr970705 XXX
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (dev->id_flags != 0)
|
|
|
|
hw_config.dma2 = dev->id_flags & 0x7;
|
|
|
|
else
|
|
|
|
hw_config.dma2 = -1;
|
|
|
|
|
|
|
|
hw_config.always_detect = 0;
|
|
|
|
hw_config.name = NULL;
|
|
|
|
hw_config.card_subtype = 0;
|
|
|
|
|
|
|
|
temp_osp->unit = dev->id_unit;
|
|
|
|
hw_config.osp = temp_osp;
|
|
|
|
unit = driver_to_voxunit(dev->id_driver);
|
|
|
|
|
|
|
|
if (sndtable_probe(unit, &hw_config)) {
|
|
|
|
dev->id_iobase = hw_config.io_base;
|
|
|
|
dev->id_irq = hw_config.irq == -1 ? 0 : (1 << hw_config.irq);
|
|
|
|
dev->id_drq = hw_config.dma;
|
|
|
|
|
|
|
|
if (hw_config.dma != hw_config.dma2 && ( hw_config.dma2 != -1))
|
|
|
|
dev->id_flags = hw_config.dma2 | 0x100; /* XXX lr */
|
|
|
|
else
|
|
|
|
dev->id_flags = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return 0;
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
int
|
|
|
|
sndattach(struct isa_device * dev)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
int unit;
|
|
|
|
static int midi_initialized = 0;
|
|
|
|
static int seq_initialized = 0;
|
|
|
|
struct address_info hw_config;
|
|
|
|
|
|
|
|
unit = driver_to_voxunit(dev->id_driver);
|
|
|
|
hw_config.io_base = dev->id_iobase;
|
|
|
|
hw_config.irq = ipri_to_irq(dev->id_irq);
|
|
|
|
hw_config.dma = dev->id_drq;
|
|
|
|
|
|
|
|
/* misuse the flags field for read dma */
|
|
|
|
if (dev->id_flags != 0)
|
|
|
|
hw_config.dma2 = dev->id_flags & 0x7;
|
|
|
|
else
|
|
|
|
hw_config.dma2 = -1;
|
|
|
|
|
|
|
|
hw_config.card_subtype = 0;
|
|
|
|
hw_config.osp = temp_osp;
|
|
|
|
|
|
|
|
if (!unit)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!(sndtable_init_card(unit, &hw_config))) { /* init card */
|
|
|
|
printf(" <Driver not configured>");
|
|
|
|
return FALSE;
|
Reorganize how sound devices are configured. Use a snd controller
with individual devices for each type of sound card:
opl, sb, sbxvi, sbmidi, pas, mpu, gus, gusxvi, gusmax, mss, uart
EXCLUDE_* options are no longer required to be included in the config file.
They are automatically determined by local.h depending on the devices
included.
Move #includes in local.h to os.h so files are included in the proper
order to avoid warnings.
soundcard.c now has additional code to reflect the device driver
routines needed.
Define new EXCLUDE_SB16MIDI for use in sb16_midi.c and dev_table.h.
#ifndef EXCLUDE_SEQUENCER or EXCLUDE_AUDIO have been added to
soundcard.c and sound_switch.c where appropriate.
Probe outputs changed to reflect new device names.
Readme.freebsd not needed. Update sound.doc with new config instructions.
Reviewed by: wollman
1995-03-12 23:34:12 +00:00
|
|
|
}
|
1997-10-31 17:25:35 +00:00
|
|
|
/*
|
|
|
|
* Init the high level sound driver
|
|
|
|
*/
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
if (!(soundcards_installed = sndtable_get_cardcount())) {
|
|
|
|
DDB(printf("No drivers actually installed\n"));
|
|
|
|
return FALSE; /* No cards detected */
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
1997-10-31 17:25:35 +00:00
|
|
|
printf("\n");
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
#ifdef CONFIG_AUDIO
|
|
|
|
if (num_audiodevs) { /* Audio devices present */
|
|
|
|
DMAbuf_init();
|
|
|
|
sound_mem_init();
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
1997-10-31 17:25:35 +00:00
|
|
|
soundcard_configured = 1;
|
1994-10-01 02:17:17 +00:00
|
|
|
#endif
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
if (num_midis && !midi_initialized)
|
|
|
|
midi_initialized = 1;
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
if ((num_midis + num_synths) && !seq_initialized) {
|
|
|
|
seq_initialized = 1;
|
|
|
|
sequencer_init();
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
1997-01-15 03:42:30 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
dev_t dev;
|
1995-12-08 11:19:42 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
dev = makedev(CDEV_MAJOR, 0);
|
|
|
|
cdevsw_add(&dev, &snd_cdevsw, NULL);
|
1997-01-15 03:42:30 +00:00
|
|
|
}
|
1995-12-08 11:19:42 +00:00
|
|
|
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
1995-12-08 11:19:42 +00:00
|
|
|
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
#ifdef CONFIG_AUDIO
|
|
|
|
|
|
|
|
static void
|
|
|
|
alloc_dmap(int dev, int chan, struct dma_buffparms * dmap)
|
|
|
|
{
|
|
|
|
char *tmpbuf;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
tmpbuf = contigmalloc(audio_devs[dev]->buffsize, M_DEVBUF, M_NOWAIT,
|
|
|
|
0ul, 0xfffffful, 1ul, chan & 4 ? 0x20000ul : 0x10000ul);
|
|
|
|
if (tmpbuf == NULL)
|
|
|
|
printf("soundcard buffer alloc failed \n");
|
|
|
|
|
|
|
|
if (tmpbuf == NULL) {
|
|
|
|
printf("snd: Unable to allocate %d bytes of buffer\n",
|
|
|
|
2 * (int) audio_devs[dev]->buffsize);
|
|
|
|
return;
|
1997-01-15 03:42:30 +00:00
|
|
|
}
|
1997-10-31 17:25:35 +00:00
|
|
|
dmap->raw_buf = tmpbuf;
|
|
|
|
/*
|
|
|
|
* Use virtual address as the physical address, since isa_dmastart
|
|
|
|
* performs the phys address computation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
dmap->raw_buf_phys = (u_long) tmpbuf;
|
|
|
|
for (i = 0; i < audio_devs[dev]->buffsize; i++) *tmpbuf++ = 0x80;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sound_mem_init(void)
|
|
|
|
{
|
|
|
|
int dev;
|
|
|
|
static u_long dsp_init_mask = 0;
|
|
|
|
|
|
|
|
for (dev = 0; dev < num_audiodevs; dev++) /* Enumerate devices */
|
|
|
|
if (!(dsp_init_mask & (1 << dev))) /* Not already done */
|
|
|
|
if (audio_devs[dev]->dmachan1 >= 0) {
|
|
|
|
dsp_init_mask |= (1 << dev);
|
|
|
|
audio_devs[dev]->buffsize = DSP_BUFFSIZE;
|
|
|
|
/* Now allocate the buffers */
|
|
|
|
alloc_dmap(dev, audio_devs[dev]->dmachan1,
|
|
|
|
audio_devs[dev]->dmap_out);
|
|
|
|
if (audio_devs[dev]->flags & DMA_DUPLEX)
|
|
|
|
alloc_dmap(dev, audio_devs[dev]->dmachan2,
|
|
|
|
audio_devs[dev]->dmap_in);
|
|
|
|
} /* for dev */
|
|
|
|
}
|
|
|
|
|
1997-01-15 03:42:30 +00:00
|
|
|
#endif
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
snd_ioctl_return(int *addr, int value)
|
|
|
|
{
|
|
|
|
if (value < 0)
|
|
|
|
return value; /* Error */
|
|
|
|
suword(addr, value);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_UNIT 50
|
|
|
|
typedef void (*irq_proc_t) (int irq);
|
|
|
|
static irq_proc_t irq_proc[MAX_UNIT] = {NULL};
|
|
|
|
static int irq_irq[MAX_UNIT] = {0};
|
|
|
|
|
|
|
|
int
|
|
|
|
snd_set_irq_handler(int int_lvl, void (*hndlr) (int), sound_os_info * osp)
|
|
|
|
{
|
|
|
|
if (osp->unit >= MAX_UNIT) {
|
|
|
|
printf("Sound error: Unit number too high (%d)\n", osp->unit);
|
|
|
|
return 0;
|
1995-12-08 11:19:42 +00:00
|
|
|
}
|
1997-10-31 17:25:35 +00:00
|
|
|
irq_proc[osp->unit] = hndlr;
|
|
|
|
irq_irq[osp->unit] = int_lvl;
|
|
|
|
return 1;
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-10-31 17:25:35 +00:00
|
|
|
sndintr(int unit)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
if ( (unit >= MAX_UNIT) || (irq_proc[unit] == NULL) )
|
|
|
|
return;
|
1994-04-11 21:27:00 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
irq_proc[unit] (irq_irq[unit]); /* Call the installed handler */
|
1993-10-23 10:55:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-10-31 17:25:35 +00:00
|
|
|
conf_printf(char *name, struct address_info * hw_config)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
if (!trace_init)
|
|
|
|
return;
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-11-16 06:23:29 +00:00
|
|
|
printf("snd0: <%s> ", name);
|
|
|
|
#if 0
|
1997-10-31 17:25:35 +00:00
|
|
|
if (hw_config->io_base != -1 )
|
|
|
|
printf("at 0x%03x", hw_config->io_base);
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
if (hw_config->irq != -1 )
|
|
|
|
printf(" irq %d", hw_config->irq);
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
if (hw_config->dma != -1 || hw_config->dma2 != -1) {
|
|
|
|
printf(" dma %d", hw_config->dma);
|
|
|
|
if (hw_config->dma2 != -1)
|
|
|
|
printf(",%d", hw_config->dma2);
|
|
|
|
}
|
1997-11-16 06:23:29 +00:00
|
|
|
#endif
|
1993-10-23 10:55:52 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-10-31 17:25:35 +00:00
|
|
|
conf_printf2(char *name, int base, int irq, int dma, int dma2)
|
1993-10-23 10:55:52 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
if (!trace_init)
|
|
|
|
return;
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-11-16 06:23:29 +00:00
|
|
|
printf("snd0: <%s> ", name);
|
|
|
|
#if 0
|
|
|
|
if (hw_config->io_base != -1 )
|
|
|
|
printf("at 0x%03x", hw_config->io_base);
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
if (irq)
|
|
|
|
printf(" irq %d", irq);
|
|
|
|
|
|
|
|
if (dma != -1 || dma2 != -1) {
|
|
|
|
printf(" dma %d", dma);
|
|
|
|
if (dma2 != -1)
|
|
|
|
printf(",%d", dma2);
|
|
|
|
}
|
1997-11-16 06:23:29 +00:00
|
|
|
#endif
|
1993-10-23 10:55:52 +00:00
|
|
|
|
1994-03-11 10:27:25 +00:00
|
|
|
}
|
|
|
|
|
1995-07-28 21:40:49 +00:00
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
void tenmicrosec (int j)
|
1994-03-11 10:27:25 +00:00
|
|
|
{
|
1997-10-31 17:25:35 +00:00
|
|
|
int i, k;
|
|
|
|
for (k = 0; k < j/10 ; k++) {
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
inb (0x80);
|
|
|
|
}
|
1994-03-11 10:27:25 +00:00
|
|
|
}
|
|
|
|
|
1997-10-31 17:25:35 +00:00
|
|
|
#endif /* NSND > 0 */
|
the second set of changes in a move towards getting devices to be
totally dynamic. (the first was about 7 weeeks ago)
this is only the devices in i386/isa
I'll do more tomorrow.
they're completely masked by #ifdef JREMOD at this stage...
the eventual aim is that every driver will do a SYSINIT
at startup BEFORE the probes, which will effectively
link it into the devsw tables etc.
If I'd thought about it more I'd have put that in in this set (damn)
The ioconf lines generated by config will also end up in the
device's own scope as well, so ioconf.c will eventually be gutted
the SYSINIT call to the driver will include a phase where the
driver links it's ioconf line into a chain of such. when this phase is done
then the user can modify them with the boot: -c
config menu if he wants, just like now..
config will put the config lines out in the .h file
(e.g. in aha.h will be the addresses for the aha driver to look.)
as I said this is a very small first step..
the aim of THIS set of edits is to not have to edit conf.c at all when
adding a new device.. the tabe will be a simple skeleton..
when this is done, it will allow other changes to be made,
all teh time still having a fully working kernel tree,
but the logical outcome is the complete REMOVAL of the devsw tables.
By the end of this, linked in drivers will be exactly the same as
run-time loaded drivers, except they JUST HAPPEN to already be linked
and present at startup..
the SYSINIT calls will be the equivalent of the "init" call
made to a newly loaded driver in every respect.
For this edit,
each of the files has the following code inserted into it:
obviously, tailored to suit..
----------------------somewhere at the top:
#ifdef JREMOD
#include <sys/conf.h>
#define CDEV_MAJOR 13
#define BDEV_MAJOR 4
static void sd_devsw_install();
#endif /*JREMOD */
---------------------somewhere that's run during bootup: EVENTUALLY a SYSINIT
#ifdef JREMOD
sd_devsw_install();
#endif /*JREMOD*/
-----------------------at the bottom:
#ifdef JREMOD
struct bdevsw sd_bdevsw =
{ sdopen, sdclose, sdstrategy, sdioctl, /*4*/
sddump, sdsize, 0 };
struct cdevsw sd_cdevsw =
{ sdopen, sdclose, rawread, rawwrite, /*13*/
sdioctl, nostop, nullreset, nodevtotty,/* sd */
seltrue, nommap, sdstrategy };
static sd_devsw_installed = 0;
static void sd_devsw_install()
{
dev_t descript;
if( ! sd_devsw_installed ) {
descript = makedev(CDEV_MAJOR,0);
cdevsw_add(&descript,&sd_cdevsw,NULL);
#if defined(BDEV_MAJOR)
descript = makedev(BDEV_MAJOR,0);
bdevsw_add(&descript,&sd_bdevsw,NULL);
#endif /*BDEV_MAJOR*/
sd_devsw_installed = 1;
}
}
#endif /* JREMOD */
1995-11-28 09:43:45 +00:00
|
|
|
|
1995-11-29 10:49:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|