aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/au88x0/au88x0_mpu401.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /sound/pci/au88x0/au88x0_mpu401.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'sound/pci/au88x0/au88x0_mpu401.c')
-rw-r--r--sound/pci/au88x0/au88x0_mpu401.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/sound/pci/au88x0/au88x0_mpu401.c b/sound/pci/au88x0/au88x0_mpu401.c
new file mode 100644
index 000000000000..c0c23466eb0e
--- /dev/null
+++ b/sound/pci/au88x0/au88x0_mpu401.c
@@ -0,0 +1,112 @@
1/*
2 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
3 * Routines for control of MPU-401 in UART mode
4 *
5 * Modified for the Aureal Vortex based Soundcards
6 * by Manuel Jander (mjande@embedded.cl).
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <sound/driver.h>
25#include <linux/time.h>
26#include <linux/init.h>
27#include <sound/core.h>
28#include <sound/mpu401.h>
29#include "au88x0.h"
30
31/* Check for mpu401 mmio support. */
32/* MPU401 legacy support is only provided as a emergency fallback *
33 * for older versions of ALSA. Its usage is strongly discouraged. */
34#ifndef MPU401_HW_AUREAL
35#define VORTEX_MPU401_LEGACY
36#endif
37
38/* Vortex MPU401 defines. */
39#define MIDI_CLOCK_DIV 0x61
40/* Standart MPU401 defines. */
41#define MPU401_RESET 0xff
42#define MPU401_ENTER_UART 0x3f
43#define MPU401_ACK 0xfe
44
45static int __devinit snd_vortex_midi(vortex_t * vortex)
46{
47 snd_rawmidi_t *rmidi;
48 int temp, mode;
49 mpu401_t *mpu;
50 int port;
51
52#ifdef VORTEX_MPU401_LEGACY
53 /* EnableHardCodedMPU401Port() */
54 /* Enable Legacy MIDI Interface port. */
55 port = (0x03 << 5); /* FIXME: static address. 0x330 */
56 temp =
57 (hwread(vortex->mmio, VORTEX_CTRL) & ~CTRL_MIDI_PORT) |
58 CTRL_MIDI_EN | port;
59 hwwrite(vortex->mmio, VORTEX_CTRL, temp);
60#else
61 /* Disable Legacy MIDI Interface port. */
62 temp =
63 (hwread(vortex->mmio, VORTEX_CTRL) & ~CTRL_MIDI_PORT) &
64 ~CTRL_MIDI_EN;
65 hwwrite(vortex->mmio, VORTEX_CTRL, temp);
66#endif
67 /* Mpu401UartInit() */
68 mode = 1;
69 temp = hwread(vortex->mmio, VORTEX_CTRL2) & 0xffff00cf;
70 temp |= (MIDI_CLOCK_DIV << 8) | ((mode >> 24) & 0xff) << 4;
71 hwwrite(vortex->mmio, VORTEX_CTRL2, temp);
72 hwwrite(vortex->mmio, VORTEX_MIDI_CMD, MPU401_RESET);
73 /* Set some kind of mode */
74 if (mode)
75 hwwrite(vortex->mmio, VORTEX_MIDI_CMD, MPU401_ENTER_UART);
76
77 /* Check if anything is OK. */
78 temp = hwread(vortex->mmio, VORTEX_MIDI_DATA);
79 if (temp != MPU401_ACK /*0xfe */ ) {
80 printk(KERN_ERR "midi port doesn't acknowledge!\n");
81 return -ENODEV;
82 }
83 /* Enable MPU401 interrupts. */
84 hwwrite(vortex->mmio, VORTEX_IRQ_CTRL,
85 hwread(vortex->mmio, VORTEX_IRQ_CTRL) | IRQ_MIDI);
86
87 /* Create MPU401 instance. */
88#ifdef VORTEX_MPU401_LEGACY
89 if ((temp =
90 snd_mpu401_uart_new(vortex->card, 0, MPU401_HW_MPU401, 0x330,
91 0, 0, 0, &rmidi)) != 0) {
92 hwwrite(vortex->mmio, VORTEX_CTRL,
93 (hwread(vortex->mmio, VORTEX_CTRL) &
94 ~CTRL_MIDI_PORT) & ~CTRL_MIDI_EN);
95 return temp;
96 }
97#else
98 port = (unsigned long)(vortex->mmio + (VORTEX_MIDI_DATA >> 2));
99 if ((temp =
100 snd_mpu401_uart_new(vortex->card, 0, MPU401_HW_AUREAL, port,
101 1, 0, 0, &rmidi)) != 0) {
102 hwwrite(vortex->mmio, VORTEX_CTRL,
103 (hwread(vortex->mmio, VORTEX_CTRL) &
104 ~CTRL_MIDI_PORT) & ~CTRL_MIDI_EN);
105 return temp;
106 }
107 mpu = rmidi->private_data;
108 mpu->cport = (unsigned long)(vortex->mmio + (VORTEX_MIDI_CMD >> 2));
109#endif
110 vortex->rmidi = rmidi;
111 return 0;
112}