• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/sound/drivers/opl3/

Lines Matching refs:opl3

26 #include <sound/opl3.h>
40 static void snd_opl2_command(struct snd_opl3 * opl3, unsigned short cmd, unsigned char val)
50 port = (cmd & OPL3_RIGHT) ? opl3->r_port : opl3->l_port;
52 spin_lock_irqsave(&opl3->reg_lock, flags);
60 spin_unlock_irqrestore(&opl3->reg_lock, flags);
63 static void snd_opl3_command(struct snd_opl3 * opl3, unsigned short cmd, unsigned char val)
73 port = (cmd & OPL3_RIGHT) ? opl3->r_port : opl3->l_port;
75 spin_lock_irqsave(&opl3->reg_lock, flags);
78 inb(opl3->l_port);
79 inb(opl3->l_port);
82 inb(opl3->l_port);
83 inb(opl3->l_port);
85 spin_unlock_irqrestore(&opl3->reg_lock, flags);
88 static int snd_opl3_detect(struct snd_opl3 * opl3)
104 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_TIMER1_MASK | OPL3_TIMER2_MASK);
106 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_IRQ_RESET);
107 signature = stat1 = inb(opl3->l_port); /* Status register */
113 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER1, 0xff);
115 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_TIMER2_MASK | OPL3_TIMER1_START);
119 stat2 = inb(opl3->l_port);
121 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_TIMER1_MASK | OPL3_TIMER2_MASK);
123 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_IRQ_RESET);
131 if (opl3->hardware != OPL3_HW_AUTO)
136 opl3->hardware = OPL3_HW_OPL2;
139 * If we had an OPL4 chip, opl3->hardware would have been set
142 if (snd_BUG_ON(!opl3->r_port))
144 opl3->hardware = OPL3_HW_OPL3;
162 struct snd_opl3 *opl3;
164 opl3 = snd_timer_chip(timer);
165 spin_lock_irqsave(&opl3->timer_lock, flags);
167 tmp = (opl3->timer_enable | OPL3_TIMER1_START) & ~OPL3_TIMER1_MASK;
168 opl3->timer_enable = tmp;
169 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER1, 256 - ticks); /* timer 1 count */
170 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, tmp); /* enable timer 1 IRQ */
171 spin_unlock_irqrestore(&opl3->timer_lock, flags);
179 struct snd_opl3 *opl3;
181 opl3 = snd_timer_chip(timer);
182 spin_lock_irqsave(&opl3->timer_lock, flags);
183 tmp = (opl3->timer_enable | OPL3_TIMER1_MASK) & ~OPL3_TIMER1_START;
184 opl3->timer_enable = tmp;
185 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, tmp); /* disable timer #1 */
186 spin_unlock_irqrestore(&opl3->timer_lock, flags);
199 struct snd_opl3 *opl3;
201 opl3 = snd_timer_chip(timer);
202 spin_lock_irqsave(&opl3->timer_lock, flags);
204 tmp = (opl3->timer_enable | OPL3_TIMER2_START) & ~OPL3_TIMER2_MASK;
205 opl3->timer_enable = tmp;
206 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER2, 256 - ticks); /* timer 1 count */
207 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, tmp); /* enable timer 1 IRQ */
208 spin_unlock_irqrestore(&opl3->timer_lock, flags);
216 struct snd_opl3 *opl3;
218 opl3 = snd_timer_chip(timer);
219 spin_lock_irqsave(&opl3->timer_lock, flags);
220 tmp = (opl3->timer_enable | OPL3_TIMER2_MASK) & ~OPL3_TIMER2_START;
221 opl3->timer_enable = tmp;
222 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, tmp); /* disable timer #1 */
223 spin_unlock_irqrestore(&opl3->timer_lock, flags);
249 static int snd_opl3_timer1_init(struct snd_opl3 * opl3, int timer_no)
257 tid.card = opl3->card->number;
260 if ((err = snd_timer_new(opl3->card, "AdLib timer #1", &tid, &timer)) >= 0) {
262 timer->private_data = opl3;
265 opl3->timer1 = timer;
269 static int snd_opl3_timer2_init(struct snd_opl3 * opl3, int timer_no)
277 tid.card = opl3->card->number;
280 if ((err = snd_timer_new(opl3->card, "AdLib timer #2", &tid, &timer)) >= 0) {
282 timer->private_data = opl3;
285 opl3->timer2 = timer;
296 struct snd_opl3 *opl3;
302 opl3 = hw->private_data;
303 status = inb(opl3->l_port);
308 timer = opl3->timer1;
312 timer = opl3->timer2;
323 static int snd_opl3_free(struct snd_opl3 *opl3)
325 if (snd_BUG_ON(!opl3))
327 if (opl3->private_free)
328 opl3->private_free(opl3);
329 snd_opl3_clear_patches(opl3);
330 release_and_free_resource(opl3->res_l_port);
331 release_and_free_resource(opl3->res_r_port);
332 kfree(opl3);
338 struct snd_opl3 *opl3 = device->device_data;
339 return snd_opl3_free(opl3);
349 struct snd_opl3 *opl3;
353 opl3 = kzalloc(sizeof(*opl3), GFP_KERNEL);
354 if (opl3 == NULL) {
355 snd_printk(KERN_ERR "opl3: cannot allocate\n");
359 opl3->card = card;
360 opl3->hardware = hardware;
361 spin_lock_init(&opl3->reg_lock);
362 spin_lock_init(&opl3->timer_lock);
364 if ((err = snd_device_new(card, SNDRV_DEV_CODEC, opl3, &ops)) < 0) {
365 snd_opl3_free(opl3);
369 *ropl3 = opl3;
375 int snd_opl3_init(struct snd_opl3 *opl3)
377 if (! opl3->command) {
382 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TEST, OPL3_ENABLE_WAVE_SELECT);
384 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION, 0x00);
386 switch (opl3->hardware & OPL3_HW_MASK) {
388 opl3->max_voices = MAX_OPL2_VOICES;
392 opl3->max_voices = MAX_OPL3_VOICES;
394 opl3->command(opl3, OPL3_RIGHT | OPL3_REG_MODE, OPL3_OPL3_ENABLE);
408 struct snd_opl3 *opl3;
412 if ((err = snd_opl3_new(card, hardware, &opl3)) < 0)
415 if ((opl3->res_l_port = request_region(l_port, 2, "OPL2/3 (left)")) == NULL) {
416 snd_printk(KERN_ERR "opl3: can't grab left port 0x%lx\n", l_port);
417 snd_device_free(card, opl3);
421 (opl3->res_r_port = request_region(r_port, 2, "OPL2/3 (right)")) == NULL) {
422 snd_printk(KERN_ERR "opl3: can't grab right port 0x%lx\n", r_port);
423 snd_device_free(card, opl3);
427 opl3->l_port = l_port;
428 opl3->r_port = r_port;
430 switch (opl3->hardware) {
435 opl3->command = &snd_opl3_command;
438 opl3->command = &snd_opl2_command;
439 if ((err = snd_opl3_detect(opl3)) < 0) {
441 opl3->l_port, opl3->r_port);
442 snd_device_free(card, opl3);
446 switch (opl3->hardware & OPL3_HW_MASK) {
449 opl3->command = &snd_opl3_command;
453 snd_opl3_init(opl3);
455 *ropl3 = opl3;
461 int snd_opl3_timer_new(struct snd_opl3 * opl3, int timer1_dev, int timer2_dev)
466 if ((err = snd_opl3_timer1_init(opl3, timer1_dev)) < 0)
469 if ((err = snd_opl3_timer2_init(opl3, timer2_dev)) < 0) {
470 snd_device_free(opl3->card, opl3->timer1);
471 opl3->timer1 = NULL;
480 int snd_opl3_hwdep_new(struct snd_opl3 * opl3,
485 struct snd_card *card = opl3->card;
494 snd_device_free(card, opl3);
497 hw->private_data = opl3;
506 switch (opl3->hardware & OPL3_HW_MASK) {
527 opl3->hwdep = hw;
528 opl3->seq_dev_num = seq_device;
532 sizeof(struct snd_opl3 *), &opl3->seq_dev) >= 0) {
533 strcpy(opl3->seq_dev->name, hw->name);
534 *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR(opl3->seq_dev) = opl3;