Lines Matching refs:gus

13 static void snd_gf1_interrupt_midi_in(struct snd_gus_card * gus)  in snd_gf1_interrupt_midi_in()  argument
22 spin_lock_irqsave(&gus->uart_cmd_lock, flags); in snd_gf1_interrupt_midi_in()
23 stat = snd_gf1_uart_stat(gus); in snd_gf1_interrupt_midi_in()
25 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_interrupt_midi_in()
30 data = snd_gf1_uart_get(gus); in snd_gf1_interrupt_midi_in()
31 if (!(gus->gf1.uart_cmd & 0x80)) { in snd_gf1_interrupt_midi_in()
32 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_interrupt_midi_in()
36 gus->gf1.uart_framing++; in snd_gf1_interrupt_midi_in()
37 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_interrupt_midi_in()
40 byte = snd_gf1_uart_get(gus); in snd_gf1_interrupt_midi_in()
41 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_interrupt_midi_in()
42 snd_rawmidi_receive(gus->midi_substream_input, &byte, 1); in snd_gf1_interrupt_midi_in()
44 gus->gf1.uart_overrun++; in snd_gf1_interrupt_midi_in()
49 static void snd_gf1_interrupt_midi_out(struct snd_gus_card * gus) in snd_gf1_interrupt_midi_out() argument
55 if (snd_gf1_uart_stat(gus) & 0x01) in snd_gf1_interrupt_midi_out()
56 snd_gf1_interrupt_midi_in(gus); in snd_gf1_interrupt_midi_out()
58 spin_lock_irqsave(&gus->uart_cmd_lock, flags); in snd_gf1_interrupt_midi_out()
59 if (snd_gf1_uart_stat(gus) & 0x02) { /* Tx FIFO free? */ in snd_gf1_interrupt_midi_out()
60 …if (snd_rawmidi_transmit(gus->midi_substream_output, &byte, 1) != 1) { /* no other bytes or error … in snd_gf1_interrupt_midi_out()
61 snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd & ~0x20); /* disable Tx interrupt */ in snd_gf1_interrupt_midi_out()
63 snd_gf1_uart_put(gus, byte); in snd_gf1_interrupt_midi_out()
66 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_interrupt_midi_out()
69 static void snd_gf1_uart_reset(struct snd_gus_card * gus, int close) in snd_gf1_uart_reset() argument
71 snd_gf1_uart_cmd(gus, 0x03); /* reset */ in snd_gf1_uart_reset()
72 if (!close && gus->uart_enable) { in snd_gf1_uart_reset()
74 snd_gf1_uart_cmd(gus, 0x00); /* normal operations */ in snd_gf1_uart_reset()
81 struct snd_gus_card *gus; in snd_gf1_uart_output_open() local
83 gus = substream->rmidi->private_data; in snd_gf1_uart_output_open()
84 spin_lock_irqsave(&gus->uart_cmd_lock, flags); in snd_gf1_uart_output_open()
85 if (!(gus->gf1.uart_cmd & 0x80)) { /* input active? */ in snd_gf1_uart_output_open()
86 snd_gf1_uart_reset(gus, 0); in snd_gf1_uart_output_open()
88 gus->gf1.interrupt_handler_midi_out = snd_gf1_interrupt_midi_out; in snd_gf1_uart_output_open()
89 gus->midi_substream_output = substream; in snd_gf1_uart_output_open()
90 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_uart_output_open()
92 …tk(KERN_DEBUG "write init - cmd = 0x%x, stat = 0x%x\n", gus->gf1.uart_cmd, snd_gf1_uart_stat(gus)); in snd_gf1_uart_output_open()
100 struct snd_gus_card *gus; in snd_gf1_uart_input_open() local
103 gus = substream->rmidi->private_data; in snd_gf1_uart_input_open()
104 spin_lock_irqsave(&gus->uart_cmd_lock, flags); in snd_gf1_uart_input_open()
105 if (gus->gf1.interrupt_handler_midi_out != snd_gf1_interrupt_midi_out) { in snd_gf1_uart_input_open()
106 snd_gf1_uart_reset(gus, 0); in snd_gf1_uart_input_open()
108 gus->gf1.interrupt_handler_midi_in = snd_gf1_interrupt_midi_in; in snd_gf1_uart_input_open()
109 gus->midi_substream_input = substream; in snd_gf1_uart_input_open()
110 if (gus->uart_enable) { in snd_gf1_uart_input_open()
111 for (i = 0; i < 1000 && (snd_gf1_uart_stat(gus) & 0x01); i++) in snd_gf1_uart_input_open()
112 snd_gf1_uart_get(gus); /* clean Rx */ in snd_gf1_uart_input_open()
116 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_uart_input_open()
120 gus->uart_enable, gus->gf1.uart_cmd, snd_gf1_uart_stat(gus)); in snd_gf1_uart_input_open()
124 gus->gf1.port + 0x100, inb(gus->gf1.port + 0x100), in snd_gf1_uart_input_open()
125 inb(gus->gf1.port + 0x101), inb(gus->gf1.port + 0x102)); in snd_gf1_uart_input_open()
133 struct snd_gus_card *gus; in snd_gf1_uart_output_close() local
135 gus = substream->rmidi->private_data; in snd_gf1_uart_output_close()
136 spin_lock_irqsave(&gus->uart_cmd_lock, flags); in snd_gf1_uart_output_close()
137 if (gus->gf1.interrupt_handler_midi_in != snd_gf1_interrupt_midi_in) in snd_gf1_uart_output_close()
138 snd_gf1_uart_reset(gus, 1); in snd_gf1_uart_output_close()
139 snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_MIDI_OUT); in snd_gf1_uart_output_close()
140 gus->midi_substream_output = NULL; in snd_gf1_uart_output_close()
141 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_uart_output_close()
148 struct snd_gus_card *gus; in snd_gf1_uart_input_close() local
150 gus = substream->rmidi->private_data; in snd_gf1_uart_input_close()
151 spin_lock_irqsave(&gus->uart_cmd_lock, flags); in snd_gf1_uart_input_close()
152 if (gus->gf1.interrupt_handler_midi_out != snd_gf1_interrupt_midi_out) in snd_gf1_uart_input_close()
153 snd_gf1_uart_reset(gus, 1); in snd_gf1_uart_input_close()
154 snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_MIDI_IN); in snd_gf1_uart_input_close()
155 gus->midi_substream_input = NULL; in snd_gf1_uart_input_close()
156 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_uart_input_close()
162 struct snd_gus_card *gus; in snd_gf1_uart_input_trigger() local
165 gus = substream->rmidi->private_data; in snd_gf1_uart_input_trigger()
167 spin_lock_irqsave(&gus->uart_cmd_lock, flags); in snd_gf1_uart_input_trigger()
169 if ((gus->gf1.uart_cmd & 0x80) == 0) in snd_gf1_uart_input_trigger()
170 snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd | 0x80); /* enable Rx interrupts */ in snd_gf1_uart_input_trigger()
172 if (gus->gf1.uart_cmd & 0x80) in snd_gf1_uart_input_trigger()
173 snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd & ~0x80); /* disable Rx interrupts */ in snd_gf1_uart_input_trigger()
175 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_uart_input_trigger()
181 struct snd_gus_card *gus; in snd_gf1_uart_output_trigger() local
185 gus = substream->rmidi->private_data; in snd_gf1_uart_output_trigger()
187 spin_lock_irqsave(&gus->uart_cmd_lock, flags); in snd_gf1_uart_output_trigger()
189 if ((gus->gf1.uart_cmd & 0x20) == 0) { in snd_gf1_uart_output_trigger()
190 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_uart_output_trigger()
193 while (timeout-- > 0 && snd_gf1_uart_stat(gus) & 0x01); in snd_gf1_uart_output_trigger()
195 spin_lock_irqsave(&gus->uart_cmd_lock, flags); in snd_gf1_uart_output_trigger()
196 if (gus->gf1.uart_cmd & 0x20) { in snd_gf1_uart_output_trigger()
197 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_uart_output_trigger()
200 if (snd_gf1_uart_stat(gus) & 0x02) { in snd_gf1_uart_output_trigger()
202 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_uart_output_trigger()
205 snd_gf1_uart_put(gus, byte); in snd_gf1_uart_output_trigger()
207 snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd | 0x20); /* enable Tx interrupt */ in snd_gf1_uart_output_trigger()
210 if (gus->gf1.uart_cmd & 0x20) in snd_gf1_uart_output_trigger()
211 snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd & ~0x20); in snd_gf1_uart_output_trigger()
213 spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); in snd_gf1_uart_output_trigger()
230 int snd_gf1_rawmidi_new(struct snd_gus_card *gus, int device) in snd_gf1_rawmidi_new() argument
235 err = snd_rawmidi_new(gus->card, "GF1", device, 1, 1, &rmidi); in snd_gf1_rawmidi_new()
238 strcpy(rmidi->name, gus->interwave ? "AMD InterWave" : "GF1"); in snd_gf1_rawmidi_new()
242 rmidi->private_data = gus; in snd_gf1_rawmidi_new()
243 gus->midi_uart = rmidi; in snd_gf1_rawmidi_new()