aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-12-04 10:22:32 -0500
committerTakashi Iwai <tiwai@suse.de>2009-12-04 10:22:32 -0500
commit79598324838a25cc378ecbb8c29dd1e3d3951d35 (patch)
tree7d29e81580cba854042df4e33bdc8f38bbd65d03 /sound/isa
parent8ee763b9c82c6ca0a59a7271ce4fa29d7baf5c09 (diff)
parentb00615d163cd24fa98d155acfc1f9d81d6fe1103 (diff)
Merge branch 'topic/core-change' into for-linus
Diffstat (limited to 'sound/isa')
-rw-r--r--sound/isa/Kconfig12
-rw-r--r--sound/isa/cmi8330.c4
-rw-r--r--sound/isa/es1688/es1688_lib.c2
-rw-r--r--sound/isa/es18xx.c132
-rw-r--r--sound/isa/sb/sb_mixer.c4
-rw-r--r--sound/isa/sscape.c727
-rw-r--r--sound/isa/wss/wss_lib.c98
7 files changed, 432 insertions, 547 deletions
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index 51a7e3777e17..02fe81ca88fd 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -372,15 +372,21 @@ config SND_SGALAXY
372 372
373config SND_SSCAPE 373config SND_SSCAPE
374 tristate "Ensoniq SoundScape driver" 374 tristate "Ensoniq SoundScape driver"
375 select SND_HWDEP
376 select SND_MPU401_UART 375 select SND_MPU401_UART
377 select SND_WSS_LIB 376 select SND_WSS_LIB
377 select FW_LOADER
378 help 378 help
379 Say Y here to include support for Ensoniq SoundScape 379 Say Y here to include support for Ensoniq SoundScape
380 soundcards. 380 and Ensoniq OEM soundcards.
381 381
382 The PCM audio is supported on SoundScape Classic, Elite, PnP 382 The PCM audio is supported on SoundScape Classic, Elite, PnP
383 and VIVO cards. The MIDI support is very experimental. 383 and VIVO cards. The supported OEM cards are SPEA Media FX and
384 Reveal SC-600.
385 The MIDI support is very experimental and requires binary
386 firmware files called "scope.cod" and "sndscape.co?" where the
387 ? is digit 0, 1, 2, 3 or 4. The firmware files can be found
388 in DOS or Windows driver packages. One has to put the firmware
389 files into the /lib/firmware directory.
384 390
385 To compile this driver as a module, choose M here: the module 391 To compile this driver as a module, choose M here: the module
386 will be called snd-sscape. 392 will be called snd-sscape.
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index 02f79d252718..8246aae32ab4 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -237,7 +237,7 @@ WSS_DOUBLE("Wavetable Capture Volume", 0,
237 CMI8330_WAVGAIN, CMI8330_WAVGAIN, 4, 0, 15, 0), 237 CMI8330_WAVGAIN, CMI8330_WAVGAIN, 4, 0, 15, 0),
238WSS_SINGLE("3D Control - Switch", 0, 238WSS_SINGLE("3D Control - Switch", 0,
239 CMI8330_RMUX3D, 5, 1, 1), 239 CMI8330_RMUX3D, 5, 1, 1),
240WSS_SINGLE("PC Speaker Playback Volume", 0, 240WSS_SINGLE("Beep Playback Volume", 0,
241 CMI8330_OUTPUTVOL, 3, 3, 0), 241 CMI8330_OUTPUTVOL, 3, 3, 0),
242WSS_DOUBLE("FM Playback Switch", 0, 242WSS_DOUBLE("FM Playback Switch", 0,
243 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), 243 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1),
@@ -262,7 +262,7 @@ SB_DOUBLE("SB Line Playback Switch", SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, 4, 3,
262SB_DOUBLE("SB Line Playback Volume", SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31), 262SB_DOUBLE("SB Line Playback Volume", SB_DSP4_LINE_DEV, (SB_DSP4_LINE_DEV + 1), 3, 3, 31),
263SB_SINGLE("SB Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1), 263SB_SINGLE("SB Mic Playback Switch", SB_DSP4_OUTPUT_SW, 0, 1),
264SB_SINGLE("SB Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31), 264SB_SINGLE("SB Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31),
265SB_SINGLE("SB PC Speaker Volume", SB_DSP4_SPEAKER_DEV, 6, 3), 265SB_SINGLE("SB Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3),
266SB_DOUBLE("SB Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3), 266SB_DOUBLE("SB Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3),
267SB_DOUBLE("SB Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3), 267SB_DOUBLE("SB Playback Volume", SB_DSP4_OGAIN_DEV, (SB_DSP4_OGAIN_DEV + 1), 6, 6, 3),
268SB_SINGLE("SB Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1), 268SB_SINGLE("SB Mic Auto Gain", SB_DSP4_MIC_AGC, 0, 1),
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index 4c6e14f87f2d..c76bb00c9d15 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -982,7 +982,7 @@ ES1688_DOUBLE("CD Playback Volume", 0, ES1688_CD_DEV, ES1688_CD_DEV, 4, 0, 15, 0
982ES1688_DOUBLE("FM Playback Volume", 0, ES1688_FM_DEV, ES1688_FM_DEV, 4, 0, 15, 0), 982ES1688_DOUBLE("FM Playback Volume", 0, ES1688_FM_DEV, ES1688_FM_DEV, 4, 0, 15, 0),
983ES1688_DOUBLE("Mic Playback Volume", 0, ES1688_MIC_DEV, ES1688_MIC_DEV, 4, 0, 15, 0), 983ES1688_DOUBLE("Mic Playback Volume", 0, ES1688_MIC_DEV, ES1688_MIC_DEV, 4, 0, 15, 0),
984ES1688_DOUBLE("Aux Playback Volume", 0, ES1688_AUX_DEV, ES1688_AUX_DEV, 4, 0, 15, 0), 984ES1688_DOUBLE("Aux Playback Volume", 0, ES1688_AUX_DEV, ES1688_AUX_DEV, 4, 0, 15, 0),
985ES1688_SINGLE("PC Speaker Playback Volume", 0, ES1688_SPEAKER_DEV, 0, 7, 0), 985ES1688_SINGLE("Beep Playback Volume", 0, ES1688_SPEAKER_DEV, 0, 7, 0),
986ES1688_DOUBLE("Capture Volume", 0, ES1688_RECLEV_DEV, ES1688_RECLEV_DEV, 4, 0, 15, 0), 986ES1688_DOUBLE("Capture Volume", 0, ES1688_RECLEV_DEV, ES1688_RECLEV_DEV, 4, 0, 15, 0),
987ES1688_SINGLE("Capture Switch", 0, ES1688_REC_DEV, 4, 1, 1), 987ES1688_SINGLE("Capture Switch", 0, ES1688_REC_DEV, 4, 1, 1),
988{ 988{
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index 8cfbff73a835..e5bf3355d2ca 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -121,7 +121,6 @@ struct snd_es18xx {
121 unsigned int dma1_shift; 121 unsigned int dma1_shift;
122 unsigned int dma2_shift; 122 unsigned int dma2_shift;
123 123
124 struct snd_card *card;
125 struct snd_pcm *pcm; 124 struct snd_pcm *pcm;
126 struct snd_pcm_substream *playback_a_substream; 125 struct snd_pcm_substream *playback_a_substream;
127 struct snd_pcm_substream *capture_a_substream; 126 struct snd_pcm_substream *capture_a_substream;
@@ -140,10 +139,6 @@ struct snd_es18xx {
140#ifdef CONFIG_PM 139#ifdef CONFIG_PM
141 unsigned char pm_reg; 140 unsigned char pm_reg;
142#endif 141#endif
143};
144
145struct snd_audiodrive {
146 struct snd_es18xx *chip;
147#ifdef CONFIG_PNP 142#ifdef CONFIG_PNP
148 struct pnp_dev *dev; 143 struct pnp_dev *dev;
149 struct pnp_dev *devc; 144 struct pnp_dev *devc;
@@ -755,7 +750,8 @@ static int snd_es18xx_playback_trigger(struct snd_pcm_substream *substream,
755 750
756static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) 751static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id)
757{ 752{
758 struct snd_es18xx *chip = dev_id; 753 struct snd_card *card = dev_id;
754 struct snd_es18xx *chip = card->private_data;
759 unsigned char status; 755 unsigned char status;
760 756
761 if (chip->caps & ES18XX_CONTROL) { 757 if (chip->caps & ES18XX_CONTROL) {
@@ -805,12 +801,16 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id)
805 int split = 0; 801 int split = 0;
806 if (chip->caps & ES18XX_HWV) { 802 if (chip->caps & ES18XX_HWV) {
807 split = snd_es18xx_mixer_read(chip, 0x64) & 0x80; 803 split = snd_es18xx_mixer_read(chip, 0x64) & 0x80;
808 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_switch->id); 804 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
809 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_volume->id); 805 &chip->hw_switch->id);
806 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
807 &chip->hw_volume->id);
810 } 808 }
811 if (!split) { 809 if (!split) {
812 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_switch->id); 810 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
813 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_volume->id); 811 &chip->master_switch->id);
812 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
813 &chip->master_volume->id);
814 } 814 }
815 /* ack interrupt */ 815 /* ack interrupt */
816 snd_es18xx_mixer_write(chip, 0x66, 0x00); 816 snd_es18xx_mixer_write(chip, 0x66, 0x00);
@@ -1313,7 +1313,7 @@ ES18XX_DOUBLE("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0)
1313 * The chipset specific mixer controls 1313 * The chipset specific mixer controls
1314 */ 1314 */
1315static struct snd_kcontrol_new snd_es18xx_opt_speaker = 1315static struct snd_kcontrol_new snd_es18xx_opt_speaker =
1316 ES18XX_SINGLE("PC Speaker Playback Volume", 0, 0x3c, 0, 7, 0); 1316 ES18XX_SINGLE("Beep Playback Volume", 0, 0x3c, 0, 7, 0);
1317 1317
1318static struct snd_kcontrol_new snd_es18xx_opt_1869[] = { 1318static struct snd_kcontrol_new snd_es18xx_opt_1869[] = {
1319ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), 1319ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1),
@@ -1691,8 +1691,10 @@ static struct snd_pcm_ops snd_es18xx_capture_ops = {
1691 .pointer = snd_es18xx_capture_pointer, 1691 .pointer = snd_es18xx_capture_pointer,
1692}; 1692};
1693 1693
1694static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct snd_pcm ** rpcm) 1694static int __devinit snd_es18xx_pcm(struct snd_card *card, int device,
1695 struct snd_pcm **rpcm)
1695{ 1696{
1697 struct snd_es18xx *chip = card->private_data;
1696 struct snd_pcm *pcm; 1698 struct snd_pcm *pcm;
1697 char str[16]; 1699 char str[16];
1698 int err; 1700 int err;
@@ -1701,9 +1703,9 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct
1701 *rpcm = NULL; 1703 *rpcm = NULL;
1702 sprintf(str, "ES%x", chip->version); 1704 sprintf(str, "ES%x", chip->version);
1703 if (chip->caps & ES18XX_PCM2) 1705 if (chip->caps & ES18XX_PCM2)
1704 err = snd_pcm_new(chip->card, str, device, 2, 1, &pcm); 1706 err = snd_pcm_new(card, str, device, 2, 1, &pcm);
1705 else 1707 else
1706 err = snd_pcm_new(chip->card, str, device, 1, 1, &pcm); 1708 err = snd_pcm_new(card, str, device, 1, 1, &pcm);
1707 if (err < 0) 1709 if (err < 0)
1708 return err; 1710 return err;
1709 1711
@@ -1734,10 +1736,9 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct
1734#ifdef CONFIG_PM 1736#ifdef CONFIG_PM
1735static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) 1737static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state)
1736{ 1738{
1737 struct snd_audiodrive *acard = card->private_data; 1739 struct snd_es18xx *chip = card->private_data;
1738 struct snd_es18xx *chip = acard->chip;
1739 1740
1740 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); 1741 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1741 1742
1742 snd_pcm_suspend_all(chip->pcm); 1743 snd_pcm_suspend_all(chip->pcm);
1743 1744
@@ -1752,24 +1753,25 @@ static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state)
1752 1753
1753static int snd_es18xx_resume(struct snd_card *card) 1754static int snd_es18xx_resume(struct snd_card *card)
1754{ 1755{
1755 struct snd_audiodrive *acard = card->private_data; 1756 struct snd_es18xx *chip = card->private_data;
1756 struct snd_es18xx *chip = acard->chip;
1757 1757
1758 /* restore PM register, we won't wake till (not 0x07) i/o activity though */ 1758 /* restore PM register, we won't wake till (not 0x07) i/o activity though */
1759 snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); 1759 snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM);
1760 1760
1761 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); 1761 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
1762 return 0; 1762 return 0;
1763} 1763}
1764#endif /* CONFIG_PM */ 1764#endif /* CONFIG_PM */
1765 1765
1766static int snd_es18xx_free(struct snd_es18xx *chip) 1766static int snd_es18xx_free(struct snd_card *card)
1767{ 1767{
1768 struct snd_es18xx *chip = card->private_data;
1769
1768 release_and_free_resource(chip->res_port); 1770 release_and_free_resource(chip->res_port);
1769 release_and_free_resource(chip->res_ctrl_port); 1771 release_and_free_resource(chip->res_ctrl_port);
1770 release_and_free_resource(chip->res_mpu_port); 1772 release_and_free_resource(chip->res_mpu_port);
1771 if (chip->irq >= 0) 1773 if (chip->irq >= 0)
1772 free_irq(chip->irq, (void *) chip); 1774 free_irq(chip->irq, (void *) card);
1773 if (chip->dma1 >= 0) { 1775 if (chip->dma1 >= 0) {
1774 disable_dma(chip->dma1); 1776 disable_dma(chip->dma1);
1775 free_dma(chip->dma1); 1777 free_dma(chip->dma1);
@@ -1778,37 +1780,29 @@ static int snd_es18xx_free(struct snd_es18xx *chip)
1778 disable_dma(chip->dma2); 1780 disable_dma(chip->dma2);
1779 free_dma(chip->dma2); 1781 free_dma(chip->dma2);
1780 } 1782 }
1781 kfree(chip);
1782 return 0; 1783 return 0;
1783} 1784}
1784 1785
1785static int snd_es18xx_dev_free(struct snd_device *device) 1786static int snd_es18xx_dev_free(struct snd_device *device)
1786{ 1787{
1787 struct snd_es18xx *chip = device->device_data; 1788 return snd_es18xx_free(device->card);
1788 return snd_es18xx_free(chip);
1789} 1789}
1790 1790
1791static int __devinit snd_es18xx_new_device(struct snd_card *card, 1791static int __devinit snd_es18xx_new_device(struct snd_card *card,
1792 unsigned long port, 1792 unsigned long port,
1793 unsigned long mpu_port, 1793 unsigned long mpu_port,
1794 unsigned long fm_port, 1794 unsigned long fm_port,
1795 int irq, int dma1, int dma2, 1795 int irq, int dma1, int dma2)
1796 struct snd_es18xx ** rchip)
1797{ 1796{
1798 struct snd_es18xx *chip; 1797 struct snd_es18xx *chip = card->private_data;
1799 static struct snd_device_ops ops = { 1798 static struct snd_device_ops ops = {
1800 .dev_free = snd_es18xx_dev_free, 1799 .dev_free = snd_es18xx_dev_free,
1801 }; 1800 };
1802 int err; 1801 int err;
1803 1802
1804 *rchip = NULL;
1805 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1806 if (chip == NULL)
1807 return -ENOMEM;
1808 spin_lock_init(&chip->reg_lock); 1803 spin_lock_init(&chip->reg_lock);
1809 spin_lock_init(&chip->mixer_lock); 1804 spin_lock_init(&chip->mixer_lock);
1810 spin_lock_init(&chip->ctrl_lock); 1805 spin_lock_init(&chip->ctrl_lock);
1811 chip->card = card;
1812 chip->port = port; 1806 chip->port = port;
1813 chip->mpu_port = mpu_port; 1807 chip->mpu_port = mpu_port;
1814 chip->fm_port = fm_port; 1808 chip->fm_port = fm_port;
@@ -1818,53 +1812,53 @@ static int __devinit snd_es18xx_new_device(struct snd_card *card,
1818 chip->audio2_vol = 0x00; 1812 chip->audio2_vol = 0x00;
1819 chip->active = 0; 1813 chip->active = 0;
1820 1814
1821 if ((chip->res_port = request_region(port, 16, "ES18xx")) == NULL) { 1815 chip->res_port = request_region(port, 16, "ES18xx");
1822 snd_es18xx_free(chip); 1816 if (chip->res_port == NULL) {
1817 snd_es18xx_free(card);
1823 snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); 1818 snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1);
1824 return -EBUSY; 1819 return -EBUSY;
1825 } 1820 }
1826 1821
1827 if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx", (void *) chip)) { 1822 if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx",
1828 snd_es18xx_free(chip); 1823 (void *) card)) {
1824 snd_es18xx_free(card);
1829 snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); 1825 snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq);
1830 return -EBUSY; 1826 return -EBUSY;
1831 } 1827 }
1832 chip->irq = irq; 1828 chip->irq = irq;
1833 1829
1834 if (request_dma(dma1, "ES18xx DMA 1")) { 1830 if (request_dma(dma1, "ES18xx DMA 1")) {
1835 snd_es18xx_free(chip); 1831 snd_es18xx_free(card);
1836 snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); 1832 snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1);
1837 return -EBUSY; 1833 return -EBUSY;
1838 } 1834 }
1839 chip->dma1 = dma1; 1835 chip->dma1 = dma1;
1840 1836
1841 if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) { 1837 if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) {
1842 snd_es18xx_free(chip); 1838 snd_es18xx_free(card);
1843 snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); 1839 snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2);
1844 return -EBUSY; 1840 return -EBUSY;
1845 } 1841 }
1846 chip->dma2 = dma2; 1842 chip->dma2 = dma2;
1847 1843
1848 if (snd_es18xx_probe(chip) < 0) { 1844 if (snd_es18xx_probe(chip) < 0) {
1849 snd_es18xx_free(chip); 1845 snd_es18xx_free(card);
1850 return -ENODEV; 1846 return -ENODEV;
1851 } 1847 }
1852 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 1848 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, NULL, &ops);
1853 snd_es18xx_free(chip); 1849 if (err < 0) {
1850 snd_es18xx_free(card);
1854 return err; 1851 return err;
1855 } 1852 }
1856 *rchip = chip;
1857 return 0; 1853 return 0;
1858} 1854}
1859 1855
1860static int __devinit snd_es18xx_mixer(struct snd_es18xx *chip) 1856static int __devinit snd_es18xx_mixer(struct snd_card *card)
1861{ 1857{
1862 struct snd_card *card; 1858 struct snd_es18xx *chip = card->private_data;
1863 int err; 1859 int err;
1864 unsigned int idx; 1860 unsigned int idx;
1865 1861
1866 card = chip->card;
1867
1868 strcpy(card->mixername, chip->pcm->name); 1862 strcpy(card->mixername, chip->pcm->name);
1869 1863
1870 for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { 1864 for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) {
@@ -2063,11 +2057,11 @@ static int __devinit snd_audiodrive_pnp_init_main(int dev, struct pnp_dev *pdev)
2063 return 0; 2057 return 0;
2064} 2058}
2065 2059
2066static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard, 2060static int __devinit snd_audiodrive_pnp(int dev, struct snd_es18xx *chip,
2067 struct pnp_dev *pdev) 2061 struct pnp_dev *pdev)
2068{ 2062{
2069 acard->dev = pdev; 2063 chip->dev = pdev;
2070 if (snd_audiodrive_pnp_init_main(dev, acard->dev) < 0) 2064 if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0)
2071 return -EBUSY; 2065 return -EBUSY;
2072 return 0; 2066 return 0;
2073} 2067}
@@ -2093,26 +2087,26 @@ static struct pnp_card_device_id snd_audiodrive_pnpids[] = {
2093 2087
2094MODULE_DEVICE_TABLE(pnp_card, snd_audiodrive_pnpids); 2088MODULE_DEVICE_TABLE(pnp_card, snd_audiodrive_pnpids);
2095 2089
2096static int __devinit snd_audiodrive_pnpc(int dev, struct snd_audiodrive *acard, 2090static int __devinit snd_audiodrive_pnpc(int dev, struct snd_es18xx *chip,
2097 struct pnp_card_link *card, 2091 struct pnp_card_link *card,
2098 const struct pnp_card_device_id *id) 2092 const struct pnp_card_device_id *id)
2099{ 2093{
2100 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); 2094 chip->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
2101 if (acard->dev == NULL) 2095 if (chip->dev == NULL)
2102 return -EBUSY; 2096 return -EBUSY;
2103 2097
2104 acard->devc = pnp_request_card_device(card, id->devs[1].id, NULL); 2098 chip->devc = pnp_request_card_device(card, id->devs[1].id, NULL);
2105 if (acard->devc == NULL) 2099 if (chip->devc == NULL)
2106 return -EBUSY; 2100 return -EBUSY;
2107 2101
2108 /* Control port initialization */ 2102 /* Control port initialization */
2109 if (pnp_activate_dev(acard->devc) < 0) { 2103 if (pnp_activate_dev(chip->devc) < 0) {
2110 snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n"); 2104 snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n");
2111 return -EAGAIN; 2105 return -EAGAIN;
2112 } 2106 }
2113 snd_printdd("pnp: port=0x%llx\n", 2107 snd_printdd("pnp: port=0x%llx\n",
2114 (unsigned long long)pnp_port_start(acard->devc, 0)); 2108 (unsigned long long)pnp_port_start(chip->devc, 0));
2115 if (snd_audiodrive_pnp_init_main(dev, acard->dev) < 0) 2109 if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0)
2116 return -EBUSY; 2110 return -EBUSY;
2117 2111
2118 return 0; 2112 return 0;
@@ -2128,24 +2122,20 @@ static int __devinit snd_audiodrive_pnpc(int dev, struct snd_audiodrive *acard,
2128static int snd_es18xx_card_new(int dev, struct snd_card **cardp) 2122static int snd_es18xx_card_new(int dev, struct snd_card **cardp)
2129{ 2123{
2130 return snd_card_create(index[dev], id[dev], THIS_MODULE, 2124 return snd_card_create(index[dev], id[dev], THIS_MODULE,
2131 sizeof(struct snd_audiodrive), cardp); 2125 sizeof(struct snd_es18xx), cardp);
2132} 2126}
2133 2127
2134static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) 2128static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev)
2135{ 2129{
2136 struct snd_audiodrive *acard = card->private_data; 2130 struct snd_es18xx *chip = card->private_data;
2137 struct snd_es18xx *chip;
2138 struct snd_opl3 *opl3; 2131 struct snd_opl3 *opl3;
2139 int err; 2132 int err;
2140 2133
2141 if ((err = snd_es18xx_new_device(card, 2134 err = snd_es18xx_new_device(card,
2142 port[dev], 2135 port[dev], mpu_port[dev], fm_port[dev],
2143 mpu_port[dev], 2136 irq[dev], dma1[dev], dma2[dev]);
2144 fm_port[dev], 2137 if (err < 0)
2145 irq[dev], dma1[dev], dma2[dev],
2146 &chip)) < 0)
2147 return err; 2138 return err;
2148 acard->chip = chip;
2149 2139
2150 sprintf(card->driver, "ES%x", chip->version); 2140 sprintf(card->driver, "ES%x", chip->version);
2151 2141
@@ -2161,10 +2151,12 @@ static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev)
2161 chip->port, 2151 chip->port,
2162 irq[dev], dma1[dev]); 2152 irq[dev], dma1[dev]);
2163 2153
2164 if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) 2154 err = snd_es18xx_pcm(card, 0, NULL);
2155 if (err < 0)
2165 return err; 2156 return err;
2166 2157
2167 if ((err = snd_es18xx_mixer(chip)) < 0) 2158 err = snd_es18xx_mixer(card);
2159 if (err < 0)
2168 return err; 2160 return err;
2169 2161
2170 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { 2162 if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c
index 475220bbcc96..318ff0c823e7 100644
--- a/sound/isa/sb/sb_mixer.c
+++ b/sound/isa/sb/sb_mixer.c
@@ -631,7 +631,7 @@ static struct sbmix_elem snd_sb16_ctl_mic_play_switch =
631static struct sbmix_elem snd_sb16_ctl_mic_play_vol = 631static struct sbmix_elem snd_sb16_ctl_mic_play_vol =
632 SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31); 632 SB_SINGLE("Mic Playback Volume", SB_DSP4_MIC_DEV, 3, 31);
633static struct sbmix_elem snd_sb16_ctl_pc_speaker_vol = 633static struct sbmix_elem snd_sb16_ctl_pc_speaker_vol =
634 SB_SINGLE("PC Speaker Volume", SB_DSP4_SPEAKER_DEV, 6, 3); 634 SB_SINGLE("Beep Volume", SB_DSP4_SPEAKER_DEV, 6, 3);
635static struct sbmix_elem snd_sb16_ctl_capture_vol = 635static struct sbmix_elem snd_sb16_ctl_capture_vol =
636 SB_DOUBLE("Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3); 636 SB_DOUBLE("Capture Volume", SB_DSP4_IGAIN_DEV, (SB_DSP4_IGAIN_DEV + 1), 6, 6, 3);
637static struct sbmix_elem snd_sb16_ctl_play_vol = 637static struct sbmix_elem snd_sb16_ctl_play_vol =
@@ -689,7 +689,7 @@ static struct sbmix_elem snd_dt019x_ctl_cd_play_vol =
689static struct sbmix_elem snd_dt019x_ctl_mic_play_vol = 689static struct sbmix_elem snd_dt019x_ctl_mic_play_vol =
690 SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7); 690 SB_SINGLE("Mic Playback Volume", SB_DT019X_MIC_DEV, 4, 7);
691static struct sbmix_elem snd_dt019x_ctl_pc_speaker_vol = 691static struct sbmix_elem snd_dt019x_ctl_pc_speaker_vol =
692 SB_SINGLE("PC Speaker Volume", SB_DT019X_SPKR_DEV, 0, 7); 692 SB_SINGLE("Beep Volume", SB_DT019X_SPKR_DEV, 0, 7);
693static struct sbmix_elem snd_dt019x_ctl_line_play_vol = 693static struct sbmix_elem snd_dt019x_ctl_line_play_vol =
694 SB_DOUBLE("Line Playback Volume", SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4,0, 15); 694 SB_DOUBLE("Line Playback Volume", SB_DT019X_LINE_DEV, SB_DT019X_LINE_DEV, 4,0, 15);
695static struct sbmix_elem snd_dt019x_ctl_pcm_play_switch = 695static struct sbmix_elem snd_dt019x_ctl_pcm_play_switch =
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 66187122377c..e2d5d2d3ed96 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Low-level ALSA driver for the ENSONIQ SoundScape PnP 2 * Low-level ALSA driver for the ENSONIQ SoundScape
3 * Copyright (c) by Chris Rankin 3 * Copyright (c) by Chris Rankin
4 * 4 *
5 * This driver was written in part using information obtained from 5 * This driver was written in part using information obtained from
@@ -25,31 +25,36 @@
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/isa.h> 26#include <linux/isa.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/firmware.h>
28#include <linux/pnp.h> 29#include <linux/pnp.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
30#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
31#include <asm/dma.h> 32#include <asm/dma.h>
32#include <sound/core.h> 33#include <sound/core.h>
33#include <sound/hwdep.h>
34#include <sound/wss.h> 34#include <sound/wss.h>
35#include <sound/mpu401.h> 35#include <sound/mpu401.h>
36#include <sound/initval.h> 36#include <sound/initval.h>
37 37
38#include <sound/sscape_ioctl.h>
39
40 38
41MODULE_AUTHOR("Chris Rankin"); 39MODULE_AUTHOR("Chris Rankin");
42MODULE_DESCRIPTION("ENSONIQ SoundScape PnP driver"); 40MODULE_DESCRIPTION("ENSONIQ SoundScape driver");
43MODULE_LICENSE("GPL"); 41MODULE_LICENSE("GPL");
44 42MODULE_FIRMWARE("sndscape.co0");
45static int index[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IDX; 43MODULE_FIRMWARE("sndscape.co1");
46static char* id[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_STR; 44MODULE_FIRMWARE("sndscape.co2");
47static long port[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PORT; 45MODULE_FIRMWARE("sndscape.co3");
48static long wss_port[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_PORT; 46MODULE_FIRMWARE("sndscape.co4");
49static int irq[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IRQ; 47MODULE_FIRMWARE("scope.cod");
50static int mpu_irq[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_IRQ; 48
51static int dma[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_DMA; 49static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
52static int dma2[SNDRV_CARDS] __devinitdata = SNDRV_DEFAULT_DMA; 50static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
51static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
52static long wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
53static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
54static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
55static int dma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;
56static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;
57static bool joystick[SNDRV_CARDS];
53 58
54module_param_array(index, int, NULL, 0444); 59module_param_array(index, int, NULL, 0444);
55MODULE_PARM_DESC(index, "Index number for SoundScape soundcard"); 60MODULE_PARM_DESC(index, "Index number for SoundScape soundcard");
@@ -75,6 +80,9 @@ MODULE_PARM_DESC(dma, "DMA # for SoundScape driver.");
75module_param_array(dma2, int, NULL, 0444); 80module_param_array(dma2, int, NULL, 0444);
76MODULE_PARM_DESC(dma2, "DMA2 # for SoundScape driver."); 81MODULE_PARM_DESC(dma2, "DMA2 # for SoundScape driver.");
77 82
83module_param_array(joystick, bool, NULL, 0444);
84MODULE_PARM_DESC(joystick, "Enable gameport.");
85
78#ifdef CONFIG_PNP 86#ifdef CONFIG_PNP
79static int isa_registered; 87static int isa_registered;
80static int pnp_registered; 88static int pnp_registered;
@@ -101,14 +109,14 @@ MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids);
101#define RX_READY 0x01 109#define RX_READY 0x01
102#define TX_READY 0x02 110#define TX_READY 0x02
103 111
104#define CMD_ACK 0x80 112#define CMD_ACK 0x80
105#define CMD_SET_MIDI_VOL 0x84 113#define CMD_SET_MIDI_VOL 0x84
106#define CMD_GET_MIDI_VOL 0x85 114#define CMD_GET_MIDI_VOL 0x85
107#define CMD_XXX_MIDI_VOL 0x86 115#define CMD_XXX_MIDI_VOL 0x86
108#define CMD_SET_EXTMIDI 0x8a 116#define CMD_SET_EXTMIDI 0x8a
109#define CMD_GET_EXTMIDI 0x8b 117#define CMD_GET_EXTMIDI 0x8b
110#define CMD_SET_MT32 0x8c 118#define CMD_SET_MT32 0x8c
111#define CMD_GET_MT32 0x8d 119#define CMD_GET_MT32 0x8d
112 120
113enum GA_REG { 121enum GA_REG {
114 GA_INTSTAT_REG = 0, 122 GA_INTSTAT_REG = 0,
@@ -127,7 +135,8 @@ enum GA_REG {
127 135
128 136
129enum card_type { 137enum card_type {
130 SSCAPE, 138 MEDIA_FX, /* Sequoia S-1000 */
139 SSCAPE, /* Sequoia S-2000 */
131 SSCAPE_PNP, 140 SSCAPE_PNP,
132 SSCAPE_VIVO, 141 SSCAPE_VIVO,
133}; 142};
@@ -140,16 +149,7 @@ struct soundscape {
140 struct resource *io_res; 149 struct resource *io_res;
141 struct resource *wss_res; 150 struct resource *wss_res;
142 struct snd_wss *chip; 151 struct snd_wss *chip;
143 struct snd_mpu401 *mpu;
144 struct snd_hwdep *hw;
145 152
146 /*
147 * The MIDI device won't work until we've loaded
148 * its firmware via a hardware-dependent device IOCTL
149 */
150 spinlock_t fwlock;
151 int hw_in_use;
152 unsigned long midi_usage;
153 unsigned char midi_vol; 153 unsigned char midi_vol;
154}; 154};
155 155
@@ -161,28 +161,21 @@ static inline struct soundscape *get_card_soundscape(struct snd_card *c)
161 return (struct soundscape *) (c->private_data); 161 return (struct soundscape *) (c->private_data);
162} 162}
163 163
164static inline struct soundscape *get_mpu401_soundscape(struct snd_mpu401 * mpu)
165{
166 return (struct soundscape *) (mpu->private_data);
167}
168
169static inline struct soundscape *get_hwdep_soundscape(struct snd_hwdep * hw)
170{
171 return (struct soundscape *) (hw->private_data);
172}
173
174
175/* 164/*
176 * Allocates some kernel memory that we can use for DMA. 165 * Allocates some kernel memory that we can use for DMA.
177 * I think this means that the memory has to map to 166 * I think this means that the memory has to map to
178 * contiguous pages of physical memory. 167 * contiguous pages of physical memory.
179 */ 168 */
180static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf, unsigned long size) 169static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf,
170 unsigned long size)
181{ 171{
182 if (buf) { 172 if (buf) {
183 if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), 173 if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV,
174 snd_dma_isa_data(),
184 size, buf) < 0) { 175 size, buf) < 0) {
185 snd_printk(KERN_ERR "sscape: Failed to allocate %lu bytes for DMA\n", size); 176 snd_printk(KERN_ERR "sscape: Failed to allocate "
177 "%lu bytes for DMA\n",
178 size);
186 return NULL; 179 return NULL;
187 } 180 }
188 } 181 }
@@ -199,13 +192,13 @@ static void free_dmabuf(struct snd_dma_buffer *buf)
199 snd_dma_free_pages(buf); 192 snd_dma_free_pages(buf);
200} 193}
201 194
202
203/* 195/*
204 * This function writes to the SoundScape's control registers, 196 * This function writes to the SoundScape's control registers,
205 * but doesn't do any locking. It's up to the caller to do that. 197 * but doesn't do any locking. It's up to the caller to do that.
206 * This is why this function is "unsafe" ... 198 * This is why this function is "unsafe" ...
207 */ 199 */
208static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, unsigned char val) 200static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg,
201 unsigned char val)
209{ 202{
210 outb(reg, ODIE_ADDR_IO(io_base)); 203 outb(reg, ODIE_ADDR_IO(io_base));
211 outb(val, ODIE_DATA_IO(io_base)); 204 outb(val, ODIE_DATA_IO(io_base));
@@ -215,7 +208,8 @@ static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, unsign
215 * Write to the SoundScape's control registers, and do the 208 * Write to the SoundScape's control registers, and do the
216 * necessary locking ... 209 * necessary locking ...
217 */ 210 */
218static void sscape_write(struct soundscape *s, enum GA_REG reg, unsigned char val) 211static void sscape_write(struct soundscape *s, enum GA_REG reg,
212 unsigned char val)
219{ 213{
220 unsigned long flags; 214 unsigned long flags;
221 215
@@ -228,7 +222,8 @@ static void sscape_write(struct soundscape *s, enum GA_REG reg, unsigned char va
228 * Read from the SoundScape's control registers, but leave any 222 * Read from the SoundScape's control registers, but leave any
229 * locking to the caller. This is why the function is "unsafe" ... 223 * locking to the caller. This is why the function is "unsafe" ...
230 */ 224 */
231static inline unsigned char sscape_read_unsafe(unsigned io_base, enum GA_REG reg) 225static inline unsigned char sscape_read_unsafe(unsigned io_base,
226 enum GA_REG reg)
232{ 227{
233 outb(reg, ODIE_ADDR_IO(io_base)); 228 outb(reg, ODIE_ADDR_IO(io_base));
234 return inb(ODIE_DATA_IO(io_base)); 229 return inb(ODIE_DATA_IO(io_base));
@@ -257,9 +252,8 @@ static inline void set_midi_mode_unsafe(unsigned io_base)
257static inline int host_read_unsafe(unsigned io_base) 252static inline int host_read_unsafe(unsigned io_base)
258{ 253{
259 int data = -1; 254 int data = -1;
260 if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0) { 255 if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0)
261 data = inb(HOST_DATA_IO(io_base)); 256 data = inb(HOST_DATA_IO(io_base));
262 }
263 257
264 return data; 258 return data;
265} 259}
@@ -301,7 +295,7 @@ static inline int host_write_unsafe(unsigned io_base, unsigned char data)
301 * Also leaves all locking-issues to the caller ... 295 * Also leaves all locking-issues to the caller ...
302 */ 296 */
303static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, 297static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data,
304 unsigned timeout) 298 unsigned timeout)
305{ 299{
306 int err; 300 int err;
307 301
@@ -320,7 +314,7 @@ static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data,
320 * 314 *
321 * NOTE: This check is based upon observation, not documentation. 315 * NOTE: This check is based upon observation, not documentation.
322 */ 316 */
323static inline int verify_mpu401(const struct snd_mpu401 * mpu) 317static inline int verify_mpu401(const struct snd_mpu401 *mpu)
324{ 318{
325 return ((inb(MPU401C(mpu)) & 0xc0) == 0x80); 319 return ((inb(MPU401C(mpu)) & 0xc0) == 0x80);
326} 320}
@@ -328,7 +322,7 @@ static inline int verify_mpu401(const struct snd_mpu401 * mpu)
328/* 322/*
329 * This is apparently the standard way to initailise an MPU-401 323 * This is apparently the standard way to initailise an MPU-401
330 */ 324 */
331static inline void initialise_mpu401(const struct snd_mpu401 * mpu) 325static inline void initialise_mpu401(const struct snd_mpu401 *mpu)
332{ 326{
333 outb(0, MPU401D(mpu)); 327 outb(0, MPU401D(mpu));
334} 328}
@@ -338,9 +332,10 @@ static inline void initialise_mpu401(const struct snd_mpu401 * mpu)
338 * The AD1845 detection fails if we *don't* do this, so I 332 * The AD1845 detection fails if we *don't* do this, so I
339 * think that this is a good idea ... 333 * think that this is a good idea ...
340 */ 334 */
341static inline void activate_ad1845_unsafe(unsigned io_base) 335static void activate_ad1845_unsafe(unsigned io_base)
342{ 336{
343 sscape_write_unsafe(io_base, GA_HMCTL_REG, (sscape_read_unsafe(io_base, GA_HMCTL_REG) & 0xcf) | 0x10); 337 unsigned char val = sscape_read_unsafe(io_base, GA_HMCTL_REG);
338 sscape_write_unsafe(io_base, GA_HMCTL_REG, (val & 0xcf) | 0x10);
344 sscape_write_unsafe(io_base, GA_CDCFG_REG, 0x80); 339 sscape_write_unsafe(io_base, GA_CDCFG_REG, 0x80);
345} 340}
346 341
@@ -359,24 +354,27 @@ static void soundscape_free(struct snd_card *c)
359 * Tell the SoundScape to begin a DMA tranfer using the given channel. 354 * Tell the SoundScape to begin a DMA tranfer using the given channel.
360 * All locking issues are left to the caller. 355 * All locking issues are left to the caller.
361 */ 356 */
362static inline void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg) 357static void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg)
363{ 358{
364 sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) | 0x01); 359 sscape_write_unsafe(io_base, reg,
365 sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) & 0xfe); 360 sscape_read_unsafe(io_base, reg) | 0x01);
361 sscape_write_unsafe(io_base, reg,
362 sscape_read_unsafe(io_base, reg) & 0xfe);
366} 363}
367 364
368/* 365/*
369 * Wait for a DMA transfer to complete. This is a "limited busy-wait", 366 * Wait for a DMA transfer to complete. This is a "limited busy-wait",
370 * and all locking issues are left to the caller. 367 * and all locking issues are left to the caller.
371 */ 368 */
372static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, unsigned timeout) 369static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg,
370 unsigned timeout)
373{ 371{
374 while (!(sscape_read_unsafe(io_base, reg) & 0x01) && (timeout != 0)) { 372 while (!(sscape_read_unsafe(io_base, reg) & 0x01) && (timeout != 0)) {
375 udelay(100); 373 udelay(100);
376 --timeout; 374 --timeout;
377 } /* while */ 375 } /* while */
378 376
379 return (sscape_read_unsafe(io_base, reg) & 0x01); 377 return sscape_read_unsafe(io_base, reg) & 0x01;
380} 378}
381 379
382/* 380/*
@@ -392,12 +390,12 @@ static int obp_startup_ack(struct soundscape *s, unsigned timeout)
392 390
393 do { 391 do {
394 unsigned long flags; 392 unsigned long flags;
395 unsigned char x; 393 int x;
396 394
397 spin_lock_irqsave(&s->lock, flags); 395 spin_lock_irqsave(&s->lock, flags);
398 x = inb(HOST_DATA_IO(s->io_base)); 396 x = host_read_unsafe(s->io_base);
399 spin_unlock_irqrestore(&s->lock, flags); 397 spin_unlock_irqrestore(&s->lock, flags);
400 if ((x & 0xfe) == 0xfe) 398 if (x == 0xfe || x == 0xff)
401 return 1; 399 return 1;
402 400
403 msleep(10); 401 msleep(10);
@@ -419,10 +417,10 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout)
419 417
420 do { 418 do {
421 unsigned long flags; 419 unsigned long flags;
422 unsigned char x; 420 int x;
423 421
424 spin_lock_irqsave(&s->lock, flags); 422 spin_lock_irqsave(&s->lock, flags);
425 x = inb(HOST_DATA_IO(s->io_base)); 423 x = host_read_unsafe(s->io_base);
426 spin_unlock_irqrestore(&s->lock, flags); 424 spin_unlock_irqrestore(&s->lock, flags);
427 if (x == 0xfe) 425 if (x == 0xfe)
428 return 1; 426 return 1;
@@ -436,15 +434,15 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout)
436/* 434/*
437 * Upload a byte-stream into the SoundScape using DMA channel A. 435 * Upload a byte-stream into the SoundScape using DMA channel A.
438 */ 436 */
439static int upload_dma_data(struct soundscape *s, 437static int upload_dma_data(struct soundscape *s, const unsigned char *data,
440 const unsigned char __user *data, 438 size_t size)
441 size_t size)
442{ 439{
443 unsigned long flags; 440 unsigned long flags;
444 struct snd_dma_buffer dma; 441 struct snd_dma_buffer dma;
445 int ret; 442 int ret;
443 unsigned char val;
446 444
447 if (!get_dmabuf(&dma, PAGE_ALIGN(size))) 445 if (!get_dmabuf(&dma, PAGE_ALIGN(32 * 1024)))
448 return -ENOMEM; 446 return -ENOMEM;
449 447
450 spin_lock_irqsave(&s->lock, flags); 448 spin_lock_irqsave(&s->lock, flags);
@@ -452,70 +450,57 @@ static int upload_dma_data(struct soundscape *s,
452 /* 450 /*
453 * Reset the board ... 451 * Reset the board ...
454 */ 452 */
455 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f); 453 val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
454 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val & 0x3f);
456 455
457 /* 456 /*
458 * Enable the DMA channels and configure them ... 457 * Enable the DMA channels and configure them ...
459 */ 458 */
460 sscape_write_unsafe(s->io_base, GA_DMACFG_REG, 0x50); 459 val = (s->chip->dma1 << 4) | DMA_8BIT;
461 sscape_write_unsafe(s->io_base, GA_DMAA_REG, (s->chip->dma1 << 4) | DMA_8BIT); 460 sscape_write_unsafe(s->io_base, GA_DMAA_REG, val);
462 sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20); 461 sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20);
463 462
464 /* 463 /*
465 * Take the board out of reset ... 464 * Take the board out of reset ...
466 */ 465 */
467 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x80); 466 val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
467 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x80);
468 468
469 /* 469 /*
470 * Upload the user's data (firmware?) to the SoundScape 470 * Upload the firmware to the SoundScape
471 * board through the DMA channel ... 471 * board through the DMA channel ...
472 */ 472 */
473 while (size != 0) { 473 while (size != 0) {
474 unsigned long len; 474 unsigned long len;
475 475
476 /*
477 * Apparently, copying to/from userspace can sleep.
478 * We are therefore forbidden from holding any
479 * spinlocks while we copy ...
480 */
481 spin_unlock_irqrestore(&s->lock, flags);
482
483 /*
484 * Remember that the data that we want to DMA
485 * comes from USERSPACE. We have already verified
486 * the userspace pointer ...
487 */
488 len = min(size, dma.bytes); 476 len = min(size, dma.bytes);
489 len -= __copy_from_user(dma.area, data, len); 477 memcpy(dma.area, data, len);
490 data += len; 478 data += len;
491 size -= len; 479 size -= len;
492 480
493 /*
494 * Grab that spinlock again, now that we've
495 * finished copying!
496 */
497 spin_lock_irqsave(&s->lock, flags);
498
499 snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE); 481 snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE);
500 sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG); 482 sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG);
501 if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) { 483 if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) {
502 /* 484 /*
503 * Don't forget to release this spinlock we're holding ... 485 * Don't forget to release this spinlock we're holding
504 */ 486 */
505 spin_unlock_irqrestore(&s->lock, flags); 487 spin_unlock_irqrestore(&s->lock, flags);
506 488
507 snd_printk(KERN_ERR "sscape: DMA upload has timed out\n"); 489 snd_printk(KERN_ERR
490 "sscape: DMA upload has timed out\n");
508 ret = -EAGAIN; 491 ret = -EAGAIN;
509 goto _release_dma; 492 goto _release_dma;
510 } 493 }
511 } /* while */ 494 } /* while */
512 495
513 set_host_mode_unsafe(s->io_base); 496 set_host_mode_unsafe(s->io_base);
497 outb(0x0, s->io_base);
514 498
515 /* 499 /*
516 * Boot the board ... (I think) 500 * Boot the board ... (I think)
517 */ 501 */
518 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x40); 502 val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
503 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x40);
519 spin_unlock_irqrestore(&s->lock, flags); 504 spin_unlock_irqrestore(&s->lock, flags);
520 505
521 /* 506 /*
@@ -525,10 +510,12 @@ static int upload_dma_data(struct soundscape *s,
525 */ 510 */
526 ret = 0; 511 ret = 0;
527 if (!obp_startup_ack(s, 5000)) { 512 if (!obp_startup_ack(s, 5000)) {
528 snd_printk(KERN_ERR "sscape: No response from on-board processor after upload\n"); 513 snd_printk(KERN_ERR "sscape: No response "
514 "from on-board processor after upload\n");
529 ret = -EAGAIN; 515 ret = -EAGAIN;
530 } else if (!host_startup_ack(s, 5000)) { 516 } else if (!host_startup_ack(s, 5000)) {
531 snd_printk(KERN_ERR "sscape: SoundScape failed to initialise\n"); 517 snd_printk(KERN_ERR
518 "sscape: SoundScape failed to initialise\n");
532 ret = -EAGAIN; 519 ret = -EAGAIN;
533 } 520 }
534 521
@@ -536,7 +523,7 @@ _release_dma:
536 /* 523 /*
537 * NOTE!!! We are NOT holding any spinlocks at this point !!! 524 * NOTE!!! We are NOT holding any spinlocks at this point !!!
538 */ 525 */
539 sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_ODIE ? 0x70 : 0x40)); 526 sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_OPUS ? 0x40 : 0x70));
540 free_dmabuf(&dma); 527 free_dmabuf(&dma);
541 528
542 return ret; 529 return ret;
@@ -546,167 +533,76 @@ _release_dma:
546 * Upload the bootblock(?) into the SoundScape. The only 533 * Upload the bootblock(?) into the SoundScape. The only
547 * purpose of this block of code seems to be to tell 534 * purpose of this block of code seems to be to tell
548 * us which version of the microcode we should be using. 535 * us which version of the microcode we should be using.
549 *
550 * NOTE: The boot-block data resides in USER-SPACE!!!
551 * However, we have already verified its memory
552 * addresses by the time we get here.
553 */ 536 */
554static int sscape_upload_bootblock(struct soundscape *sscape, struct sscape_bootblock __user *bb) 537static int sscape_upload_bootblock(struct snd_card *card)
555{ 538{
539 struct soundscape *sscape = get_card_soundscape(card);
556 unsigned long flags; 540 unsigned long flags;
541 const struct firmware *init_fw = NULL;
557 int data = 0; 542 int data = 0;
558 int ret; 543 int ret;
559 544
560 ret = upload_dma_data(sscape, bb->code, sizeof(bb->code)); 545 ret = request_firmware(&init_fw, "scope.cod", card->dev);
561 546 if (ret < 0) {
562 spin_lock_irqsave(&sscape->lock, flags); 547 snd_printk(KERN_ERR "sscape: Error loading scope.cod");
563 if (ret == 0) { 548 return ret;
564 data = host_read_ctrl_unsafe(sscape->io_base, 100);
565 }
566 set_midi_mode_unsafe(sscape->io_base);
567 spin_unlock_irqrestore(&sscape->lock, flags);
568
569 if (ret == 0) {
570 if (data < 0) {
571 snd_printk(KERN_ERR "sscape: timeout reading firmware version\n");
572 ret = -EAGAIN;
573 }
574 else if (__copy_to_user(&bb->version, &data, sizeof(bb->version))) {
575 ret = -EFAULT;
576 }
577 } 549 }
550 ret = upload_dma_data(sscape, init_fw->data, init_fw->size);
578 551
579 return ret; 552 release_firmware(init_fw);
580}
581
582/*
583 * Upload the microcode into the SoundScape. The
584 * microcode is 64K of data, and if we try to copy
585 * it into a local variable then we will SMASH THE
586 * KERNEL'S STACK! We therefore leave it in USER
587 * SPACE, and save ourselves from copying it at all.
588 */
589static int sscape_upload_microcode(struct soundscape *sscape,
590 const struct sscape_microcode __user *mc)
591{
592 unsigned long flags;
593 char __user *code;
594 int err;
595 553
596 /* 554 spin_lock_irqsave(&sscape->lock, flags);
597 * We are going to have to copy this data into a special 555 if (ret == 0)
598 * DMA-able buffer before we can upload it. We shall therefore 556 data = host_read_ctrl_unsafe(sscape->io_base, 100);
599 * just check that the data pointer is valid for now.
600 *
601 * NOTE: This buffer is 64K long! That's WAY too big to
602 * copy into a stack-temporary anyway.
603 */
604 if ( get_user(code, &mc->code) ||
605 !access_ok(VERIFY_READ, code, SSCAPE_MICROCODE_SIZE) )
606 return -EFAULT;
607 557
608 if ((err = upload_dma_data(sscape, code, SSCAPE_MICROCODE_SIZE)) == 0) { 558 if (data & 0x10)
609 snd_printk(KERN_INFO "sscape: MIDI firmware loaded\n"); 559 sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2f);
610 }
611 560
612 spin_lock_irqsave(&sscape->lock, flags);
613 set_midi_mode_unsafe(sscape->io_base);
614 spin_unlock_irqrestore(&sscape->lock, flags); 561 spin_unlock_irqrestore(&sscape->lock, flags);
615 562
616 initialise_mpu401(sscape->mpu); 563 data &= 0xf;
564 if (ret == 0 && data > 7) {
565 snd_printk(KERN_ERR
566 "sscape: timeout reading firmware version\n");
567 ret = -EAGAIN;
568 }
617 569
618 return err; 570 return (ret == 0) ? data : ret;
619} 571}
620 572
621/* 573/*
622 * Hardware-specific device functions, to implement special 574 * Upload the microcode into the SoundScape.
623 * IOCTLs for the SoundScape card. This is how we upload
624 * the microcode into the card, for example, and so we
625 * must ensure that no two processes can open this device
626 * simultaneously, and that we can't open it at all if
627 * someone is using the MIDI device.
628 */ 575 */
629static int sscape_hw_open(struct snd_hwdep * hw, struct file *file) 576static int sscape_upload_microcode(struct snd_card *card, int version)
630{ 577{
631 register struct soundscape *sscape = get_hwdep_soundscape(hw); 578 struct soundscape *sscape = get_card_soundscape(card);
632 unsigned long flags; 579 const struct firmware *init_fw = NULL;
580 char name[14];
633 int err; 581 int err;
634 582
635 spin_lock_irqsave(&sscape->fwlock, flags); 583 snprintf(name, sizeof(name), "sndscape.co%d", version);
636 584
637 if ((sscape->midi_usage != 0) || sscape->hw_in_use) { 585 err = request_firmware(&init_fw, name, card->dev);
638 err = -EBUSY; 586 if (err < 0) {
639 } else { 587 snd_printk(KERN_ERR "sscape: Error loading sndscape.co%d",
640 sscape->hw_in_use = 1; 588 version);
641 err = 0; 589 return err;
642 } 590 }
591 err = upload_dma_data(sscape, init_fw->data, init_fw->size);
592 if (err == 0)
593 snd_printk(KERN_INFO "sscape: MIDI firmware loaded %d KBs\n",
594 init_fw->size >> 10);
643 595
644 spin_unlock_irqrestore(&sscape->fwlock, flags); 596 release_firmware(init_fw);
645 return err;
646}
647
648static int sscape_hw_release(struct snd_hwdep * hw, struct file *file)
649{
650 register struct soundscape *sscape = get_hwdep_soundscape(hw);
651 unsigned long flags;
652
653 spin_lock_irqsave(&sscape->fwlock, flags);
654 sscape->hw_in_use = 0;
655 spin_unlock_irqrestore(&sscape->fwlock, flags);
656 return 0;
657}
658
659static int sscape_hw_ioctl(struct snd_hwdep * hw, struct file *file,
660 unsigned int cmd, unsigned long arg)
661{
662 struct soundscape *sscape = get_hwdep_soundscape(hw);
663 int err = -EBUSY;
664
665 switch (cmd) {
666 case SND_SSCAPE_LOAD_BOOTB:
667 {
668 register struct sscape_bootblock __user *bb = (struct sscape_bootblock __user *) arg;
669
670 /*
671 * We are going to have to copy this data into a special
672 * DMA-able buffer before we can upload it. We shall therefore
673 * just check that the data pointer is valid for now ...
674 */
675 if ( !access_ok(VERIFY_READ, bb->code, sizeof(bb->code)) )
676 return -EFAULT;
677
678 /*
679 * Now check that we can write the firmware version number too...
680 */
681 if ( !access_ok(VERIFY_WRITE, &bb->version, sizeof(bb->version)) )
682 return -EFAULT;
683
684 err = sscape_upload_bootblock(sscape, bb);
685 }
686 break;
687
688 case SND_SSCAPE_LOAD_MCODE:
689 {
690 register const struct sscape_microcode __user *mc = (const struct sscape_microcode __user *) arg;
691
692 err = sscape_upload_microcode(sscape, mc);
693 }
694 break;
695
696 default:
697 err = -EINVAL;
698 break;
699 } /* switch */
700 597
701 return err; 598 return err;
702} 599}
703 600
704
705/* 601/*
706 * Mixer control for the SoundScape's MIDI device. 602 * Mixer control for the SoundScape's MIDI device.
707 */ 603 */
708static int sscape_midi_info(struct snd_kcontrol *ctl, 604static int sscape_midi_info(struct snd_kcontrol *ctl,
709 struct snd_ctl_elem_info *uinfo) 605 struct snd_ctl_elem_info *uinfo)
710{ 606{
711 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 607 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
712 uinfo->count = 1; 608 uinfo->count = 1;
@@ -716,7 +612,7 @@ static int sscape_midi_info(struct snd_kcontrol *ctl,
716} 612}
717 613
718static int sscape_midi_get(struct snd_kcontrol *kctl, 614static int sscape_midi_get(struct snd_kcontrol *kctl,
719 struct snd_ctl_elem_value *uctl) 615 struct snd_ctl_elem_value *uctl)
720{ 616{
721 struct snd_wss *chip = snd_kcontrol_chip(kctl); 617 struct snd_wss *chip = snd_kcontrol_chip(kctl);
722 struct snd_card *card = chip->card; 618 struct snd_card *card = chip->card;
@@ -730,16 +626,18 @@ static int sscape_midi_get(struct snd_kcontrol *kctl,
730} 626}
731 627
732static int sscape_midi_put(struct snd_kcontrol *kctl, 628static int sscape_midi_put(struct snd_kcontrol *kctl,
733 struct snd_ctl_elem_value *uctl) 629 struct snd_ctl_elem_value *uctl)
734{ 630{
735 struct snd_wss *chip = snd_kcontrol_chip(kctl); 631 struct snd_wss *chip = snd_kcontrol_chip(kctl);
736 struct snd_card *card = chip->card; 632 struct snd_card *card = chip->card;
737 register struct soundscape *s = get_card_soundscape(card); 633 struct soundscape *s = get_card_soundscape(card);
738 unsigned long flags; 634 unsigned long flags;
739 int change; 635 int change;
636 unsigned char new_val;
740 637
741 spin_lock_irqsave(&s->lock, flags); 638 spin_lock_irqsave(&s->lock, flags);
742 639
640 new_val = uctl->value.integer.value[0] & 127;
743 /* 641 /*
744 * We need to put the board into HOST mode before we 642 * We need to put the board into HOST mode before we
745 * can send any volume-changing HOST commands ... 643 * can send any volume-changing HOST commands ...
@@ -752,15 +650,16 @@ static int sscape_midi_put(struct snd_kcontrol *kctl,
752 * and then perform another volume-related command. Perhaps the 650 * and then perform another volume-related command. Perhaps the
753 * first command is an "open" and the second command is a "close"? 651 * first command is an "open" and the second command is a "close"?
754 */ 652 */
755 if (s->midi_vol == ((unsigned char) uctl->value.integer. value[0] & 127)) { 653 if (s->midi_vol == new_val) {
756 change = 0; 654 change = 0;
757 goto __skip_change; 655 goto __skip_change;
758 } 656 }
759 change = (host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100) 657 change = host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100)
760 && host_write_ctrl_unsafe(s->io_base, ((unsigned char) uctl->value.integer. value[0]) & 127, 100) 658 && host_write_ctrl_unsafe(s->io_base, new_val, 100)
761 && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100)); 659 && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100)
762 s->midi_vol = (unsigned char) uctl->value.integer.value[0] & 127; 660 && host_write_ctrl_unsafe(s->io_base, new_val, 100);
763 __skip_change: 661 s->midi_vol = new_val;
662__skip_change:
764 663
765 /* 664 /*
766 * Take the board out of HOST mode and back into MIDI mode ... 665 * Take the board out of HOST mode and back into MIDI mode ...
@@ -784,20 +683,25 @@ static struct snd_kcontrol_new midi_mixer_ctl = {
784 * These IRQs are encoded as bit patterns so that they can be 683 * These IRQs are encoded as bit patterns so that they can be
785 * written to the control registers. 684 * written to the control registers.
786 */ 685 */
787static unsigned __devinit get_irq_config(int irq) 686static unsigned __devinit get_irq_config(int sscape_type, int irq)
788{ 687{
789 static const int valid_irq[] = { 9, 5, 7, 10 }; 688 static const int valid_irq[] = { 9, 5, 7, 10 };
689 static const int old_irq[] = { 9, 7, 5, 15 };
790 unsigned cfg; 690 unsigned cfg;
791 691
792 for (cfg = 0; cfg < ARRAY_SIZE(valid_irq); ++cfg) { 692 if (sscape_type == MEDIA_FX) {
793 if (irq == valid_irq[cfg]) 693 for (cfg = 0; cfg < ARRAY_SIZE(old_irq); ++cfg)
794 return cfg; 694 if (irq == old_irq[cfg])
795 } /* for */ 695 return cfg;
696 } else {
697 for (cfg = 0; cfg < ARRAY_SIZE(valid_irq); ++cfg)
698 if (irq == valid_irq[cfg])
699 return cfg;
700 }
796 701
797 return INVALID_IRQ; 702 return INVALID_IRQ;
798} 703}
799 704
800
801/* 705/*
802 * Perform certain arcane port-checks to see whether there 706 * Perform certain arcane port-checks to see whether there
803 * is a SoundScape board lurking behind the given ports. 707 * is a SoundScape board lurking behind the given ports.
@@ -842,11 +746,38 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io)
842 if (s->type != SSCAPE_VIVO && (d & 0x9f) != 0x0e) 746 if (s->type != SSCAPE_VIVO && (d & 0x9f) != 0x0e)
843 goto _done; 747 goto _done;
844 748
845 d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f; 749 if (s->ic_type == IC_OPUS)
846 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0); 750 activate_ad1845_unsafe(s->io_base);
847 751
848 if (s->type == SSCAPE_VIVO) 752 if (s->type == SSCAPE_VIVO)
849 wss_io += 4; 753 wss_io += 4;
754
755 d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
756 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0);
757
758 /* wait for WSS codec */
759 for (d = 0; d < 500; d++) {
760 if ((inb(wss_io) & 0x80) == 0)
761 break;
762 spin_unlock_irqrestore(&s->lock, flags);
763 msleep(1);
764 spin_lock_irqsave(&s->lock, flags);
765 }
766
767 if ((inb(wss_io) & 0x80) != 0)
768 goto _done;
769
770 if (inb(wss_io + 2) == 0xff)
771 goto _done;
772
773 d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f;
774 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d);
775
776 if ((inb(wss_io) & 0x80) != 0)
777 s->type = MEDIA_FX;
778
779 d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
780 sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0);
850 /* wait for WSS codec */ 781 /* wait for WSS codec */
851 for (d = 0; d < 500; d++) { 782 for (d = 0; d < 500; d++) {
852 if ((inb(wss_io) & 0x80) == 0) 783 if ((inb(wss_io) & 0x80) == 0)
@@ -855,14 +786,13 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io)
855 msleep(1); 786 msleep(1);
856 spin_lock_irqsave(&s->lock, flags); 787 spin_lock_irqsave(&s->lock, flags);
857 } 788 }
858 snd_printd(KERN_INFO "init delay = %d ms\n", d);
859 789
860 /* 790 /*
861 * SoundScape successfully detected! 791 * SoundScape successfully detected!
862 */ 792 */
863 retval = 1; 793 retval = 1;
864 794
865 _done: 795_done:
866 spin_unlock_irqrestore(&s->lock, flags); 796 spin_unlock_irqrestore(&s->lock, flags);
867 return retval; 797 return retval;
868} 798}
@@ -873,63 +803,35 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io)
873 * to crash the machine. Also check that someone isn't using the hardware 803 * to crash the machine. Also check that someone isn't using the hardware
874 * IOCTL device. 804 * IOCTL device.
875 */ 805 */
876static int mpu401_open(struct snd_mpu401 * mpu) 806static int mpu401_open(struct snd_mpu401 *mpu)
877{ 807{
878 int err;
879
880 if (!verify_mpu401(mpu)) { 808 if (!verify_mpu401(mpu)) {
881 snd_printk(KERN_ERR "sscape: MIDI disabled, please load firmware\n"); 809 snd_printk(KERN_ERR "sscape: MIDI disabled, "
882 err = -ENODEV; 810 "please load firmware\n");
883 } else { 811 return -ENODEV;
884 register struct soundscape *sscape = get_mpu401_soundscape(mpu);
885 unsigned long flags;
886
887 spin_lock_irqsave(&sscape->fwlock, flags);
888
889 if (sscape->hw_in_use || (sscape->midi_usage == ULONG_MAX)) {
890 err = -EBUSY;
891 } else {
892 ++(sscape->midi_usage);
893 err = 0;
894 }
895
896 spin_unlock_irqrestore(&sscape->fwlock, flags);
897 } 812 }
898 813
899 return err; 814 return 0;
900}
901
902static void mpu401_close(struct snd_mpu401 * mpu)
903{
904 register struct soundscape *sscape = get_mpu401_soundscape(mpu);
905 unsigned long flags;
906
907 spin_lock_irqsave(&sscape->fwlock, flags);
908 --(sscape->midi_usage);
909 spin_unlock_irqrestore(&sscape->fwlock, flags);
910} 815}
911 816
912/* 817/*
913 * Initialse an MPU-401 subdevice for MIDI support on the SoundScape. 818 * Initialse an MPU-401 subdevice for MIDI support on the SoundScape.
914 */ 819 */
915static int __devinit create_mpu401(struct snd_card *card, int devnum, unsigned long port, int irq) 820static int __devinit create_mpu401(struct snd_card *card, int devnum,
821 unsigned long port, int irq)
916{ 822{
917 struct soundscape *sscape = get_card_soundscape(card); 823 struct soundscape *sscape = get_card_soundscape(card);
918 struct snd_rawmidi *rawmidi; 824 struct snd_rawmidi *rawmidi;
919 int err; 825 int err;
920 826
921 if ((err = snd_mpu401_uart_new(card, devnum, 827 err = snd_mpu401_uart_new(card, devnum, MPU401_HW_MPU401, port,
922 MPU401_HW_MPU401, 828 MPU401_INFO_INTEGRATED, irq, IRQF_DISABLED,
923 port, MPU401_INFO_INTEGRATED, 829 &rawmidi);
924 irq, IRQF_DISABLED, 830 if (err == 0) {
925 &rawmidi)) == 0) { 831 struct snd_mpu401 *mpu = rawmidi->private_data;
926 struct snd_mpu401 *mpu = (struct snd_mpu401 *) rawmidi->private_data;
927 mpu->open_input = mpu401_open; 832 mpu->open_input = mpu401_open;
928 mpu->open_output = mpu401_open; 833 mpu->open_output = mpu401_open;
929 mpu->close_input = mpu401_close;
930 mpu->close_output = mpu401_close;
931 mpu->private_data = sscape; 834 mpu->private_data = sscape;
932 sscape->mpu = mpu;
933 835
934 initialise_mpu401(mpu); 836 initialise_mpu401(mpu);
935 } 837 }
@@ -950,32 +852,34 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
950 register struct soundscape *sscape = get_card_soundscape(card); 852 register struct soundscape *sscape = get_card_soundscape(card);
951 struct snd_wss *chip; 853 struct snd_wss *chip;
952 int err; 854 int err;
855 int codec_type = WSS_HW_DETECT;
953 856
954 if (sscape->type == SSCAPE_VIVO) 857 switch (sscape->type) {
955 port += 4; 858 case MEDIA_FX:
859 case SSCAPE:
860 /*
861 * There are some freak examples of early Soundscape cards
862 * with CS4231 instead of AD1848/CS4248. Unfortunately, the
863 * CS4231 works only in CS4248 compatibility mode on
864 * these cards so force it.
865 */
866 if (sscape->ic_type != IC_OPUS)
867 codec_type = WSS_HW_AD1848;
868 break;
956 869
957 if (dma1 == dma2) 870 case SSCAPE_VIVO:
958 dma2 = -1; 871 port += 4;
872 break;
873 default:
874 break;
875 }
959 876
960 err = snd_wss_create(card, port, -1, irq, dma1, dma2, 877 err = snd_wss_create(card, port, -1, irq, dma1, dma2,
961 WSS_HW_DETECT, WSS_HWSHARE_DMA1, &chip); 878 codec_type, WSS_HWSHARE_DMA1, &chip);
962 if (!err) { 879 if (!err) {
963 unsigned long flags; 880 unsigned long flags;
964 struct snd_pcm *pcm; 881 struct snd_pcm *pcm;
965 882
966/*
967 * It turns out that the PLAYBACK_ENABLE bit is set
968 * by the lowlevel driver ...
969 *
970#define AD1845_IFACE_CONFIG \
971 (CS4231_AUTOCALIB | CS4231_RECORD_ENABLE | CS4231_PLAYBACK_ENABLE)
972 snd_wss_mce_up(chip);
973 spin_lock_irqsave(&chip->reg_lock, flags);
974 snd_wss_out(chip, CS4231_IFACE_CTRL, AD1845_IFACE_CONFIG);
975 spin_unlock_irqrestore(&chip->reg_lock, flags);
976 snd_wss_mce_down(chip);
977 */
978
979 if (sscape->type != SSCAPE_VIVO) { 883 if (sscape->type != SSCAPE_VIVO) {
980 /* 884 /*
981 * The input clock frequency on the SoundScape must 885 * The input clock frequency on the SoundScape must
@@ -1022,17 +926,10 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
1022 } 926 }
1023 } 927 }
1024 928
1025 strcpy(card->driver, "SoundScape");
1026 strcpy(card->shortname, pcm->name);
1027 snprintf(card->longname, sizeof(card->longname),
1028 "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n",
1029 pcm->name, chip->port, chip->irq,
1030 chip->dma1, chip->dma2);
1031
1032 sscape->chip = chip; 929 sscape->chip = chip;
1033 } 930 }
1034 931
1035 _error: 932_error:
1036 return err; 933 return err;
1037} 934}
1038 935
@@ -1051,21 +948,8 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1051 struct resource *wss_res; 948 struct resource *wss_res;
1052 unsigned long flags; 949 unsigned long flags;
1053 int err; 950 int err;
1054 951 int val;
1055 /* 952 const char *name;
1056 * Check that the user didn't pass us garbage data ...
1057 */
1058 irq_cfg = get_irq_config(irq[dev]);
1059 if (irq_cfg == INVALID_IRQ) {
1060 snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]);
1061 return -ENXIO;
1062 }
1063
1064 mpu_irq_cfg = get_irq_config(mpu_irq[dev]);
1065 if (mpu_irq_cfg == INVALID_IRQ) {
1066 printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]);
1067 return -ENXIO;
1068 }
1069 953
1070 /* 954 /*
1071 * Grab IO ports that we will need to probe so that we 955 * Grab IO ports that we will need to probe so that we
@@ -1098,41 +982,51 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1098 } 982 }
1099 983
1100 spin_lock_init(&sscape->lock); 984 spin_lock_init(&sscape->lock);
1101 spin_lock_init(&sscape->fwlock);
1102 sscape->io_res = io_res; 985 sscape->io_res = io_res;
1103 sscape->wss_res = wss_res; 986 sscape->wss_res = wss_res;
1104 sscape->io_base = port[dev]; 987 sscape->io_base = port[dev];
1105 988
1106 if (!detect_sscape(sscape, wss_port[dev])) { 989 if (!detect_sscape(sscape, wss_port[dev])) {
1107 printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base); 990 printk(KERN_ERR "sscape: hardware not detected at 0x%x\n",
991 sscape->io_base);
1108 err = -ENODEV; 992 err = -ENODEV;
1109 goto _release_dma; 993 goto _release_dma;
1110 } 994 }
1111 995
1112 printk(KERN_INFO "sscape: hardware detected at 0x%x, using IRQ %d, DMA %d\n", 996 switch (sscape->type) {
1113 sscape->io_base, irq[dev], dma[dev]); 997 case MEDIA_FX:
998 name = "MediaFX/SoundFX";
999 break;
1000 case SSCAPE:
1001 name = "Soundscape";
1002 break;
1003 case SSCAPE_PNP:
1004 name = "Soundscape PnP";
1005 break;
1006 case SSCAPE_VIVO:
1007 name = "Soundscape VIVO";
1008 break;
1009 default:
1010 name = "unknown Soundscape";
1011 break;
1012 }
1114 1013
1115 if (sscape->type != SSCAPE_VIVO) { 1014 printk(KERN_INFO "sscape: %s card detected at 0x%x, using IRQ %d, DMA %d\n",
1116 /* 1015 name, sscape->io_base, irq[dev], dma[dev]);
1117 * Now create the hardware-specific device so that we can 1016
1118 * load the microcode into the on-board processor. 1017 /*
1119 * We cannot use the MPU-401 MIDI system until this firmware 1018 * Check that the user didn't pass us garbage data ...
1120 * has been loaded into the card. 1019 */
1121 */ 1020 irq_cfg = get_irq_config(sscape->type, irq[dev]);
1122 err = snd_hwdep_new(card, "MC68EC000", 0, &(sscape->hw)); 1021 if (irq_cfg == INVALID_IRQ) {
1123 if (err < 0) { 1022 snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]);
1124 printk(KERN_ERR "sscape: Failed to create " 1023 return -ENXIO;
1125 "firmware device\n"); 1024 }
1126 goto _release_dma; 1025
1127 } 1026 mpu_irq_cfg = get_irq_config(sscape->type, mpu_irq[dev]);
1128 strlcpy(sscape->hw->name, "SoundScape M68K", 1027 if (mpu_irq_cfg == INVALID_IRQ) {
1129 sizeof(sscape->hw->name)); 1028 snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]);
1130 sscape->hw->name[sizeof(sscape->hw->name) - 1] = '\0'; 1029 return -ENXIO;
1131 sscape->hw->iface = SNDRV_HWDEP_IFACE_SSCAPE;
1132 sscape->hw->ops.open = sscape_hw_open;
1133 sscape->hw->ops.release = sscape_hw_release;
1134 sscape->hw->ops.ioctl = sscape_hw_ioctl;
1135 sscape->hw->private_data = sscape;
1136 } 1030 }
1137 1031
1138 /* 1032 /*
@@ -1141,9 +1035,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1141 */ 1035 */
1142 spin_lock_irqsave(&sscape->lock, flags); 1036 spin_lock_irqsave(&sscape->lock, flags);
1143 1037
1144 activate_ad1845_unsafe(sscape->io_base);
1145
1146 sscape_write_unsafe(sscape->io_base, GA_INTENA_REG, 0x00); /* disable */
1147 sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2e); 1038 sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2e);
1148 sscape_write_unsafe(sscape->io_base, GA_SMCFGB_REG, 0x00); 1039 sscape_write_unsafe(sscape->io_base, GA_SMCFGB_REG, 0x00);
1149 1040
@@ -1151,15 +1042,23 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1151 * Enable and configure the DMA channels ... 1042 * Enable and configure the DMA channels ...
1152 */ 1043 */
1153 sscape_write_unsafe(sscape->io_base, GA_DMACFG_REG, 0x50); 1044 sscape_write_unsafe(sscape->io_base, GA_DMACFG_REG, 0x50);
1154 dma_cfg = (sscape->ic_type == IC_ODIE ? 0x70 : 0x40); 1045 dma_cfg = (sscape->ic_type == IC_OPUS ? 0x40 : 0x70);
1155 sscape_write_unsafe(sscape->io_base, GA_DMAA_REG, dma_cfg); 1046 sscape_write_unsafe(sscape->io_base, GA_DMAA_REG, dma_cfg);
1156 sscape_write_unsafe(sscape->io_base, GA_DMAB_REG, 0x20); 1047 sscape_write_unsafe(sscape->io_base, GA_DMAB_REG, 0x20);
1157 1048
1158 sscape_write_unsafe(sscape->io_base, 1049 mpu_irq_cfg |= mpu_irq_cfg << 2;
1159 GA_INTCFG_REG, 0xf0 | (mpu_irq_cfg << 2) | mpu_irq_cfg); 1050 val = sscape_read_unsafe(sscape->io_base, GA_HMCTL_REG) & 0xF7;
1051 if (joystick[dev])
1052 val |= 8;
1053 sscape_write_unsafe(sscape->io_base, GA_HMCTL_REG, val | 0x10);
1054 sscape_write_unsafe(sscape->io_base, GA_INTCFG_REG, 0xf0 | mpu_irq_cfg);
1160 sscape_write_unsafe(sscape->io_base, 1055 sscape_write_unsafe(sscape->io_base,
1161 GA_CDCFG_REG, 0x09 | DMA_8BIT 1056 GA_CDCFG_REG, 0x09 | DMA_8BIT
1162 | (dma[dev] << 4) | (irq_cfg << 1)); 1057 | (dma[dev] << 4) | (irq_cfg << 1));
1058 /*
1059 * Enable the master IRQ ...
1060 */
1061 sscape_write_unsafe(sscape->io_base, GA_INTENA_REG, 0x80);
1163 1062
1164 spin_unlock_irqrestore(&sscape->lock, flags); 1063 spin_unlock_irqrestore(&sscape->lock, flags);
1165 1064
@@ -1170,32 +1069,56 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
1170 err = create_ad1845(card, wss_port[dev], irq[dev], 1069 err = create_ad1845(card, wss_port[dev], irq[dev],
1171 dma[dev], dma2[dev]); 1070 dma[dev], dma2[dev]);
1172 if (err < 0) { 1071 if (err < 0) {
1173 printk(KERN_ERR "sscape: No AD1845 device at 0x%lx, IRQ %d\n", 1072 snd_printk(KERN_ERR
1174 wss_port[dev], irq[dev]); 1073 "sscape: No AD1845 device at 0x%lx, IRQ %d\n",
1074 wss_port[dev], irq[dev]);
1175 goto _release_dma; 1075 goto _release_dma;
1176 } 1076 }
1077 strcpy(card->driver, "SoundScape");
1078 strcpy(card->shortname, name);
1079 snprintf(card->longname, sizeof(card->longname),
1080 "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n",
1081 name, sscape->chip->port, sscape->chip->irq,
1082 sscape->chip->dma1, sscape->chip->dma2);
1083
1177#define MIDI_DEVNUM 0 1084#define MIDI_DEVNUM 0
1178 if (sscape->type != SSCAPE_VIVO) { 1085 if (sscape->type != SSCAPE_VIVO) {
1179 err = create_mpu401(card, MIDI_DEVNUM, port[dev], mpu_irq[dev]); 1086 err = sscape_upload_bootblock(card);
1180 if (err < 0) { 1087 if (err >= 0)
1181 printk(KERN_ERR "sscape: Failed to create " 1088 err = sscape_upload_microcode(card, err);
1182 "MPU-401 device at 0x%lx\n",
1183 port[dev]);
1184 goto _release_dma;
1185 }
1186 1089
1187 /* 1090 if (err == 0) {
1188 * Enable the master IRQ ... 1091 err = create_mpu401(card, MIDI_DEVNUM, port[dev],
1189 */ 1092 mpu_irq[dev]);
1190 sscape_write(sscape, GA_INTENA_REG, 0x80); 1093 if (err < 0) {
1094 snd_printk(KERN_ERR "sscape: Failed to create "
1095 "MPU-401 device at 0x%lx\n",
1096 port[dev]);
1097 goto _release_dma;
1098 }
1191 1099
1192 /* 1100 /*
1193 * Initialize mixer 1101 * Initialize mixer
1194 */ 1102 */
1195 sscape->midi_vol = 0; 1103 spin_lock_irqsave(&sscape->lock, flags);
1196 host_write_ctrl_unsafe(sscape->io_base, CMD_SET_MIDI_VOL, 100); 1104 sscape->midi_vol = 0;
1197 host_write_ctrl_unsafe(sscape->io_base, 0, 100); 1105 host_write_ctrl_unsafe(sscape->io_base,
1198 host_write_ctrl_unsafe(sscape->io_base, CMD_XXX_MIDI_VOL, 100); 1106 CMD_SET_MIDI_VOL, 100);
1107 host_write_ctrl_unsafe(sscape->io_base,
1108 sscape->midi_vol, 100);
1109 host_write_ctrl_unsafe(sscape->io_base,
1110 CMD_XXX_MIDI_VOL, 100);
1111 host_write_ctrl_unsafe(sscape->io_base,
1112 sscape->midi_vol, 100);
1113 host_write_ctrl_unsafe(sscape->io_base,
1114 CMD_SET_EXTMIDI, 100);
1115 host_write_ctrl_unsafe(sscape->io_base,
1116 0, 100);
1117 host_write_ctrl_unsafe(sscape->io_base, CMD_ACK, 100);
1118
1119 set_midi_mode_unsafe(sscape->io_base);
1120 spin_unlock_irqrestore(&sscape->lock, flags);
1121 }
1199 } 1122 }
1200 1123
1201 /* 1124 /*
@@ -1231,7 +1154,8 @@ static int __devinit snd_sscape_match(struct device *pdev, unsigned int i)
1231 mpu_irq[i] == SNDRV_AUTO_IRQ || 1154 mpu_irq[i] == SNDRV_AUTO_IRQ ||
1232 dma[i] == SNDRV_AUTO_DMA) { 1155 dma[i] == SNDRV_AUTO_DMA) {
1233 printk(KERN_INFO 1156 printk(KERN_INFO
1234 "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); 1157 "sscape: insufficient parameters, "
1158 "need IO, IRQ, MPU-IRQ and DMA\n");
1235 return 0; 1159 return 0;
1236 } 1160 }
1237 1161
@@ -1253,13 +1177,15 @@ static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev)
1253 sscape->type = SSCAPE; 1177 sscape->type = SSCAPE;
1254 1178
1255 dma[dev] &= 0x03; 1179 dma[dev] &= 0x03;
1180 snd_card_set_dev(card, pdev);
1181
1256 ret = create_sscape(dev, card); 1182 ret = create_sscape(dev, card);
1257 if (ret < 0) 1183 if (ret < 0)
1258 goto _release_card; 1184 goto _release_card;
1259 1185
1260 snd_card_set_dev(card, pdev); 1186 ret = snd_card_register(card);
1261 if ((ret = snd_card_register(card)) < 0) { 1187 if (ret < 0) {
1262 printk(KERN_ERR "sscape: Failed to register sound card\n"); 1188 snd_printk(KERN_ERR "sscape: Failed to register sound card\n");
1263 goto _release_card; 1189 goto _release_card;
1264 } 1190 }
1265 dev_set_drvdata(pdev, card); 1191 dev_set_drvdata(pdev, card);
@@ -1311,36 +1237,20 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard,
1311 * Allow this function to fail *quietly* if all the ISA PnP 1237 * Allow this function to fail *quietly* if all the ISA PnP
1312 * devices were configured using module parameters instead. 1238 * devices were configured using module parameters instead.
1313 */ 1239 */
1314 if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS) 1240 idx = get_next_autoindex(idx);
1241 if (idx >= SNDRV_CARDS)
1315 return -ENOSPC; 1242 return -ENOSPC;
1316 1243
1317 /* 1244 /*
1318 * We have found a candidate ISA PnP card. Now we
1319 * have to check that it has the devices that we
1320 * expect it to have.
1321 *
1322 * We will NOT try and autoconfigure all of the resources
1323 * needed and then activate the card as we are assuming that
1324 * has already been done at boot-time using /proc/isapnp.
1325 * We shall simply try to give each active card the resources
1326 * that it wants. This is a sensible strategy for a modular
1327 * system where unused modules are unloaded regularly.
1328 *
1329 * This strategy is utterly useless if we compile the driver
1330 * into the kernel, of course.
1331 */
1332 // printk(KERN_INFO "sscape: %s\n", card->name);
1333
1334 /*
1335 * Check that we still have room for another sound card ... 1245 * Check that we still have room for another sound card ...
1336 */ 1246 */
1337 dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); 1247 dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL);
1338 if (! dev) 1248 if (!dev)
1339 return -ENODEV; 1249 return -ENODEV;
1340 1250
1341 if (!pnp_is_active(dev)) { 1251 if (!pnp_is_active(dev)) {
1342 if (pnp_activate_dev(dev) < 0) { 1252 if (pnp_activate_dev(dev) < 0) {
1343 printk(KERN_INFO "sscape: device is inactive\n"); 1253 snd_printk(KERN_INFO "sscape: device is inactive\n");
1344 return -EBUSY; 1254 return -EBUSY;
1345 } 1255 }
1346 } 1256 }
@@ -1378,14 +1288,15 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard,
1378 wss_port[idx] = pnp_port_start(dev, 1); 1288 wss_port[idx] = pnp_port_start(dev, 1);
1379 dma2[idx] = pnp_dma(dev, 1); 1289 dma2[idx] = pnp_dma(dev, 1);
1380 } 1290 }
1291 snd_card_set_dev(card, &pcard->card->dev);
1381 1292
1382 ret = create_sscape(idx, card); 1293 ret = create_sscape(idx, card);
1383 if (ret < 0) 1294 if (ret < 0)
1384 goto _release_card; 1295 goto _release_card;
1385 1296
1386 snd_card_set_dev(card, &pcard->card->dev); 1297 ret = snd_card_register(card);
1387 if ((ret = snd_card_register(card)) < 0) { 1298 if (ret < 0) {
1388 printk(KERN_ERR "sscape: Failed to register sound card\n"); 1299 snd_printk(KERN_ERR "sscape: Failed to register sound card\n");
1389 goto _release_card; 1300 goto _release_card;
1390 } 1301 }
1391 1302
diff --git a/sound/isa/wss/wss_lib.c b/sound/isa/wss/wss_lib.c
index 5d2ba1b749ab..2ba18978b419 100644
--- a/sound/isa/wss/wss_lib.c
+++ b/sound/isa/wss/wss_lib.c
@@ -2198,84 +2198,61 @@ EXPORT_SYMBOL(snd_wss_put_double);
2198static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0); 2198static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
2199static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); 2199static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
2200static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0); 2200static const DECLARE_TLV_DB_SCALE(db_scale_rec_gain, 0, 150, 0);
2201static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0);
2201 2202
2202static struct snd_kcontrol_new snd_ad1848_controls[] = { 2203static struct snd_kcontrol_new snd_wss_controls[] = {
2203WSS_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 2204WSS_DOUBLE("PCM Playback Switch", 0,
2204 7, 7, 1, 1), 2205 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1),
2205WSS_DOUBLE_TLV("PCM Playback Volume", 0, 2206WSS_DOUBLE_TLV("PCM Playback Volume", 0,
2206 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1, 2207 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1,
2207 db_scale_6bit), 2208 db_scale_6bit),
2208WSS_DOUBLE("Aux Playback Switch", 0, 2209WSS_DOUBLE("Aux Playback Switch", 0,
2209 CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1), 2210 CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1),
2210WSS_DOUBLE_TLV("Aux Playback Volume", 0, 2211WSS_DOUBLE_TLV("Aux Playback Volume", 0,
2211 CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1, 2212 CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1,
2212 db_scale_5bit_12db_max), 2213 db_scale_5bit_12db_max),
2213WSS_DOUBLE("Aux Playback Switch", 1, 2214WSS_DOUBLE("Aux Playback Switch", 1,
2214 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1), 2215 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1),
2215WSS_DOUBLE_TLV("Aux Playback Volume", 1, 2216WSS_DOUBLE_TLV("Aux Playback Volume", 1,
2216 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1, 2217 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1,
2217 db_scale_5bit_12db_max), 2218 db_scale_5bit_12db_max),
2218WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 2219WSS_DOUBLE_TLV("Capture Volume", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT,
2219 0, 0, 15, 0, db_scale_rec_gain), 2220 0, 0, 15, 0, db_scale_rec_gain),
2220{ 2221{
2221 .name = "Capture Source",
2222 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2222 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2223 .name = "Capture Source",
2223 .info = snd_wss_info_mux, 2224 .info = snd_wss_info_mux,
2224 .get = snd_wss_get_mux, 2225 .get = snd_wss_get_mux,
2225 .put = snd_wss_put_mux, 2226 .put = snd_wss_put_mux,
2226}, 2227},
2227WSS_SINGLE("Loopback Capture Switch", 0, CS4231_LOOPBACK, 0, 1, 0), 2228WSS_DOUBLE("Mic Boost", 0,
2228WSS_SINGLE_TLV("Loopback Capture Volume", 0, CS4231_LOOPBACK, 1, 63, 0, 2229 CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0),
2229 db_scale_6bit), 2230WSS_SINGLE("Loopback Capture Switch", 0,
2230}; 2231 CS4231_LOOPBACK, 0, 1, 0),
2231 2232WSS_SINGLE_TLV("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1,
2232static struct snd_kcontrol_new snd_wss_controls[] = { 2233 db_scale_6bit),
2233WSS_DOUBLE("PCM Playback Switch", 0,
2234 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1),
2235WSS_DOUBLE("PCM Playback Volume", 0,
2236 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1),
2237WSS_DOUBLE("Line Playback Switch", 0, 2234WSS_DOUBLE("Line Playback Switch", 0,
2238 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), 2235 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1),
2239WSS_DOUBLE("Line Playback Volume", 0, 2236WSS_DOUBLE_TLV("Line Playback Volume", 0,
2240 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1), 2237 CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 31, 1,
2241WSS_DOUBLE("Aux Playback Switch", 0, 2238 db_scale_5bit_12db_max),
2242 CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 7, 7, 1, 1),
2243WSS_DOUBLE("Aux Playback Volume", 0,
2244 CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 0, 0, 31, 1),
2245WSS_DOUBLE("Aux Playback Switch", 1,
2246 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 7, 7, 1, 1),
2247WSS_DOUBLE("Aux Playback Volume", 1,
2248 CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 0, 0, 31, 1),
2249WSS_SINGLE("Mono Playback Switch", 0, 2239WSS_SINGLE("Mono Playback Switch", 0,
2250 CS4231_MONO_CTRL, 7, 1, 1), 2240 CS4231_MONO_CTRL, 7, 1, 1),
2251WSS_SINGLE("Mono Playback Volume", 0, 2241WSS_SINGLE_TLV("Mono Playback Volume", 0,
2252 CS4231_MONO_CTRL, 0, 15, 1), 2242 CS4231_MONO_CTRL, 0, 15, 1,
2243 db_scale_4bit),
2253WSS_SINGLE("Mono Output Playback Switch", 0, 2244WSS_SINGLE("Mono Output Playback Switch", 0,
2254 CS4231_MONO_CTRL, 6, 1, 1), 2245 CS4231_MONO_CTRL, 6, 1, 1),
2255WSS_SINGLE("Mono Output Playback Bypass", 0, 2246WSS_SINGLE("Mono Output Playback Bypass", 0,
2256 CS4231_MONO_CTRL, 5, 1, 0), 2247 CS4231_MONO_CTRL, 5, 1, 0),
2257WSS_DOUBLE("Capture Volume", 0,
2258 CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 0, 0, 15, 0),
2259{
2260 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2261 .name = "Capture Source",
2262 .info = snd_wss_info_mux,
2263 .get = snd_wss_get_mux,
2264 .put = snd_wss_put_mux,
2265},
2266WSS_DOUBLE("Mic Boost", 0,
2267 CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT, 5, 5, 1, 0),
2268WSS_SINGLE("Loopback Capture Switch", 0,
2269 CS4231_LOOPBACK, 0, 1, 0),
2270WSS_SINGLE("Loopback Capture Volume", 0,
2271 CS4231_LOOPBACK, 2, 63, 1)
2272}; 2248};
2273 2249
2274static struct snd_kcontrol_new snd_opti93x_controls[] = { 2250static struct snd_kcontrol_new snd_opti93x_controls[] = {
2275WSS_DOUBLE("Master Playback Switch", 0, 2251WSS_DOUBLE("Master Playback Switch", 0,
2276 OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), 2252 OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
2277WSS_DOUBLE("Master Playback Volume", 0, 2253WSS_DOUBLE_TLV("Master Playback Volume", 0,
2278 OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), 2254 OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1,
2255 db_scale_6bit),
2279WSS_DOUBLE("PCM Playback Switch", 0, 2256WSS_DOUBLE("PCM Playback Switch", 0,
2280 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), 2257 CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1),
2281WSS_DOUBLE("PCM Playback Volume", 0, 2258WSS_DOUBLE("PCM Playback Volume", 0,
@@ -2334,22 +2311,21 @@ int snd_wss_mixer(struct snd_wss *chip)
2334 if (err < 0) 2311 if (err < 0)
2335 return err; 2312 return err;
2336 } 2313 }
2337 else if (chip->hardware & WSS_HW_AD1848_MASK) 2314 else {
2338 for (idx = 0; idx < ARRAY_SIZE(snd_ad1848_controls); idx++) { 2315 int count = ARRAY_SIZE(snd_wss_controls);
2339 err = snd_ctl_add(card, 2316
2340 snd_ctl_new1(&snd_ad1848_controls[idx], 2317 /* Use only the first 11 entries on AD1848 */
2341 chip)); 2318 if (chip->hardware & WSS_HW_AD1848_MASK)
2342 if (err < 0) 2319 count = 11;
2343 return err; 2320
2344 } 2321 for (idx = 0; idx < count; idx++) {
2345 else
2346 for (idx = 0; idx < ARRAY_SIZE(snd_wss_controls); idx++) {
2347 err = snd_ctl_add(card, 2322 err = snd_ctl_add(card,
2348 snd_ctl_new1(&snd_wss_controls[idx], 2323 snd_ctl_new1(&snd_wss_controls[idx],
2349 chip)); 2324 chip));
2350 if (err < 0) 2325 if (err < 0)
2351 return err; 2326 return err;
2352 } 2327 }
2328 }
2353 return 0; 2329 return 0;
2354} 2330}
2355EXPORT_SYMBOL(snd_wss_mixer); 2331EXPORT_SYMBOL(snd_wss_mixer);