Update of /cvsroot/alsa/alsa-kernel/pcmcia/pdaudiocf
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19034/pcmcia/pdaudiocf

Modified Files:
        pdaudiocf.c pdaudiocf.h pdaudiocf_core.c 
Log Message:
Clean up of power-management codes.

- moved commonly used codes to the core layer.
- using the unified suspend/resume callbacks for PCI and ISA
- added snd_card_set_pm_callbacks() and snd_card_set_isa_pm_callbacks()
  as the registration functions.


Index: pdaudiocf.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pcmcia/pdaudiocf/pdaudiocf.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- pdaudiocf.c 7 Apr 2004 17:48:22 -0000       1.5
+++ pdaudiocf.c 8 Apr 2004 16:35:00 -0000       1.6
@@ -243,10 +243,7 @@
        if (err < 0)
                return err;
 
-#ifdef CONFIG_PM
-       card->power_state_private_data = pdacf;
-       card->set_power_state = snd_pdacf_set_power_state;
-#endif
+       snd_card_set_pm_callback(card, snd_pdacf_suspend, snd_pdacf_resume, pdacf);
 
        if ((err = snd_card_register(card)) < 0)
                return err;
@@ -371,7 +368,7 @@
                link->state |= DEV_SUSPEND;
                if (chip) {
                        snd_printdd(KERN_DEBUG "snd_pdacf_suspend calling\n");
-                       snd_pdacf_suspend(chip);
+                       snd_pdacf_suspend(chip->card, 0);
                }
                /* Fall through... */
        case CS_EVENT_RESET_PHYSICAL:
@@ -390,7 +387,7 @@
                        pcmcia_request_configuration(link->handle, &link->conf);
                        if (chip) {
                                snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n");
-                               snd_pdacf_resume(chip);
+                               snd_pdacf_resume(chip->card, 0);
                        }
                }
                snd_printdd(KERN_DEBUG "resume done!\n");

Index: pdaudiocf.h
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pcmcia/pdaudiocf/pdaudiocf.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- pdaudiocf.h 6 Mar 2004 16:51:31 -0000       1.4
+++ pdaudiocf.h 8 Apr 2004 16:35:01 -0000       1.5
@@ -136,9 +136,8 @@
 int snd_pdacf_ak4117_create(pdacf_t *pdacf);
 void snd_pdacf_powerdown(pdacf_t *chip);
 #ifdef CONFIG_PM
-void snd_pdacf_suspend(pdacf_t *chip);
-void snd_pdacf_resume(pdacf_t *chip);
-int snd_pdacf_set_power_state(snd_card_t *card, unsigned int power_state);
+int snd_pdacf_suspend(snd_card_t *card, unsigned int state);
+int snd_pdacf_resume(snd_card_t *card, unsigned int state);
 #endif
 int snd_pdacf_pcm_new(pdacf_t *chip);
 void pdacf_interrupt(int irq, void *dev, struct pt_regs *regs);

Index: pdaudiocf_core.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pcmcia/pdaudiocf/pdaudiocf_core.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pdaudiocf_core.c    20 Mar 2004 19:16:59 -0000      1.2
+++ pdaudiocf_core.c    8 Apr 2004 16:35:01 -0000       1.3
@@ -255,13 +255,11 @@
 
 #ifdef CONFIG_PM
 
-void snd_pdacf_suspend(pdacf_t *chip)
+int snd_pdacf_suspend(snd_card_t *card, unsigned int state)
 {
-       snd_card_t *card = chip->card;
+       pdacf_t *chip = snd_magic_cast(pdacf_t, card->pm_private_data, return -EINVAL);
        u16 val;
        
-       if (card->power_state == SNDRV_CTL_POWER_D3hot)
-               return;
        snd_pcm_suspend_all(chip->pcm);
        /* disable interrupts, but use direct write to preserve old register value in 
chip->regmap */
        val = inw(chip->port + PDAUDIOCF_REG_IER);
@@ -270,6 +268,7 @@
        chip->chip_status |= PDAUDIOCF_STAT_IS_SUSPENDED;       /* ignore interrupts 
from now */
        snd_pdacf_powerdown(chip);
        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
+       return 0;
 }
 
 static inline int check_signal(pdacf_t *chip)
@@ -277,13 +276,11 @@
        return (chip->ak4117->rcs0 & AK4117_UNLCK) == 0;
 }
 
-void snd_pdacf_resume(pdacf_t *chip)
+int snd_pdacf_resume(snd_card_t *card, unsigned int state)
 {
-       snd_card_t *card = chip->card;
+       pdacf_t *chip = snd_magic_cast(pdacf_t, card->pm_private_data, return -EINVAL);
        int timeout = 40;
 
-       if (card->power_state == SNDRV_CTL_POWER_D0)
-               return;
        pdacf_reinit(chip, 1);
        /* wait for AK4117's PLL */
        while (timeout-- > 0 &&
@@ -291,26 +288,6 @@
                mdelay(1);
        chip->chip_status &= ~PDAUDIOCF_STAT_IS_SUSPENDED;
        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
-}
-
-int snd_pdacf_set_power_state(snd_card_t *card, unsigned int power_state)
-{
-       pdacf_t *chip = snd_magic_cast(pdacf_t, card->power_state_private_data, return 
-ENXIO);
-
-       switch (power_state) {
-       case SNDRV_CTL_POWER_D0:
-       case SNDRV_CTL_POWER_D1:
-       case SNDRV_CTL_POWER_D2:
-               snd_pdacf_resume(chip);
-               break;
-       case SNDRV_CTL_POWER_D3hot:
-       case SNDRV_CTL_POWER_D3cold:
-               snd_pdacf_suspend(chip);
-               break;
-       default:
-               return -EINVAL;
-       }
        return 0;
 }
-
 #endif



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to