patch courtesy of Greg Crain

* fix and enable midi support
* clean up of useless commented code

Greg added: "I even tested the driver, module and midi_server on Haiku ! It was
working, both input and output. Some midi programs don't run, and I
don't know if it is the midi_server or something else, but several apps
run fine.". Good work!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17627 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2006-05-29 12:12:49 +00:00
parent ef64b24102
commit b084f230d8
3 changed files with 22 additions and 40 deletions

View File

@ -1907,9 +1907,10 @@ emuxki_int(void *arg)
}
}
#if MIDI
if (ipr & (/*EMU_IPR_MIDITRANSBUFE | */EMU_IPR_MIDIRECVBUFE)) {
midi_interrupt(card);
if (ipr & (EMU_IPR_MIDIRECVBUFE)) {
midi_interrupt(card); /* Gameport */
}
if (ipr & (EMU_IPR_MIDITRANSBUFE)) {
if(!midi_interrupt(card)) {
emuxki_inte_disable(&card->config, EMU_INTE_MIDITXENABLE);
@ -2066,10 +2067,11 @@ emuxki_setup(emuxki_dev * card)
dump_hardware_regs(&card->config);
#if MIDI
if ((err = (*mpu401->create_device)(card->config.nabmbar + (IS_AUDIGY(&card->config) ? EMU_A_MUDATA1 : EMU_MUDATA),
&card->midi.driver, 0, midi_interrupt_op, &card->midi)) < B_OK)
//SBLIVE : EMU_MUDATA, workaround 0, AUDIGY, AUDIGY2: 0, workaround 0x11020004
if ((err = (*mpu401->create_device)((card->config.nabmbar + !IS_AUDIGY(&card->config) ? EMU_MUDATA : 0),
&card->midi.driver, !IS_AUDIGY(&card->config) ? 0 : 0x11020004, midi_interrupt_op, &card->midi)) < B_OK)
return (err);
card->midi.card = card;
#endif

View File

@ -55,7 +55,7 @@
#define CREATIVELABS_AUDIGY_DEVICE_ID 0x0004 /* Creative Labs Audigy and Audigy 2 */
#define AUDIGY 1 // Audigy seems to work
#define MIDI 0 // Midi is not supported for now
#define MIDI 1
#define VERSION "Version alpha 7, Copyright (c) 2002,2003 Jérôme Duval, compiled on " ## __DATE__ ## " " ## __TIME__
#define DRIVER_NAME "emuxki"

View File

@ -46,52 +46,32 @@ midi_interrupt_op(
int32 op,
void * data)
{
cpu_status status;
// dprint seems to be disabled here, will have to enable it to trace
midi_dev * port = (midi_dev *)data;
TRACE(("port = %p\n", port));
LOG(("mpu401:midi_interrupt_op %x\n",op));
LOG(("port = %p\n", port));
if (op == B_MPU_401_ENABLE_CARD_INT) {
// sample code
/*cpu_status cp;
ddprintf(("sonic_vibes: B_MPU_401_ENABLE_CARD_INT\n"));
cp = disable_interrupts();
acquire_spinlock(&port->card->hardware);
increment_interrupt_handler(port->card);
set_direct(port->card, 0x01, 0x00, 0x80);
set_indirect(port->card, 0x2A, 0x04, 0xff);
release_spinlock(&port->card->hardware);
restore_interrupts(cp);*/
//real code
cpu_status status;
/* turn on MPU interrupts */
LOG(("emuxki: B_MPU_401_ENABLE_CARD_INT\n"));
status = lock();
emuxki_reg_write_32(&(port->card->config), EMU_INTE,
emuxki_reg_read_32(&(port->card->config), EMU_INTE) |
EMU_INTE_MIDITXENABLE | EMU_INTE_MIDIRXENABLE );
emuxki_reg_read_32(&(port->card->config), EMU_INTE) | EMU_INTE_MIDIRXENABLE );
unlock(status);
LOG(("INTE address: %x\n",&port->card->config));
}
else if (op == B_MPU_401_DISABLE_CARD_INT) {
// sample code
/* turn off MPU interrupts */
/*cpu_status cp;
ddprintf(("sonic_vibes: B_MPU_401_DISABLE_CARD_INT\n"));
cp = disable_interrupts();
acquire_spinlock(&port->card->hardware);
set_direct(port->card, 0x01, 0x80, 0x80);*/
/* remove interrupt handler if necessary */
/*decrement_interrupt_handler(port->card);
release_spinlock(&port->card->hardware);
restore_interrupts(cp);*/
//real code
cpu_status status;
LOG(("emuxki: B_MPU_401_DISABLE_CARD_INT\n"));
status = lock();
emuxki_reg_write_32(&port->card->config, EMU_INTE,
emuxki_reg_read_32(&port->card->config, EMU_INTE) &
~ (EMU_INTE_MIDITXENABLE | EMU_INTE_MIDIRXENABLE ) );
emuxki_reg_read_32(&port->card->config, EMU_INTE) & ~ EMU_INTE_MIDIRXENABLE);
unlock(status);
}
TRACE(("midi_interrupt_op() done\n"));
LOG(("midi_interrupt_op() done\n"));
}
static status_t midi_open(const char *name, uint32 flags, void **cookie);
@ -217,7 +197,7 @@ midi_interrupt(emuxki_dev *card)
{
TRACE(("midi_interrupt\n"));
if (!card->midi.driver) {
// kprintf("aiigh\n");
dprintf("aiigh\n");
return false;
}