[ALSA] caiaq - Fix indent in Kconfig
[linux-2.6.git] / sound / isa / als100.c
index 0d709bc..f2bcfb2 100644 (file)
@@ -83,6 +83,7 @@ struct snd_card_als100 {
        struct pnp_dev *dev;
        struct pnp_dev *devmpu;
        struct pnp_dev *devopl;
+       struct snd_sb *chip;
 };
 
 static struct pnp_card_device_id snd_als100_pnpids[] = {
@@ -198,7 +199,7 @@ static int __devinit snd_card_als100_pnp(int dev, struct snd_card_als100 *acard,
        return 0;
 }
 
-static int __init snd_card_als100_probe(int dev,
+static int __devinit snd_card_als100_probe(int dev,
                                        struct pnp_card_link *pcard,
                                        const struct pnp_card_device_id *pid)
 {
@@ -211,7 +212,7 @@ static int __init snd_card_als100_probe(int dev,
        if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE,
                                 sizeof(struct snd_card_als100))) == NULL)
                return -ENOMEM;
-       acard = (struct snd_card_als100 *)card->private_data;
+       acard = card->private_data;
 
        if ((error = snd_card_als100_pnp(dev, acard, pcard, pid))) {
                snd_card_free(card);
@@ -228,6 +229,7 @@ static int __init snd_card_als100_probe(int dev,
                snd_card_free(card);
                return error;
        }
+       acard->chip = chip;
 
        strcpy(card->driver, "ALS100");
        strcpy(card->shortname, "Avance Logic ALS100");
@@ -248,7 +250,7 @@ static int __init snd_card_als100_probe(int dev,
        if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
                if (snd_mpu401_uart_new(card, 0, MPU401_HW_ALS100,
                                        mpu_port[dev], 0, 
-                                       mpu_irq[dev], SA_INTERRUPT,
+                                       mpu_irq[dev], IRQF_DISABLED,
                                        NULL) < 0)
                        snd_printk(KERN_ERR PFX "no MPU-401 device at 0x%lx\n", mpu_port[dev]);
        }
@@ -279,6 +281,8 @@ static int __init snd_card_als100_probe(int dev,
        return 0;
 }
 
+static unsigned int __devinitdata als100_devices;
+
 static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card,
                                           const struct pnp_card_device_id *id)
 {
@@ -292,6 +296,7 @@ static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card,
                if (res < 0)
                        return res;
                dev++;
+               als100_devices++;
                return 0;
        }
        return -ENODEV;
@@ -299,11 +304,35 @@ static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card,
 
 static void __devexit snd_als100_pnp_remove(struct pnp_card_link * pcard)
 {
-       struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard);
+       snd_card_free(pnp_get_card_drvdata(pcard));
+       pnp_set_card_drvdata(pcard, NULL);
+}
+
+#ifdef CONFIG_PM
+static int snd_als100_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state)
+{
+       struct snd_card *card = pnp_get_card_drvdata(pcard);
+       struct snd_card_als100 *acard = card->private_data;
+       struct snd_sb *chip = acard->chip;
 
-       snd_card_disconnect(card);
-       snd_card_free_in_thread(card);
+       snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
+       snd_pcm_suspend_all(chip->pcm);
+       snd_sbmixer_suspend(chip);
+       return 0;
+}
+
+static int snd_als100_pnp_resume(struct pnp_card_link *pcard)
+{
+       struct snd_card *card = pnp_get_card_drvdata(pcard);
+       struct snd_card_als100 *acard = card->private_data;
+       struct snd_sb *chip = acard->chip;
+
+       snd_sbdsp_reset(chip);
+       snd_sbmixer_resume(chip);
+       snd_power_change_state(card, SNDRV_CTL_POWER_D0);
+       return 0;
 }
+#endif
 
 static struct pnp_card_driver als100_pnpc_driver = {
        .flags          = PNP_DRIVER_RES_DISABLE,
@@ -311,20 +340,28 @@ static struct pnp_card_driver als100_pnpc_driver = {
         .id_table       = snd_als100_pnpids,
         .probe          = snd_als100_pnp_detect,
         .remove         = __devexit_p(snd_als100_pnp_remove),
+#ifdef CONFIG_PM
+       .suspend        = snd_als100_pnp_suspend,
+       .resume         = snd_als100_pnp_resume,
+#endif
 };
 
 static int __init alsa_card_als100_init(void)
 {
-       int cards = 0;
+       int err;
 
-       cards += pnp_register_card_driver(&als100_pnpc_driver);
-#ifdef MODULE
-       if (!cards) {
+       err = pnp_register_card_driver(&als100_pnpc_driver);
+       if (err)
+               return err;
+
+       if (!als100_devices) {
                pnp_unregister_card_driver(&als100_pnpc_driver);
+#ifdef MODULE
                snd_printk(KERN_ERR "no ALS100 based soundcards found\n");
-       }
 #endif
-       return cards ? 0 : -ENODEV;
+               return -ENODEV;
+       }
+       return 0;
 }
 
 static void __exit alsa_card_als100_exit(void)