diff --git a/sys/i386/isa/sound/audio.c b/sys/i386/isa/sound/audio.c index c6f7972bc377..b73cf4a9a8aa 100644 --- a/sys/i386/isa/sound/audio.c +++ b/sys/i386/isa/sound/audio.c @@ -491,43 +491,37 @@ audio_init (long mem_start) #ifdef ALLOW_SELECT int -audio_select (int dev, struct fileinfo *file, int sel_type, select_table * wait) +audio_poll (int dev, struct fileinfo *file, int events, select_table * wait) { int l; char *dmabuf; + int revents = 0; dev = dev >> 4; - switch (sel_type) - { - case SEL_IN: - if (audio_mode[dev] != AM_READ && /* Wrong direction */ - audio_mode[dev] != AM_NONE) - return 0; + if (events & (POLLIN | POLLRDNORM)) { + if (audio_mode[dev] == AM_READ || /* Right direction */ + audio_mode[dev] == AM_NONE) - if (DMAbuf_getrdbuffer (dev, &dmabuf, &l, - 1 /* Don't block */ ) >= 0) - return 1; /* We have data */ + if (DMAbuf_getrdbuffer (dev, &dmabuf, &l, 1 /* Don't block */ ) >= 0) + revents |= events & (POLLIN | POLLRDNORM); /* We have data */ + else + revents |= DMAbuf_poll (dev, file, events, wait); - return DMAbuf_select (dev, file, sel_type, wait); - break; + } - case SEL_OUT: - if (audio_mode[dev] != AM_WRITE && /* Wrong direction */ - audio_mode[dev] != AM_NONE) - return 0; + if (events & (POLLOUT | POLLWRNORM)) { + if (audio_mode[dev] == AM_WRITE || /* Right direction */ + audio_mode[dev] == AM_NONE) if (wr_buff_no[dev] != -1) - return 1; /* There is space in the current buffer */ + revents |= events & (POLLOUT | POLLWRNORM); /* There is space in the current buffer */ + else + revents |= DMAbuf_poll (dev, file, events, wait); - return DMAbuf_select (dev, file, sel_type, wait); - break; + } - case SEL_EX: - return 0; - } - - return 0; + return (revents); } #endif /* ALLOW_SELECT */ diff --git a/sys/i386/isa/sound/dmabuf.c b/sys/i386/isa/sound/dmabuf.c index 4211bdb793bb..02ad992f4104 100644 --- a/sys/i386/isa/sound/dmabuf.c +++ b/sys/i386/isa/sound/dmabuf.c @@ -1000,61 +1000,43 @@ DMAbuf_reset_dma (int dev) #ifdef ALLOW_SELECT int -DMAbuf_select (int dev, struct fileinfo *file, int sel_type, select_table * wait) +DMAbuf_poll (int dev, struct fileinfo *file, int events, select_table * wait) { struct dma_buffparms *dmap = audio_devs[dev]->dmap; unsigned long flags; + int revents = 0; - switch (sel_type) - { - case SEL_IN: - if (dmap->dma_mode != DMODE_INPUT) - return 0; + if (events & (POLLIN | POLLRDNORM)) + if (dmap->dma_mode == DMODE_INPUT) { DISABLE_INTR (flags); + if (!dmap->qlen) - { -#if defined(__FreeBSD__) - selrecord(wait, &selinfo[dev]); -#else - dev_sleep_flag[dev].mode = WK_SLEEP; - select_wait (&dev_sleeper[dev], wait); -#endif - RESTORE_INTR (flags); - return 0; - } + selrecord(wait, &selinfo[dev]); + else + revents |= events & (POLLIN | POLLRDNORM); + RESTORE_INTR (flags); - return 1; - break; - - case SEL_OUT: - if (dmap->dma_mode == DMODE_INPUT) - return 0; - - if (dmap->dma_mode == DMODE_NONE) - return 1; - - DISABLE_INTR (flags); - if (!space_in_queue (dev)) - { -#if defined(__FreeBSD__) - selrecord(wait, &selinfo[dev]); -#else - dev_sleep_flag[dev].mode = WK_SLEEP; - select_wait (&dev_sleeper[dev], wait); -#endif - RESTORE_INTR (flags); - return 0; - } - RESTORE_INTR (flags); - return 1; - break; - - case SEL_EX: - return 0; } - return 0; + if (events & (POLLOUT | POLLWRNORM)) + if (dmap->dma_mode != DMODE_INPUT) { + + if (dmap->dma_mode == DMODE_NONE) + revents |= events & (POLLOUT | POLLWRNORM); + else { + DISABLE_INTR (flags); + + if (!space_in_queue (dev)) + selrecord(wait, &selinfo[dev]); + else + revents |= events & (POLLOUT | POLLWRNORM); + + RESTORE_INTR (flags); + } + } + + return (revents); } #endif /* ALLOW_SELECT */ diff --git a/sys/i386/isa/sound/midibuf.c b/sys/i386/isa/sound/midibuf.c index 58ff1ee1e7ec..79e1a169a8bb 100644 --- a/sys/i386/isa/sound/midibuf.c +++ b/sys/i386/isa/sound/midibuf.c @@ -418,45 +418,25 @@ MIDIbuf_ioctl (int dev, struct fileinfo *file, #ifdef ALLOW_SELECT int -MIDIbuf_select (int dev, struct fileinfo *file, int sel_type, select_table * wait) +MIDIbuf_poll (int dev, struct fileinfo *file, int events, select_table * wait) { + int revents = 0; + dev = dev >> 4; - switch (sel_type) - { - case SEL_IN: - if (!DATA_AVAIL (midi_in_buf[dev])) - { -#if defined(__FreeBSD__) - selrecord(wait, &selinfo[dev]); -#else - input_sleep_flag[dev].mode = WK_SLEEP; - select_wait (&input_sleeper[dev], wait); -#endif - return 0; - } - return 1; - break; + if (events & (POLLIN | POLLRDNORM)) + if (!DATA_AVAIL (midi_in_buf[dev])) + selrecord(wait, &selinfo[dev]); + else + revents |= events & (POLLIN | POLLRDNORM); - case SEL_OUT: - if (SPACE_AVAIL (midi_out_buf[dev])) - { -#if defined(__FreeBSD__) - selrecord(wait, &selinfo[dev]); -#else - midi_sleep_flag[dev].mode = WK_SLEEP; - select_wait (&midi_sleeper[dev], wait); -#endif - return 0; - } - return 1; - break; + if (events & (POLLOUT | POLLWRNORM)) + if (SPACE_AVAIL (midi_out_buf[dev])) + selrecord(wait, &selinfo[dev]); + else + revents |= events & (POLLOUT | POLLWRNORM); - case SEL_EX: - return 0; - } - - return 0; + return revents; } #endif /* ALLOW_SELECT */ diff --git a/sys/i386/isa/sound/os.h b/sys/i386/isa/sound/os.h index 779378667443..055755b2f7b2 100644 --- a/sys/i386/isa/sound/os.h +++ b/sys/i386/isa/sound/os.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/i386/isa/sound/sequencer.c b/sys/i386/isa/sound/sequencer.c index 49be353763f3..ea049a6e85e5 100644 --- a/sys/i386/isa/sound/sequencer.c +++ b/sys/i386/isa/sound/sequencer.c @@ -1770,55 +1770,34 @@ sequencer_ioctl (int dev, struct fileinfo *file, #ifdef ALLOW_SELECT int -sequencer_select (int dev, struct fileinfo *file, int sel_type, select_table * wait) +sequencer_poll (int dev, struct fileinfo *file, int events, select_table * wait) { unsigned long flags; + int revents = 0; dev = dev >> 4; - switch (sel_type) - { - case SEL_IN: - DISABLE_INTR (flags); - if (!iqlen) - { -#if defined(__FreeBSD__) - selrecord(wait, &selinfo[dev]); -#else - midi_sleep_flag.mode = WK_SLEEP; - select_wait (&midi_sleeper, wait); -#endif - RESTORE_INTR (flags); - return 0; - } + DISABLE_INTR (flags); + + if (events & (POLLIN | POLLRDNORM)) + if (!iqlen) + selrecord(wait, &selinfo[dev]); + else { + revents |= events & (POLLIN | POLLRDNORM); midi_sleep_flag.mode &= ~WK_SLEEP; - RESTORE_INTR (flags); - return 1; - break; - - case SEL_OUT: - DISABLE_INTR (flags); - if (qlen >= SEQ_MAX_QUEUE) - { -#if defined(__FreeBSD__) - selrecord(wait, &selinfo[dev]); -#else - seq_sleep_flag.mode = WK_SLEEP; - select_wait (&seq_sleeper, wait); -#endif - RESTORE_INTR (flags); - return 0; - } - seq_sleep_flag.mode &= ~WK_SLEEP; - RESTORE_INTR (flags); - return 1; - break; - - case SEL_EX: - return 0; } - return 0; + if (events & (POLLOUT | POLLWRNORM)) + if (qlen >= SEQ_MAX_QUEUE) + selrecord(wait, &selinfo[dev]); + else { + revents |= events & (POLLOUT | POLLWRNORM); + seq_sleep_flag.mode &= ~WK_SLEEP; + } + + RESTORE_INTR (flags); + + return (revents); } #endif @@ -1976,9 +1955,9 @@ sequencer_init (long mem_start) #ifdef ALLOW_SELECT int -sequencer_select (int dev, struct fileinfo *file, int sel_type, select_table * wait) +sequencer_poll (int dev, struct fileinfo *file, int events, select_table * wait) { - return RET_ERROR (EIO); + return (events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLHUP); } #endif diff --git a/sys/i386/isa/sound/sound_calls.h b/sys/i386/isa/sound/sound_calls.h index f5aa363f8a76..28fcc4d87ee6 100644 --- a/sys/i386/isa/sound/sound_calls.h +++ b/sys/i386/isa/sound/sound_calls.h @@ -17,7 +17,7 @@ void DMAbuf_reset_dma (int dev); void DMAbuf_inputintr(int dev); void DMAbuf_outputintr(int dev, int underflow_flag); #ifdef ALLOW_SELECT -int DMAbuf_select(int dev, struct fileinfo *file, int sel_type, select_table * wait); +int DMAbuf_poll(int dev, struct fileinfo *file, int events, select_table * wait); #endif /* @@ -34,7 +34,7 @@ int audio_lseek (int dev, struct fileinfo *file, off_t offset, int orig); long audio_init (long mem_start); #ifdef ALLOW_SELECT -int audio_select(int dev, struct fileinfo *file, int sel_type, select_table * wait); +int audio_poll(int dev, struct fileinfo *file, int events, select_table * wait); #endif /* @@ -56,7 +56,7 @@ void seq_input_event(unsigned char *event, int len); void seq_copy_to_input (unsigned char *event, int len); #ifdef ALLOW_SELECT -int sequencer_select(int dev, struct fileinfo *file, int sel_type, select_table * wait); +int sequencer_poll(int dev, struct fileinfo *file, int events, select_table * wait); #endif /* @@ -74,7 +74,7 @@ void MIDIbuf_bytes_received(int dev, unsigned char *buf, int count); long MIDIbuf_init(long mem_start); #ifdef ALLOW_SELECT -int MIDIbuf_select(int dev, struct fileinfo *file, int sel_type, select_table * wait); +int MIDIbuf_poll(int dev, struct fileinfo *file, int events, select_table * wait); #endif /* diff --git a/sys/i386/isa/sound/soundcard.c b/sys/i386/isa/sound/soundcard.c index c0058b6fab9f..0c57ee5db6ba 100644 --- a/sys/i386/isa/sound/soundcard.c +++ b/sys/i386/isa/sound/soundcard.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: soundcard.c,v 1.51 1997/06/08 12:55:26 ache Exp $ + * $Id: soundcard.c,v 1.52 1997/07/20 11:58:40 bde Exp $ */ #include @@ -69,13 +69,13 @@ static d_close_t sndclose; static d_read_t sndread; static d_write_t sndwrite; static d_ioctl_t sndioctl; -static d_select_t sndselect; +static d_poll_t sndpoll; #define CDEV_MAJOR 30 static struct cdevsw snd_cdevsw = { sndopen, sndclose, sndread, sndwrite, /*30*/ sndioctl, nostop, nullreset, nodevtotty,/* sound */ - sndselect, nommap, NULL, "snd", NULL, -1 }; + sndpoll, nommap, NULL, "snd", NULL, -1 }; struct isa_driver opldriver = {sndprobe, sndattach, "opl"}; struct isa_driver sbdriver = {sndprobe, sndattach, "sb"}; @@ -197,24 +197,24 @@ sndioctl (dev_t dev, int cmd, caddr_t arg, int flags, struct proc *p) } static int -sndselect (dev_t dev, int rw, struct proc *p) +sndpoll (dev_t dev, int events, struct proc *p) { dev = minor (dev); - DEB (printk ("snd_select(dev=%d, rw=%d, pid=%d)\n", dev, rw, p->p_pid)); + DEB (printk ("snd_poll(dev=%d, rw=%d, pid=%d)\n", dev, rw, p->p_pid)); #ifdef ALLOW_SELECT switch (dev & 0x0f) { #ifndef EXCLUDE_SEQUENCER case SND_DEV_SEQ: case SND_DEV_SEQ2: - return sequencer_select (dev, &files[dev], rw, p); + return sequencer_poll (dev, &files[dev], events, p); break; #endif #ifndef EXCLUDE_MIDI case SND_DEV_MIDIN: - return MIDIbuf_select (dev, &files[dev], rw, p); + return MIDIbuf_poll (dev, &files[dev], events, p); break; #endif @@ -222,7 +222,7 @@ sndselect (dev_t dev, int rw, struct proc *p) case SND_DEV_DSP: case SND_DEV_DSP16: case SND_DEV_AUDIO: - return audio_select (dev, &files[dev], rw, p); + return audio_poll (dev, &files[dev], events, p); break; #endif