diff options
Diffstat (limited to 'sound/isa/opti9xx/opti92x-ad1848.c')
-rw-r--r-- | sound/isa/opti9xx/opti92x-ad1848.c | 94 |
1 files changed, 39 insertions, 55 deletions
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index df227377c333..1c390580bd50 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 | ||
261 | static int snd_opti9xx_pnp_is_probed; | 261 | static int snd_opti9xx_pnp_is_probed; |
262 | static struct platform_device *snd_opti9xx_platform_device; | ||
263 | 262 | ||
264 | #ifdef CONFIG_PNP | 263 | #ifdef CONFIG_PNP |
265 | 264 | ||
@@ -294,7 +293,7 @@ static char * snd_opti9xx_names[] = { | |||
294 | }; | 293 | }; |
295 | 294 | ||
296 | 295 | ||
297 | static long __init snd_legacy_find_free_ioport(long *port_table, long size) | 296 | static 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 | ||
309 | static int __init snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware) | 308 | static 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 | ||
454 | static int __init snd_opti9xx_configure(struct snd_opti9xx *chip) | 454 | static 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; |
@@ -1561,7 +1561,7 @@ static int snd_opti93x_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_ | |||
1561 | return change; | 1561 | return change; |
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | static struct snd_kcontrol_new snd_opti93x_controls[] = { | 1564 | static struct snd_kcontrol_new snd_opti93x_controls[] __devinitdata = { |
1565 | OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), | 1565 | OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), |
1566 | OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), | 1566 | OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), |
1567 | OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1), | 1567 | OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1), |
@@ -1622,7 +1622,8 @@ static int snd_opti93x_mixer(struct snd_opti93x *chip) | |||
1622 | 1622 | ||
1623 | #endif /* OPTi93X */ | 1623 | #endif /* OPTi93X */ |
1624 | 1624 | ||
1625 | static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti9xx *chip) | 1625 | static int __devinit snd_card_opti9xx_detect(struct snd_card *card, |
1626 | struct snd_opti9xx *chip) | ||
1626 | { | 1627 | { |
1627 | int i, err; | 1628 | int i, err; |
1628 | 1629 | ||
@@ -1676,8 +1677,9 @@ static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti | |||
1676 | } | 1677 | } |
1677 | 1678 | ||
1678 | #ifdef CONFIG_PNP | 1679 | #ifdef CONFIG_PNP |
1679 | static int __init snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_card_link *card, | 1680 | static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, |
1680 | const struct pnp_card_device_id *pid) | 1681 | struct pnp_card_link *card, |
1682 | const struct pnp_card_device_id *pid) | ||
1681 | { | 1683 | { |
1682 | struct pnp_dev *pdev; | 1684 | struct pnp_dev *pdev; |
1683 | struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); | 1685 | struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); |
@@ -1778,7 +1780,7 @@ static void snd_card_opti9xx_free(struct snd_card *card) | |||
1778 | release_and_free_resource(chip->res_mc_base); | 1780 | release_and_free_resource(chip->res_mc_base); |
1779 | } | 1781 | } |
1780 | 1782 | ||
1781 | static int __init snd_opti9xx_probe(struct snd_card *card) | 1783 | static int __devinit snd_opti9xx_probe(struct snd_card *card) |
1782 | { | 1784 | { |
1783 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; | 1785 | static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; |
1784 | int error; | 1786 | int error; |
@@ -1924,7 +1926,18 @@ static struct snd_card *snd_opti9xx_card_new(void) | |||
1924 | return card; | 1926 | return card; |
1925 | } | 1927 | } |
1926 | 1928 | ||
1927 | static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr) | 1929 | static int __devinit snd_opti9xx_isa_match(struct device *devptr, |
1930 | unsigned int dev) | ||
1931 | { | ||
1932 | if (snd_opti9xx_pnp_is_probed) | ||
1933 | return 0; | ||
1934 | if (isapnp) | ||
1935 | return 0; | ||
1936 | return 1; | ||
1937 | } | ||
1938 | |||
1939 | static int __devinit snd_opti9xx_isa_probe(struct device *devptr, | ||
1940 | unsigned int dev) | ||
1928 | { | 1941 | { |
1929 | struct snd_card *card; | 1942 | struct snd_card *card; |
1930 | int error; | 1943 | int error; |
@@ -1940,9 +1953,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}}; | 1953 | static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; |
1941 | #endif /* CS4231 || OPTi93X */ | 1954 | #endif /* CS4231 || OPTi93X */ |
1942 | 1955 | ||
1943 | if (snd_opti9xx_pnp_is_probed) | ||
1944 | return -EBUSY; | ||
1945 | |||
1946 | if (mpu_port == SNDRV_AUTO_PORT) { | 1956 | if (mpu_port == SNDRV_AUTO_PORT) { |
1947 | if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { | 1957 | 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"); | 1958 | snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); |
@@ -1984,25 +1994,27 @@ static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr) | |||
1984 | snd_card_free(card); | 1994 | snd_card_free(card); |
1985 | return error; | 1995 | return error; |
1986 | } | 1996 | } |
1987 | snd_card_set_dev(card, &devptr->dev); | 1997 | snd_card_set_dev(card, devptr); |
1988 | if ((error = snd_opti9xx_probe(card)) < 0) { | 1998 | if ((error = snd_opti9xx_probe(card)) < 0) { |
1989 | snd_card_free(card); | 1999 | snd_card_free(card); |
1990 | return error; | 2000 | return error; |
1991 | } | 2001 | } |
1992 | platform_set_drvdata(devptr, card); | 2002 | dev_set_drvdata(devptr, card); |
1993 | return 0; | 2003 | return 0; |
1994 | } | 2004 | } |
1995 | 2005 | ||
1996 | static int __devexit snd_opti9xx_nonpnp_remove(struct platform_device *devptr) | 2006 | static int __devexit snd_opti9xx_isa_remove(struct device *devptr, |
2007 | unsigned int dev) | ||
1997 | { | 2008 | { |
1998 | snd_card_free(platform_get_drvdata(devptr)); | 2009 | snd_card_free(dev_get_drvdata(devptr)); |
1999 | platform_set_drvdata(devptr, NULL); | 2010 | dev_set_drvdata(devptr, NULL); |
2000 | return 0; | 2011 | return 0; |
2001 | } | 2012 | } |
2002 | 2013 | ||
2003 | static struct platform_driver snd_opti9xx_driver = { | 2014 | static struct isa_driver snd_opti9xx_driver = { |
2004 | .probe = snd_opti9xx_nonpnp_probe, | 2015 | .match = snd_opti9xx_isa_match, |
2005 | .remove = __devexit_p(snd_opti9xx_nonpnp_remove), | 2016 | .probe = snd_opti9xx_isa_probe, |
2017 | .remove = __devexit_p(snd_opti9xx_isa_remove), | ||
2006 | /* FIXME: suspend/resume */ | 2018 | /* FIXME: suspend/resume */ |
2007 | .driver = { | 2019 | .driver = { |
2008 | .name = DRIVER_NAME | 2020 | .name = DRIVER_NAME |
@@ -2010,8 +2022,8 @@ static struct platform_driver snd_opti9xx_driver = { | |||
2010 | }; | 2022 | }; |
2011 | 2023 | ||
2012 | #ifdef CONFIG_PNP | 2024 | #ifdef CONFIG_PNP |
2013 | static int __init snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, | 2025 | static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, |
2014 | const struct pnp_card_device_id *pid) | 2026 | const struct pnp_card_device_id *pid) |
2015 | { | 2027 | { |
2016 | struct snd_card *card; | 2028 | struct snd_card *card; |
2017 | int error, hw; | 2029 | int error, hw; |
@@ -2074,11 +2086,6 @@ static struct pnp_card_driver opti9xx_pnpc_driver = { | |||
2074 | }; | 2086 | }; |
2075 | #endif | 2087 | #endif |
2076 | 2088 | ||
2077 | #ifdef CONFIG_PNP | ||
2078 | #define is_isapnp_selected() isapnp | ||
2079 | #else | ||
2080 | #define is_isapnp_selected() 0 | ||
2081 | #endif | ||
2082 | #ifdef OPTi93X | 2089 | #ifdef OPTi93X |
2083 | #define CHIP_NAME "82C93x" | 2090 | #define CHIP_NAME "82C93x" |
2084 | #else | 2091 | #else |
@@ -2087,42 +2094,19 @@ static struct pnp_card_driver opti9xx_pnpc_driver = { | |||
2087 | 2094 | ||
2088 | static int __init alsa_card_opti9xx_init(void) | 2095 | static int __init alsa_card_opti9xx_init(void) |
2089 | { | 2096 | { |
2090 | int error; | ||
2091 | struct platform_device *device; | ||
2092 | |||
2093 | #ifdef CONFIG_PNP | 2097 | #ifdef CONFIG_PNP |
2094 | pnp_register_card_driver(&opti9xx_pnpc_driver); | 2098 | pnp_register_card_driver(&opti9xx_pnpc_driver); |
2095 | if (snd_opti9xx_pnp_is_probed) | 2099 | if (snd_opti9xx_pnp_is_probed) |
2096 | return 0; | 2100 | return 0; |
2097 | #endif | 2101 | #endif |
2098 | if (! is_isapnp_selected()) { | 2102 | 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 | } | 2103 | } |
2120 | 2104 | ||
2121 | static void __exit alsa_card_opti9xx_exit(void) | 2105 | static void __exit alsa_card_opti9xx_exit(void) |
2122 | { | 2106 | { |
2123 | if (!snd_opti9xx_pnp_is_probed) { | 2107 | if (!snd_opti9xx_pnp_is_probed) { |
2124 | platform_device_unregister(snd_opti9xx_platform_device); | 2108 | isa_unregister_driver(&snd_opti9xx_driver); |
2125 | platform_driver_unregister(&snd_opti9xx_driver); | 2109 | return; |
2126 | } | 2110 | } |
2127 | #ifdef CONFIG_PNP | 2111 | #ifdef CONFIG_PNP |
2128 | pnp_unregister_card_driver(&opti9xx_pnpc_driver); | 2112 | pnp_unregister_card_driver(&opti9xx_pnpc_driver); |