diff options
author | jkh <jkh@FreeBSD.org> | 1995-11-29 01:07:59 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-11-29 01:07:59 +0000 |
commit | 8b518c54b47f7a852f4e88e1174e3dc3edc4bca1 (patch) | |
tree | 1edc6902afaa1aa0384c0537aa6ab3d68b13456c /sys/i386/isa/sound | |
parent | 072ed4b1b938c9263f06b0b51f077d17ec0363be (diff) | |
download | FreeBSD-src-8b518c54b47f7a852f4e88e1174e3dc3edc4bca1.zip FreeBSD-src-8b518c54b47f7a852f4e88e1174e3dc3edc4bca1.tar.gz |
A batch of Jim Lowe's patches:
o Add signed/unsigned functionality to the matrox meteor device driver.
o Apply a few fixes to the sound driver.
o Add a ``SPIGOT_UNSECURE'' compile time definition so, if one defines
SPIGOT_UNSECURE in their conf file, then they can use the spigot w/o
root. There is a warning that this allows users access to the IO
page which is probably not secure.
Submitted by: james
Diffstat (limited to 'sys/i386/isa/sound')
-rw-r--r-- | sys/i386/isa/sound/audio.c | 30 | ||||
-rw-r--r-- | sys/i386/isa/sound/dmabuf.c | 10 | ||||
-rw-r--r-- | sys/i386/isa/sound/gus_wave.c | 74 | ||||
-rw-r--r-- | sys/i386/isa/sound/soundcard.c | 7 |
4 files changed, 103 insertions, 18 deletions
diff --git a/sys/i386/isa/sound/audio.c b/sys/i386/isa/sound/audio.c index 005915b..770babc 100644 --- a/sys/i386/isa/sound/audio.c +++ b/sys/i386/isa/sound/audio.c @@ -227,10 +227,16 @@ audio_write (int dev, struct fileinfo *file, snd_rw_buf * buf, int count) /* Handle nonblocking mode */ #if defined(__FreeBSD__) if (dev_nblock[dev] && wr_buff_no[dev] == RET_ERROR (EWOULDBLOCK)) + return wr_buff_no[dev]; /* + * XXX Return error, write() will + * supply # of accepted bytes. + * In fact, in FreeBSD the check + * above should not be needed + */ #else if (dev_nblock[dev] && wr_buff_no[dev] == RET_ERROR (EAGAIN)) -#endif return p; /* No more space. Return # of accepted bytes */ +#endif return wr_buff_no[dev]; } wr_buff_ptr[dev] = 0; @@ -317,10 +323,16 @@ audio_read (int dev, struct fileinfo *file, snd_rw_buf * buf, int count) #if defined(__FreeBSD__) if (dev_nblock[dev] && buff_no == RET_ERROR (EWOULDBLOCK)) + return buff_no; /* + * XXX Return error, read() will supply + * # of bytes actually read. In fact, + * in FreeBSD the check above should not + * be needed + */ #else if (dev_nblock[dev] && buff_no == RET_ERROR (EAGAIN)) -#endif return p; +#endif return buff_no; } @@ -449,6 +461,20 @@ audio_ioctl (int dev, struct fileinfo *file, return 0; break; +#ifdef __FreeBSD__ + case FIONBIO: /* XXX Is this the same in Linux? */ + if (*(int *)arg) + dev_nblock[dev] = 1; + else + dev_nblock[dev] = 0; + return 0; + break; + + case FIOASYNC: + return 0; /* XXX Useful for ampling input notification? */ + break; +#endif + default: return DMAbuf_ioctl (dev, cmd, arg, 0); } diff --git a/sys/i386/isa/sound/dmabuf.c b/sys/i386/isa/sound/dmabuf.c index f696de7..d748005 100644 --- a/sys/i386/isa/sound/dmabuf.c +++ b/sys/i386/isa/sound/dmabuf.c @@ -527,7 +527,7 @@ space_in_queue (int dev) int len, max, tmp; struct dma_buffparms *dmap = audio_devs[dev]->dmap; - if (dmap->qlen == dmap->nbufs) /* No space at all */ + if (dmap->qlen >= dmap->nbufs) /* No space at all */ return 0; /* @@ -587,7 +587,7 @@ DMAbuf_getwrbuffer (int dev, char **buf, int *size, int dontblock) } - if (dontblock) + if (dontblock && !space_in_queue (dev)) /* XXX */ #if defined(__FreeBSD__) return RET_ERROR (EWOULDBLOCK); #else @@ -961,9 +961,9 @@ DMAbuf_select (int dev, struct fileinfo *file, int sel_type, select_table * wait if (dmap->dma_mode != DMODE_INPUT) return 0; + DISABLE_INTR (flags); if (!dmap->qlen) { - DISABLE_INTR (flags); #if defined(__FreeBSD__) selrecord(wait, &selinfo[dev]); #else @@ -973,6 +973,7 @@ DMAbuf_select (int dev, struct fileinfo *file, int sel_type, select_table * wait RESTORE_INTR (flags); return 0; } + RESTORE_INTR (flags); return 1; break; @@ -983,9 +984,9 @@ DMAbuf_select (int dev, struct fileinfo *file, int sel_type, select_table * wait if (dmap->dma_mode == DMODE_NONE) return 1; + DISABLE_INTR (flags); if (!space_in_queue (dev)) { - DISABLE_INTR (flags); #if defined(__FreeBSD__) selrecord(wait, &selinfo[dev]); #else @@ -995,6 +996,7 @@ DMAbuf_select (int dev, struct fileinfo *file, int sel_type, select_table * wait RESTORE_INTR (flags); return 0; } + RESTORE_INTR (flags); return 1; break; diff --git a/sys/i386/isa/sound/gus_wave.c b/sys/i386/isa/sound/gus_wave.c index ecc266d..eb7227a 100644 --- a/sys/i386/isa/sound/gus_wave.c +++ b/sys/i386/isa/sound/gus_wave.c @@ -131,6 +131,10 @@ static unsigned long pcm_current_buf; static int pcm_current_count; static int pcm_current_intrflag; +#if defined(__FreeBSD__) +static char *gus_copy_buf; +#endif + struct voice_info voices[32]; static int freq_div_table[] = @@ -2003,11 +2007,13 @@ static int gus_sampling_open (int dev, int mode) { int dev_flag; + int init_flag; #ifdef GUS_NO_DMA printk ("GUS: DMA mode not enabled. Device not supported\n"); return RET_ERROR (ENXIO); #endif dev_flag = 0; + init_flag = (gus_busy[gus_devnum] == 0 && gus_busy[gus_dspnum] == 0); if(mode & OPEN_WRITE) { if (gus_busy[gus_devnum]) @@ -2029,18 +2035,20 @@ gus_sampling_open (int dev, int mode) } } - if(gus_busy[gus_devnum] == 0 && gus_busy[gus_dspnum] == 0) - gus_initialize (); + if(init_flag) + { + gus_initialize (); - active_device = 0; + active_device = 0; - gus_reset (); - reset_sample_memory (); - gus_select_max_voices (14); + gus_reset (); + reset_sample_memory (); + gus_select_max_voices (14); - pcm_active = 0; - dma_active = 0; - pcm_opened = 1; + pcm_active = 0; + dma_active = 0; + pcm_opened = 1; + } if (mode & OPEN_READ) { recording_active = 1; @@ -2055,7 +2063,7 @@ static void gus_sampling_close (int dev) { gus_busy[dev] = 0; - if (gus_busy[gus_devnum] == 0 && gus_busy[gus_dspnum]) { + if (gus_busy[gus_devnum] == 0 && gus_busy[gus_dspnum] == 0) { active_device = 0; gus_reset(); pcm_opened = 0; @@ -2392,6 +2400,47 @@ gus_copy_from_user (int dev, char *localbuf, int localoffs, COPY_FROM_USER (&localbuf[localoffs], userbuf, useroffs, len); } else if (gus_sampling_bits == 8) +#if defined(__FreeBSD__) + { + char *in_left = gus_copy_buf; + char *in_right = in_left + 1; + char *out_left = localbuf + (localoffs / 2); + char *out_right = out_left + pcm_bsize; + int i; + + COPY_FROM_USER (gus_copy_buf, userbuf, useroffs, len); + + len /= 2; + + for (i = 0; i < len; i++) + { + *out_left++ = *in_left++; + in_left++; + *out_right++ = *in_right++; + in_right++; + } + } + else + { + short *in_left = (short *)gus_copy_buf; + short *in_right = in_left + 1; + short *out_left = (short *)localbuf + (localoffs / 4); + short *out_right = out_left + (pcm_bsize / 2); + int i; + + COPY_FROM_USER (gus_copy_buf, userbuf, useroffs, len); + + len /= 4; + + for (i = 0; i < len; i++) + { + *out_left++ = *in_left++; + in_left++; + *out_right++ = *in_right++; + in_right++; + } + } +#else { int in_left = useroffs; int in_right = useroffs + 1; @@ -2439,6 +2488,7 @@ gus_copy_from_user (int dev, char *localbuf, int localoffs, #endif } } +#endif } static struct audio_operations gus_sampling_operations = @@ -3055,6 +3105,10 @@ gus_wave_init (long mem_start, int irq, int dma, int dma_read) synth_devs[num_synths++] = &guswave_operations; } +#if defined(__FreeBSD__) + PERMANENT_MALLOC (char *, gus_copy_buf, DSP_BUFFSIZE, mem_start); +#endif + PERMANENT_MALLOC (struct patch_info *, samples, (MAX_SAMPLE + 1) * sizeof (*samples), mem_start); diff --git a/sys/i386/isa/sound/soundcard.c b/sys/i386/isa/sound/soundcard.c index 8542e0a..d417c30 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.30 1995/11/04 13:24:48 bde Exp $ + * $Id: soundcard.c,v 1.31 1995/11/28 09:43:45 julian Exp $ */ #include "sound_config.h" @@ -53,7 +53,10 @@ u_int snd7_imask; u_int snd8_imask; u_int snd9_imask; -#define FIX_RETURN(ret) {if ((ret)<0) return -(ret); else return 0;} +#define FIX_RETURN(ret) { \ + int tmp_ret = (ret); \ + if (tmp_ret<0) return -tmp_ret; else return 0; \ + } static int timer_running = 0; |