ALSA: ymfpci: Store additional legacy registers on suspend
authorTasos Sahanidis <tasos@tasossah.com>
Wed, 29 Mar 2023 04:14:40 +0000 (07:14 +0300)
committerTakashi Iwai <tiwai@suse.de>
Wed, 29 Mar 2023 06:28:35 +0000 (08:28 +0200)
YMF744 and newer store the base IO ports in separate PCI config registers.

Since these registers were not restored, when set to a non-default value,
features that rely on them (FM, MPU401, gameport) were not functional
after restore, as their respective IO ports were reset to their defaults.

Signed-off-by: Tasos Sahanidis <tasos@tasossah.com>
Link: https://lore.kernel.org/r/20230329041440.177363-5-tasos@tasossah.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/ymfpci/ymfpci.h
sound/pci/ymfpci/ymfpci_main.c

index 192f6ce..d5dd0e5 100644 (file)
@@ -298,10 +298,18 @@ static const int saved_regs_index[] = {
 #define YDSXGR_NUM_SAVED_REGS  ARRAY_SIZE(saved_regs_index)
 
 static const int pci_saved_regs_index[] = {
+       /* All Chips */
        PCIR_DSXG_LEGACY,
        PCIR_DSXG_ELEGACY,
+       /* YMF 744/754 */
+       PCIR_DSXG_FMBASE,
+       PCIR_DSXG_SBBASE,
+       PCIR_DSXG_MPU401BASE,
+       PCIR_DSXG_JOYBASE,
 };
 #define DSXG_PCI_NUM_SAVED_REGS        ARRAY_SIZE(pci_saved_regs_index)
+#define DSXG_PCI_NUM_SAVED_LEGACY_REGS 2
+static_assert(DSXG_PCI_NUM_SAVED_LEGACY_REGS <= DSXG_PCI_NUM_SAVED_REGS);
 
 struct snd_ymfpci {
        int irq;
index 02c9e45..0963f3a 100644 (file)
@@ -2224,8 +2224,11 @@ static int snd_ymfpci_suspend(struct device *dev)
 {
        struct snd_card *card = dev_get_drvdata(dev);
        struct snd_ymfpci *chip = card->private_data;
-       unsigned int i;
-       
+       unsigned int i, legacy_reg_count = DSXG_PCI_NUM_SAVED_LEGACY_REGS;
+
+       if (chip->pci->device >= 0x0010) /* YMF 744/754 */
+               legacy_reg_count = DSXG_PCI_NUM_SAVED_REGS;
+
        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
        snd_ac97_suspend(chip->ac97);
 
@@ -2234,7 +2237,7 @@ static int snd_ymfpci_suspend(struct device *dev)
 
        chip->saved_ydsxgr_mode = snd_ymfpci_readl(chip, YDSXGR_MODE);
 
-       for (i = 0; i < DSXG_PCI_NUM_SAVED_REGS; i++)
+       for (i = 0; i < legacy_reg_count; i++)
                pci_read_config_word(chip->pci, pci_saved_regs_index[i],
                                      chip->saved_dsxg_pci_regs + i);
 
@@ -2249,7 +2252,10 @@ static int snd_ymfpci_resume(struct device *dev)
        struct pci_dev *pci = to_pci_dev(dev);
        struct snd_card *card = dev_get_drvdata(dev);
        struct snd_ymfpci *chip = card->private_data;
-       unsigned int i;
+       unsigned int i, legacy_reg_count = DSXG_PCI_NUM_SAVED_LEGACY_REGS;
+
+       if (chip->pci->device >= 0x0010) /* YMF 744/754 */
+               legacy_reg_count = DSXG_PCI_NUM_SAVED_REGS;
 
        snd_ymfpci_aclink_reset(pci);
        snd_ymfpci_codec_ready(chip, 0);
@@ -2261,7 +2267,7 @@ static int snd_ymfpci_resume(struct device *dev)
 
        snd_ac97_resume(chip->ac97);
 
-       for (i = 0; i < DSXG_PCI_NUM_SAVED_REGS; i++)
+       for (i = 0; i < legacy_reg_count; i++)
                pci_write_config_word(chip->pci, pci_saved_regs_index[i],
                                      chip->saved_dsxg_pci_regs[i]);