patch-2.3.43 linux/drivers/sound/nm256_audio.c
Next file: linux/drivers/sound/sb_card.c
Previous file: linux/drivers/sound/msnd_pinnacle.c
Back to the patch index
Back to the overall index
- Lines: 126
- Date:
Tue Feb 8 18:49:27 2000
- Orig file:
v2.3.42/linux/drivers/sound/nm256_audio.c
- Orig date:
Fri Jan 7 19:13:22 2000
diff -u --recursive --new-file v2.3.42/linux/drivers/sound/nm256_audio.c linux/drivers/sound/nm256_audio.c
@@ -13,13 +13,10 @@
* off of it; go on, I dare you.
*/
-#include <linux/config.h>
#define __NO_VERSION__
#include <linux/pci.h>
#include <linux/module.h>
-#ifdef CONFIG_APM
-#include <linux/apm_bios.h>
-#endif
+#include <linux/pm.h>
#include "sound_config.h"
#include "soundmodule.h"
#include "nm256.h"
@@ -41,6 +38,7 @@
static int nm256_releaseInterrupt (struct nm256_info *card);
static void nm256_interrupt (int irq, void *dev_id, struct pt_regs *dummy);
static void nm256_interrupt_zx (int irq, void *dev_id, struct pt_regs *dummy);
+static int handle_pm_event (struct pm_dev *dev, pm_request_t rqst, void *data);
/* These belong in linux/pci.h. */
#define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005
@@ -1037,6 +1035,7 @@
nm256_install(struct pci_dev *pcidev, enum nm256rev rev, char *verstr)
{
struct nm256_info *card;
+ struct pm_dev *pmdev;
int x;
card = kmalloc (sizeof (struct nm256_info), GFP_KERNEL);
@@ -1211,50 +1210,42 @@
nm256_install_mixer (card);
+ pmdev = pm_register(PM_PCI_DEV, PM_PCI_ID(pcidev), handle_pm_event);
+ if (pmdev)
+ pmdev->data = card;
+
return 1;
}
-#ifdef CONFIG_APM
/*
- * APM event handler, so the card is properly reinitialized after a power
+ * PM event handler, so the card is properly reinitialized after a power
* event.
*/
static int
-handle_apm_event (apm_event_t event)
+handle_pm_event (struct pm_dev *dev, pm_request_t rqst, void *data)
{
- static int down = 0;
-
- switch (event)
- {
- case APM_SYS_SUSPEND:
- case APM_USER_SUSPEND:
- down++;
+ struct nm256_info *crd = (struct nm256_info*) dev->data;
+ if (crd) {
+ switch (rqst) {
+ case PM_SUSPEND:
break;
- case APM_NORMAL_RESUME:
- case APM_CRITICAL_RESUME:
- if (down)
- {
- struct nm256_info *crd;
-
- down = 0;
- for (crd = nmcard_list; crd != NULL; crd = crd->next_card)
- {
- int playing = crd->playing;
- nm256_full_reset (crd);
- /*
- * A little ugly, but that's ok; pretend the
- * block we were playing is done.
- */
- if (playing)
- DMAbuf_outputintr (crd->dev_for_play, 1);
- }
- }
+ case PM_RESUME:
+ {
+ int playing = crd->playing;
+ nm256_full_reset (crd);
+ /*
+ * A little ugly, but that's ok; pretend the
+ * block we were playing is done.
+ */
+ if (playing)
+ DMAbuf_outputintr (crd->dev_for_play, 1);
+ }
break;
}
+ }
return 0;
}
-#endif
/*
* This loop walks the PCI configuration database and finds where
@@ -1285,10 +1276,6 @@
if (count == 0)
return -ENODEV;
-#ifdef CONFIG_APM
- apm_register_callback (&handle_apm_event);
-#endif
-
printk (KERN_INFO "Done installing NM256 audio driver.\n");
return 0;
}
@@ -1699,9 +1686,7 @@
}
nmcard_list = NULL;
}
-#ifdef CONFIG_APM
- apm_unregister_callback (&handle_apm_event);
-#endif
+ pm_unregister_all (&handle_pm_event);
}
#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)