This source file includes following definitions.
- sb_midi_open
- sb_midi_close
- sb_midi_out
- sb_midi_start_read
- sb_midi_end_read
- sb_midi_ioctl
- sb_midi_interrupt
- sb_midi_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 #include "sound_config.h"
31
32 #if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_SB) && !defined(EXCLUDE_MIDI)
33
34 #include "sb.h"
35 #undef SB_TEST_IRQ
36
37
38
39
40
41
42
43
44
45 extern int sb_dsp_ok;
46 extern int sbc_base;
47
48 extern int sb_midi_mode;
49 extern int sb_midi_busy;
50
51
52
53
54
55 extern int sb_dsp_busy;
56 extern int sb_dsp_highspeed;
57
58 extern volatile int sb_irq_mode;
59 extern int sb_duplex_midi;
60 extern int sb_intr_active;
61 int input_opened = 0;
62 static int my_dev;
63
64 void (*midi_input_intr) (int dev, unsigned char data);
65
66 static int
67 sb_midi_open (int dev, int mode,
68 void (*input) (int dev, unsigned char data),
69 void (*output) (int dev)
70 )
71 {
72 int ret;
73
74 if (!sb_dsp_ok)
75 {
76 printk ("SB Error: MIDI hardware not installed\n");
77 return RET_ERROR (ENXIO);
78 }
79
80 if (sb_midi_busy)
81 return RET_ERROR (EBUSY);
82
83 if (mode != OPEN_WRITE && !sb_duplex_midi)
84 {
85 if (num_midis == 1)
86 printk ("SoundBlaster: Midi input not currently supported\n");
87 return RET_ERROR (EPERM);
88 }
89
90 sb_midi_mode = NORMAL_MIDI;
91 if (mode != OPEN_WRITE)
92 {
93 if (sb_dsp_busy || sb_intr_active)
94 return RET_ERROR (EBUSY);
95 sb_midi_mode = UART_MIDI;
96 }
97
98 if (sb_dsp_highspeed)
99 {
100 printk ("SB Error: Midi output not possible during stereo or high speed audio\n");
101 return RET_ERROR (EBUSY);
102 }
103
104 if (sb_midi_mode == UART_MIDI)
105 {
106 sb_irq_mode = IMODE_MIDI;
107
108 sb_reset_dsp ();
109
110 if (!sb_dsp_command (0x35))
111 return RET_ERROR (EIO);
112
113
114 sb_intr_active = 1;
115
116 if ((ret = sb_get_irq ()) < 0)
117 {
118 sb_reset_dsp ();
119 return 0;
120
121
122 }
123 input_opened = 1;
124 midi_input_intr = input;
125 }
126
127 sb_midi_busy = 1;
128
129 return 0;
130 }
131
132 static void
133 sb_midi_close (int dev)
134 {
135 if (sb_midi_mode == UART_MIDI)
136 {
137 sb_reset_dsp ();
138
139
140 sb_free_irq ();
141 }
142 sb_intr_active = 0;
143 sb_midi_busy = 0;
144 input_opened = 0;
145 }
146
147 static int
148 sb_midi_out (int dev, unsigned char midi_byte)
149 {
150 unsigned long flags;
151
152 if (sb_midi_mode == NORMAL_MIDI)
153 {
154 DISABLE_INTR (flags);
155 if (sb_dsp_command (0x38))
156 sb_dsp_command (midi_byte);
157 else
158 printk ("SB Error: Unable to send a MIDI byte\n");
159 RESTORE_INTR (flags);
160 }
161 else
162 sb_dsp_command (midi_byte);
163
164
165
166 return 1;
167 }
168
169 static int
170 sb_midi_start_read (int dev)
171 {
172 if (sb_midi_mode != UART_MIDI)
173 {
174 printk ("SoundBlaster: MIDI input not implemented.\n");
175 return RET_ERROR (EPERM);
176 }
177 return 0;
178 }
179
180 static int
181 sb_midi_end_read (int dev)
182 {
183 if (sb_midi_mode == UART_MIDI)
184 {
185 sb_reset_dsp ();
186 sb_intr_active = 0;
187 }
188 return 0;
189 }
190
191 static int
192 sb_midi_ioctl (int dev, unsigned cmd, unsigned arg)
193 {
194 return RET_ERROR (EPERM);
195 }
196
197 void
198 sb_midi_interrupt (int dummy)
199 {
200 unsigned long flags;
201 unsigned char data;
202
203 DISABLE_INTR (flags);
204
205 data = INB (DSP_READ);
206 if (input_opened)
207 midi_input_intr (my_dev, data);
208
209 RESTORE_INTR (flags);
210 }
211
212 #define MIDI_SYNTH_NAME "SoundBlaster Midi"
213 #define MIDI_SYNTH_CAPS 0
214 #include "midi_synth.h"
215
216 static struct midi_operations sb_midi_operations =
217 {
218 {"SoundBlaster", 0, 0, SNDCARD_SB},
219 &std_midi_synth,
220 {0},
221 sb_midi_open,
222 sb_midi_close,
223 sb_midi_ioctl,
224 sb_midi_out,
225 sb_midi_start_read,
226 sb_midi_end_read,
227 NULL,
228
229
230 NULL,
231
232
233 NULL,
234
235
236 NULL
237 };
238
239 void
240 sb_midi_init (int model)
241 {
242 if (num_midis >= MAX_MIDI_DEV)
243 {
244 printk ("Sound: Too many midi devices detected\n");
245 return;
246 }
247
248 std_midi_synth.midi_dev = num_midis;
249 my_dev = num_midis;
250 midi_devs[num_midis++] = &sb_midi_operations;
251 }
252
253 #endif