aboutsummaryrefslogtreecommitdiffstats
path: root/sound/isa/opti9xx/opti92x-ad1848.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/isa/opti9xx/opti92x-ad1848.c')
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c108
1 files changed, 45 insertions, 63 deletions
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index df227377c333..60c120ffb9de 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -26,7 +26,7 @@
26#include <sound/driver.h> 26#include <sound/driver.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/platform_device.h> 29#include <linux/isa.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/pnp.h> 32#include <linux/pnp.h>
@@ -259,7 +259,6 @@ struct snd_opti9xx {
259}; 259};
260 260
261static int snd_opti9xx_pnp_is_probed; 261static int snd_opti9xx_pnp_is_probed;
262static struct platform_device *snd_opti9xx_platform_device;
263 262
264#ifdef CONFIG_PNP 263#ifdef CONFIG_PNP
265 264
@@ -281,10 +280,10 @@ MODULE_DEVICE_TABLE(pnp_card, snd_opti9xx_pnpids);
281#endif /* CONFIG_PNP */ 280#endif /* CONFIG_PNP */
282 281
283#ifdef OPTi93X 282#ifdef OPTi93X
284#define DRIVER_NAME "snd-card-opti93x" 283#define DEV_NAME "opti93x"
285#else 284#else
286#define DRIVER_NAME "snd-card-opti92x" 285#define DEV_NAME "opti92x"
287#endif /* OPTi93X */ 286#endif
288 287
289static char * snd_opti9xx_names[] = { 288static char * snd_opti9xx_names[] = {
290 "unkown", 289 "unkown",
@@ -294,7 +293,7 @@ static char * snd_opti9xx_names[] = {
294}; 293};
295 294
296 295
297static long __init snd_legacy_find_free_ioport(long *port_table, long size) 296static long __devinit snd_legacy_find_free_ioport(long *port_table, long size)
298{ 297{
299 while (*port_table != -1) { 298 while (*port_table != -1) {
300 if (request_region(*port_table, size, "ALSA test")) { 299 if (request_region(*port_table, size, "ALSA test")) {
@@ -306,7 +305,8 @@ static long __init snd_legacy_find_free_ioport(long *port_table, long size)
306 return -1; 305 return -1;
307} 306}
308 307
309static int __init snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware) 308static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip,
309 unsigned short hardware)
310{ 310{
311 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; 311 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
312 312
@@ -451,7 +451,7 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg,
451 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) 451 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
452 452
453 453
454static int __init snd_opti9xx_configure(struct snd_opti9xx *chip) 454static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip)
455{ 455{
456 unsigned char wss_base_bits; 456 unsigned char wss_base_bits;
457 unsigned char irq_bits; 457 unsigned char irq_bits;
@@ -934,10 +934,8 @@ static int snd_opti93x_trigger(struct snd_pcm_substream *substream,
934 case SNDRV_PCM_TRIGGER_STOP: 934 case SNDRV_PCM_TRIGGER_STOP:
935 { 935 {
936 unsigned int what = 0; 936 unsigned int what = 0;
937 struct list_head *pos;
938 struct snd_pcm_substream *s; 937 struct snd_pcm_substream *s;
939 snd_pcm_group_for_each(pos, substream) { 938 snd_pcm_group_for_each_entry(s, substream) {
940 s = snd_pcm_group_substream_entry(pos);
941 if (s == chip->playback_substream) { 939 if (s == chip->playback_substream) {
942 what |= OPTi93X_PLAYBACK_ENABLE; 940 what |= OPTi93X_PLAYBACK_ENABLE;
943 snd_pcm_trigger_done(s, substream); 941 snd_pcm_trigger_done(s, substream);
@@ -1291,7 +1289,7 @@ static int snd_opti93x_create(struct snd_card *card, struct snd_opti9xx *chip,
1291 } 1289 }
1292 codec->dma2 = chip->dma2; 1290 codec->dma2 = chip->dma2;
1293 1291
1294 if (request_irq(chip->irq, snd_opti93x_interrupt, IRQF_DISABLED, DRIVER_NAME" - WSS", codec)) { 1292 if (request_irq(chip->irq, snd_opti93x_interrupt, IRQF_DISABLED, DEV_NAME" - WSS", codec)) {
1295 snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq); 1293 snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq);
1296 snd_opti93x_free(codec); 1294 snd_opti93x_free(codec);
1297 return -EBUSY; 1295 return -EBUSY;
@@ -1561,7 +1559,7 @@ static int snd_opti93x_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_
1561 return change; 1559 return change;
1562} 1560}
1563 1561
1564static struct snd_kcontrol_new snd_opti93x_controls[] = { 1562static struct snd_kcontrol_new snd_opti93x_controls[] __devinitdata = {
1565OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), 1563OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
1566OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), 1564OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1),
1567OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1), 1565OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1),
@@ -1622,7 +1620,8 @@ static int snd_opti93x_mixer(struct snd_opti93x *chip)
1622 1620
1623#endif /* OPTi93X */ 1621#endif /* OPTi93X */
1624 1622
1625static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti9xx *chip) 1623static int __devinit snd_card_opti9xx_detect(struct snd_card *card,
1624 struct snd_opti9xx *chip)
1626{ 1625{
1627 int i, err; 1626 int i, err;
1628 1627
@@ -1676,8 +1675,9 @@ static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti
1676} 1675}
1677 1676
1678#ifdef CONFIG_PNP 1677#ifdef CONFIG_PNP
1679static int __init snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_card_link *card, 1678static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip,
1680 const struct pnp_card_device_id *pid) 1679 struct pnp_card_link *card,
1680 const struct pnp_card_device_id *pid)
1681{ 1681{
1682 struct pnp_dev *pdev; 1682 struct pnp_dev *pdev;
1683 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 1683 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
@@ -1778,7 +1778,7 @@ static void snd_card_opti9xx_free(struct snd_card *card)
1778 release_and_free_resource(chip->res_mc_base); 1778 release_and_free_resource(chip->res_mc_base);
1779} 1779}
1780 1780
1781static int __init snd_opti9xx_probe(struct snd_card *card) 1781static int __devinit snd_opti9xx_probe(struct snd_card *card)
1782{ 1782{
1783 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; 1783 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
1784 int error; 1784 int error;
@@ -1924,7 +1924,18 @@ static struct snd_card *snd_opti9xx_card_new(void)
1924 return card; 1924 return card;
1925} 1925}
1926 1926
1927static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr) 1927static int __devinit snd_opti9xx_isa_match(struct device *devptr,
1928 unsigned int dev)
1929{
1930 if (snd_opti9xx_pnp_is_probed)
1931 return 0;
1932 if (isapnp)
1933 return 0;
1934 return 1;
1935}
1936
1937static int __devinit snd_opti9xx_isa_probe(struct device *devptr,
1938 unsigned int dev)
1928{ 1939{
1929 struct snd_card *card; 1940 struct snd_card *card;
1930 int error; 1941 int error;
@@ -1940,9 +1951,6 @@ static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr)
1940 static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; 1951 static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}};
1941#endif /* CS4231 || OPTi93X */ 1952#endif /* CS4231 || OPTi93X */
1942 1953
1943 if (snd_opti9xx_pnp_is_probed)
1944 return -EBUSY;
1945
1946 if (mpu_port == SNDRV_AUTO_PORT) { 1954 if (mpu_port == SNDRV_AUTO_PORT) {
1947 if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { 1955 if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) {
1948 snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); 1956 snd_printk(KERN_ERR "unable to find a free MPU401 port\n");
@@ -1984,34 +1992,36 @@ static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr)
1984 snd_card_free(card); 1992 snd_card_free(card);
1985 return error; 1993 return error;
1986 } 1994 }
1987 snd_card_set_dev(card, &devptr->dev); 1995 snd_card_set_dev(card, devptr);
1988 if ((error = snd_opti9xx_probe(card)) < 0) { 1996 if ((error = snd_opti9xx_probe(card)) < 0) {
1989 snd_card_free(card); 1997 snd_card_free(card);
1990 return error; 1998 return error;
1991 } 1999 }
1992 platform_set_drvdata(devptr, card); 2000 dev_set_drvdata(devptr, card);
1993 return 0; 2001 return 0;
1994} 2002}
1995 2003
1996static int __devexit snd_opti9xx_nonpnp_remove(struct platform_device *devptr) 2004static int __devexit snd_opti9xx_isa_remove(struct device *devptr,
2005 unsigned int dev)
1997{ 2006{
1998 snd_card_free(platform_get_drvdata(devptr)); 2007 snd_card_free(dev_get_drvdata(devptr));
1999 platform_set_drvdata(devptr, NULL); 2008 dev_set_drvdata(devptr, NULL);
2000 return 0; 2009 return 0;
2001} 2010}
2002 2011
2003static struct platform_driver snd_opti9xx_driver = { 2012static struct isa_driver snd_opti9xx_driver = {
2004 .probe = snd_opti9xx_nonpnp_probe, 2013 .match = snd_opti9xx_isa_match,
2005 .remove = __devexit_p(snd_opti9xx_nonpnp_remove), 2014 .probe = snd_opti9xx_isa_probe,
2015 .remove = __devexit_p(snd_opti9xx_isa_remove),
2006 /* FIXME: suspend/resume */ 2016 /* FIXME: suspend/resume */
2007 .driver = { 2017 .driver = {
2008 .name = DRIVER_NAME 2018 .name = DEV_NAME
2009 }, 2019 },
2010}; 2020};
2011 2021
2012#ifdef CONFIG_PNP 2022#ifdef CONFIG_PNP
2013static int __init snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, 2023static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
2014 const struct pnp_card_device_id *pid) 2024 const struct pnp_card_device_id *pid)
2015{ 2025{
2016 struct snd_card *card; 2026 struct snd_card *card;
2017 int error, hw; 2027 int error, hw;
@@ -2074,11 +2084,6 @@ static struct pnp_card_driver opti9xx_pnpc_driver = {
2074}; 2084};
2075#endif 2085#endif
2076 2086
2077#ifdef CONFIG_PNP
2078#define is_isapnp_selected() isapnp
2079#else
2080#define is_isapnp_selected() 0
2081#endif
2082#ifdef OPTi93X 2087#ifdef OPTi93X
2083#define CHIP_NAME "82C93x" 2088#define CHIP_NAME "82C93x"
2084#else 2089#else
@@ -2087,42 +2092,19 @@ static struct pnp_card_driver opti9xx_pnpc_driver = {
2087 2092
2088static int __init alsa_card_opti9xx_init(void) 2093static int __init alsa_card_opti9xx_init(void)
2089{ 2094{
2090 int error;
2091 struct platform_device *device;
2092
2093#ifdef CONFIG_PNP 2095#ifdef CONFIG_PNP
2094 pnp_register_card_driver(&opti9xx_pnpc_driver); 2096 pnp_register_card_driver(&opti9xx_pnpc_driver);
2095 if (snd_opti9xx_pnp_is_probed) 2097 if (snd_opti9xx_pnp_is_probed)
2096 return 0; 2098 return 0;
2097#endif 2099#endif
2098 if (! is_isapnp_selected()) { 2100 return isa_register_driver(&snd_opti9xx_driver, 1);
2099 error = platform_driver_register(&snd_opti9xx_driver);
2100 if (error < 0)
2101 return error;
2102 device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
2103 if (!IS_ERR(device)) {
2104 if (platform_get_drvdata(device)) {
2105 snd_opti9xx_platform_device = device;
2106 return 0;
2107 }
2108 platform_device_unregister(device);
2109 }
2110 platform_driver_unregister(&snd_opti9xx_driver);
2111 }
2112#ifdef CONFIG_PNP
2113 pnp_unregister_card_driver(&opti9xx_pnpc_driver);
2114#endif
2115#ifdef MODULE
2116 printk(KERN_ERR "no OPTi " CHIP_NAME " soundcard found\n");
2117#endif
2118 return -ENODEV;
2119} 2101}
2120 2102
2121static void __exit alsa_card_opti9xx_exit(void) 2103static void __exit alsa_card_opti9xx_exit(void)
2122{ 2104{
2123 if (!snd_opti9xx_pnp_is_probed) { 2105 if (!snd_opti9xx_pnp_is_probed) {
2124 platform_device_unregister(snd_opti9xx_platform_device); 2106 isa_unregister_driver(&snd_opti9xx_driver);
2125 platform_driver_unregister(&snd_opti9xx_driver); 2107 return;
2126 } 2108 }
2127#ifdef CONFIG_PNP 2109#ifdef CONFIG_PNP
2128 pnp_unregister_card_driver(&opti9xx_pnpc_driver); 2110 pnp_unregister_card_driver(&opti9xx_pnpc_driver);