aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/es18xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/es18xx.c')
-rw-r--r--sound/isa/es18xx.c130
1 files changed, 61 insertions, 69 deletions
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index 8cfbff73a835..5cf42b4d65fd 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);
@@ -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) {