summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1996-01-14 16:05:25 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1996-01-14 16:05:25 +0000
commitd8e28423102cdbc476396e31eb02731da3c548ee (patch)
tree3b27433f0046d1fa5d9f9d7c5d70d8f1a745c4c1 /sys
parentf26b4ac1cca30ecfe35f43651827ce03167ca9a4 (diff)
Add hooks for custom audio players. This is the original untouched
kernel diffs from Tim Newsham <newsham@hookomo.aloha.net> found in his well-known audio LKM kit.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amiga/amiga/cc.c55
-rw-r--r--sys/arch/amiga/amiga/cc.h2
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.
*/