29 #include <linux/module.h>
31 #include <linux/slab.h>
41 static void snd_opl2_command(
struct snd_opl3 * opl3,
unsigned short cmd,
unsigned char val)
55 outb((
unsigned char) cmd, port);
58 outb((
unsigned char) val, port + 1);
61 spin_unlock_irqrestore(&opl3->
reg_lock, flags);
64 static void snd_opl3_command(
struct snd_opl3 * opl3,
unsigned short cmd,
unsigned char val)
78 outb((
unsigned char) cmd, port);
82 outb((
unsigned char) val, port + 1);
86 spin_unlock_irqrestore(&opl3->
reg_lock, flags);
89 static int snd_opl3_detect(
struct snd_opl3 * opl3)
109 if ((stat1 & 0xe0) != 0x00) {
125 if ((stat2 & 0xe0) != 0xc0) {
136 if (signature == 0x06) {
172 spin_unlock_irqrestore(&opl3->
timer_lock, flags);
176 static int snd_opl3_timer1_stop(
struct snd_timer * timer)
187 spin_unlock_irqrestore(&opl3->
timer_lock, flags);
195 static int snd_opl3_timer2_start(
struct snd_timer * timer)
209 spin_unlock_irqrestore(&opl3->
timer_lock, flags);
213 static int snd_opl3_timer2_stop(
struct snd_timer * timer)
224 spin_unlock_irqrestore(&opl3->
timer_lock, flags);
237 .start = snd_opl3_timer1_start,
238 .stop = snd_opl3_timer1_stop,
244 .resolution = 320000,
246 .start = snd_opl3_timer2_start,
247 .stop = snd_opl3_timer2_stop,
250 static int snd_opl3_timer1_init(
struct snd_opl3 * opl3,
int timer_no)
259 tid.device = timer_no;
264 timer->
hw = snd_opl3_timer1;
270 static int snd_opl3_timer2_init(
struct snd_opl3 * opl3,
int timer_no)
279 tid.device = timer_no;
284 timer->
hw = snd_opl3_timer2;
308 if (!(status & 0x80))
327 static int snd_opl3_free(
struct snd_opl3 *opl3)
333 snd_opl3_clear_patches(opl3);
343 return snd_opl3_free(opl3);
439 opl3->
command = &snd_opl3_command;
442 opl3->
command = &snd_opl2_command;
443 if ((err = snd_opl3_detect(opl3)) < 0) {
444 snd_printd(
"OPL2/3 chip not detected at 0x%lx/0x%lx\n",
453 opl3->
command = &snd_opl3_command;
470 if ((err = snd_opl3_timer1_init(opl3, timer1_dev)) < 0)
472 if (timer2_dev >= 0) {
473 if ((err = snd_opl3_timer2_init(opl3, timer2_dev)) < 0) {
485 int device,
int seq_device,
497 if ((err =
snd_hwdep_new(card,
"OPL2/OPL3", device, &hw)) < 0) {
503 #ifdef CONFIG_SND_OSSEMUL
505 hw->oss_type = SNDRV_OSS_DEVICE_TYPE_DMFM;
533 #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
535 sizeof(
struct snd_opl3 *), &opl3->seq_dev) >= 0) {
551 static int __init alsa_opl3_init(
void)
556 static void __exit alsa_opl3_exit(
void)