Skip to content

Commit

Permalink
ALSA: ymfpci: Store saved legacy registers in an array
Browse files Browse the repository at this point in the history
In preparation for storing more than two legacy PCI registers, the
existing ones are moved into a new array.

Signed-off-by: Tasos Sahanidis <tasos@tasossah.com>
Link: https://lore.kernel.org/r/20230329041440.177363-4-tasos@tasossah.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Tasos Sahanidis authored and Takashi Iwai committed Mar 29, 2023
1 parent 69a6c1b commit 39fef76
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
9 changes: 7 additions & 2 deletions sound/pci/ymfpci/ymfpci.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ static const int saved_regs_index[] = {
};
#define YDSXGR_NUM_SAVED_REGS ARRAY_SIZE(saved_regs_index)

static const int pci_saved_regs_index[] = {
PCIR_DSXG_LEGACY,
PCIR_DSXG_ELEGACY,
};
#define DSXG_PCI_NUM_SAVED_REGS ARRAY_SIZE(pci_saved_regs_index)

struct snd_ymfpci {
int irq;

Expand Down Expand Up @@ -376,8 +382,7 @@ struct snd_ymfpci {

u32 saved_regs[YDSXGR_NUM_SAVED_REGS];
u32 saved_ydsxgr_mode;
u16 saved_dsxg_legacy;
u16 saved_dsxg_elegacy;
u16 saved_dsxg_pci_regs[DSXG_PCI_NUM_SAVED_REGS];
};

int snd_ymfpci_create(struct snd_card *card,
Expand Down
18 changes: 10 additions & 8 deletions sound/pci/ymfpci/ymfpci_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2228,13 +2228,16 @@ static int snd_ymfpci_suspend(struct device *dev)

snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
snd_ac97_suspend(chip->ac97);

for (i = 0; i < YDSXGR_NUM_SAVED_REGS; i++)
chip->saved_regs[i] = snd_ymfpci_readl(chip, saved_regs_index[i]);

chip->saved_ydsxgr_mode = snd_ymfpci_readl(chip, YDSXGR_MODE);
pci_read_config_word(chip->pci, PCIR_DSXG_LEGACY,
&chip->saved_dsxg_legacy);
pci_read_config_word(chip->pci, PCIR_DSXG_ELEGACY,
&chip->saved_dsxg_elegacy);

for (i = 0; i < DSXG_PCI_NUM_SAVED_REGS; i++)
pci_read_config_word(chip->pci, pci_saved_regs_index[i],
chip->saved_dsxg_pci_regs + i);

snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0);
snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0);
snd_ymfpci_disable_dsp(chip);
Expand All @@ -2258,10 +2261,9 @@ static int snd_ymfpci_resume(struct device *dev)

snd_ac97_resume(chip->ac97);

pci_write_config_word(chip->pci, PCIR_DSXG_LEGACY,
chip->saved_dsxg_legacy);
pci_write_config_word(chip->pci, PCIR_DSXG_ELEGACY,
chip->saved_dsxg_elegacy);
for (i = 0; i < DSXG_PCI_NUM_SAVED_REGS; i++)
pci_write_config_word(chip->pci, pci_saved_regs_index[i],
chip->saved_dsxg_pci_regs[i]);

/* start hw again */
if (chip->start_count > 0) {
Expand Down

0 comments on commit 39fef76

Please sign in to comment.