move channel-swapping support to the hardware driver since it knows the card

state best
This commit is contained in:
cg 1999-12-12 02:18:58 +00:00
parent f1be6706cf
commit 1698a08e9a
4 changed files with 11 additions and 12 deletions

View File

@ -129,6 +129,7 @@ struct _pcm_channel {
void *devinfo; void *devinfo;
}; };
typedef void (pcm_swap_t)(void *data, int dir);
#define SND_STATUSLEN 64 #define SND_STATUSLEN 64
/* descriptor of audio device */ /* descriptor of audio device */
struct _snddev_info { struct _snddev_info {
@ -138,6 +139,7 @@ struct _snddev_info {
u_long magic; u_long magic;
unsigned flags; unsigned flags;
void *devinfo; void *devinfo;
pcm_swap_t *swap;
char status[SND_STATUSLEN]; char status[SND_STATUSLEN];
}; };

View File

@ -70,16 +70,7 @@ setchns(snddev_info *d, int chan)
KASSERT((d->flags & SD_F_PRIO_SET) != SD_F_PRIO_SET, \ KASSERT((d->flags & SD_F_PRIO_SET) != SD_F_PRIO_SET, \
("getchns: read and write both prioritised")); ("getchns: read and write both prioritised"));
d->flags |= SD_F_DIR_SET; d->flags |= SD_F_DIR_SET;
if (d->flags & SD_F_EVILSB16) { if (d->swap) d->swap(d->devinfo, (d->flags & SD_F_PRIO_WR)? PCMDIR_PLAY : PCMDIR_REC);
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);
}
} }
int int

View File

@ -129,6 +129,12 @@ pcm_setflags(device_t dev, u_int32_t val)
d->flags = 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 */ /* This is the generic init routine */
int int
pcm_register(device_t dev, void *devinfo, int numplay, int numrec) 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); fkchan_setup(&d->fakechan);
chn_init(&d->fakechan, NULL, 0); chn_init(&d->fakechan, NULL, 0);
d->magic = MAGIC(unit); /* debugging... */ d->magic = MAGIC(unit); /* debugging... */
d->swap = NULL;
return 0; return 0;
no: no:

View File

@ -97,8 +97,6 @@ struct isa_device { int dummy; };
#define MAGIC(unit) (0xa4d10de0 + unit) #define MAGIC(unit) (0xa4d10de0 + unit)
#define SD_F_SIMPLEX 0x00000001 #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_RD 0x10000000
#define SD_F_PRIO_WR 0x20000000 #define SD_F_PRIO_WR 0x20000000
#define SD_F_PRIO_SET (SD_F_PRIO_RD | SD_F_PRIO_WR) #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); int pcm_setstatus(device_t dev, char *str);
u_int32_t pcm_getflags(device_t dev); u_int32_t pcm_getflags(device_t dev);
void pcm_setflags(device_t dev, u_int32_t val); void pcm_setflags(device_t dev, u_int32_t val);
void pcm_setswap(device_t dev, pcm_swap_t *swap);
#endif /* KERNEL */ #endif /* KERNEL */