123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- #include <linux/time.h>
- #include <linux/init.h>
- #include <sound/core.h>
- #include <sound/mpu401.h>
- #include "au88x0.h"
- #ifndef MPU401_HW_AUREAL
- #define VORTEX_MPU401_LEGACY
- #endif
- #define MIDI_CLOCK_DIV 0x61
- #define MPU401_RESET 0xff
- #define MPU401_ENTER_UART 0x3f
- #define MPU401_ACK 0xfe
- static int snd_vortex_midi(vortex_t *vortex)
- {
- struct snd_rawmidi *rmidi;
- int temp, mode;
- struct snd_mpu401 *mpu;
- unsigned long port;
- #ifdef VORTEX_MPU401_LEGACY
-
-
- port = (0x03 << 5);
- temp =
- (hwread(vortex->mmio, VORTEX_CTRL) & ~CTRL_MIDI_PORT) |
- CTRL_MIDI_EN | port;
- hwwrite(vortex->mmio, VORTEX_CTRL, temp);
- #else
-
- temp =
- (hwread(vortex->mmio, VORTEX_CTRL) & ~CTRL_MIDI_PORT) &
- ~CTRL_MIDI_EN;
- hwwrite(vortex->mmio, VORTEX_CTRL, temp);
- #endif
-
- mode = 1;
- temp = hwread(vortex->mmio, VORTEX_CTRL2) & 0xffff00cf;
- temp |= (MIDI_CLOCK_DIV << 8) | ((mode >> 24) & 0xff) << 4;
- hwwrite(vortex->mmio, VORTEX_CTRL2, temp);
- hwwrite(vortex->mmio, VORTEX_MIDI_CMD, MPU401_RESET);
-
- temp = hwread(vortex->mmio, VORTEX_MIDI_DATA);
- if (temp != MPU401_ACK ) {
- dev_err(vortex->card->dev, "midi port doesn't acknowledge!\n");
- return -ENODEV;
- }
-
- hwwrite(vortex->mmio, VORTEX_IRQ_CTRL,
- hwread(vortex->mmio, VORTEX_IRQ_CTRL) | IRQ_MIDI);
-
- #ifdef VORTEX_MPU401_LEGACY
- if ((temp =
- snd_mpu401_uart_new(vortex->card, 0, MPU401_HW_MPU401, 0x330,
- MPU401_INFO_IRQ_HOOK, -1, &rmidi)) != 0) {
- hwwrite(vortex->mmio, VORTEX_CTRL,
- (hwread(vortex->mmio, VORTEX_CTRL) &
- ~CTRL_MIDI_PORT) & ~CTRL_MIDI_EN);
- return temp;
- }
- #else
- port = (unsigned long)(vortex->mmio + VORTEX_MIDI_DATA);
- if ((temp =
- snd_mpu401_uart_new(vortex->card, 0, MPU401_HW_AUREAL, port,
- MPU401_INFO_INTEGRATED | MPU401_INFO_MMIO |
- MPU401_INFO_IRQ_HOOK, -1, &rmidi)) != 0) {
- hwwrite(vortex->mmio, VORTEX_CTRL,
- (hwread(vortex->mmio, VORTEX_CTRL) &
- ~CTRL_MIDI_PORT) & ~CTRL_MIDI_EN);
- return temp;
- }
- mpu = rmidi->private_data;
- mpu->cport = (unsigned long)(vortex->mmio + VORTEX_MIDI_CMD);
- #endif
-
- snprintf(rmidi->name, sizeof(rmidi->name), "%s MIDI %d", CARD_NAME_SHORT , vortex->card->number);
- vortex->rmidi = rmidi;
- return 0;
- }
|