aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@suse.cz>2005-01-03 13:13:30 +0100
committerJaroslav Kysela <perex@suse.cz>2005-01-03 13:13:30 +0100
commit74e89507df5198f81b495de8f8d30db556e3e2a0 (patch)
treebd67a2f681dcb5f9197a2f7867cfea398e16dfaf /sound
parentc35adcff41c2b5c5f68b29e1a0ede8301c1bf3c4 (diff)
downloadhistory-74e89507df5198f81b495de8f8d30db556e3e2a0.tar.gz
[ALSA] Clean up power-management
Documentation,SA11xx UDA1341 driver,Control Midlevel,ALSA Core ES18xx driver,OPL3SA2 driver,AD1848 driver,CS4231 driver,ATIIXP driver ATIIXP-modem driver,CS4281 driver,ES1938 driver,ES1968 driver Intel8x0 driver,Intel8x0-modem driver,Maestro3 driver,VIA82xx driver VIA82xx-modem driver,ALI5451 driver,CS46xx driver,NM256 driver Trident driver,YMFPCI driver,Sound Core PDAudioCF driver PPC PMAC driver Clean up for PM code. snd_power_change() is called in the common routines instead of driver's callback. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/arm/sa11xx-uda1341.c4
-rw-r--r--sound/core/control.c15
-rw-r--r--sound/core/init.c11
-rw-r--r--sound/isa/ad1848/ad1848_lib.c8
-rw-r--r--sound/isa/cs423x/cs4231_lib.c8
-rw-r--r--sound/isa/es18xx.c2
-rw-r--r--sound/isa/opl3sa2.c2
-rw-r--r--sound/pci/ali5451/ali5451.c2
-rw-r--r--sound/pci/atiixp.c2
-rw-r--r--sound/pci/atiixp_modem.c2
-rw-r--r--sound/pci/cs4281.c2
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c2
-rw-r--r--sound/pci/es1938.c2
-rw-r--r--sound/pci/es1968.c2
-rw-r--r--sound/pci/intel8x0.c2
-rw-r--r--sound/pci/intel8x0m.c2
-rw-r--r--sound/pci/maestro3.c2
-rw-r--r--sound/pci/nm256/nm256.c2
-rw-r--r--sound/pci/trident/trident_main.c2
-rw-r--r--sound/pci/via82xx.c47
-rw-r--r--sound/pci/via82xx_modem.c2
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c2
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf_core.c2
-rw-r--r--sound/ppc/pmac.c2
24 files changed, 53 insertions, 76 deletions
diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c
index 782fed3c9f957b..21103c7aed5aaa 100644
--- a/sound/arm/sa11xx-uda1341.c
+++ b/sound/arm/sa11xx-uda1341.c
@@ -21,7 +21,7 @@
* merged HAL layer (patches from Brian)
*/
-/* $Id: sa11xx-uda1341.c,v 1.18 2004/07/20 15:54:09 cladisch Exp $ */
+/* $Id: sa11xx-uda1341.c,v 1.19 2004/12/15 15:26:10 tiwai Exp $ */
/***************************************************************************************************
*
@@ -875,7 +875,6 @@ static int snd_sa11xx_uda1341_suspend(snd_card_t *card, unsigned int state)
#endif
l3_command(chip->uda1341, CMD_SUSPEND, NULL);
sa11xx_uda1341_audio_shutdown(chip);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -891,7 +890,6 @@ static int snd_sa11xx_uda1341_resume(snd_card_t *card, unsigned int state)
#else
//FIXME
#endif
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* COMFIG_PM */
diff --git a/sound/core/control.c b/sound/core/control.c
index 191a0ed67060e9..aaff8b3a9e0898 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1020,18 +1020,23 @@ static int snd_ctl_set_power_state(snd_card_t *card, unsigned int power_state)
{
switch (power_state) {
case SNDRV_CTL_POWER_D0:
- case SNDRV_CTL_POWER_D1:
- case SNDRV_CTL_POWER_D2:
- if (card->power_state != power_state)
+ if (card->power_state != power_state) {
/* FIXME: pass the correct state value */
card->pm_resume(card, 0);
+ snd_power_change_state(card, power_state);
+ }
break;
case SNDRV_CTL_POWER_D3hot:
- case SNDRV_CTL_POWER_D3cold:
- if (card->power_state != power_state)
+ if (card->power_state != power_state) {
/* FIXME: pass the correct state value */
card->pm_suspend(card, 0);
+ snd_power_change_state(card, power_state);
+ }
break;
+ case SNDRV_CTL_POWER_D1:
+ case SNDRV_CTL_POWER_D2:
+ case SNDRV_CTL_POWER_D3cold:
+ /* not supported yet */
default:
return -EINVAL;
}
diff --git a/sound/core/init.c b/sound/core/init.c
index 4dfc0290ed6539..3e5eae098b629d 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -741,12 +741,18 @@ static int snd_generic_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *
switch (rqst) {
case PM_SUSPEND:
+ if (card->power_state == SNDRV_CTL_POWER_D3hot)
+ break;
/* FIXME: the correct state value? */
card->pm_suspend(card, 0);
+ snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
break;
case PM_RESUME:
+ if (card->power_state == SNDRV_CTL_POWER_D0)
+ break;
/* FIXME: the correct state value? */
card->pm_resume(card, 0);
+ snd_power_change_state(card, SNDRV_CTL_POWER_D0);
break;
}
return 0;
@@ -789,6 +795,7 @@ int snd_card_pci_suspend(struct pci_dev *dev, u32 state)
/* FIXME: correct state value? */
err = card->pm_suspend(card, 0);
pci_save_state(dev);
+ snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return err;
}
@@ -802,7 +809,9 @@ int snd_card_pci_resume(struct pci_dev *dev)
/* restore the PCI config space */
pci_restore_state(dev);
/* FIXME: correct state value? */
- return card->pm_resume(card, 0);
+ card->pm_resume(card, 0);
+ snd_power_change_state(card, SNDRV_CTL_POWER_D0);
+ return 0;
}
#endif
diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c
index 7cab7c5e0b250d..97b8f87108020a 100644
--- a/sound/isa/ad1848/ad1848_lib.c
+++ b/sound/isa/ad1848/ad1848_lib.c
@@ -648,16 +648,12 @@ static int snd_ad1848_suspend(snd_card_t *card, unsigned int state)
{
ad1848_t *chip = card->pm_private_data;
- if (card->power_state == SNDRV_CTL_POWER_D3hot)
- return 0;
-
snd_pcm_suspend_all(chip->pcm);
/* FIXME: save registers? */
if (chip->thinkpad_flag)
snd_ad1848_thinkpad_twiddle(chip, 0);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -665,15 +661,11 @@ static int snd_ad1848_resume(snd_card_t *card, unsigned int state)
{
ad1848_t *chip = card->pm_private_data;
- if (card->power_state == SNDRV_CTL_POWER_D0)
- return 0;
-
if (chip->thinkpad_flag)
snd_ad1848_thinkpad_twiddle(chip, 1);
/* FIXME: restore registers? */
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c
index f46cf12979dd31..888e2b00f9d96a 100644
--- a/sound/isa/cs423x/cs4231_lib.c
+++ b/sound/isa/cs423x/cs4231_lib.c
@@ -1397,20 +1397,16 @@ static void snd_cs4231_resume(cs4231_t *chip)
static int snd_cs4231_pm_suspend(snd_card_t *card, unsigned int state)
{
cs4231_t *chip = card->pm_private_data;
- if (chip->suspend) {
+ if (chip->suspend)
chip->suspend(chip);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
- }
return 0;
}
static int snd_cs4231_pm_resume(snd_card_t *card, unsigned int state)
{
cs4231_t *chip = card->pm_private_data;
- if (chip->resume) {
+ if (chip->resume)
chip->resume(chip);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
- }
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index 30a6a924ebb3e2..4939aad0aebbff 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -1624,7 +1624,6 @@ static int snd_es18xx_suspend(snd_card_t *card, unsigned int state)
snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg);
snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_SUS);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -1635,7 +1634,6 @@ static int snd_es18xx_resume(snd_card_t *card, unsigned int state)
/* restore PM register, we won't wake till (not 0x07) i/o activity though */
snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index 52381fcee59670..4596883648ff09 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -539,7 +539,6 @@ static int snd_opl3sa2_suspend(snd_card_t *card, unsigned int state)
/* power down */
snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -563,7 +562,6 @@ static int snd_opl3sa2_resume(snd_card_t *card, unsigned int state)
/* restore cs4231 */
chip->cs4231_resume(chip->cs4231);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index eed535774598a4..b58de44409047e 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -1933,7 +1933,6 @@ static int ali_suspend(snd_card_t *card, unsigned int state)
spin_unlock_irq(&chip->reg_lock);
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -1971,7 +1970,6 @@ static int ali_resume(snd_card_t *card, unsigned int state)
spin_unlock_irq(&chip->reg_lock);
snd_ac97_resume(chip->ac97);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 36010940e1d1cc..07800df4690f55 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1409,7 +1409,6 @@ static int snd_atiixp_suspend(snd_card_t *card, unsigned int state)
pci_set_power_state(chip->pci, 3);
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -1429,7 +1428,6 @@ static int snd_atiixp_resume(snd_card_t *card, unsigned int state)
if (chip->ac97[i])
snd_ac97_resume(chip->ac97[i]);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index e1ed2e3a87fbab..4404f564c506e0 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -1131,7 +1131,6 @@ static int snd_atiixp_suspend(snd_card_t *card, unsigned int state)
pci_set_power_state(chip->pci, 3);
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -1151,7 +1150,6 @@ static int snd_atiixp_resume(snd_card_t *card, unsigned int state)
if (chip->ac97[i])
snd_ac97_resume(chip->ac97[i]);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index d1ac0dd2814f13..a34e91524bfee2 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -2079,7 +2079,6 @@ static int cs4281_suspend(snd_card_t *card, unsigned int state)
snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK);
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -2112,7 +2111,6 @@ static int cs4281_resume(snd_card_t *card, unsigned int state)
ulCLK &= ~CLKCR1_CKRA;
snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index fb6f915d96be42..54771fa4d94a6f 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -3725,7 +3725,6 @@ static int snd_cs46xx_suspend(snd_card_t *card, unsigned int state)
chip->active_ctrl(chip, -chip->amplifier);
chip->amplifier = amp_saved; /* restore the status */
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -3762,7 +3761,6 @@ static int snd_cs46xx_resume(snd_card_t *card, unsigned int state)
else
chip->active_ctrl(chip, -1); /* disable CLKRUN */
chip->amplifier = amp_saved;
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 4ef94409b9c4a5..43359836a8b2b9 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1395,7 +1395,6 @@ static int es1938_suspend(snd_card_t *card, unsigned int state)
outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -1415,7 +1414,6 @@ static int es1938_resume(snd_card_t *card, unsigned int state)
snd_es1938_write(chip, *s, *d);
}
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index d374f9b5748eac..f3a6a488cf783e 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -2415,7 +2415,6 @@ static int es1968_suspend(snd_card_t *card, unsigned int state)
snd_es1968_bob_stop(chip);
snd_es1968_set_acpi(chip, ACPI_D3);
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -2446,7 +2445,6 @@ static int es1968_resume(snd_card_t *card, unsigned int state)
if (chip->bobclient)
snd_es1968_bob_start(chip);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 50278917dd572e..d88a769fc6ba48 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -2314,7 +2314,6 @@ static int intel8x0_suspend(snd_card_t *card, unsigned int state)
if (chip->ac97[i])
snd_ac97_suspend(chip->ac97[i]);
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -2347,7 +2346,6 @@ static int intel8x0_resume(snd_card_t *card, unsigned int state)
}
}
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index e97b41452df9fc..e638be03c294ab 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -1093,7 +1093,6 @@ static int intel8x0m_suspend(snd_card_t *card, unsigned int state)
if (chip->ac97)
snd_ac97_suspend(chip->ac97);
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -1106,7 +1105,6 @@ static int intel8x0m_resume(snd_card_t *card, unsigned int state)
if (chip->ac97)
snd_ac97_resume(chip->ac97);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 6eaf5dbfb7bf1f..a617badec89a11 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2424,7 +2424,6 @@ static int m3_suspend(snd_card_t *card, unsigned int state)
snd_m3_outw(chip, 0xffff, 0x56);
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -2467,7 +2466,6 @@ static int m3_resume(snd_card_t *card, unsigned int state)
snd_m3_enable_ints(chip);
snd_m3_amp_enable(chip, 1);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 25949c43497bd5..c7c4e78ba69321 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1275,7 +1275,6 @@ static int nm256_suspend(snd_card_t *card, unsigned int state)
snd_ac97_suspend(chip->ac97);
chip->coeffs_current = 0;
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -1290,7 +1289,6 @@ static int nm256_resume(snd_card_t *card, unsigned int state)
/* restore ac97 */
snd_ac97_resume(chip->ac97);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index c64935d4e5724d..295626c0441b1b 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -3946,7 +3946,6 @@ static int snd_trident_suspend(snd_card_t *card, unsigned int state)
break;
}
pci_disable_device(trident->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -3981,7 +3980,6 @@ static int snd_trident_resume(snd_card_t *card, unsigned int state)
snd_trident_enable_eso(trident);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
trident->in_suspend = 0;
return 0;
}
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 5e30ae3e44a976..cefe6b0a1919fd 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -332,6 +332,7 @@ struct via_dev {
struct snd_via_sg_table *idx_table;
/* for recovery from the unexpected pointer */
unsigned int lastpos;
+ unsigned int fragsize;
unsigned int bufsize;
unsigned int bufsize2;
};
@@ -478,6 +479,7 @@ static int build_via_table(viadev_t *dev, snd_pcm_substream_t *substream,
dev->tbl_entries = idx;
dev->bufsize = periods * fragsize;
dev->bufsize2 = dev->bufsize / 2;
+ dev->fragsize = fragsize;
return 0;
}
@@ -706,29 +708,34 @@ static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd)
static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count)
{
- unsigned int size, res;
+ unsigned int size, base, res;
size = viadev->idx_table[idx].size;
- res = viadev->idx_table[idx].offset + size - count;
+ base = viadev->idx_table[idx].offset;
+ res = base + size - count;
/* check the validity of the calculated position */
if (size < count) {
snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n", (int)size, (int)count);
res = viadev->lastpos;
- } else if (check_invalid_pos(viadev, res)) {
+ } else {
+ if (! count) {
+ /* Some mobos report count = 0 on the DMA boundary,
+ * i.e. count = size indeed.
+ * Let's check whether this step is above the expected size.
+ */
+ int delta = res - viadev->lastpos;
+ if (delta < 0)
+ delta += viadev->bufsize;
+ if ((unsigned int)delta > viadev->fragsize)
+ res = base;
+ }
+ if (check_invalid_pos(viadev, res)) {
#ifdef POINTER_DEBUG
- printk("fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count);
+ printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count);
#endif
- if (count && size < count) {
- snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n");
- res = viadev->lastpos;
- } else {
- if (! count)
- /* bogus count 0 on the DMA boundary? */
- res = viadev->idx_table[idx].offset;
- else
- /* count register returns full size when end of buffer is reached */
- res = viadev->idx_table[idx].offset + size;
+ /* count register returns full size when end of buffer is reached */
+ res = base + size;
if (check_invalid_pos(viadev, res)) {
snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n");
res = viadev->lastpos;
@@ -778,12 +785,20 @@ static snd_pcm_uframes_t snd_via8233_pcm_pointer(snd_pcm_substream_t *substream)
via82xx_t *chip = snd_pcm_substream_chip(substream);
viadev_t *viadev = (viadev_t *)substream->runtime->private_data;
unsigned int idx, count, res;
+ int timeout = 5000;
snd_assert(viadev->tbl_entries, return 0);
if (!(inb(VIADEV_REG(viadev, OFFSET_STATUS)) & VIA_REG_STAT_ACTIVE))
return 0;
spin_lock(&chip->reg_lock);
- count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT));
+ do {
+ count = inl(VIADEV_REG(viadev, OFFSET_CURR_COUNT));
+ /* some mobos read 0 count */
+ if ((count & 0xffffff) || ! viadev->running)
+ break;
+ } while (--timeout);
+ if (! timeout)
+ snd_printd(KERN_ERR "zero position is read\n");
idx = count >> 24;
if (idx >= viadev->tbl_entries) {
#ifdef POINTER_DEBUG
@@ -1908,7 +1923,6 @@ static int snd_via82xx_suspend(snd_card_t *card, unsigned int state)
pci_set_power_state(chip->pci, 3);
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -1943,7 +1957,6 @@ static int snd_via82xx_resume(snd_card_t *card, unsigned int state)
for (i = 0; i < chip->num_devs; i++)
snd_via82xx_channel_reset(chip, &chip->devs[i]);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 02898ce8074ea9..0efc41e728a446 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -1054,7 +1054,6 @@ static int snd_via82xx_suspend(snd_card_t *card, unsigned int state)
snd_ac97_suspend(chip->ac97);
pci_set_power_state(chip->pci, 3);
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -1074,7 +1073,6 @@ static int snd_via82xx_resume(snd_card_t *card, unsigned int state)
for (i = 0; i < chip->num_devs; i++)
snd_via82xx_channel_reset(chip, &chip->devs[i]);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 52da44735f4864..af913f623bab62 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -2153,7 +2153,6 @@ static int snd_ymfpci_suspend(snd_card_t *card, unsigned int state)
snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0);
snd_ymfpci_disable_dsp(chip);
pci_disable_device(chip->pci);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -2181,7 +2180,6 @@ static int snd_ymfpci_resume(snd_card_t *card, unsigned int state)
chip->active_bank = snd_ymfpci_readl(chip, YDSXGR_CTRLSELECT);
spin_unlock_irq(&chip->reg_lock);
}
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif /* CONFIG_PM */
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
index 11eb7275456c55..f845503bb44938 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c
@@ -267,7 +267,6 @@ int snd_pdacf_suspend(snd_card_t *card, unsigned int state)
outw(val, chip->port + PDAUDIOCF_REG_IER);
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;
}
@@ -287,7 +286,6 @@ int snd_pdacf_resume(snd_card_t *card, unsigned int state)
(snd_ak4117_external_rate(chip->ak4117) <= 0 || !check_signal(chip)))
mdelay(1);
chip->chip_status &= ~PDAUDIOCF_STAT_IS_SUSPENDED;
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}
#endif
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index d194dd03680e4f..07f9ad60493504 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -1248,7 +1248,6 @@ static int snd_pmac_suspend(snd_card_t *card, unsigned int state)
if (chip->rx_irq >= 0)
disable_irq(chip->rx_irq);
snd_pmac_sound_feature(chip, 0);
- snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
return 0;
}
@@ -1275,7 +1274,6 @@ static int snd_pmac_resume(snd_card_t *card, unsigned int state)
if (chip->rx_irq >= 0)
enable_irq(chip->rx_irq);
- snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
}