Skip to content

Commit 00a409b

Browse files
committed
sound/pci: Enable MIDI code in emu10kx.
NOTE: this depends on pull requests freebsd#1905 and freebsd#1892. MIDI code in emu10kx driver was disabled due to possible locking problems in MIDI core, which should have been corrected by freebsd#1905. Here, we also fixed that the card interrupts were enabled too early and disabled too late. This was tested under FreeBSD 15.0 using a SoundBlaster Audigy (chipset CA0100, I will also try one Audigy2). Signed-off-by: Nicolas Provost <dev@nicolas-provost.fr>
1 parent 57c0a33 commit 00a409b

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

sys/dev/sound/pci/emu10kx-midi.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,37 +173,34 @@ emu_midi_attach(device_t dev)
173173

174174
if (scp->is_emu10k1) {
175175
/* SB Live! - only one MIDI device here */
176-
inte_val = 0;
177-
/* inte_val |= EMU_INTE_MIDITXENABLE;*/
176+
inte_val = EMU_INTE_MIDITXENABLE;
178177
inte_val |= EMU_INTE_MIDIRXENABLE;
179178
ipr_val = EMU_IPR_MIDITRANSBUFE;
180179
ipr_val |= EMU_IPR_MIDIRECVBUFE;
181180
} else {
182181
if (scp->port == EMU_A_MUDATA1) {
183182
/* EXTERNAL MIDI (AudigyDrive) */
184-
inte_val = 0;
185-
/* inte_val |= A_EMU_INTE_MIDITXENABLE1;*/
183+
inte_val = EMU_INTE_MIDITXENABLE;
186184
inte_val |= EMU_INTE_MIDIRXENABLE;
187185
ipr_val = EMU_IPR_MIDITRANSBUFE;
188186
ipr_val |= EMU_IPR_MIDIRECVBUFE;
189187
} else {
190188
/* MIDI hw config port 2 */
191-
inte_val = 0;
192-
/* inte_val |= A_EMU_INTE_MIDITXENABLE2;*/
189+
inte_val = EMU_INTE_A_MIDITXENABLE2;
193190
inte_val |= EMU_INTE_A_MIDIRXENABLE2;
194191
ipr_val = EMU_IPR_A_MIDITRANSBUFE2;
195192
ipr_val |= EMU_IPR_A_MIDIRECBUFE2;
196193
}
197194
}
198195

199-
scp->ihandle = emu_intr_register(scp->card, inte_val, ipr_val, &emu_midi_card_intr, scp);
200196
/* Init the interface. */
201197
scp->mpu = mpu401_init(&emu_mpu_class, scp, emu_midi_intr, &scp->mpu_intr);
202198
if (scp->mpu == NULL) {
203199
emu_intr_unregister(scp->card, scp->ihandle);
204200
mtx_destroy(&scp->mtx);
205201
return (ENOMEM);
206202
}
203+
scp->ihandle = emu_intr_register(scp->card, inte_val, ipr_val, &emu_midi_card_intr, scp);
207204
/*
208205
* XXX I don't know how to check for Live!Drive / AudigyDrive
209206
* presence. Let's hope that IR enabling code will not harm if
@@ -225,8 +222,8 @@ emu_midi_detach(device_t dev)
225222
struct emu_midi_softc *scp;
226223

227224
scp = device_get_softc(dev);
228-
mpu401_uninit(scp->mpu);
229225
emu_intr_unregister(scp->card, scp->ihandle);
226+
mpu401_uninit(scp->mpu);
230227
mtx_destroy(&scp->mtx);
231228
return (0);
232229
}

sys/dev/sound/pci/emu10kx.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,9 +3007,8 @@ emu_pci_attach(device_t dev)
30073007
struct sndcard_func *func;
30083008
struct emu_sc_info *sc;
30093009
struct emu_pcminfo *pcminfo;
3010-
#if 0
30113010
struct emu_midiinfo *midiinfo;
3012-
#endif
3011+
30133012
int i;
30143013
int device_flags;
30153014
char status[255];
@@ -3283,8 +3282,6 @@ emu_pci_attach(device_t dev)
32833282
for (i = 0; i < 2; i++)
32843283
sc->midi[i] = NULL;
32853284

3286-
/* MIDI has some memory mangament and (possible) locking problems */
3287-
#if 0
32883285
/* Midi Interface 1: Live!, Audigy, Audigy 2 */
32893286
if ((sc->is_emu10k1) || (sc->is_emu10k2) || (sc->is_ca0102)) {
32903287
func = malloc(sizeof(struct sndcard_func), M_DEVBUF, M_WAITOK | M_ZERO);
@@ -3295,7 +3292,7 @@ emu_pci_attach(device_t dev)
32953292
midiinfo->portnr = 1;
32963293
}
32973294
if (sc->is_emu10k1) {
3298-
midiinfo->port = MUDATA;
3295+
midiinfo->port = EMU_MUDATA;
32993296
midiinfo->portnr = 1;
33003297
}
33013298
func->func = SCF_MIDI;
@@ -3317,7 +3314,6 @@ emu_pci_attach(device_t dev)
33173314
sc->midi[1] = device_add_child(dev, "midi", DEVICE_UNIT_ANY);
33183315
device_set_ivars(sc->midi[1], func);
33193316
}
3320-
#endif
33213317
bus_attach_children(dev);
33223318
return (0);
33233319

0 commit comments

Comments
 (0)