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