diff options
Diffstat (limited to 'sound/isa/es18xx.c')
-rw-r--r-- | sound/isa/es18xx.c | 75 |
1 files changed, 44 insertions, 31 deletions
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 8cfbff73a835..160752bc2e8e 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; |
@@ -755,7 +754,9 @@ static int snd_es18xx_playback_trigger(struct snd_pcm_substream *substream, | |||
755 | 754 | ||
756 | static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) | 755 | static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) |
757 | { | 756 | { |
758 | struct snd_es18xx *chip = dev_id; | 757 | struct snd_card *card = dev_id; |
758 | struct snd_audiodrive *acard = card->private_data; | ||
759 | struct snd_es18xx *chip = acard->chip; | ||
759 | unsigned char status; | 760 | unsigned char status; |
760 | 761 | ||
761 | if (chip->caps & ES18XX_CONTROL) { | 762 | if (chip->caps & ES18XX_CONTROL) { |
@@ -805,12 +806,16 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) | |||
805 | int split = 0; | 806 | int split = 0; |
806 | if (chip->caps & ES18XX_HWV) { | 807 | if (chip->caps & ES18XX_HWV) { |
807 | split = snd_es18xx_mixer_read(chip, 0x64) & 0x80; | 808 | split = snd_es18xx_mixer_read(chip, 0x64) & 0x80; |
808 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_switch->id); | 809 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, |
809 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_volume->id); | 810 | &chip->hw_switch->id); |
811 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
812 | &chip->hw_volume->id); | ||
810 | } | 813 | } |
811 | if (!split) { | 814 | if (!split) { |
812 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_switch->id); | 815 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, |
813 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_volume->id); | 816 | &chip->master_switch->id); |
817 | snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
818 | &chip->master_volume->id); | ||
814 | } | 819 | } |
815 | /* ack interrupt */ | 820 | /* ack interrupt */ |
816 | snd_es18xx_mixer_write(chip, 0x66, 0x00); | 821 | snd_es18xx_mixer_write(chip, 0x66, 0x00); |
@@ -1691,8 +1696,11 @@ static struct snd_pcm_ops snd_es18xx_capture_ops = { | |||
1691 | .pointer = snd_es18xx_capture_pointer, | 1696 | .pointer = snd_es18xx_capture_pointer, |
1692 | }; | 1697 | }; |
1693 | 1698 | ||
1694 | static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct snd_pcm ** rpcm) | 1699 | static int __devinit snd_es18xx_pcm(struct snd_card *card, int device, |
1700 | struct snd_pcm **rpcm) | ||
1695 | { | 1701 | { |
1702 | struct snd_audiodrive *acard = card->private_data; | ||
1703 | struct snd_es18xx *chip = acard->chip; | ||
1696 | struct snd_pcm *pcm; | 1704 | struct snd_pcm *pcm; |
1697 | char str[16]; | 1705 | char str[16]; |
1698 | int err; | 1706 | int err; |
@@ -1701,9 +1709,9 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct | |||
1701 | *rpcm = NULL; | 1709 | *rpcm = NULL; |
1702 | sprintf(str, "ES%x", chip->version); | 1710 | sprintf(str, "ES%x", chip->version); |
1703 | if (chip->caps & ES18XX_PCM2) | 1711 | if (chip->caps & ES18XX_PCM2) |
1704 | err = snd_pcm_new(chip->card, str, device, 2, 1, &pcm); | 1712 | err = snd_pcm_new(card, str, device, 2, 1, &pcm); |
1705 | else | 1713 | else |
1706 | err = snd_pcm_new(chip->card, str, device, 1, 1, &pcm); | 1714 | err = snd_pcm_new(card, str, device, 1, 1, &pcm); |
1707 | if (err < 0) | 1715 | if (err < 0) |
1708 | return err; | 1716 | return err; |
1709 | 1717 | ||
@@ -1737,7 +1745,7 @@ static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) | |||
1737 | struct snd_audiodrive *acard = card->private_data; | 1745 | struct snd_audiodrive *acard = card->private_data; |
1738 | struct snd_es18xx *chip = acard->chip; | 1746 | struct snd_es18xx *chip = acard->chip; |
1739 | 1747 | ||
1740 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); | 1748 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
1741 | 1749 | ||
1742 | snd_pcm_suspend_all(chip->pcm); | 1750 | snd_pcm_suspend_all(chip->pcm); |
1743 | 1751 | ||
@@ -1758,18 +1766,21 @@ static int snd_es18xx_resume(struct snd_card *card) | |||
1758 | /* restore PM register, we won't wake till (not 0x07) i/o activity though */ | 1766 | /* 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); | 1767 | snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); |
1760 | 1768 | ||
1761 | snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); | 1769 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
1762 | return 0; | 1770 | return 0; |
1763 | } | 1771 | } |
1764 | #endif /* CONFIG_PM */ | 1772 | #endif /* CONFIG_PM */ |
1765 | 1773 | ||
1766 | static int snd_es18xx_free(struct snd_es18xx *chip) | 1774 | static int snd_es18xx_free(struct snd_card *card) |
1767 | { | 1775 | { |
1776 | struct snd_audiodrive *acard = card->private_data; | ||
1777 | struct snd_es18xx *chip = acard->chip; | ||
1778 | |||
1768 | release_and_free_resource(chip->res_port); | 1779 | release_and_free_resource(chip->res_port); |
1769 | release_and_free_resource(chip->res_ctrl_port); | 1780 | release_and_free_resource(chip->res_ctrl_port); |
1770 | release_and_free_resource(chip->res_mpu_port); | 1781 | release_and_free_resource(chip->res_mpu_port); |
1771 | if (chip->irq >= 0) | 1782 | if (chip->irq >= 0) |
1772 | free_irq(chip->irq, (void *) chip); | 1783 | free_irq(chip->irq, (void *) card); |
1773 | if (chip->dma1 >= 0) { | 1784 | if (chip->dma1 >= 0) { |
1774 | disable_dma(chip->dma1); | 1785 | disable_dma(chip->dma1); |
1775 | free_dma(chip->dma1); | 1786 | free_dma(chip->dma1); |
@@ -1784,8 +1795,7 @@ static int snd_es18xx_free(struct snd_es18xx *chip) | |||
1784 | 1795 | ||
1785 | static int snd_es18xx_dev_free(struct snd_device *device) | 1796 | static int snd_es18xx_dev_free(struct snd_device *device) |
1786 | { | 1797 | { |
1787 | struct snd_es18xx *chip = device->device_data; | 1798 | return snd_es18xx_free(device->card); |
1788 | return snd_es18xx_free(chip); | ||
1789 | } | 1799 | } |
1790 | 1800 | ||
1791 | static int __devinit snd_es18xx_new_device(struct snd_card *card, | 1801 | static int __devinit snd_es18xx_new_device(struct snd_card *card, |
@@ -1808,7 +1818,6 @@ static int __devinit snd_es18xx_new_device(struct snd_card *card, | |||
1808 | spin_lock_init(&chip->reg_lock); | 1818 | spin_lock_init(&chip->reg_lock); |
1809 | spin_lock_init(&chip->mixer_lock); | 1819 | spin_lock_init(&chip->mixer_lock); |
1810 | spin_lock_init(&chip->ctrl_lock); | 1820 | spin_lock_init(&chip->ctrl_lock); |
1811 | chip->card = card; | ||
1812 | chip->port = port; | 1821 | chip->port = port; |
1813 | chip->mpu_port = mpu_port; | 1822 | chip->mpu_port = mpu_port; |
1814 | chip->fm_port = fm_port; | 1823 | chip->fm_port = fm_port; |
@@ -1818,53 +1827,55 @@ static int __devinit snd_es18xx_new_device(struct snd_card *card, | |||
1818 | chip->audio2_vol = 0x00; | 1827 | chip->audio2_vol = 0x00; |
1819 | chip->active = 0; | 1828 | chip->active = 0; |
1820 | 1829 | ||
1821 | if ((chip->res_port = request_region(port, 16, "ES18xx")) == NULL) { | 1830 | chip->res_port = request_region(port, 16, "ES18xx"); |
1822 | snd_es18xx_free(chip); | 1831 | if (chip->res_port == NULL) { |
1832 | snd_es18xx_free(card); | ||
1823 | snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); | 1833 | snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); |
1824 | return -EBUSY; | 1834 | return -EBUSY; |
1825 | } | 1835 | } |
1826 | 1836 | ||
1827 | if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx", (void *) chip)) { | 1837 | if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx", |
1828 | snd_es18xx_free(chip); | 1838 | (void *) card)) { |
1839 | snd_es18xx_free(card); | ||
1829 | snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); | 1840 | snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); |
1830 | return -EBUSY; | 1841 | return -EBUSY; |
1831 | } | 1842 | } |
1832 | chip->irq = irq; | 1843 | chip->irq = irq; |
1833 | 1844 | ||
1834 | if (request_dma(dma1, "ES18xx DMA 1")) { | 1845 | if (request_dma(dma1, "ES18xx DMA 1")) { |
1835 | snd_es18xx_free(chip); | 1846 | snd_es18xx_free(card); |
1836 | snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); | 1847 | snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); |
1837 | return -EBUSY; | 1848 | return -EBUSY; |
1838 | } | 1849 | } |
1839 | chip->dma1 = dma1; | 1850 | chip->dma1 = dma1; |
1840 | 1851 | ||
1841 | if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) { | 1852 | if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) { |
1842 | snd_es18xx_free(chip); | 1853 | snd_es18xx_free(card); |
1843 | snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); | 1854 | snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); |
1844 | return -EBUSY; | 1855 | return -EBUSY; |
1845 | } | 1856 | } |
1846 | chip->dma2 = dma2; | 1857 | chip->dma2 = dma2; |
1847 | 1858 | ||
1848 | if (snd_es18xx_probe(chip) < 0) { | 1859 | if (snd_es18xx_probe(chip) < 0) { |
1849 | snd_es18xx_free(chip); | 1860 | snd_es18xx_free(card); |
1850 | return -ENODEV; | 1861 | return -ENODEV; |
1851 | } | 1862 | } |
1852 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 1863 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, NULL, &ops); |
1853 | snd_es18xx_free(chip); | 1864 | if (err < 0) { |
1865 | snd_es18xx_free(card); | ||
1854 | return err; | 1866 | return err; |
1855 | } | 1867 | } |
1856 | *rchip = chip; | 1868 | *rchip = chip; |
1857 | return 0; | 1869 | return 0; |
1858 | } | 1870 | } |
1859 | 1871 | ||
1860 | static int __devinit snd_es18xx_mixer(struct snd_es18xx *chip) | 1872 | static int __devinit snd_es18xx_mixer(struct snd_card *card) |
1861 | { | 1873 | { |
1862 | struct snd_card *card; | 1874 | struct snd_audiodrive *acard = card->private_data; |
1875 | struct snd_es18xx *chip = acard->chip; | ||
1863 | int err; | 1876 | int err; |
1864 | unsigned int idx; | 1877 | unsigned int idx; |
1865 | 1878 | ||
1866 | card = chip->card; | ||
1867 | |||
1868 | strcpy(card->mixername, chip->pcm->name); | 1879 | strcpy(card->mixername, chip->pcm->name); |
1869 | 1880 | ||
1870 | for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { | 1881 | for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { |
@@ -2161,10 +2172,12 @@ static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) | |||
2161 | chip->port, | 2172 | chip->port, |
2162 | irq[dev], dma1[dev]); | 2173 | irq[dev], dma1[dev]); |
2163 | 2174 | ||
2164 | if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) | 2175 | err = snd_es18xx_pcm(card, 0, NULL); |
2176 | if (err < 0) | ||
2165 | return err; | 2177 | return err; |
2166 | 2178 | ||
2167 | if ((err = snd_es18xx_mixer(chip)) < 0) | 2179 | err = snd_es18xx_mixer(card); |
2180 | if (err < 0) | ||
2168 | return err; | 2181 | return err; |
2169 | 2182 | ||
2170 | if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { | 2183 | if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { |