Commit the new (old) midi framework. It's based in parts on the NetBSD code,

but large parts are rewritten by matk and tanimura.

This is old code, it's not maintained since 2003. We also don't have a
maintainer for this! Yuriy Tsibizov took it and uses it in his emu10kx
driver. Since the emu10kx driver will enter the tree "soon" (some bugs
have to be fixed after Yuriy return from his holidays), I add it here
already.

This also contains some changes to emu10k1 and cmi, so if you're lucky,
you can now make some kind of use of midi with those soundcards.

To all those poor souls which don't have such a card: feel free to send
patches, we don't have a maintainer for this.

To those which miss a specific feature in the midi code: feel free to
submit patches, we don't have a maintainer for this.

Oh, did I already told that it would be nice if someone would take care
of it? Maintainer with midi equipment wanted! :-)

If you get LOR's, submit a PR and notify multimedia@ please. If you get
panics, submit a PR with a backtrace (compile the sound system into your
kernel instead of using modules in this case) and notify multimedia@
please.

Written by:	matk, tanimura
Submitted by:	"Yuriy Tsibizov" <Yuriy.Tsibizov@gfk.ru>
Based upon:	code from NetBSD
This commit is contained in:
netchild 2006-05-27 16:32:05 +00:00
parent 25066c8b6b
commit 1686236080
15 changed files with 4562 additions and 2 deletions

View File

@ -905,6 +905,12 @@ dev/sound/pcm/vchan.c optional sound
#dev/sound/usb/upcm.c optional snd_upcm usb
dev/sound/usb/uaudio.c optional snd_uaudio usb
dev/sound/usb/uaudio_pcm.c optional snd_uaudio usb
dev/sound/midi/midi.c optional sound
dev/sound/midi/mpu401.c optional sound
dev/sound/midi/mpu_if.m optional sound
dev/sound/midi/mpufoi_if.m optional sound
dev/sound/midi/sequencer.c optional sound
dev/sound/midi/synth_if.m optional sound
dev/sr/if_sr.c optional sr
dev/sr/if_sr_pci.c optional sr pci
dev/stg/tmc18c30.c optional stg

View File

@ -321,8 +321,9 @@ MFILES?= dev/acpica/acpi_if.m dev/ata/ata_if.m dev/eisa/eisa_if.m \
dev/pci/pcib_if.m dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m \
dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m \
dev/usb/usb_if.m isa/isa_if.m kern/bus_if.m kern/cpufreq_if.m \
kern/device_if.m kern/serdev_if.m \
dev/sound/midi/mpu_if.m dev/sound/midi/mpufoi_if.m \
dev/sound/midi/synth_if.m dev/usb/usb_if.m isa/isa_if.m \
kern/bus_if.m kern/cpufreq_if.m kern/device_if.m kern/serdev_if.m \
libkern/iconv_converter_if.m opencrypto/crypto_if.m \
pc98/pc98/canbus_if.m pci/agp_if.m

1509
sys/dev/sound/midi/midi.c Normal file

File diff suppressed because it is too large Load Diff

55
sys/dev/sound/midi/midi.h Normal file
View File

@ -0,0 +1,55 @@
/*-
* (c) 2003 Mathew Kanner
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. 2.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef MIDI_H
#define MIDI_H
#include <sys/types.h>
#include <sys/malloc.h>
MALLOC_DECLARE(M_MIDI);
#define M_RX 0x01
#define M_TX 0x02
#define M_RXEN 0x04
#define M_TXEN 0x08
#define MIDI_TYPE unsigned char
struct snd_midi;
struct snd_midi *midi_init(kobj_class_t _mpu_cls, int _unit, int _channel,
void *cookie);
int midi_uninit(struct snd_midi * _m);
int midi_out(struct snd_midi * _m, MIDI_TYPE * _buf, int _size);
int midi_in(struct snd_midi * _m, MIDI_TYPE * _buf, int _size);
kobj_t midimapper_addseq(void *arg1, int *unit, void **cookie);
int midimapper_open(void *arg1, void **cookie);
int midimapper_close(void *arg1, void *cookie);
kobj_t midimapper_fetch_synth(void *arg, void *cookie, int unit);
#endif

104
sys/dev/sound/midi/midiq.h Normal file
View File

@ -0,0 +1,104 @@
/*-
* (c) 2003 Mathew Kanner
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. 2.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef MIDIQ_H
#define MIDIQ_H
#define MIDIQ_MOVE(a,b,c) bcopy(b,a,c)
#define MIDIQ_HEAD(name, type) \
struct name { \
int h, t, s; \
type * b; \
}
#define MIDIQ_INIT(head, buf, size) do { \
(head).h=(head).t=0; \
(head).s=size; \
(head).b=buf; \
} while (0)
#define MIDIQ_EMPTY(head) ((head).h == (head).t )
#define MIDIQ_LENBASE(head) ((head).h - (head).t < 0 ? \
(head).h - (head).t + (head).s : \
(head).h - (head).t)
#define MIDIQ_FULL(head) ((head).h == -1)
#define MIDIQ_AVAIL(head) (MIDIQ_FULL(head) ? 0 : (head).s - MIDIQ_LENBASE(head))
#define MIDIQ_LEN(head) ((head).s - MIDIQ_AVAIL(head))
#define MIDIQ_DEBUG 0
/*
* No protection against overflow, underflow
*/
#define MIDIQ_ENQ(head, buf, size) do { \
if(MIDIQ_DEBUG)\
printf("#1 %p %p bytes copied %jd tran req s %d h %d t %d\n", \
&(head).b[(head).h], (buf), \
(intmax_t)(sizeof(*(head).b) * \
MIN( (size), (head).s - (head).h) ), \
(size), (head).h, (head).t); \
MIDIQ_MOVE(&(head).b[(head).h], (buf), sizeof(*(head).b) * MIN((size), (head).s - (head).h)); \
if( (head).s - (head).h < (size) ) { \
if(MIDIQ_DEBUG) \
printf("#2 %p %p bytes copied %jd\n", (head).b, (buf) + (head).s - (head).h, (intmax_t)sizeof(*(head).b) * ((size) - (head).s + (head).h) ); \
MIDIQ_MOVE((head).b, (buf) + (head).s - (head).h, sizeof(*(head).b) * ((size) - (head).s + (head).h) ); \
} \
(head).h+=(size); \
(head).h%=(head).s; \
if(MIDIQ_EMPTY(head)) (head).h=-1; \
if(MIDIQ_DEBUG)\
printf("#E h %d t %d\n", (head).h, (head).t); \
} while (0)
#define MIDIQ_DEQ_I(head, buf, size, move, update) do { \
if(MIDIQ_FULL(head)) (head).h=(head).t; \
if(MIDIQ_DEBUG)\
printf("#1 %p %p bytes copied %jd tran req s %d h %d t %d\n", &(head).b[(head).t], (buf), (intmax_t)sizeof(*(head).b) * MIN((size), (head).s - (head).t), (size), (head).h, (head).t); \
if (move) MIDIQ_MOVE((buf), &(head).b[(head).t], sizeof(*(head).b) * MIN((size), (head).s - (head).t)); \
if( (head).s - (head).t < (size) ) { \
if(MIDIQ_DEBUG) \
printf("#2 %p %p bytes copied %jd\n", (head).b, (buf) + (head).s - (head).t, (intmax_t)sizeof(*(head).b) * ((size) - (head).s + (head).t) ); \
if (move) MIDIQ_MOVE((buf) + (head).s - (head).t, (head).b, sizeof(*(head).b) * ((size) - (head).s + (head).t) ); \
} \
if (update) { \
(head).t+=(size); \
(head).t%=(head).s; \
} else { \
if (MIDIQ_EMPTY(head)) (head).h=-1; \
} \
if(MIDIQ_DEBUG)\
printf("#E h %d t %d\n", (head).h, (head).t); \
} while (0)
#define MIDIQ_SIZE(head) ((head).s)
#define MIDIQ_CLEAR(head) ((head).h = (head).t = 0)
#define MIDIQ_BUF(head) ((head).b)
#define MIDIQ_DEQ(head, buf, size) MIDIQ_DEQ_I(head, buf, size, 1, 1)
#define MIDIQ_PEEK(head, buf, size) MIDIQ_DEQ_I(head, buf, size, 1, 0)
#define MIDIQ_POP(head, size) MIDIQ_DEQ_I(head, &head, size, 0, 1)
#endif

284
sys/dev/sound/midi/mpu401.c Normal file
View File

@ -0,0 +1,284 @@
/*-
* (c) 2003 Mathew Kanner
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. 2.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/kobj.h>
#include <sys/malloc.h>
#include <sys/bus.h> /* to get driver_intr_t */
#include <dev/sound/midi/mpu401.h>
#include <dev/sound/midi/midi.h>
#include "mpu_if.h"
#include "mpufoi_if.h"
#define MPU_DATAPORT 0
#define MPU_CMDPORT 1
#define MPU_STATPORT 1
#define MPU_RESET 0xff
#define MPU_UART 0x3f
#define MPU_ACK 0xfe
#define MPU_STATMASK 0xc0
#define MPU_OUTPUTBUSY 0x40
#define MPU_INPUTBUSY 0x80
#define MPU_TRYDATA 50
#define MPU_DELAY 2500
#define CMD(m,d) MPUFOI_WRITE(m, m->cookie, MPU_CMDPORT,d)
#define STATUS(m) MPUFOI_READ(m, m->cookie, MPU_STATPORT)
#define READ(m) MPUFOI_READ(m, m->cookie, MPU_DATAPORT)
#define WRITE(m,d) MPUFOI_WRITE(m, m->cookie, MPU_DATAPORT,d)
struct mpu401 {
KOBJ_FIELDS;
struct snd_midi *mid;
int flags;
driver_intr_t *si;
void *cookie;
struct callout timer;
};
static void mpu401_timeout(void *m) ;
static mpu401_intr_t mpu401_intr;
static int mpu401_minit(kobj_t obj, struct mpu401 *m);
static int mpu401_muninit(kobj_t obj, struct mpu401 *m);
static int mpu401_minqsize(kobj_t obj, struct mpu401 *m);
static int mpu401_moutqsize(kobj_t obj, struct mpu401 *m);
static void mpu401_mcallback(kobj_t obj, struct mpu401 *m, int flags);
static void mpu401_mcallbackp(kobj_t obj, struct mpu401 *m, int flags);
static const char *mpu401_mdescr(kobj_t obj, struct mpu401 *m, int verbosity);
static const char *mpu401_mprovider(kobj_t obj, struct mpu401 *m);
static kobj_method_t mpu401_methods[] = {
KOBJMETHOD(mpu_init,mpu401_minit),
KOBJMETHOD(mpu_uninit,mpu401_muninit),
KOBJMETHOD(mpu_inqsize,mpu401_minqsize),
KOBJMETHOD(mpu_outqsize,mpu401_moutqsize),
KOBJMETHOD(mpu_callback,mpu401_mcallback),
KOBJMETHOD(mpu_callbackp,mpu401_mcallbackp),
KOBJMETHOD(mpu_descr,mpu401_mdescr),
KOBJMETHOD(mpu_provider,mpu401_mprovider),
{ 0, 0 }
};
DEFINE_CLASS(mpu401, mpu401_methods, 0);
void
mpu401_timeout(void *a)
{ struct mpu401 *m=(struct mpu401 *)a;
if (m->si)
(m->si)(m->cookie);
}
static int
mpu401_intr(struct mpu401 *m)
{
#define MPU_INTR_BUF 16
MIDI_TYPE b[MPU_INTR_BUF];
int i;
int s;
/*
printf("mpu401_intr\n");
*/
#define RXRDY(m) ( (STATUS(m) & MPU_INPUTBUSY) == 0)
#define TXRDY(m) ( (STATUS(m) & MPU_OUTPUTBUSY) == 0)
#if 0
#define D(x,l) printf("mpu401_intr %d %x %s %s\n",l, x, x&MPU_INPUTBUSY?"RX":"", x&MPU_OUTPUTBUSY?"TX":"")
#else
#define D(x,l)
#endif
i=0;
s = STATUS(m);
D(s,1);
while ( (s&MPU_INPUTBUSY) == 0 && i<MPU_INTR_BUF) {
b[i]=READ(m);
/*
printf("mpu401_intr in i %d d %d\n", i, b[i]);
*/
i++;
s = STATUS(m);
}
if (i) midi_in(m->mid, b, i);
i=0;
while ( !(s&MPU_OUTPUTBUSY) && i<MPU_INTR_BUF) {
if(midi_out(m->mid, b, 1)) {
/*
printf("mpu401_intr out i %d d %d\n", i, b[0]);
*/
WRITE(m, *b);
}
else {
/*
printf("mpu401_intr write: no output\n");
*/
return 0;
}
i++;
/* DELAY(100); */
s = STATUS(m);
}
if ((m->flags & M_TXEN) && (m->si) ) {
callout_reset(&m->timer, 1, mpu401_timeout, m);
}
return (m->flags & M_TXEN) == M_TXEN;
}
struct mpu401 *
mpu401_init(kobj_class_t cls, void *cookie,driver_intr_t softintr, mpu401_intr_t **cb)
{
struct mpu401 *m;
*cb = NULL;
m = malloc(sizeof(*m), M_MIDI, M_NOWAIT | M_ZERO);
if(!m)
return NULL;
kobj_init((kobj_t)m, cls);
callout_init(&m->timer, 1);
m->si = softintr;
m->cookie = cookie;
m->flags = 0;
m->mid = midi_init(&mpu401_class,0,0,m);
if (!m->mid)
goto err;
*cb = mpu401_intr;
return m;
err:
printf("mpu401_init error\n");
free(m, M_MIDI);
return NULL;
}
int
mpu401_uninit(struct mpu401 *m)
{
int retval;
CMD(m, MPU_RESET);
retval = midi_uninit(m->mid);
if (retval)
return retval;
free(m, M_MIDI);
return 0;
}
static int
mpu401_minit(kobj_t obj, struct mpu401 *m)
{
int i;
CMD(m, MPU_RESET);
CMD(m, MPU_UART);
return 0;
i=0;
while(++i<2000) {
if(RXRDY(m))
if(READ(m) == MPU_ACK)
break;
}
if( i < 2000 ) {
CMD(m, MPU_UART);
return 0;
}
printf("mpu401_minit failed active sensing\n");
return 1;
}
int
mpu401_muninit(kobj_t obj, struct mpu401 *m)
{
return MPUFOI_UNINIT(m, m->cookie);
}
int
mpu401_minqsize(kobj_t obj, struct mpu401 *m)
{
return 128;
}
int
mpu401_moutqsize(kobj_t obj, struct mpu401 *m)
{
return 128;
}
static void
mpu401_mcallback(kobj_t obj, struct mpu401 *m, int flags)
{
#if 0
printf("mpu401_callback %s %s %s %s\n",
flags & M_RX ? "M_RX" : "",
flags & M_TX ? "M_TX" : "",
flags & M_RXEN ? "M_RXEN" : "",
flags & M_TXEN ? "M_TXEN" : "" );
#endif
if (flags & M_TXEN && m->si) {
callout_reset(&m->timer, 1, mpu401_timeout, m);
}
m->flags = flags;
}
static void
mpu401_mcallbackp(kobj_t obj, struct mpu401 *m, int flags)
{
/* printf("mpu401_callbackp\n"); */
mpu401_mcallback(obj, m, flags);
}
static const char *
mpu401_mdescr(kobj_t obj, struct mpu401 *m, int verbosity)
{
return "descr mpu401";
}
static const char *
mpu401_mprovider(kobj_t obj, struct mpu401 *m)
{
return "provider mpu401";
}

View File

@ -0,0 +1,37 @@
/*-
* (c) 2003 Mathew Kanner
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. 2.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef MPU401_H
#define MPU401_H
struct mpu401;
typedef int mpu401_intr_t(struct mpu401 * _obj);
extern struct mpu401 *mpu401_init(kobj_class_t _cls, void *cookie,
driver_intr_t *_softintr,mpu401_intr_t **_cb);
extern int mpu401_uninit(struct mpu401 * _obj);
#endif

View File

@ -0,0 +1,72 @@
#-
# (c) 2003 Mathew Kanner
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer. 2.
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
#include <dev/sound/midi/midi.h>
INTERFACE mpu;
METHOD int inqsize{
struct snd_midi * _kobj;
void *_cookie;
};
METHOD int outqsize {
struct snd_midi * _kobj;
void *_cookie;
};
METHOD int init {
struct snd_midi * _kobj;
void *_cookie;
};
METHOD void callbackp {
struct snd_midi * _kobj;
void *_cookie;
int _flags;
};
METHOD void callback {
struct snd_midi * _kobj;
void *_cookie;
int _flags;
};
METHOD const char * provider{
struct snd_midi * _kobj;
void *_cookie;
};
METHOD const char * descr {
struct snd_midi * _kobj;
void *_cookie;
int _verbosity;
};
METHOD int uninit {
struct snd_midi * _kobj;
void *_cookie;
};

View File

@ -0,0 +1,48 @@
#-
# (c) 2003 Mathew Kanner
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer. 2.
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
#include <sys/bus.h>
#include <dev/sound/midi/mpu401.h>
INTERFACE mpufoi;
METHOD unsigned char read {
struct mpu401 *_kobj;
void *_cookie;
int _reg;
};
METHOD void write {
struct mpu401 *_kobj;
void *_cookie;
int _reg;
unsigned char _d;
};
METHOD int uninit {
struct mpu401 *_kobj;
void *_cookie;
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,85 @@
/*-
* Include file for midi sequencer driver.
* (c) 2003 Mathew Kanner
* Copyright by Seigo Tanimura 1999.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _SEQUENCER_H_
#define _SEQUENCER_H_
#define NSEQ_MAX 16
/*
* many variables should be reduced to a range. Here define a macro
*/
#define RANGE(var, low, high) (var) = \
((var)<(low)?(low) : (var)>(high)?(high) : (var))
#ifdef _KERNEL
void seq_timer(void *arg);
SYSCTL_DECL(_hw_midi_seq);
extern int seq_debug;
#define SEQ_DEBUG(y, x) \
do { \
if (seq_debug >= y) { \
(x); \
} \
} while(0)
SYSCTL_DECL(_hw_midi);
#endif /* _KERNEL */
#define SYNTHPROP_MIDI 1
#define SYNTHPROP_SYNTH 2
#define SYNTHPROP_RX 4
#define SYNTHPROP_TX 8
struct _midi_cmdtab {
int cmd;
char * name;
};
typedef struct _midi_cmdtab midi_cmdtab;
extern midi_cmdtab cmdtab_seqevent[];
extern midi_cmdtab cmdtab_seqioctl[];
extern midi_cmdtab cmdtab_timer[];
extern midi_cmdtab cmdtab_seqcv[];
extern midi_cmdtab cmdtab_seqccmn[];
char *midi_cmdname(int cmd, midi_cmdtab *tab);
enum {
MORE,
TIMERARMED,
QUEUEFULL
};
#endif

View File

@ -0,0 +1,311 @@
#-
# (c) 2003 Mathew Kanner
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer. 2.
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
INTERFACE synth;
#include <sys/systm.h>
CODE {
synth_killnote_t nokillnote;
synth_startnote_t nostartnote;
synth_setinstr_t nosetinstr;
synth_hwcontrol_t nohwcontrol;
synth_aftertouch_t noaftertouch;
synth_panning_t nopanning;
synth_controller_t nocontroller;
synth_volumemethod_t novolumemethod;
synth_bender_t nobender;
synth_setupvoice_t nosetupvoice;
synth_sendsysex_t nosendsysex;
synth_allocvoice_t noallocvoice;
synth_writeraw_t nowriteraw;
synth_reset_t noreset;
synth_shortname_t noshortname;
synth_open_t noopen;
synth_close_t noclose;
synth_query_t noquery;
synth_insync_t noinsync;
synth_alloc_t noalloc;
int
nokillnote(void *_kobj, uint8_t _chn, uint8_t _note, uint8_t _vel)
{
printf("nokillnote\n");
return 0;
}
int
noopen(void *_kobj, void *_arg, int mode)
{
printf("noopen\n");
return 0;
}
int
noquery(void *_kboj)
{
printf("noquery\n");
return 0;
}
int
nostartnote(void *_kb, uint8_t _voice, uint8_t _note, uint8_t _parm)
{
printf("nostartnote\n");
return 0;
}
int
nosetinstr(void *_kb, uint8_t _chn, uint16_t _patchno)
{
printf("nosetinstr\n");
return 0;
}
int
nohwcontrol(void *_kb, uint8_t *_event)
{
printf("nohwcontrol\n");
return 0;
}
int
noaftertouch ( void /* X */ * _kobj, uint8_t _x1, uint8_t _x2)
{
printf("noaftertouch\n");
return 0;
}
int
nopanning ( void /* X */ * _kobj, uint8_t _x1, uint8_t _x2)
{
printf("nopanning\n");
return 0;
}
int
nocontroller ( void /* X */ * _kobj, uint8_t _x1, uint8_t _x2, uint16_t _x3)
{
printf("nocontroller\n");
return 0;
}
int
novolumemethod (
void /* X */ * _kobj,
uint8_t _x1)
{
printf("novolumemethod\n");
return 0;
}
int
nobender ( void /* X */ * _kobj, uint8_t _voice, uint16_t _bend)
{
printf("nobender\n");
return 0;
}
int
nosetupvoice ( void /* X */ * _kobj, uint8_t _voice, uint8_t _chn)
{
printf("nosetupvoice\n");
return 0;
}
int
nosendsysex ( void /* X */ * _kobj, void * _buf, size_t _len)
{
printf("nosendsysex\n");
return 0;
}
int
noallocvoice ( void /* X */ * _kobj, uint8_t _chn, uint8_t _note, void *_x)
{
printf("noallocvoice\n");
return 0;
}
int
nowriteraw ( void /* X */ * _kobjt, uint8_t * _buf, size_t _len)
{
printf("nowriteraw\n");
return 1;
}
int
noreset ( void /* X */ * _kobjt)
{
printf("noreset\n");
return 0;
}
char *
noshortname (void /* X */ * _kobjt)
{
printf("noshortname\n");
return "noshortname";
}
int
noclose ( void /* X */ * _kobjt)
{
printf("noclose\n");
return 0;
}
int
noinsync (void /* X */ * _kobjt)
{
printf("noinsync\n");
return 0;
}
int
noalloc ( void /* x */ * _kbojt, uint8_t _chn, uint8_t _note)
{
printf("noalloc\n");
return 0;
}
}
METHOD int killnote {
void /* X */ * _kobj;
uint8_t _chan;
uint8_t _note;
uint8_t _vel;
} DEFAULT nokillnote;
METHOD int startnote {
void /* X */ * _kobj;
uint8_t _voice;
uint8_t _note;
uint8_t _parm;
} DEFAULT nostartnote;
METHOD int setinstr {
void /* X */ * _kobj;
uint8_t _chn;
uint16_t _patchno;
} DEFAULT nosetinstr;
METHOD int hwcontrol {
void /* X */ * _kobj;
uint8_t *_event;
} DEFAULT nohwcontrol;
METHOD int aftertouch {
void /* X */ * _kobj;
uint8_t _x1;
uint8_t _x2;
} DEFAULT noaftertouch;
METHOD int panning {
void /* X */ * _kobj;
uint8_t _x1;
uint8_t _x2;
} DEFAULT nopanning;
METHOD int controller {
void /* X */ * _kobj;
uint8_t _x1;
uint8_t _x2;
uint16_t _x3;
} DEFAULT nocontroller;
METHOD int volumemethod {
void /* X */ * _kobj;
uint8_t _x1;
} DEFAULT novolumemethod;
METHOD int bender {
void /* X */ * _kobj;
uint8_t _voice;
uint16_t _bend;
} DEFAULT nobender;
METHOD int setupvoice {
void /* X */ * _kobj;
uint8_t _voice;
uint8_t _chn;
} DEFAULT nosetupvoice;
METHOD int sendsysex {
void /* X */ * _kobj;
void * _buf;
size_t _len;
} DEFAULT nosendsysex;
METHOD int allocvoice {
void /* X */ * _kobj;
uint8_t _chn;
uint8_t _note;
void *_x;
} DEFAULT noallocvoice;
METHOD int writeraw {
void /* X */ * _kobjt;
uint8_t * _buf;
size_t _len;
} DEFAULT nowriteraw;
METHOD int reset {
void /* X */ * _kobjt;
} DEFAULT noreset;
METHOD char * shortname {
void /* X */ * _kobjt;
} DEFAULT noshortname;
METHOD int open {
void /* X */ * _kobjt;
void * _sythn;
int _mode;
} DEFAULT noopen;
METHOD int close {
void /* X */ * _kobjt;
} DEFAULT noclose;
METHOD int query {
void /* X */ * _kobjt;
} DEFAULT noquery;
METHOD int insync {
void /* X */ * _kobjt;
} DEFAULT noinsync;
METHOD int alloc {
void /* x */ * _kbojt;
uint8_t _chn;
uint8_t _note;
} DEFAULT noalloc;

View File

@ -4,6 +4,7 @@
KMOD= snd_cmi
SRCS= device_if.h bus_if.h pci_if.h
SRCS+= mpufoi_if.h
SRCS+= cmi.c
.include <bsd.kmod.mk>

View File

@ -5,6 +5,7 @@
KMOD= snd_emu10k1
SRCS= device_if.h bus_if.h pci_if.h emu10k1-alsa%diked.h
SRCS+= mpufoi_if.h
SRCS+= emu10k1.c
CLEANFILES+= emu10k1-alsa%diked.h

View File

@ -1,15 +1,19 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../../dev/sound/pcm
.PATH: ${.CURDIR}/../../../dev/sound/midi
.PATH: ${.CURDIR}/../../../dev/sound/isa
KMOD= sound
SRCS= device_if.h bus_if.h isa_if.h pci_if.h opt_isa.h
SRCS+= ac97_if.h channel_if.h feeder_if.h mixer_if.h
SRCS+= ac97_if.c channel_if.c feeder_if.c mixer_if.c
SRCS+= mpu_if.h mpufoi_if.h synth_if.h
SRCS+= mpu_if.c mpufoi_if.c synth_if.c
SRCS+= ac97.c ac97_patch.c buffer.c channel.c dsp.c
SRCS+= fake.c feeder.c feeder_fmt.c feeder_rate.c feeder_volume.c
SRCS+= mixer.c sndstat.c sound.c vchan.c
SRCS+= midi.c mpu401.c sequencer.c
EXPORT_SYMS= YES # XXX evaluate