Fixed acquired dma channel problem.

This commit is contained in:
Amancio Hasty 1997-11-23 07:35:06 +00:00
parent 60dc9be97b
commit 26ed678ef9
2 changed files with 56 additions and 4 deletions

View File

@ -48,6 +48,8 @@ static int dsp_stereo = 0;
static int dsp_current_speed = 8000;
static int dsp_busy = 0;
static int dma16, dma8;
static int trigger_bits = 0;
static u_long dsp_count = 0;
@ -198,6 +200,7 @@ sb16_dsp_open(int dev, int mode)
int retval;
DEB(printf("sb16_dsp_open()\n"));
if (!sb16_dsp_ok) {
printf("SB16 Error: SoundBlaster board not installed\n");
return -(ENXIO);
@ -207,6 +210,7 @@ sb16_dsp_open(int dev, int mode)
sb_reset_dsp();
irq_mode = IMODE_NONE;
dsp_busy = 1;
trigger_bits = 0;
@ -229,6 +233,8 @@ sb16_dsp_close(int dev)
dsp_cleanup();
dsp_busy = 0;
splx(flags);
}
@ -237,10 +243,12 @@ sb16_dsp_output_block(int dev, u_long buf, int count, int intrflag, int dma_rest
{
u_long flags, cnt;
cnt = count;
if (dsp_16bit)
cnt >>= 1;
cnt--;
if (audio_devs[dev]->flags & DMA_AUTOMODE && intrflag && cnt==dsp_count) {
irq_mode = IMODE_OUTPUT;
intr_active = 1;
@ -309,7 +317,20 @@ sb16_dsp_start_input(int dev, u_long buf, int count, int intrflag, int dma_resta
static int
sb16_dsp_prepare_for_input(int dev, int bsize, int bcount)
{
int fudge;
struct dma_buffparms *dmap = audio_devs[dev]->dmap_in;
audio_devs[my_dev]->dmachan2 = dsp_16bit ? dma16 : dma8;
fudge = audio_devs[my_dev]->dmachan2 ;
if (dmap->dma_chan != fudge ) {
isa_dma_release( dmap->dma_chan);
isa_dma_acquire(fudge);
dmap->dma_chan = fudge;
}
dsp_count = 0;
dsp_cleanup();
if (dsp_16bit)
@ -325,11 +346,16 @@ static int
sb16_dsp_prepare_for_output(int dev, int bsize, int bcount)
{
int fudge = dsp_16bit ? dma16 : dma8;
struct dma_buffparms *dmap = audio_devs[dev]->dmap_out;
isa_dma_release( audio_devs[my_dev]->dmachan1 );
isa_dma_acquire(fudge);
if (dmap->dma_chan != fudge ) {
isa_dma_release( dmap->dma_chan);
isa_dma_acquire(fudge);
dmap->dma_chan = fudge;
}
audio_devs[my_dev]->dmachan1 = fudge;
dsp_count = 0;
dsp_cleanup();
if (dsp_16bit)

View File

@ -50,6 +50,8 @@
* variables are put in a struct sb_unit[] array
*/
int sbc_base = 0;
int sbc_irq = 0;
static int open_mode = 0; /* Read, write or both */
@ -231,7 +233,6 @@ dsp_speed(int speed)
u_long flags;
int max_speed = 44100;
printf("dsp_speed %d\n", speed); /* XXX lr 970601 */
if (speed < 4000)
speed = 4000;
@ -310,7 +311,6 @@ printf("dsp_speed %d\n", speed); /* XXX lr 970601 */
speed /= 2;
dsp_current_speed = speed;
printf("dsp_speed done %d\n", speed);
return speed;
}
@ -445,6 +445,9 @@ dsp_cleanup(void)
static int
sb_dsp_prepare_for_input(int dev, int bsize, int bcount)
{
int fudge = -1;
struct dma_buffparms *dmap = audio_devs[dev]->dmap_in;
dsp_cleanup();
dsp_speaker(OFF);
@ -470,6 +473,14 @@ sb_dsp_prepare_for_input(int dev, int bsize, int bcount)
dsp_speed(dsp_current_speed); /* Speed must be recalculated
* if #channels * changes */
}
fudge = audio_devs[my_dev]->dmachan1;
if (dmap->dma_chan != fudge ) {
isa_dma_release( dmap->dma_chan);
isa_dma_acquire(fudge);
dmap->dma_chan = fudge;
}
trigger_bits = 0;
sb_dsp_command(DSP_CMD_DMAHALT); /* Halt DMA */
return 0;
@ -478,6 +489,10 @@ sb_dsp_prepare_for_input(int dev, int bsize, int bcount)
static int
sb_dsp_prepare_for_output(int dev, int bsize, int bcount)
{
int fudge;
struct dma_buffparms *dmap = audio_devs[dev]->dmap_out;
dsp_cleanup();
dsp_speaker(ON);
@ -488,6 +503,7 @@ sb_dsp_prepare_for_output(int dev, int bsize, int bcount)
* 16 bit specific instructions
*/
audio_devs[my_dev]->dmachan1 = dsp_16bit ? dma16 : dma8;
if (Jazz16_detected != 2) /* SM Wave */
sb_mixer_set_stereo(dsp_stereo);
if (dsp_stereo)
@ -501,6 +517,14 @@ sb_dsp_prepare_for_output(int dev, int bsize, int bcount)
* if #channels * changes */
}
#endif
fudge = audio_devs[my_dev]->dmachan1;
if (dmap->dma_chan != fudge ) {
isa_dma_release( dmap->dma_chan);
isa_dma_acquire(fudge);
dmap->dma_chan = fudge;
}
trigger_bits = 0;
sb_dsp_command(DSP_CMD_DMAHALT); /* Halt DMA */
return 0;
@ -548,6 +572,7 @@ sb_dsp_open(int dev, int mode)
sb_dsp_busy = 1;
open_mode = mode;
return 0;
}
@ -569,6 +594,7 @@ sb_dsp_close(int dev)
sb_dsp_busy = 0;
sb_dsp_highspeed = 0;
open_mode = 0;
}
#ifdef JAZZ16