23 #include <linux/slab.h>
34 spin_unlock_irqrestore(&gus->
reg_lock, flags);
37 static void snd_gf1_dma_program(
struct snd_gus_card * gus,
45 unsigned char dma_cmd;
46 unsigned int address_high;
48 snd_printdd(
"dma_transfer: addr=0x%x, buf=0x%lx, count=0x%x\n",
49 addr, buf_addr, count);
51 if (gus->
gf1.dma1 > 3) {
52 if (gus->
gf1.enh_mode) {
56 snd_printd(
"snd_gf1_dma_transfer: unaligned address (0x%x)?\n", addr);
59 address = (addr & 0x000c0000) | ((addr & 0x0003ffff) >> 1);
73 if (gus->
gf1.dma1 > 3) {
82 address << 1, count, dma_cmd);
85 if (gus->
gf1.enh_mode) {
86 address_high = ((address >> 16) & 0x000000f0) | (address & 0x0000000f);
92 spin_unlock_irqrestore(&gus->
reg_lock, flags);
100 if (gus->
gf1.dma_data_pcm) {
101 block = gus->
gf1.dma_data_pcm;
102 if (gus->
gf1.dma_data_pcm_last == block) {
103 gus->
gf1.dma_data_pcm =
104 gus->
gf1.dma_data_pcm_last =
NULL;
106 gus->
gf1.dma_data_pcm = block->
next;
108 }
else if (gus->
gf1.dma_data_synth) {
109 block = gus->
gf1.dma_data_synth;
110 if (gus->
gf1.dma_data_synth_last == block) {
111 gus->
gf1.dma_data_synth =
112 gus->
gf1.dma_data_synth_last =
NULL;
114 gus->
gf1.dma_data_synth = block->
next;
120 gus->
gf1.dma_ack = block->
ack;
127 static void snd_gf1_dma_interrupt(
struct snd_gus_card * gus)
131 snd_gf1_dma_ack(gus);
132 if (gus->
gf1.dma_ack)
133 gus->
gf1.dma_ack(gus, gus->
gf1.dma_private_data);
135 if (gus->
gf1.dma_data_pcm ==
NULL &&
136 gus->
gf1.dma_data_synth ==
NULL) {
142 block = snd_gf1_dma_next_block(gus);
144 snd_gf1_dma_program(gus, block->
addr, block->
buf_addr, block->
count, (
unsigned short) block->
cmd);
148 "addr = 0x%x, buffer = 0x%lx, count = 0x%x, cmd = 0x%x\n",
156 gus->
gf1.dma_shared++;
157 if (gus->
gf1.dma_shared > 1) {
161 gus->
gf1.interrupt_handler_dma_write = snd_gf1_dma_interrupt;
162 gus->
gf1.dma_data_pcm =
163 gus->
gf1.dma_data_pcm_last =
164 gus->
gf1.dma_data_synth =
165 gus->
gf1.dma_data_synth_last =
NULL;
175 gus->
gf1.dma_shared--;
176 if (!gus->
gf1.dma_shared) {
179 snd_gf1_dma_ack(gus);
180 while ((block = gus->
gf1.dma_data_pcm)) {
181 gus->
gf1.dma_data_pcm = block->
next;
184 while ((block = gus->
gf1.dma_data_synth)) {
185 gus->
gf1.dma_data_synth = block->
next;
188 gus->
gf1.dma_data_pcm_last =
189 gus->
gf1.dma_data_synth_last =
NULL;
211 snd_printdd(
"addr = 0x%x, buffer = 0x%lx, count = 0x%x, cmd = 0x%x\n",
215 snd_printdd(
"gus->gf1.dma_data_pcm_last = 0x%lx\n",
216 (
long)gus->
gf1.dma_data_pcm_last);
218 (
long)gus->
gf1.dma_data_pcm);
222 if (gus->
gf1.dma_data_synth_last) {
223 gus->
gf1.dma_data_synth_last->next =
block;
224 gus->
gf1.dma_data_synth_last =
block;
226 gus->
gf1.dma_data_synth =
227 gus->
gf1.dma_data_synth_last =
block;
230 if (gus->
gf1.dma_data_pcm_last) {
231 gus->
gf1.dma_data_pcm_last->next =
block;
234 gus->
gf1.dma_data_pcm =
240 block = snd_gf1_dma_next_block(gus);
241 spin_unlock_irqrestore(&gus->
dma_lock, flags);
244 snd_gf1_dma_program(gus, block->
addr, block->
buf_addr, block->
count, (
unsigned short) block->
cmd);
248 spin_unlock_irqrestore(&gus->
dma_lock, flags);