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()
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()
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 if ((err = snd_timer_new(opl3->card, "AdLib timer #1", &tid, &timer)) >= 0) { in snd_opl3_timer1_init()
248 timer->private_data = opl3; in snd_opl3_timer1_init()
251 opl3->timer1 = timer; in snd_opl3_timer1_init()
255 static int snd_opl3_timer2_init(struct snd_opl3 * opl3, int timer_no) in snd_opl3_timer2_init() argument
263 tid.card = opl3->card->number; in snd_opl3_timer2_init()
266 if ((err = snd_timer_new(opl3->card, "AdLib timer #2", &tid, &timer)) >= 0) { in snd_opl3_timer2_init()
268 timer->private_data = opl3; in snd_opl3_timer2_init()
271 opl3->timer2 = timer; in snd_opl3_timer2_init()
282 struct snd_opl3 *opl3; in snd_opl3_interrupt() local
288 opl3 = hw->private_data; in snd_opl3_interrupt()
289 status = inb(opl3->l_port); in snd_opl3_interrupt()
297 timer = opl3->timer1; in snd_opl3_interrupt()
301 timer = opl3->timer2; in snd_opl3_interrupt()
312 static int snd_opl3_free(struct snd_opl3 *opl3) in snd_opl3_free() argument
314 if (snd_BUG_ON(!opl3)) in snd_opl3_free()
316 if (opl3->private_free) in snd_opl3_free()
317 opl3->private_free(opl3); in snd_opl3_free()
318 snd_opl3_clear_patches(opl3); in snd_opl3_free()
319 release_and_free_resource(opl3->res_l_port); in snd_opl3_free()
320 release_and_free_resource(opl3->res_r_port); in snd_opl3_free()
321 kfree(opl3); in snd_opl3_free()
327 struct snd_opl3 *opl3 = device->device_data; in snd_opl3_dev_free() local
328 return snd_opl3_free(opl3); in snd_opl3_dev_free()
338 struct snd_opl3 *opl3; in snd_opl3_new() local
342 opl3 = kzalloc(sizeof(*opl3), GFP_KERNEL); in snd_opl3_new()
343 if (!opl3) in snd_opl3_new()
346 opl3->card = card; in snd_opl3_new()
347 opl3->hardware = hardware; in snd_opl3_new()
348 spin_lock_init(&opl3->reg_lock); in snd_opl3_new()
349 spin_lock_init(&opl3->timer_lock); in snd_opl3_new()
351 if ((err = snd_device_new(card, SNDRV_DEV_CODEC, opl3, &ops)) < 0) { 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()
369 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TEST, OPL3_ENABLE_WAVE_SELECT); in snd_opl3_init()
371 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION, 0x00); in snd_opl3_init()
373 switch (opl3->hardware & OPL3_HW_MASK) { in snd_opl3_init()
375 opl3->max_voices = MAX_OPL2_VOICES; in snd_opl3_init()
379 opl3->max_voices = MAX_OPL3_VOICES; in snd_opl3_init()
381 opl3->command(opl3, OPL3_RIGHT | OPL3_REG_MODE, OPL3_OPL3_ENABLE); in snd_opl3_init()
395 struct snd_opl3 *opl3; in snd_opl3_create() local
399 if ((err = snd_opl3_new(card, hardware, &opl3)) < 0) in snd_opl3_create()
402 if ((opl3->res_l_port = request_region(l_port, 2, "OPL2/3 (left)")) == NULL) { in snd_opl3_create()
404 snd_device_free(card, opl3); in snd_opl3_create()
408 (opl3->res_r_port = request_region(r_port, 2, "OPL2/3 (right)")) == NULL) { in snd_opl3_create()
410 snd_device_free(card, opl3); in snd_opl3_create()
414 opl3->l_port = l_port; in snd_opl3_create()
415 opl3->r_port = r_port; in snd_opl3_create()
417 switch (opl3->hardware) { in snd_opl3_create()
422 opl3->command = &snd_opl3_command; in snd_opl3_create()
425 opl3->command = &snd_opl2_command; in snd_opl3_create()
426 if ((err = snd_opl3_detect(opl3)) < 0) { in snd_opl3_create()
428 opl3->l_port, opl3->r_port); in snd_opl3_create()
429 snd_device_free(card, opl3); in snd_opl3_create()
433 switch (opl3->hardware & OPL3_HW_MASK) { in snd_opl3_create()
436 opl3->command = &snd_opl3_command; in snd_opl3_create()
440 snd_opl3_init(opl3); in snd_opl3_create()
442 *ropl3 = opl3; in snd_opl3_create()
448 int snd_opl3_timer_new(struct snd_opl3 * opl3, int timer1_dev, int timer2_dev) in snd_opl3_timer_new() argument
453 if ((err = snd_opl3_timer1_init(opl3, timer1_dev)) < 0) in snd_opl3_timer_new()
456 if ((err = snd_opl3_timer2_init(opl3, timer2_dev)) < 0) { in snd_opl3_timer_new()
457 snd_device_free(opl3->card, opl3->timer1); in snd_opl3_timer_new()
458 opl3->timer1 = NULL; in snd_opl3_timer_new()
467 int snd_opl3_hwdep_new(struct snd_opl3 * opl3, in snd_opl3_hwdep_new() argument
472 struct snd_card *card = opl3->card; in snd_opl3_hwdep_new()
481 snd_device_free(card, opl3); in snd_opl3_hwdep_new()
484 hw->private_data = opl3; in snd_opl3_hwdep_new()
491 switch (opl3->hardware & OPL3_HW_MASK) { in snd_opl3_hwdep_new()
512 opl3->hwdep = hw; in snd_opl3_hwdep_new()
513 opl3->seq_dev_num = seq_device; in snd_opl3_hwdep_new()
516 sizeof(struct snd_opl3 *), &opl3->seq_dev) >= 0) { in snd_opl3_hwdep_new()
517 strcpy(opl3->seq_dev->name, hw->name); in snd_opl3_hwdep_new()
518 *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR(opl3->seq_dev) = opl3; in snd_opl3_hwdep_new()