Date: Thu, 23 Apr 98 21:38:27 EDT From: luoqi@watermarkgroup.com (Luoqi Chen) To: cvs-all@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, cvs-sys@FreeBSD.ORG, eivind@FreeBSD.ORG Subject: Re: cvs commit: src/sys/i386/isa/sound soundcard.c Message-ID: <9804240138.AA11338@watermarkgroup.com>
next in thread | raw e-mail | index | archive | help
> eivind 1998/04/22 17:06:44 PDT > > Modified files: > sys/i386/isa/sound soundcard.c > Log: > Add devfs support. > > Submitted by: somebody whose name escapes me :-( > > Revision Changes Path > 1.65 +32 -2 src/sys/i386/isa/sound/soundcard.c > This patch doesn't work quite right. For my AWE32 card, there are two mixer devices, but this patch will only install the first one. I have a patch that should work for more general cases (and should continue to work if new card drivers are added). -lq Index: soundcard.c =================================================================== RCS file: /fun/cvs/src/sys/i386/isa/sound/soundcard.c,v retrieving revision 1.64 diff -u -r1.64 soundcard.c --- soundcard.c 1998/03/29 12:15:57 1.64 +++ soundcard.c 1998/04/22 02:13:51 @@ -27,6 +27,8 @@ * */ +#include "opt_devfs.h" + #include <i386/isa/sound/sound_config.h> #if NSND > 0 /* from "snd.h" */ @@ -36,6 +38,9 @@ #include <i386/isa/isa_device.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ /* ** Register definitions for DMA controller 1 (channels 0..3): @@ -61,6 +66,9 @@ static struct fileinfo files[SND_NDEVS]; struct selinfo selinfo[SND_NDEVS >> 4]; +#ifdef DEVFS +static void *devfs_token[SND_NDEVS]; +#endif int MIDIbuf_poll (int dev, struct fileinfo *file, int events, select_table * wait); @@ -447,6 +455,83 @@ cdevsw_add(&dev, &snd_cdevsw, NULL); } +#ifdef DEVFS + { + static int prev_num_sndstat = 0; + static int prev_num_mixers = 0; + static int prev_num_audiodevs = 0; + static int prev_num_seqs = 0; + static int prev_num_midis = 0; + int i, dev; + + if (prev_num_sndstat == 0) { + dev = SND_DEV_STATUS; + devfs_token[dev] = devfs_add_devswf(&snd_cdevsw, dev, + DV_CHR, UID_ROOT, GID_WHEEL, 0666, "sndstat"); + prev_num_sndstat++; + } + + if (num_mixers > prev_num_mixers) { + for (i = prev_num_mixers; i < num_mixers; i++) { + dev = (i << 4) + SND_DEV_CTL; + devfs_token[dev] = devfs_add_devswf(&snd_cdevsw, dev, + DV_CHR, UID_ROOT, GID_WHEEL, 0666, "mixer%d", i); + } + if (prev_num_mixers == 0) + devfs_link(devfs_token[SND_DEV_CTL], "mixer"); + prev_num_mixers = num_mixers; + } + +#ifdef CONFIG_AUDIO + if (num_audiodevs > prev_num_audiodevs) { + for (i = prev_num_audiodevs; i < num_audiodevs; i++) { + dev = (i << 4) + SND_DEV_DSP; + devfs_token[dev] = devfs_add_devswf(&snd_cdevsw, dev, + DV_CHR, UID_ROOT, GID_WHEEL, 0666, "dsp%d", i); + dev = (i << 4) + SND_DEV_DSP16; + devfs_token[dev] = devfs_add_devswf(&snd_cdevsw, dev, + DV_CHR, UID_ROOT, GID_WHEEL, 0666, "dspW%d", i); + dev = (i << 4) + SND_DEV_AUDIO; + devfs_token[dev] = devfs_add_devswf(&snd_cdevsw, dev, + DV_CHR, UID_ROOT, GID_WHEEL, 0666, "audio%d", i); + } + if (prev_num_audiodevs == 0) { + devfs_link(devfs_token[SND_DEV_DSP], "dsp"); + devfs_link(devfs_token[SND_DEV_DSP16], "dspW"); + devfs_link(devfs_token[SND_DEV_AUDIO], "audio"); + } + prev_num_audiodevs = num_audiodevs; + } +#endif + +#ifdef CONFIG_SEQUENCER + if (prev_num_seqs == 0 && num_midis + num_synths > 0) { + dev = SND_DEV_SEQ; + devfs_token[dev] = devfs_add_devswf(&snd_cdevsw, dev, + DV_CHR, UID_ROOT, GID_WHEEL, 0666, "sequencer%d", 0); + dev = SND_DEV_SEQ2; + devfs_token[dev] = devfs_add_devswf(&snd_cdevsw, dev, + DV_CHR, UID_ROOT, GID_WHEEL, 0666, "music%d", 0); + devfs_link(devfs_token[SND_DEV_SEQ], "sequencer"); + devfs_link(devfs_token[SND_DEV_SEQ2], "music"); + prev_num_seqs++; + } +#endif + +#ifdef CONFIG_MIDI + if (num_midis > prev_num_midis) { + for (i = prev_num_midis; i < num_midis; i++) { + dev = (i << 4) + SND_DEV_MIDIN; + devfs_token[dev] = devfs_add_devswf(&snd_cdevsw, dev, + DV_CHR, UID_ROOT, GID_WHEEL, 0666, "midi%d", i); + } + if (prev_num_midis == 0) + devfs_link(devfs_token[SND_DEV_MIDIN], "midi"); + prev_num_midis = num_midis; + } +#endif + } +#endif /*DEVFS*/ return TRUE; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9804240138.AA11338>