From patchwork Wed Mar 29 04:14:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tasos Sahanidis X-Patchwork-Id: 668133 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 61760C761AF for ; Wed, 29 Mar 2023 04:18:01 +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 DDB3274C; Wed, 29 Mar 2023 06:17:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DDB3274C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1680063478; bh=n/3oNMC4NKPNIOYS0LS51C8OTzsSte+iJ+FXy0Ut5oM=; 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=ZoNnwKN+ijbLzc06kHDiPEeWFhH40U/gvddg8/Dta4oTbXnC1UpDhfvHMUQE8uZC9 /8GgE8yfbrqrif5+oaV9JtOlDJ3VR1zvTeHx2QLe5r7KnpQEVVQ0PgZQKeFR3wHIRB JkRWI+Qgm6zvnq4X/eAT4eOwCYBG8zoTsVS4EpYI= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 588F5F80542; Wed, 29 Mar 2023 06:16:03 +0200 (CEST) To: alsa-devel@alsa-project.org Subject: [PATCH 4/4] ALSA: ymfpci: Store additional legacy registers on suspend Date: Wed, 29 Mar 2023 07:14:40 +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: <168006336180.26.16161966652336525961@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 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 --- 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]);