Lines Matching refs:opl3
26 static void snd_opl2_command(struct snd_opl3 * opl3, unsigned short cmd, unsigned char val) in snd_opl2_command() argument
36 port = (cmd & OPL3_RIGHT) ? opl3->r_port : opl3->l_port; in snd_opl2_command()
38 spin_lock_irqsave(&opl3->reg_lock, flags); in snd_opl2_command()
46 spin_unlock_irqrestore(&opl3->reg_lock, flags); in snd_opl2_command()
49 static void snd_opl3_command(struct snd_opl3 * opl3, unsigned short cmd, unsigned char val) in snd_opl3_command() argument
59 port = (cmd & OPL3_RIGHT) ? opl3->r_port : opl3->l_port; in snd_opl3_command()
61 spin_lock_irqsave(&opl3->reg_lock, flags); in snd_opl3_command()
64 inb(opl3->l_port); in snd_opl3_command()
65 inb(opl3->l_port); in snd_opl3_command()
68 inb(opl3->l_port); in snd_opl3_command()
69 inb(opl3->l_port); in snd_opl3_command()
71 spin_unlock_irqrestore(&opl3->reg_lock, flags); in snd_opl3_command()
74 static int snd_opl3_detect(struct snd_opl3 * opl3) in snd_opl3_detect() argument
90 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_TIMER1_MASK | OPL3_TIMER2_MASK); in snd_opl3_detect()
92 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_IRQ_RESET); in snd_opl3_detect()
93 signature = stat1 = inb(opl3->l_port); /* Status register */ in snd_opl3_detect()
95 dev_dbg(opl3->card->dev, "OPL3: stat1 = 0x%x\n", stat1); in snd_opl3_detect()
99 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER1, 0xff); in snd_opl3_detect()
101 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_TIMER2_MASK | OPL3_TIMER1_START); in snd_opl3_detect()
105 stat2 = inb(opl3->l_port); in snd_opl3_detect()
107 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_TIMER1_MASK | OPL3_TIMER2_MASK); in snd_opl3_detect()
109 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_IRQ_RESET); in snd_opl3_detect()
111 dev_dbg(opl3->card->dev, "OPL3: stat2 = 0x%x\n", stat2); in snd_opl3_detect()
117 if (opl3->hardware != OPL3_HW_AUTO) in snd_opl3_detect()
122 opl3->hardware = OPL3_HW_OPL2; in snd_opl3_detect()
128 if (snd_BUG_ON(!opl3->r_port)) in snd_opl3_detect()
130 opl3->hardware = OPL3_HW_OPL3; in snd_opl3_detect()
148 struct snd_opl3 *opl3; in snd_opl3_timer1_start() local
150 opl3 = snd_timer_chip(timer); in snd_opl3_timer1_start()
151 spin_lock_irqsave(&opl3->timer_lock, flags); in snd_opl3_timer1_start()
153 tmp = (opl3->timer_enable | OPL3_TIMER1_START) & ~OPL3_TIMER1_MASK; in snd_opl3_timer1_start()
154 opl3->timer_enable = tmp; in snd_opl3_timer1_start()
155 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER1, 256 - ticks); /* timer 1 count */ in snd_opl3_timer1_start()
156 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, tmp); /* enable timer 1 IRQ */ in snd_opl3_timer1_start()
157 spin_unlock_irqrestore(&opl3->timer_lock, flags); in snd_opl3_timer1_start()
165 struct snd_opl3 *opl3; in snd_opl3_timer1_stop() local
167 opl3 = snd_timer_chip(timer); in snd_opl3_timer1_stop()
168 spin_lock_irqsave(&opl3->timer_lock, flags); in snd_opl3_timer1_stop()
169 tmp = (opl3->timer_enable | OPL3_TIMER1_MASK) & ~OPL3_TIMER1_START; in snd_opl3_timer1_stop()
170 opl3->timer_enable = tmp; in snd_opl3_timer1_stop()
171 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, tmp); /* disable timer #1 */ in snd_opl3_timer1_stop()
172 spin_unlock_irqrestore(&opl3->timer_lock, flags); in snd_opl3_timer1_stop()
185 struct snd_opl3 *opl3; in snd_opl3_timer2_start() local
187 opl3 = snd_timer_chip(timer); in snd_opl3_timer2_start()
188 spin_lock_irqsave(&opl3->timer_lock, flags); in snd_opl3_timer2_start()
190 tmp = (opl3->timer_enable | OPL3_TIMER2_START) & ~OPL3_TIMER2_MASK; in snd_opl3_timer2_start()
191 opl3->timer_enable = tmp; in snd_opl3_timer2_start()
192 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER2, 256 - ticks); /* timer 1 count */ in snd_opl3_timer2_start()
193 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, tmp); /* enable timer 1 IRQ */ in snd_opl3_timer2_start()
194 spin_unlock_irqrestore(&opl3->timer_lock, flags); in snd_opl3_timer2_start()
202 struct snd_opl3 *opl3; in snd_opl3_timer2_stop() local
204 opl3 = snd_timer_chip(timer); in snd_opl3_timer2_stop()
205 spin_lock_irqsave(&opl3->timer_lock, flags); in snd_opl3_timer2_stop()
206 tmp = (opl3->timer_enable | OPL3_TIMER2_MASK) & ~OPL3_TIMER2_START; in snd_opl3_timer2_stop()
207 opl3->timer_enable = tmp; in snd_opl3_timer2_stop()
208 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, tmp); /* disable timer #1 */ in snd_opl3_timer2_stop()
209 spin_unlock_irqrestore(&opl3->timer_lock, flags); in snd_opl3_timer2_stop()
235 static int snd_opl3_timer1_init(struct snd_opl3 * opl3, int timer_no) in snd_opl3_timer1_init() argument
243 tid.card = opl3->card->number; in snd_opl3_timer1_init()
246 err = snd_timer_new(opl3->card, "AdLib timer #1", &tid, &timer); in snd_opl3_timer1_init()
249 timer->private_data = opl3; in snd_opl3_timer1_init()
252 opl3->timer1 = timer; in snd_opl3_timer1_init()
256 static int snd_opl3_timer2_init(struct snd_opl3 * opl3, int timer_no) in snd_opl3_timer2_init() argument
264 tid.card = opl3->card->number; in snd_opl3_timer2_init()
267 err = snd_timer_new(opl3->card, "AdLib timer #2", &tid, &timer); in snd_opl3_timer2_init()
270 timer->private_data = opl3; in snd_opl3_timer2_init()
273 opl3->timer2 = timer; in snd_opl3_timer2_init()
284 struct snd_opl3 *opl3; in snd_opl3_interrupt() local
290 opl3 = hw->private_data; in snd_opl3_interrupt()
291 status = inb(opl3->l_port); in snd_opl3_interrupt()
296 timer = opl3->timer1; in snd_opl3_interrupt()
300 timer = opl3->timer2; in snd_opl3_interrupt()
311 static int snd_opl3_free(struct snd_opl3 *opl3) in snd_opl3_free() argument
313 if (snd_BUG_ON(!opl3)) in snd_opl3_free()
315 if (opl3->private_free) in snd_opl3_free()
316 opl3->private_free(opl3); in snd_opl3_free()
317 snd_opl3_clear_patches(opl3); in snd_opl3_free()
318 release_and_free_resource(opl3->res_l_port); in snd_opl3_free()
319 release_and_free_resource(opl3->res_r_port); in snd_opl3_free()
320 kfree(opl3); in snd_opl3_free()
326 struct snd_opl3 *opl3 = device->device_data; in snd_opl3_dev_free() local
327 return snd_opl3_free(opl3); in snd_opl3_dev_free()
337 struct snd_opl3 *opl3; in snd_opl3_new() local
341 opl3 = kzalloc(sizeof(*opl3), GFP_KERNEL); in snd_opl3_new()
342 if (!opl3) in snd_opl3_new()
345 opl3->card = card; in snd_opl3_new()
346 opl3->hardware = hardware; in snd_opl3_new()
347 spin_lock_init(&opl3->reg_lock); in snd_opl3_new()
348 spin_lock_init(&opl3->timer_lock); in snd_opl3_new()
350 err = snd_device_new(card, SNDRV_DEV_CODEC, opl3, &ops); in snd_opl3_new()
352 snd_opl3_free(opl3); in snd_opl3_new()
356 *ropl3 = opl3; in snd_opl3_new()
362 int snd_opl3_init(struct snd_opl3 *opl3) in snd_opl3_init() argument
364 if (! opl3->command) { in snd_opl3_init()
365 dev_err(opl3->card->dev, in snd_opl3_init()
370 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TEST, OPL3_ENABLE_WAVE_SELECT); in snd_opl3_init()
372 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION, 0x00); in snd_opl3_init()
374 switch (opl3->hardware & OPL3_HW_MASK) { in snd_opl3_init()
376 opl3->max_voices = MAX_OPL2_VOICES; in snd_opl3_init()
380 opl3->max_voices = MAX_OPL3_VOICES; in snd_opl3_init()
382 opl3->command(opl3, OPL3_RIGHT | OPL3_REG_MODE, OPL3_OPL3_ENABLE); in snd_opl3_init()
396 struct snd_opl3 *opl3; in snd_opl3_create() local
400 err = snd_opl3_new(card, hardware, &opl3); in snd_opl3_create()
404 opl3->res_l_port = request_region(l_port, 2, "OPL2/3 (left)"); in snd_opl3_create()
405 if (!opl3->res_l_port) { in snd_opl3_create()
407 snd_device_free(card, opl3); in snd_opl3_create()
411 opl3->res_r_port = request_region(r_port, 2, "OPL2/3 (right)"); in snd_opl3_create()
412 if (!opl3->res_r_port) { in snd_opl3_create()
414 snd_device_free(card, opl3); in snd_opl3_create()
419 opl3->l_port = l_port; in snd_opl3_create()
420 opl3->r_port = r_port; in snd_opl3_create()
422 switch (opl3->hardware) { in snd_opl3_create()
427 opl3->command = &snd_opl3_command; in snd_opl3_create()
430 opl3->command = &snd_opl2_command; in snd_opl3_create()
431 err = snd_opl3_detect(opl3); in snd_opl3_create()
434 opl3->l_port, opl3->r_port); in snd_opl3_create()
435 snd_device_free(card, opl3); in snd_opl3_create()
439 switch (opl3->hardware & OPL3_HW_MASK) { in snd_opl3_create()
442 opl3->command = &snd_opl3_command; in snd_opl3_create()
446 snd_opl3_init(opl3); in snd_opl3_create()
448 *ropl3 = opl3; in snd_opl3_create()
454 int snd_opl3_timer_new(struct snd_opl3 * opl3, int timer1_dev, int timer2_dev) in snd_opl3_timer_new() argument
459 err = snd_opl3_timer1_init(opl3, timer1_dev); in snd_opl3_timer_new()
464 err = snd_opl3_timer2_init(opl3, timer2_dev); in snd_opl3_timer_new()
466 snd_device_free(opl3->card, opl3->timer1); in snd_opl3_timer_new()
467 opl3->timer1 = NULL; in snd_opl3_timer_new()
476 int snd_opl3_hwdep_new(struct snd_opl3 * opl3, in snd_opl3_hwdep_new() argument
481 struct snd_card *card = opl3->card; in snd_opl3_hwdep_new()
491 snd_device_free(card, opl3); in snd_opl3_hwdep_new()
494 hw->private_data = opl3; in snd_opl3_hwdep_new()
501 switch (opl3->hardware & OPL3_HW_MASK) { in snd_opl3_hwdep_new()
522 opl3->hwdep = hw; in snd_opl3_hwdep_new()
523 opl3->seq_dev_num = seq_device; in snd_opl3_hwdep_new()
526 sizeof(struct snd_opl3 *), &opl3->seq_dev) >= 0) { in snd_opl3_hwdep_new()
527 strcpy(opl3->seq_dev->name, hw->name); in snd_opl3_hwdep_new()
528 *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR(opl3->seq_dev) = opl3; in snd_opl3_hwdep_new()