From patchwork Wed Mar 29 04:14:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tasos Sahanidis X-Patchwork-Id: 668134 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 71C7EC761AF for ; Wed, 29 Mar 2023 04:17:37 +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 D65B61F6; Wed, 29 Mar 2023 06:16:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D65B61F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1680063453; bh=6vx1Lb5SegnTjMm1n5QwqwKVxUHh3miCTZYweYGbO74=; 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=b3lqaY1zuvVWORY7Yif2YqhCBMzv7F41ruKb9zqCgqvKLCWNpVpr0Gi19PFZNfo0p pgo/JAZI8uqI8iByndm2+3jII0PToYPiEgVKj42Rd1AhR8xxbWhx1jqNc+Bnefqg90 +FdY1vZfL06JSlMPFos2hzEjMMJpHjB/ALGJtM74= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id CB7B8F80529; Wed, 29 Mar 2023 06:15:51 +0200 (CEST) To: alsa-devel@alsa-project.org Subject: [PATCH 1/4] ALSA: ymfpci: Switch to DEFINE_SIMPLE_DEV_PM_OPS() Date: Wed, 29 Mar 2023 07:14:37 +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: <168006335063.26.17112137661731848878@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 Since commit 1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones") SIMPLE_DEV_PM_OPS has been marked deprecated. The intent is to remove CONFIG_PM_SLEEP guards for PM callbacks. As such the ifdefs are now removed. Signed-off-by: Tasos Sahanidis --- sound/pci/ymfpci/ymfpci.c | 4 +--- sound/pci/ymfpci/ymfpci.h | 2 -- sound/pci/ymfpci/ymfpci_main.c | 6 +----- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index 1e198e4d5..30109aa0f 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c @@ -337,11 +337,9 @@ static struct pci_driver ymfpci_driver = { .name = KBUILD_MODNAME, .id_table = snd_ymfpci_ids, .probe = snd_card_ymfpci_probe, -#ifdef CONFIG_PM_SLEEP .driver = { - .pm = &snd_ymfpci_pm, + .pm = pm_sleep_ptr(&snd_ymfpci_pm), }, -#endif }; module_pci_driver(ymfpci_driver); diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h index 669687764..2103654c6 100644 --- a/sound/pci/ymfpci/ymfpci.h +++ b/sound/pci/ymfpci/ymfpci.h @@ -345,12 +345,10 @@ struct snd_ymfpci { const struct firmware *dsp_microcode; const struct firmware *controller_microcode; -#ifdef CONFIG_PM_SLEEP u32 *saved_regs; u32 saved_ydsxgr_mode; u16 saved_dsxg_legacy; u16 saved_dsxg_elegacy; -#endif }; 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 2858736ed..6d13f4152 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -2220,7 +2220,6 @@ static void snd_ymfpci_free(struct snd_card *card) release_firmware(chip->controller_microcode); } -#ifdef CONFIG_PM_SLEEP static const int saved_regs_index[] = { /* spdif */ YDSXGR_SPDIFOUTCTRL, @@ -2304,8 +2303,7 @@ static int snd_ymfpci_resume(struct device *dev) return 0; } -SIMPLE_DEV_PM_OPS(snd_ymfpci_pm, snd_ymfpci_suspend, snd_ymfpci_resume); -#endif /* CONFIG_PM_SLEEP */ +DEFINE_SIMPLE_DEV_PM_OPS(snd_ymfpci_pm, snd_ymfpci_suspend, snd_ymfpci_resume); int snd_ymfpci_create(struct snd_card *card, struct pci_dev *pci, @@ -2374,12 +2372,10 @@ int snd_ymfpci_create(struct snd_card *card, if (err < 0) return err; -#ifdef CONFIG_PM_SLEEP chip->saved_regs = devm_kmalloc_array(&pci->dev, YDSXGR_NUM_SAVED_REGS, sizeof(u32), GFP_KERNEL); if (!chip->saved_regs) return -ENOMEM; -#endif snd_ymfpci_proc_init(card, chip); From patchwork Wed Mar 29 04:14:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tasos Sahanidis X-Patchwork-Id: 668880 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 6E565C6FD18 for ; Wed, 29 Mar 2023 04:17:37 +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 F1CC1201; Wed, 29 Mar 2023 06:16:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F1CC1201 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1680063454; bh=/w7wXYIbbjds+dHj8hzQlMWEZHlwt0WI/Lgw35hj5Dc=; 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=ps3TeTllSZFgdbGSCsosRQVtuvc2XHVvxSfzKeebAurRtkc4puGR/7m4jkMGM+/Qy EZZTUOoCnu/0B3OWNomnriDwiS2LTK+NH/7Bjx2GWR9JZWaiZYljtT7Zv4OV9aHgGR +L57Jix8YRv1M1h3kdxljv3qX7KVJ7RHjszPhj3I= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id CC77AF80290; Wed, 29 Mar 2023 06:15:50 +0200 (CEST) To: alsa-devel@alsa-project.org Subject: [PATCH 2/4] ALSA: ymfpci: Move allocation of saved registers to struct snd_ymfpci Date: Wed, 29 Mar 2023 07:14:38 +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: <168006334833.26.13441719652980718121@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 The registers were previously allocated when CONFIG_PM_SLEEP was set, however this only saved an insignificant amount of memory otherwise. Signed-off-by: Tasos Sahanidis --- sound/pci/ymfpci/ymfpci.h | 31 ++++++++++++++++++++++++++++++- sound/pci/ymfpci/ymfpci_main.c | 34 ---------------------------------- 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h index 2103654c6..04e280004 100644 --- a/sound/pci/ymfpci/ymfpci.h +++ b/sound/pci/ymfpci/ymfpci.h @@ -268,6 +268,35 @@ struct snd_ymfpci_pcm { u32 shift; }; +static const int saved_regs_index[] = { + /* spdif */ + YDSXGR_SPDIFOUTCTRL, + YDSXGR_SPDIFOUTSTATUS, + YDSXGR_SPDIFINCTRL, + /* volumes */ + YDSXGR_PRIADCLOOPVOL, + YDSXGR_NATIVEDACINVOL, + YDSXGR_NATIVEDACOUTVOL, + YDSXGR_BUF441OUTVOL, + YDSXGR_NATIVEADCINVOL, + YDSXGR_SPDIFLOOPVOL, + YDSXGR_SPDIFOUTVOL, + YDSXGR_ZVOUTVOL, + YDSXGR_LEGACYOUTVOL, + /* address bases */ + YDSXGR_PLAYCTRLBASE, + YDSXGR_RECCTRLBASE, + YDSXGR_EFFCTRLBASE, + YDSXGR_WORKBASE, + /* capture set up */ + YDSXGR_MAPOFREC, + YDSXGR_RECFORMAT, + YDSXGR_RECSLOTSR, + YDSXGR_ADCFORMAT, + YDSXGR_ADCSLOTSR, +}; +#define YDSXGR_NUM_SAVED_REGS ARRAY_SIZE(saved_regs_index) + struct snd_ymfpci { int irq; @@ -345,7 +374,7 @@ struct snd_ymfpci { const struct firmware *dsp_microcode; const struct firmware *controller_microcode; - u32 *saved_regs; + u32 saved_regs[YDSXGR_NUM_SAVED_REGS]; u32 saved_ydsxgr_mode; u16 saved_dsxg_legacy; u16 saved_dsxg_elegacy; diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 6d13f4152..8bf647824 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -2220,35 +2220,6 @@ static void snd_ymfpci_free(struct snd_card *card) release_firmware(chip->controller_microcode); } -static const int saved_regs_index[] = { - /* spdif */ - YDSXGR_SPDIFOUTCTRL, - YDSXGR_SPDIFOUTSTATUS, - YDSXGR_SPDIFINCTRL, - /* volumes */ - YDSXGR_PRIADCLOOPVOL, - YDSXGR_NATIVEDACINVOL, - YDSXGR_NATIVEDACOUTVOL, - YDSXGR_BUF441OUTVOL, - YDSXGR_NATIVEADCINVOL, - YDSXGR_SPDIFLOOPVOL, - YDSXGR_SPDIFOUTVOL, - YDSXGR_ZVOUTVOL, - YDSXGR_LEGACYOUTVOL, - /* address bases */ - YDSXGR_PLAYCTRLBASE, - YDSXGR_RECCTRLBASE, - YDSXGR_EFFCTRLBASE, - YDSXGR_WORKBASE, - /* capture set up */ - YDSXGR_MAPOFREC, - YDSXGR_RECFORMAT, - YDSXGR_RECSLOTSR, - YDSXGR_ADCFORMAT, - YDSXGR_ADCSLOTSR, -}; -#define YDSXGR_NUM_SAVED_REGS ARRAY_SIZE(saved_regs_index) - static int snd_ymfpci_suspend(struct device *dev) { struct snd_card *card = dev_get_drvdata(dev); @@ -2372,11 +2343,6 @@ int snd_ymfpci_create(struct snd_card *card, if (err < 0) return err; - chip->saved_regs = devm_kmalloc_array(&pci->dev, YDSXGR_NUM_SAVED_REGS, - sizeof(u32), GFP_KERNEL); - if (!chip->saved_regs) - return -ENOMEM; - snd_ymfpci_proc_init(card, chip); return 0; 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) { 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]);