From 1698a08e9a67d82f9a1b778dda598e34ff59c19b Mon Sep 17 00:00:00 2001 From: cg Date: Sun, 12 Dec 1999 02:18:58 +0000 Subject: [PATCH] move channel-swapping support to the hardware driver since it knows the card state best --- sys/dev/sound/pcm/datatypes.h | 2 ++ sys/dev/sound/pcm/dsp.c | 11 +---------- sys/dev/sound/pcm/sound.c | 7 +++++++ sys/dev/sound/pcm/sound.h | 3 +-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sys/dev/sound/pcm/datatypes.h b/sys/dev/sound/pcm/datatypes.h index a163d123222b..5a719c4d419f 100644 --- a/sys/dev/sound/pcm/datatypes.h +++ b/sys/dev/sound/pcm/datatypes.h @@ -129,6 +129,7 @@ struct _pcm_channel { void *devinfo; }; +typedef void (pcm_swap_t)(void *data, int dir); #define SND_STATUSLEN 64 /* descriptor of audio device */ struct _snddev_info { @@ -138,6 +139,7 @@ struct _snddev_info { u_long magic; unsigned flags; void *devinfo; + pcm_swap_t *swap; char status[SND_STATUSLEN]; }; diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index 395515534b1b..eceab195de69 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -70,16 +70,7 @@ setchns(snddev_info *d, int chan) KASSERT((d->flags & SD_F_PRIO_SET) != SD_F_PRIO_SET, \ ("getchns: read and write both prioritised")); d->flags |= SD_F_DIR_SET; - if (d->flags & SD_F_EVILSB16) { - if ((d->flags & SD_F_PRIO_RD) && (d->aplay[chan])) { - pcm_channel *tmp; - tmp = d->arec[chan]; - d->arec[chan] = d->aplay[chan]; - d->aplay[chan] = tmp; - } - if (d->aplay[chan]) chn_setdir(d->aplay[chan], PCMDIR_PLAY); - if (d->arec[chan]) chn_setdir(d->arec[chan], PCMDIR_REC); - } + if (d->swap) d->swap(d->devinfo, (d->flags & SD_F_PRIO_WR)? PCMDIR_PLAY : PCMDIR_REC); } int diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index b464ebd8b3f8..a76a6b078362 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -129,6 +129,12 @@ pcm_setflags(device_t dev, u_int32_t val) d->flags = val; } +void +pcm_setswap(device_t dev, pcm_swap_t *swap) +{ + snddev_info *d = device_get_softc(dev); + d->swap = swap; +} /* This is the generic init routine */ int pcm_register(device_t dev, void *devinfo, int numplay, int numrec) @@ -172,6 +178,7 @@ pcm_register(device_t dev, void *devinfo, int numplay, int numrec) fkchan_setup(&d->fakechan); chn_init(&d->fakechan, NULL, 0); d->magic = MAGIC(unit); /* debugging... */ + d->swap = NULL; return 0; no: diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index 97cbd0d7cfa6..d2409ef60810 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -97,8 +97,6 @@ struct isa_device { int dummy; }; #define MAGIC(unit) (0xa4d10de0 + unit) #define SD_F_SIMPLEX 0x00000001 -#define SD_F_EVILSB16 0x00000002 -#define SD_F_EVILERSB16X 0x00000004 #define SD_F_PRIO_RD 0x10000000 #define SD_F_PRIO_WR 0x20000000 #define SD_F_PRIO_SET (SD_F_PRIO_RD | SD_F_PRIO_WR) @@ -165,6 +163,7 @@ int pcm_register(device_t dev, void *devinfo, int numplay, int numrec); int pcm_setstatus(device_t dev, char *str); u_int32_t pcm_getflags(device_t dev); void pcm_setflags(device_t dev, u_int32_t val); +void pcm_setswap(device_t dev, pcm_swap_t *swap); #endif /* KERNEL */