From patchwork Wed Mar 29 04:14:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tasos Sahanidis X-Patchwork-Id: 668879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E80AC74A5B for ; Wed, 29 Mar 2023 04:17:42 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9578F210; Wed, 29 Mar 2023 06:16:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9578F210 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1680063460; bh=DssIjk1H7SHsPXibJaOYmRJ0ZpHjkkyvtKJ8o7TAtEk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Reply-To:Cc:From; b=e3GrUTJt+Xo90WlHMI2hk2W0bQ2fgsc/Yans5kfzI/FNYRGEic41pL/XA78UBhFcM ppWpWewMSUdZB7FHw1KXoeUkhYv5BWowdMczudHLFXKa7Bhe4BSJOkM5XwvU3wMuaP RgC8uNW3rUOfpdeERzNcQ56fC5BuMSIB1cJ+ylTc= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6B4BCF80533; Wed, 29 Mar 2023 06:16:01 +0200 (CEST) To: alsa-devel@alsa-project.org Subject: [PATCH 3/4] ALSA: ymfpci: Store saved legacy registers in an array Date: Wed, 29 Mar 2023 07:14:39 +0300 In-Reply-To: <20230329041440.177363-1-tasos@tasossah.com> References: <20230329041440.177363-1-tasos@tasossah.com> X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <168006335932.26.8046936037081040657@mailman-core.alsa-project.org> X-Patchwork-Original-From: Tasos Sahanidis via Alsa-devel From: Tasos Sahanidis Reply-To: Tasos Sahanidis Cc: tiwai@suse.com, tasos@tasossah.com Content-Disposition: inline In preparation for storing more than two legacy PCI registers, the existing ones are moved into a new array. Signed-off-by: Tasos Sahanidis --- sound/pci/ymfpci/ymfpci.h | 9 +++++++-- sound/pci/ymfpci/ymfpci_main.c | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h index 04e280004..192f6ce9b 100644 --- a/sound/pci/ymfpci/ymfpci.h +++ b/sound/pci/ymfpci/ymfpci.h @@ -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; @@ -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, diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 8bf647824..02c9e454c 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -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); @@ -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) {