Lines Matching +full:aux +full:- +full:devs

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 card-opti92x-ad1848.c - driver for OPTi 82c92x based soundcards.
4 Copyright (C) 1998-2000 by Massimo Piccioni <dafastidio@libero.it>
41 MODULE_DESCRIPTION("OPTi92X - CS4231");
43 MODULE_DESCRIPTION("OPTi92X - AD1848");
47 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
76 MODULE_PARM_DESC(mpu_port, "MPU-401 port # for opti9xx driver.");
82 MODULE_PARM_DESC(mpu_irq, "MPU-401 irq # for opti9xx driver.");
104 #define OPTi93X_PORT(chip, r) ((chip)->port + OPTi93X_##r)
140 .devs = { { "OPT0000" }, { "OPT0002" }, { "OPT0005" } },
144 .devs = { { "OPT9250" }, { "OPT0002" }, { "OPT0005" } },
148 { .id = "OPT0931", .devs = { { "OPT9310" }, { "OPT0002" } },
172 chip->hardware = hardware; in snd_opti9xx_init()
173 strcpy(chip->name, snd_opti9xx_names[hardware]); in snd_opti9xx_init()
175 spin_lock_init(&chip->lock); in snd_opti9xx_init()
177 chip->irq = -1; in snd_opti9xx_init()
181 if (isapnp && chip->mc_base) in snd_opti9xx_init()
183 chip->mc_base |= 0xc00; in snd_opti9xx_init()
187 chip->mc_base = 0xf8c; in snd_opti9xx_init()
188 chip->mc_base_size = opti9xx_mc_size[hardware]; in snd_opti9xx_init()
191 chip->mc_base_size = opti9xx_mc_size[hardware]; in snd_opti9xx_init()
198 chip->password = (hardware == OPTi9XX_HW_82C928) ? 0xe2 : 0xe3; in snd_opti9xx_init()
199 chip->pwd_reg = 3; in snd_opti9xx_init()
204 chip->password = 0xe5; in snd_opti9xx_init()
205 chip->pwd_reg = 3; in snd_opti9xx_init()
212 chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d; in snd_opti9xx_init()
213 if (!chip->mc_indir_index) in snd_opti9xx_init()
214 chip->mc_indir_index = 0xe0e; in snd_opti9xx_init()
215 chip->password = 0xe4; in snd_opti9xx_init()
216 chip->pwd_reg = 0; in snd_opti9xx_init()
222 return -ENODEV; in snd_opti9xx_init()
233 spin_lock_irqsave(&chip->lock, flags); in snd_opti9xx_read()
234 outb(chip->password, chip->mc_base + chip->pwd_reg); in snd_opti9xx_read()
236 switch (chip->hardware) { in snd_opti9xx_read()
241 outb(reg, chip->mc_base + 8); in snd_opti9xx_read()
242 outb(chip->password, chip->mc_base + chip->pwd_reg); in snd_opti9xx_read()
243 retval = inb(chip->mc_base + 9); in snd_opti9xx_read()
250 retval = inb(chip->mc_base + reg); in snd_opti9xx_read()
257 outb(reg, chip->mc_indir_index); in snd_opti9xx_read()
258 outb(chip->password, chip->mc_base + chip->pwd_reg); in snd_opti9xx_read()
259 retval = inb(chip->mc_indir_index + 1); in snd_opti9xx_read()
264 snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); in snd_opti9xx_read()
267 spin_unlock_irqrestore(&chip->lock, flags); in snd_opti9xx_read()
276 spin_lock_irqsave(&chip->lock, flags); in snd_opti9xx_write()
277 outb(chip->password, chip->mc_base + chip->pwd_reg); in snd_opti9xx_write()
279 switch (chip->hardware) { in snd_opti9xx_write()
284 outb(reg, chip->mc_base + 8); in snd_opti9xx_write()
285 outb(chip->password, chip->mc_base + chip->pwd_reg); in snd_opti9xx_write()
286 outb(value, chip->mc_base + 9); in snd_opti9xx_write()
293 outb(value, chip->mc_base + reg); in snd_opti9xx_write()
300 outb(reg, chip->mc_indir_index); in snd_opti9xx_write()
301 outb(chip->password, chip->mc_base + chip->pwd_reg); in snd_opti9xx_write()
302 outb(value, chip->mc_indir_index + 1); in snd_opti9xx_write()
307 snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); in snd_opti9xx_write()
310 spin_unlock_irqrestore(&chip->lock, flags); in snd_opti9xx_write()
333 switch (chip->hardware) { in snd_opti9xx_configure()
396 (chip->hardware == OPTi9XX_HW_82C930 ? 0x00 : 0x04), in snd_opti9xx_configure()
403 snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware); in snd_opti9xx_configure()
404 return -EINVAL; in snd_opti9xx_configure()
410 chip->wss_base = 0x530; in snd_opti9xx_configure()
414 chip->wss_base = 0x604; in snd_opti9xx_configure()
418 chip->wss_base = 0xe80; in snd_opti9xx_configure()
422 chip->wss_base = 0xf40; in snd_opti9xx_configure()
473 return -EBUSY; in snd_opti9xx_configure()
488 outb(irq_bits << 3 | dma_bits, chip->wss_base); in snd_opti9xx_configure()
494 if (chip->hardware > OPTi9XX_HW_82C928) { in snd_opti9xx_configure()
497 case -1: in snd_opti9xx_configure()
513 "MPU-401 port 0x%lx not valid\n", mpu_port); in snd_opti9xx_configure()
531 snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n", in snd_opti9xx_configure()
548 static const DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_step, -9300, 300, 0);
549 static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0);
550 static const DECLARE_TLV_DB_SCALE(db_scale_4bit_12db_max, -3300, 300, 0);
577 WSS_DOUBLE("Aux Playback Switch", 0,
579 WSS_DOUBLE_TLV("Aux Playback Volume", 0,
591 if (snd_BUG_ON(!chip || !chip->pcm)) in snd_opti93x_mixer()
592 return -EINVAL; in snd_opti93x_mixer()
594 card = chip->card; in snd_opti93x_mixer()
596 strcpy(card->mixername, chip->pcm->name); in snd_opti93x_mixer()
602 strcpy(id1.name, "Aux Playback Switch"); in snd_opti93x_mixer()
610 strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; in snd_opti93x_mixer()
618 strcpy(id1.name, "Aux Playback Volume"); id1.index = 1; in snd_opti93x_mixer()
638 struct snd_wss *codec = chip->codec; in snd_opti93x_interrupt()
645 if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream) in snd_opti93x_interrupt()
646 snd_pcm_period_elapsed(codec->playback_substream); in snd_opti93x_interrupt()
647 if ((status & OPTi93X_IRQ_CAPTURE) && codec->capture_substream) { in snd_opti93x_interrupt()
649 snd_pcm_period_elapsed(codec->capture_substream); in snd_opti93x_interrupt()
665 chip->res_mc_base = in snd_opti9xx_read_check()
666 devm_request_region(card->dev, chip->mc_base, in snd_opti9xx_read_check()
667 chip->mc_base_size, "OPTi9xx MC"); in snd_opti9xx_read_check()
668 if (!chip->res_mc_base) in snd_opti9xx_read_check()
669 return -EBUSY; in snd_opti9xx_read_check()
672 if (value != 0xff && value != inb(chip->mc_base + OPTi9XX_MC_REG(1))) in snd_opti9xx_read_check()
676 chip->res_mc_indir = in snd_opti9xx_read_check()
677 devm_request_region(card->dev, chip->mc_indir_index, 2, in snd_opti9xx_read_check()
679 if (!chip->res_mc_indir) in snd_opti9xx_read_check()
680 return -EBUSY; in snd_opti9xx_read_check()
682 spin_lock_irqsave(&chip->lock, flags); in snd_opti9xx_read_check()
683 outb(chip->password, chip->mc_base + chip->pwd_reg); in snd_opti9xx_read_check()
684 outb(((chip->mc_indir_index & 0x1f0) >> 4), chip->mc_base); in snd_opti9xx_read_check()
685 spin_unlock_irqrestore(&chip->lock, flags); in snd_opti9xx_read_check()
688 snd_opti9xx_write(chip, OPTi9XX_MC_REG(7), 0xff - value); in snd_opti9xx_read_check()
689 if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value) in snd_opti9xx_read_check()
692 devm_release_resource(card->dev, chip->res_mc_indir); in snd_opti9xx_read_check()
693 chip->res_mc_indir = NULL; in snd_opti9xx_read_check()
695 devm_release_resource(card->dev, chip->res_mc_base); in snd_opti9xx_read_check()
696 chip->res_mc_base = NULL; in snd_opti9xx_read_check()
698 return -ENODEV; in snd_opti9xx_read_check()
709 for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) {
719 chip->mc_indir_index = 0;
722 return -ENODEV;
737 pdev = pnp_request_card_device(card, pid->devs[0].id, NULL);
739 return -EBUSY;
748 port = pnp_port_start(pdev, 0) - 4;
750 /* adjust mc_indir_index - some cards report it at 0xe?d,
752 chip->mc_indir_index = (pnp_port_start(pdev, 3) & ~0xf) | 0xe;
754 devmc = pnp_request_card_device(card, pid->devs[2].id, NULL);
756 return -EBUSY;
770 chip->mc_base = pnp_port_start(devmc, 0) - 1;
771 chip->mc_base_size = pnp_port_len(devmc, 0) + 1;
779 devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL);
785 mpu_port = -1;
791 return pid->driver_data;
797 static const long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
800 struct snd_opti9xx *chip = card->private_data;
808 xdma2 = -1;
815 return -EBUSY;
823 error = snd_wss_create(card, chip->wss_base + 4, -1, irq, dma1, xdma2,
832 chip->codec = codec;
850 error = devm_request_irq(card->dev, irq, snd_opti93x_interrupt,
851 0, DEV_NAME" - WSS", chip);
857 chip->irq = irq;
858 card->sync_irq = chip->irq;
859 strcpy(card->driver, chip->name);
860 sprintf(card->shortname, "OPTi %s", card->driver);
862 scnprintf(card->longname, sizeof(card->longname),
864 card->shortname, codec->pcm->name,
865 chip->wss_base + 4, irq, dma1, xdma2);
867 scnprintf(card->longname, sizeof(card->longname),
869 card->shortname, codec->pcm->name, chip->wss_base + 4, irq,
879 snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n",
886 if (chip->hardware == OPTi9XX_HW_82C928 ||
887 chip->hardware == OPTi9XX_HW_82C929 ||
888 chip->hardware == OPTi9XX_HW_82C924) {
893 if (snd_opl4_create(card, fm_port, fm_port - 8,
903 snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n",
904 fm_port, fm_port + 4 - 1);
946 static const long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1};
948 static const int possible_irqs[] = {5, 9, 10, 11, 7, -1};
950 static const int possible_irqs[] = {9, 10, 11, 7, -1};
952 static const int possible_mpu_irqs[] = {5, 9, 10, 7, -1};
953 static const int possible_dma1s[] = {3, 1, 0, -1};
955 static const int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}};
962 return -EBUSY;
969 return -EBUSY;
976 return -EBUSY;
983 return -EBUSY;
991 return -EBUSY;
1000 error = snd_card_opti9xx_detect(card, card->private_data);
1013 struct snd_opti9xx *chip = card->private_data;
1016 chip->codec->suspend(chip->codec);
1022 struct snd_opti9xx *chip = card->private_data;
1027 xdma2 = -1;
1034 chip->codec->resume(chip->codec);
1072 return -EBUSY;
1074 return -ENODEV;
1075 error = snd_opti9xx_card_new(&pcard->card->dev, &card);
1078 chip = card->private_data;
1092 return -ENODEV;