From 41e4fa8d02a2ca85c871c8cc3a4c6c93331cdfb3 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Wed, 23 Jan 2019 03:53:46 +0200 Subject: [PATCH] fixed soundblaster output (DMA bug) --- Makefile | 7 +++++++ src/au_sb.c | 4 ++-- src/dma.c | 4 ++-- src/intr.c | 3 +++ src/pci.c | 4 ++-- src/test/vbetest.c | 19 +------------------ 6 files changed, 17 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 9622719..fcbe869 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,13 @@ floppy.img: boot.img dd if=/dev/zero of=$@ bs=512 count=2880 dd if=$< of=$@ conv=notrunc +pcboot.iso: floppy.img + rm -rf cdrom + git archive --format=tar --prefix=cdrom/ HEAD | tar xf - + cp $< cdrom + mkisofs -o $@ -V pcboot -b $< cdrom + + boot.img: bootldr.bin $(bin) cat bootldr.bin $(bin) >$@ diff --git a/src/au_sb.c b/src/au_sb.c index 1adcfc1..fc9761d 100644 --- a/src/au_sb.c +++ b/src/au_sb.c @@ -194,9 +194,9 @@ void sb_start(int rate, int nchan) interrupt(IRQ_TO_INTR(irq), intr_handler); + write_dsp(CMD_ENABLE_OUTPUT); sb_set_output_rate(rate); start_dma_transfer(addr, size); - write_dsp(CMD_ENABLE_OUTPUT); } void sb_pause(void) @@ -241,7 +241,7 @@ static void start_dma_transfer(uint32_t addr, int size) dma_out(dma_chan, addr, size, DMA_SINGLE); /* program the DSP to accept the DMA transfer */ - write_dsp(CMD_START_DMA8 | CMD_FIFO); + write_dsp(CMD_START_DMA8); write_dsp(xfer_mode); size--; write_dsp(size & 0xff); diff --git a/src/dma.c b/src/dma.c index b6c4605..8d36edf 100644 --- a/src/dma.c +++ b/src/dma.c @@ -117,8 +117,8 @@ static void dma_io(int chan, uint32_t phyaddr, int size, unsigned int flags, uns mask(chan); outb(0, DMA_CLR_FLIPFLOP(chan)); - /* single / block / cascade */ - mode = ((flags & 3) << 6) | MODE_CHAN(chan); + /* first 2 bits of flags correspond to the mode bits 6,7 */ + mode = ((flags & 3) << 6) | dir | MODE_CHAN(chan); if(flags & DMA_DECR) mode |= MODE_DECR; if(flags & DMA_AUTO) mode |= MODE_AUTO; outb(mode, DMA_MODE(chan)); diff --git a/src/intr.c b/src/intr.c index a9bd5f1..e04a177 100644 --- a/src/intr.c +++ b/src/intr.c @@ -116,7 +116,10 @@ struct intr_frame *get_intr_frame(void) /* set an interrupt handler function for a particular interrupt */ void interrupt(int intr_num, intr_func_t func) { + int iflag = get_intr_flag(); + disable_intr(); intr_func[intr_num] = func; + set_intr_flag(iflag); } /* this function is called from all interrupt entry points diff --git a/src/pci.c b/src/pci.c index 0813ba7..93ea560 100644 --- a/src/pci.c +++ b/src/pci.c @@ -129,7 +129,7 @@ static int enum_dev(int busid, int dev) if(read_dev_info(&info, busid, dev, 0) == -1) { return 0; } - print_dev_info(&info, busid, dev, 0); + /*print_dev_info(&info, busid, dev, 0);*/ count = 1; @@ -138,7 +138,7 @@ static int enum_dev(int busid, int dev) if(read_dev_info(&info, busid, dev, i) == -1) { continue; } - print_dev_info(&info, busid, dev, i); + /*print_dev_info(&info, busid, dev, i);*/ count++; } } diff --git a/src/test/vbetest.c b/src/test/vbetest.c index 8625631..8a61516 100644 --- a/src/test/vbetest.c +++ b/src/test/vbetest.c @@ -176,24 +176,7 @@ static void draw_cursor(int x, int y, uint16_t col) static int click_sound_callback(void *buffer, int size, void *cls) { if(click) { - int i; - signed char *ptr = buffer; - signed char *src = snd_click; - /* - for(i=0; i