--- Begin Message ---
- To: alsa-devel@xxxxxxxxxxxxxxxx
- Subject: [PATCH 4/4] ALSA: ymfpci: Store additional legacy registers on suspend
- From: Tasos Sahanidis <tasos@xxxxxxxxxxxx>
- Date: Wed, 29 Mar 2023 07:14:40 +0300
- Cc: tiwai@xxxxxxxx, tasos@xxxxxxxxxxxx
- In-reply-to: <20230329041440.177363-1-tasos@tasossah.com>
- References: <20230329041440.177363-1-tasos@tasossah.com>
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@xxxxxxxxxxxx>
---
sound/pci/ymfpci/ymfpci.h | 8 ++++++++
sound/pci/ymfpci/ymfpci_main.c | 16 +++++++++++-----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
index 192f6ce9b..d5dd0e5ae 100644
--- a/sound/pci/ymfpci/ymfpci.h
+++ b/sound/pci/ymfpci/ymfpci.h
@@ -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;
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 02c9e454c..0963f3ae3 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -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]);
--
2.25.1
--- End Message ---