Lines Matching refs:gus
23 static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches);
25 int snd_gus_use_inc(struct snd_gus_card * gus) in snd_gus_use_inc() argument
27 if (!try_module_get(gus->card->module)) in snd_gus_use_inc()
32 void snd_gus_use_dec(struct snd_gus_card * gus) in snd_gus_use_dec() argument
34 module_put(gus->card->module); in snd_gus_use_dec()
48 struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); in snd_gus_joystick_get() local
50 ucontrol->value.integer.value[0] = gus->joystick_dac & 31; in snd_gus_joystick_get()
56 struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); in snd_gus_joystick_put() local
62 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gus_joystick_put()
63 change = gus->joystick_dac != nval; in snd_gus_joystick_put()
64 gus->joystick_dac = nval; in snd_gus_joystick_put()
65 snd_gf1_write8(gus, SNDRV_GF1_GB_JOYSTICK_DAC_LEVEL, gus->joystick_dac); in snd_gus_joystick_put()
66 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gus_joystick_put()
78 static void snd_gus_init_control(struct snd_gus_card *gus) in snd_gus_init_control() argument
80 if (!gus->ace_flag) in snd_gus_init_control()
81 snd_ctl_add(gus->card, snd_ctl_new1(&snd_gus_joystick_control, gus)); in snd_gus_init_control()
88 static int snd_gus_free(struct snd_gus_card *gus) in snd_gus_free() argument
90 if (gus->gf1.res_port2 == NULL) in snd_gus_free()
92 snd_gf1_stop(gus); in snd_gus_free()
93 snd_gus_init_dma_irq(gus, 0); in snd_gus_free()
95 release_and_free_resource(gus->gf1.res_port1); in snd_gus_free()
96 release_and_free_resource(gus->gf1.res_port2); in snd_gus_free()
97 if (gus->gf1.irq >= 0) in snd_gus_free()
98 free_irq(gus->gf1.irq, (void *) gus); in snd_gus_free()
99 if (gus->gf1.dma1 >= 0) { in snd_gus_free()
100 disable_dma(gus->gf1.dma1); in snd_gus_free()
101 free_dma(gus->gf1.dma1); in snd_gus_free()
103 if (!gus->equal_dma && gus->gf1.dma2 >= 0) { in snd_gus_free()
104 disable_dma(gus->gf1.dma2); in snd_gus_free()
105 free_dma(gus->gf1.dma2); in snd_gus_free()
107 kfree(gus); in snd_gus_free()
113 struct snd_gus_card *gus = device->device_data; in snd_gus_dev_free() local
114 return snd_gus_free(gus); in snd_gus_dev_free()
126 struct snd_gus_card *gus; in snd_gus_create() local
133 gus = kzalloc(sizeof(*gus), GFP_KERNEL); in snd_gus_create()
134 if (gus == NULL) in snd_gus_create()
136 spin_lock_init(&gus->reg_lock); in snd_gus_create()
137 spin_lock_init(&gus->voice_alloc); in snd_gus_create()
138 spin_lock_init(&gus->active_voice_lock); in snd_gus_create()
139 spin_lock_init(&gus->event_lock); in snd_gus_create()
140 spin_lock_init(&gus->dma_lock); in snd_gus_create()
141 spin_lock_init(&gus->pcm_volume_level_lock); in snd_gus_create()
142 spin_lock_init(&gus->uart_cmd_lock); in snd_gus_create()
143 mutex_init(&gus->dma_mutex); in snd_gus_create()
144 gus->gf1.irq = -1; in snd_gus_create()
145 gus->gf1.dma1 = -1; in snd_gus_create()
146 gus->gf1.dma2 = -1; in snd_gus_create()
147 gus->card = card; in snd_gus_create()
148 gus->gf1.port = port; in snd_gus_create()
150 gus->gf1.reg_page = GUSP(gus, GF1PAGE); in snd_gus_create()
151 gus->gf1.reg_regsel = GUSP(gus, GF1REGSEL); in snd_gus_create()
152 gus->gf1.reg_data8 = GUSP(gus, GF1DATAHIGH); in snd_gus_create()
153 gus->gf1.reg_data16 = GUSP(gus, GF1DATALOW); in snd_gus_create()
154 gus->gf1.reg_irqstat = GUSP(gus, IRQSTAT); in snd_gus_create()
155 gus->gf1.reg_dram = GUSP(gus, DRAM); in snd_gus_create()
156 gus->gf1.reg_timerctrl = GUSP(gus, TIMERCNTRL); in snd_gus_create()
157 gus->gf1.reg_timerdata = GUSP(gus, TIMERDATA); in snd_gus_create()
159 gus->gf1.res_port1 = request_region(port, 16, "GUS GF1 (Adlib/SB)"); in snd_gus_create()
160 if (!gus->gf1.res_port1) { in snd_gus_create()
162 snd_gus_free(gus); in snd_gus_create()
165 gus->gf1.res_port2 = request_region(port + 0x100, 12, "GUS GF1 (Synth)"); in snd_gus_create()
166 if (!gus->gf1.res_port2) { in snd_gus_create()
168 snd_gus_free(gus); in snd_gus_create()
171 if (irq >= 0 && request_irq(irq, snd_gus_interrupt, 0, "GUS GF1", (void *) gus)) { in snd_gus_create()
173 snd_gus_free(gus); in snd_gus_create()
176 gus->gf1.irq = irq; in snd_gus_create()
180 snd_gus_free(gus); in snd_gus_create()
183 gus->gf1.dma1 = dma1; in snd_gus_create()
187 snd_gus_free(gus); in snd_gus_create()
190 gus->gf1.dma2 = dma2; in snd_gus_create()
192 gus->gf1.dma2 = gus->gf1.dma1; in snd_gus_create()
193 gus->equal_dma = 1; in snd_gus_create()
195 gus->timer_dev = timer_dev; in snd_gus_create()
206 gus->gf1.effect = effect ? 1 : 0; in snd_gus_create()
207 gus->gf1.active_voices = voices; in snd_gus_create()
208 gus->gf1.pcm_channels = pcm_channels; in snd_gus_create()
209 gus->gf1.volume_ramp = 25; in snd_gus_create()
210 gus->gf1.smooth_pan = 1; in snd_gus_create()
211 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, gus, &ops); in snd_gus_create()
213 snd_gus_free(gus); in snd_gus_create()
216 *rgus = gus; in snd_gus_create()
224 static int snd_gus_detect_memory(struct snd_gus_card * gus) in snd_gus_detect_memory() argument
229 snd_gf1_poke(gus, 0L, 0xaa); in snd_gus_detect_memory()
230 snd_gf1_poke(gus, 1L, 0x55); in snd_gus_detect_memory()
231 if (snd_gf1_peek(gus, 0L) != 0xaa || snd_gf1_peek(gus, 1L) != 0x55) { in snd_gus_detect_memory()
232 snd_printk(KERN_ERR "plain GF1 card at 0x%lx without onboard DRAM?\n", gus->gf1.port); in snd_gus_detect_memory()
237 snd_gf1_poke(gus, local, d); in snd_gus_detect_memory()
238 snd_gf1_poke(gus, local + 1, d + 1); in snd_gus_detect_memory()
239 if (snd_gf1_peek(gus, local) != d || in snd_gus_detect_memory()
240 snd_gf1_peek(gus, local + 1) != d + 1 || in snd_gus_detect_memory()
241 snd_gf1_peek(gus, 0L) != 0xaa) in snd_gus_detect_memory()
245 gus->gf1.memory = idx << 18; in snd_gus_detect_memory()
247 gus->gf1.memory = 256 * 1024; in snd_gus_detect_memory()
249 for (l = 0, local = gus->gf1.memory; l < 4; l++, local -= 256 * 1024) { in snd_gus_detect_memory()
250 gus->gf1.mem_alloc.banks_8[l].address = in snd_gus_detect_memory()
251 gus->gf1.mem_alloc.banks_8[l].size = 0; in snd_gus_detect_memory()
252 gus->gf1.mem_alloc.banks_16[l].address = l << 18; in snd_gus_detect_memory()
253 gus->gf1.mem_alloc.banks_16[l].size = local > 0 ? 256 * 1024 : 0; in snd_gus_detect_memory()
255 gus->gf1.mem_alloc.banks_8[0].size = gus->gf1.memory; in snd_gus_detect_memory()
259 static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches) in snd_gus_init_dma_irq() argument
269 if (snd_BUG_ON(!gus)) in snd_gus_init_dma_irq()
271 card = gus->card; in snd_gus_init_dma_irq()
275 gus->mix_cntrl_reg &= 0xf8; in snd_gus_init_dma_irq()
276 gus->mix_cntrl_reg |= 0x01; /* disable MIC, LINE IN, enable LINE OUT */ in snd_gus_init_dma_irq()
277 if (gus->codec_flag || gus->ess_flag) { in snd_gus_init_dma_irq()
278 gus->mix_cntrl_reg &= ~1; /* enable LINE IN */ in snd_gus_init_dma_irq()
279 gus->mix_cntrl_reg |= 4; /* enable MIC */ in snd_gus_init_dma_irq()
281 dma1 = gus->gf1.dma1; in snd_gus_init_dma_irq()
284 dma2 = gus->gf1.dma2; in snd_gus_init_dma_irq()
287 dma1 |= gus->equal_dma ? 0x40 : (dma2 << 3); in snd_gus_init_dma_irq()
293 irq = gus->gf1.irq; in snd_gus_init_dma_irq()
305 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gus_init_dma_irq()
306 outb(5, GUSP(gus, REGCNTRLS)); in snd_gus_init_dma_irq()
307 outb(gus->mix_cntrl_reg, GUSP(gus, MIXCNTRLREG)); in snd_gus_init_dma_irq()
308 outb(0x00, GUSP(gus, IRQDMACNTRLREG)); in snd_gus_init_dma_irq()
309 outb(0, GUSP(gus, REGCNTRLS)); in snd_gus_init_dma_irq()
310 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gus_init_dma_irq()
314 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gus_init_dma_irq()
315 outb(0x00 | gus->mix_cntrl_reg, GUSP(gus, MIXCNTRLREG)); in snd_gus_init_dma_irq()
316 outb(dma1, GUSP(gus, IRQDMACNTRLREG)); in snd_gus_init_dma_irq()
318 outb(0x40 | gus->mix_cntrl_reg, GUSP(gus, MIXCNTRLREG)); in snd_gus_init_dma_irq()
319 outb(irq, GUSP(gus, IRQDMACNTRLREG)); in snd_gus_init_dma_irq()
321 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gus_init_dma_irq()
325 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gus_init_dma_irq()
326 outb(0x00 | gus->mix_cntrl_reg, GUSP(gus, MIXCNTRLREG)); in snd_gus_init_dma_irq()
327 outb(dma1, GUSP(gus, IRQDMACNTRLREG)); in snd_gus_init_dma_irq()
329 outb(0x40 | gus->mix_cntrl_reg, GUSP(gus, MIXCNTRLREG)); in snd_gus_init_dma_irq()
330 outb(irq, GUSP(gus, IRQDMACNTRLREG)); in snd_gus_init_dma_irq()
332 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gus_init_dma_irq()
334 snd_gf1_delay(gus); in snd_gus_init_dma_irq()
337 gus->mix_cntrl_reg |= 0x08; /* enable latches */ in snd_gus_init_dma_irq()
339 gus->mix_cntrl_reg &= ~0x08; /* disable latches */ in snd_gus_init_dma_irq()
340 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gus_init_dma_irq()
341 outb(gus->mix_cntrl_reg, GUSP(gus, MIXCNTRLREG)); in snd_gus_init_dma_irq()
342 outb(0, GUSP(gus, GF1PAGE)); in snd_gus_init_dma_irq()
343 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gus_init_dma_irq()
348 static int snd_gus_check_version(struct snd_gus_card * gus) in snd_gus_check_version() argument
354 card = gus->card; in snd_gus_check_version()
355 spin_lock_irqsave(&gus->reg_lock, flags); in snd_gus_check_version()
356 outb(0x20, GUSP(gus, REGCNTRLS)); in snd_gus_check_version()
357 val = inb(GUSP(gus, REGCNTRLS)); in snd_gus_check_version()
358 rev = inb(GUSP(gus, BOARDVERSION)); in snd_gus_check_version()
359 spin_unlock_irqrestore(&gus->reg_lock, flags); in snd_gus_check_version()
360 snd_printdd("GF1 [0x%lx] init - val = 0x%x, rev = 0x%x\n", gus->gf1.port, val, rev); in snd_gus_check_version()
365 gus->ics_flag = 1; in snd_gus_check_version()
367 gus->ics_flipped = 1; in snd_gus_check_version()
375 gus->max_flag = 1; in snd_gus_check_version()
379 gus->ace_flag = 1; in snd_gus_check_version()
383 gus->ess_flag = 1; in snd_gus_check_version()
385 …snd_printk(KERN_ERR "unknown GF1 revision number at 0x%lx - 0x%x (0x%x)\n", gus->gf1.port, rev, va… in snd_gus_check_version()
391 gus->uart_enable = 1; /* standard GUSes doesn't have midi uart trouble */ in snd_gus_check_version()
392 snd_gus_init_control(gus); in snd_gus_check_version()
396 int snd_gus_initialize(struct snd_gus_card *gus) in snd_gus_initialize() argument
400 if (!gus->interwave) { in snd_gus_initialize()
401 err = snd_gus_check_version(gus); in snd_gus_initialize()
406 err = snd_gus_detect_memory(gus); in snd_gus_initialize()
410 err = snd_gus_init_dma_irq(gus, 1); in snd_gus_initialize()
413 snd_gf1_start(gus); in snd_gus_initialize()
414 gus->initialized = 1; in snd_gus_initialize()