Lines Matching +full:invert +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for Yamaha OPL3-SA[2,3] soundcards
25 MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF719E-S},"
31 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
33 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ variable
35 static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
48 MODULE_PARM_DESC(index, "Index value for OPL3-SA soundcard.");
50 MODULE_PARM_DESC(id, "ID string for OPL3-SA soundcard.");
51 module_param_array(enable, bool, NULL, 0444);
52 MODULE_PARM_DESC(enable, "Enable OPL3-SA soundcard.");
58 MODULE_PARM_DESC(port, "Port # for OPL3-SA driver.");
60 MODULE_PARM_DESC(sb_port, "SB port # for OPL3-SA driver.");
62 MODULE_PARM_DESC(wss_port, "WSS port # for OPL3-SA driver.");
64 MODULE_PARM_DESC(fm_port, "FM port # for OPL3-SA driver.");
66 MODULE_PARM_DESC(midi_port, "MIDI port # for OPL3-SA driver.");
68 MODULE_PARM_DESC(irq, "IRQ # for OPL3-SA driver.");
70 MODULE_PARM_DESC(dma1, "DMA1 # for OPL3-SA driver.");
72 MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver.");
138 /* Yamaha YMF719E-S (Genius Sound Maker 3DX) */
140 /* Yamaha OPL3-SA3 (integrated on Intel's Pentium II AL440LX motherboard) */
142 /* Yamaha OPL3-SA2 */
144 /* Yamaha OPL3-SA2 */
150 /* --- */
167 outb(reg, chip->port); /* register */ in __snd_opl3sa2_read()
168 result = inb(chip->port + 1); in __snd_opl3sa2_read()
182 spin_lock_irqsave(&chip->reg_lock, flags); in snd_opl3sa2_read()
184 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_opl3sa2_read()
194 outb(reg, chip->port); /* register */ in __snd_opl3sa2_write()
195 outb(value, chip->port + 1); in __snd_opl3sa2_write()
196 chip->ctlregs[reg] = value; in __snd_opl3sa2_write()
203 spin_lock_irqsave(&chip->reg_lock, flags); in snd_opl3sa2_write()
205 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_opl3sa2_write()
210 struct snd_opl3sa2 *chip = card->private_data; in snd_opl3sa2_detect()
215 port = chip->port; in snd_opl3sa2_detect()
216 if ((chip->res_port = request_region(port, 2, "OPL3-SA control")) == NULL) { in snd_opl3sa2_detect()
218 return -EBUSY; in snd_opl3sa2_detect()
224 chip->version = 0; in snd_opl3sa2_detect()
227 snd_printd("OPL3-SA [0x%lx] detect = 0x%x\n", port, tmp); in snd_opl3sa2_detect()
228 return -ENODEV; in snd_opl3sa2_detect()
232 chip->version = 2; /* YMF711 */ in snd_opl3sa2_detect()
235 chip->version = 3; in snd_opl3sa2_detect()
236 /* 0x02 - standard */ in snd_opl3sa2_detect()
237 /* 0x03 - YM715B */ in snd_opl3sa2_detect()
238 /* 0x04 - YM719 - OPL-SA4? */ in snd_opl3sa2_detect()
239 /* 0x05 - OPL3-SA3 - Libretto 100 */ in snd_opl3sa2_detect()
240 /* 0x07 - unknown - Neomagic MagicWave 3D */ in snd_opl3sa2_detect()
243 str[0] = chip->version + '0'; in snd_opl3sa2_detect()
245 strcat(card->shortname, str); in snd_opl3sa2_detect()
248 snd_printd("OPL3-SA [0x%lx] detect (1) = 0x%x (0x%x)\n", port, tmp, tmp1); in snd_opl3sa2_detect()
249 return -ENODEV; in snd_opl3sa2_detect()
255 snd_printd("OPL3-SA [0x%lx] detect (2) = 0x%x (0x%x)\n", port, tmp, tmp1); in snd_opl3sa2_detect()
256 return -ENODEV; in snd_opl3sa2_detect()
260 /* Power Management - full on */ in snd_opl3sa2_detect()
262 if (chip->version > 2) { in snd_opl3sa2_detect()
264 snd_opl3sa2_write(chip, OPL3SA2_SYS_CTRL, (chip->ymode << 4)); in snd_opl3sa2_detect()
269 …snd_opl3sa2_write(chip, OPL3SA2_IRQ_CONFIG, 0x0d); /* Interrupt Channel Configuration - IRQ A = OP… in snd_opl3sa2_detect()
270 if (chip->single_dma) { in snd_opl3sa2_detect()
271 snd_opl3sa2_write(chip, OPL3SA2_DMA_CONFIG, 0x03); /* DMA Configuration - DMA A = WSS-R + WSS-P */ in snd_opl3sa2_detect()
273 …l3sa2_write(chip, OPL3SA2_DMA_CONFIG, 0x21); /* DMA Configuration - DMA B = WSS-R, DMA A = WSS-P */ in snd_opl3sa2_detect()
275 snd_opl3sa2_write(chip, OPL3SA2_MISC, 0x80 | (tmp & 7)); /* Miscellaneous - default */ in snd_opl3sa2_detect()
276 if (chip->version > 2) { in snd_opl3sa2_detect()
277 snd_opl3sa2_write(chip, OPL3SA3_DGTL_DOWN, 0x00); /* Digital Block Partial Power Down - default */ in snd_opl3sa2_detect()
278 snd_opl3sa2_write(chip, OPL3SA3_ANLG_DOWN, 0x00); /* Analog Block Partial Power Down - default */ in snd_opl3sa2_detect()
293 chip = card->private_data; in snd_opl3sa2_interrupt()
298 snd_opl3_interrupt(chip->synth); in snd_opl3sa2_interrupt()
301 if ((status & 0x10) && chip->rmidi != NULL) { in snd_opl3sa2_interrupt()
303 snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); in snd_opl3sa2_interrupt()
308 snd_wss_interrupt(irq, chip->wss); in snd_opl3sa2_interrupt()
316 if (chip->master_switch && chip->master_volume) { in snd_opl3sa2_interrupt()
318 &chip->master_switch->id); in snd_opl3sa2_interrupt()
320 &chip->master_volume->id); in snd_opl3sa2_interrupt()
326 #define OPL3SA2_SINGLE(xname, xindex, reg, shift, mask, invert) \ argument
330 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
331 #define OPL3SA2_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \ argument
337 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24), \
344 int reg = kcontrol->private_value & 0xff; in snd_opl3sa2_get_single()
345 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_opl3sa2_get_single()
346 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_opl3sa2_get_single()
347 int invert = (kcontrol->private_value >> 24) & 0xff; in snd_opl3sa2_get_single() local
349 spin_lock_irqsave(&chip->reg_lock, flags); in snd_opl3sa2_get_single()
350 ucontrol->value.integer.value[0] = (chip->ctlregs[reg] >> shift) & mask; in snd_opl3sa2_get_single()
351 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_opl3sa2_get_single()
352 if (invert) in snd_opl3sa2_get_single()
353 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_opl3sa2_get_single()
361 int reg = kcontrol->private_value & 0xff; in snd_opl3sa2_put_single()
362 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_opl3sa2_put_single()
363 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_opl3sa2_put_single()
364 int invert = (kcontrol->private_value >> 24) & 0xff; in snd_opl3sa2_put_single() local
368 val = (ucontrol->value.integer.value[0] & mask); in snd_opl3sa2_put_single()
369 if (invert) in snd_opl3sa2_put_single()
370 val = mask - val; in snd_opl3sa2_put_single()
372 spin_lock_irqsave(&chip->reg_lock, flags); in snd_opl3sa2_put_single()
373 oval = chip->ctlregs[reg]; in snd_opl3sa2_put_single()
377 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_opl3sa2_put_single()
381 #define OPL3SA2_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \ argument
385 …reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
386 …L3SA2_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert, xtlv) \ argument
392 …eg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22), \
399 int left_reg = kcontrol->private_value & 0xff; in snd_opl3sa2_get_double()
400 int right_reg = (kcontrol->private_value >> 8) & 0xff; in snd_opl3sa2_get_double()
401 int shift_left = (kcontrol->private_value >> 16) & 0x07; in snd_opl3sa2_get_double()
402 int shift_right = (kcontrol->private_value >> 19) & 0x07; in snd_opl3sa2_get_double()
403 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_opl3sa2_get_double()
404 int invert = (kcontrol->private_value >> 22) & 1; in snd_opl3sa2_get_double() local
406 spin_lock_irqsave(&chip->reg_lock, flags); in snd_opl3sa2_get_double()
407 ucontrol->value.integer.value[0] = (chip->ctlregs[left_reg] >> shift_left) & mask; in snd_opl3sa2_get_double()
408 ucontrol->value.integer.value[1] = (chip->ctlregs[right_reg] >> shift_right) & mask; in snd_opl3sa2_get_double()
409 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_opl3sa2_get_double()
410 if (invert) { in snd_opl3sa2_get_double()
411 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_opl3sa2_get_double()
412 ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1]; in snd_opl3sa2_get_double()
421 int left_reg = kcontrol->private_value & 0xff; in snd_opl3sa2_put_double()
422 int right_reg = (kcontrol->private_value >> 8) & 0xff; in snd_opl3sa2_put_double()
423 int shift_left = (kcontrol->private_value >> 16) & 0x07; in snd_opl3sa2_put_double()
424 int shift_right = (kcontrol->private_value >> 19) & 0x07; in snd_opl3sa2_put_double()
425 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_opl3sa2_put_double()
426 int invert = (kcontrol->private_value >> 22) & 1; in snd_opl3sa2_put_double() local
430 val1 = ucontrol->value.integer.value[0] & mask; in snd_opl3sa2_put_double()
431 val2 = ucontrol->value.integer.value[1] & mask; in snd_opl3sa2_put_double()
432 if (invert) { in snd_opl3sa2_put_double()
433 val1 = mask - val1; in snd_opl3sa2_put_double()
434 val2 = mask - val2; in snd_opl3sa2_put_double()
438 spin_lock_irqsave(&chip->reg_lock, flags); in snd_opl3sa2_put_double()
440 oval1 = chip->ctlregs[left_reg]; in snd_opl3sa2_put_double()
441 oval2 = chip->ctlregs[right_reg]; in snd_opl3sa2_put_double()
448 oval1 = chip->ctlregs[left_reg]; in snd_opl3sa2_put_double()
453 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_opl3sa2_put_double()
457 static const DECLARE_TLV_DB_SCALE(db_scale_master, -3000, 200, 0);
458 static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
471 OPL3SA2_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0),
472 OPL3SA2_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0),
473 OPL3SA2_DOUBLE("Tone Control - Treble", 0, 0x16, 0x16, 4, 0, 7, 0)
479 chip->master_switch = NULL; in snd_opl3sa2_master_free()
480 chip->master_volume = NULL; in snd_opl3sa2_master_free()
485 struct snd_opl3sa2 *chip = card->private_data; in snd_opl3sa2_mixer()
525 case 0: chip->master_switch = kctl; kctl->private_free = snd_opl3sa2_master_free; break; in snd_opl3sa2_mixer()
526 case 1: chip->master_volume = kctl; kctl->private_free = snd_opl3sa2_master_free; break; in snd_opl3sa2_mixer()
529 if (chip->version > 2) { in snd_opl3sa2_mixer()
542 struct snd_opl3sa2 *chip = card->private_data; in snd_opl3sa2_suspend()
545 chip->wss->suspend(chip->wss); in snd_opl3sa2_suspend()
561 chip = card->private_data; in snd_opl3sa2_resume()
568 snd_opl3sa2_write(chip, i, chip->ctlregs[i]); in snd_opl3sa2_resume()
570 if (chip->version > 2) { in snd_opl3sa2_resume()
572 snd_opl3sa2_write(chip, i, chip->ctlregs[i]); in snd_opl3sa2_resume()
575 chip->wss->resume(chip->wss); in snd_opl3sa2_resume()
588 return -EBUSY; in snd_opl3sa2_pnp()
598 snd_printdd("%sPnP OPL3-SA: sb port=0x%lx, wss port=0x%lx, fm port=0x%lx, midi port=0x%lx\n", in snd_opl3sa2_pnp()
600 snd_printdd("%sPnP OPL3-SA: control port=0x%lx, dma1=%i, dma2=%i, irq=%i\n", in snd_opl3sa2_pnp()
608 struct snd_opl3sa2 *chip = card->private_data; in snd_opl3sa2_free()
609 if (chip->irq >= 0) in snd_opl3sa2_free()
610 free_irq(chip->irq, card); in snd_opl3sa2_free()
611 release_and_free_resource(chip->res_port); in snd_opl3sa2_free()
625 strcpy(card->driver, "OPL3SA2"); in snd_opl3sa2_card_new()
626 strcpy(card->shortname, "Yamaha OPL3-SA"); in snd_opl3sa2_card_new()
627 chip = card->private_data; in snd_opl3sa2_card_new()
628 spin_lock_init(&chip->reg_lock); in snd_opl3sa2_card_new()
629 chip->irq = -1; in snd_opl3sa2_card_new()
630 card->private_free = snd_opl3sa2_free; in snd_opl3sa2_card_new()
644 chip = card->private_data; in snd_opl3sa2_probe()
645 chip->ymode = opl3sa3_ymode[dev] & 0x03 ; in snd_opl3sa2_probe()
646 chip->port = port[dev]; in snd_opl3sa2_probe()
651 chip->single_dma = 1; in snd_opl3sa2_probe()
656 "OPL3-SA2", card); in snd_opl3sa2_probe()
659 return -ENODEV; in snd_opl3sa2_probe()
661 chip->irq = xirq; in snd_opl3sa2_probe()
662 card->sync_irq = chip->irq; in snd_opl3sa2_probe()
664 wss_port[dev] + 4, -1, in snd_opl3sa2_probe()
671 chip->wss = wss; in snd_opl3sa2_probe()
691 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, &chip->synth)) < 0) in snd_opl3sa2_probe()
697 MPU401_INFO_IRQ_HOOK, -1, in snd_opl3sa2_probe()
698 &chip->rmidi)) < 0) in snd_opl3sa2_probe()
701 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", in snd_opl3sa2_probe()
702 card->shortname, chip->port, xirq, xdma1); in snd_opl3sa2_probe()
704 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); in snd_opl3sa2_probe()
718 return -ENOENT; /* we have another procedure - card */ in snd_opl3sa2_pnp_detect()
720 if (enable[dev] && isapnp[dev]) in snd_opl3sa2_pnp_detect()
724 return -ENODEV; in snd_opl3sa2_pnp_detect()
726 err = snd_opl3sa2_card_new(&pdev->dev, dev, &card); in snd_opl3sa2_pnp_detect()
729 if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) { in snd_opl3sa2_pnp_detect()
759 .name = "snd-opl3sa2-pnpbios",
777 pdev = pnp_request_card_device(pcard, id->devs[0].id, NULL); in snd_opl3sa2_pnp_cdetect()
780 id->devs[0].id); in snd_opl3sa2_pnp_cdetect()
781 return -EBUSY; in snd_opl3sa2_pnp_cdetect()
784 if (enable[dev] && isapnp[dev]) in snd_opl3sa2_pnp_cdetect()
788 return -ENODEV; in snd_opl3sa2_pnp_cdetect()
790 err = snd_opl3sa2_card_new(&pdev->dev, dev, &card); in snd_opl3sa2_pnp_cdetect()
793 if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) { in snd_opl3sa2_pnp_cdetect()
825 .name = "snd-opl3sa2-cpnp",
839 if (!enable[dev]) in snd_opl3sa2_isa_match()