From dd4974a47c99833efc50751ced2d577b32d109d2 Mon Sep 17 00:00:00 2001 From: niklas Date: Sun, 14 Jan 1996 16:05:23 +0000 Subject: [PATCH] Add hooks for custom audio players. This is the original untouched kernel diffs from Tim Newsham found in his well-known audio LKM kit. --- sys/arch/amiga/amiga/cc.c | 55 ++++++++++++++++++++++++++------------- sys/arch/amiga/amiga/cc.h | 2 ++ 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/sys/arch/amiga/amiga/cc.c b/sys/arch/amiga/amiga/cc.c index 2d2ba1aa5d8..1bf1b4c6d8a 100644 --- a/sys/arch/amiga/amiga/cc.c +++ b/sys/arch/amiga/amiga/cc.c @@ -323,12 +323,13 @@ copper_handler() */ struct audio_channel { - u_short play_count; + u_short play_count; /* number of times to loop sample */ + handler_func_t handler; /* interupt handler for channel */ }; /* - channel[4] */ /* the data for each audio channel and what to do with it. */ -static struct audio_channel channel[4]; +struct audio_channel channel[4]; /* audio vbl node for vbl function */ struct vbl_node audio_vbl_node; @@ -337,6 +338,7 @@ void cc_init_audio() { int i; + extern int defchannel_handler(); /* * disable all audio interupts @@ -346,8 +348,10 @@ cc_init_audio() /* * initialize audio channels to off. */ - for (i=0; i < 4; i++) + for (i=0; i < 4; i++) { channel[i].play_count = 0; + channel[i].handler = defchannel_handler; + } } @@ -393,22 +397,14 @@ audio_handler() if ((ir & (flag << 7)) == 0) continue; - if (channel[i].play_count) - channel[i].play_count--; - else { - /* - * disable DMA to this channel and - * disable interrupts to this channel - */ - custom.dmacon = flag; - custom.intena = (flag << 7); - } + if (channel[i].handler) + channel[i].handler(i); + /* * clear this channels interrupt. */ custom.intreq = (flag << 7); } - out: /* * enable audio interupts with dma still set. @@ -418,6 +414,26 @@ out: custom.intena = INTF_SETCLR | (audio_dma << 7); } +/* + * this is the channel handler used by the system + * other software modules are free to install their own + * handler + */ +defchannel_handler(i) + int i; +{ + if (channel[i].play_count) + channel[i].play_count--; + else { + /* + * disable DMA to this channel and + * disable interrupts to this channel + */ + custom.dmacon = (1 << i); + custom.intena = (1 << (i + 7)); + } +} + void play_sample(len, data, period, volume, channels, count) u_short len, *data, period, volume, channels; @@ -430,13 +446,16 @@ play_sample(len, data, period, volume, channels, count) /* load the channels */ for (ch = 0; ch < 4; ch++) { - if ((dmabits & (ch << ch)) == 0) + if ((dmabits & (1 << ch)) == 0) continue; - custom.aud[ch].len = len; - custom.aud[ch].lc = data; + /* busy */ + if (channel[ch].handler != defchannel_handler) + continue; + channel[ch].play_count = count; custom.aud[ch].per = period; custom.aud[ch].vol = volume; - channel[ch].play_count = count; + custom.aud[ch].len = len; + custom.aud[ch].lc = data; } /* * turn on interrupts and enable dma for channels and diff --git a/sys/arch/amiga/amiga/cc.h b/sys/arch/amiga/amiga/cc.h index 3b85f8fddba..29464e78142 100644 --- a/sys/arch/amiga/amiga/cc.h +++ b/sys/arch/amiga/amiga/cc.h @@ -147,6 +147,8 @@ vm_offset_t chipmem_end; #define CHIPMEMTOP (0x00200000) #define NCHIPMEMPG btoc(CHIPMEMTOP - CHIPMEMBASE) +typedef int (*handler_func_t)(); + /* * Prototypes. */ -- 2.20.1