* [PATCH v2 0/3] ALSA: add suspend/resume support for InterWave ISA cards
@ 2026-04-07 15:35 Cássio Gabriel
2026-04-07 15:35 ` [PATCH v2 1/3] ALSA: tea6330t: move snd_tea6330t_detect() EXPORT_SYMBOL Cássio Gabriel
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Cássio Gabriel @ 2026-04-07 15:35 UTC (permalink / raw)
To: Takashi Iwai, Jaroslav Kysela
Cc: linux-sound, linux-kernel, Cássio Gabriel
This 3-patch series wires up suspend and resume support for the
InterWave ISA drivers and their PnP front-end around the shared
GUS PM helpers.
The first patch moves the remaining standalone
snd_tea6330t_detect() EXPORT_SYMBOL() declaration next to its
function definition as a requested small cleanup.
The second patch adds a small TEA6330T helper so the InterWave STB
variant can restore its cached external mixer state after resume.
The third patch adds ISA and PnP PM callbacks to snd-interwave and
restores the remaining InterWave-specific state that the generic GUS
resume path does not cover, including the GF1 board registers and the
detected memory layout.
The resume path intentionally does not rerun probe-time DRAM/ROM
detection. As with the shared GUS PM support, this does not guarantee
preservation of sample RAM contents across suspend.
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
---
Changes in v2:
- Add a separate tea6330t cleanup patch moving the standalone
snd_tea6330t_detect() EXPORT_SYMBOL() next to its function.
- Extend snd_i2c_lock() to cover the full device lookup/list traversal
in snd_tea6330t_restore_mixer().
- Renumber the InterWave PM patch to 3/3 after splitting out the
cleanup patch.
- Link to v1: https://lore.kernel.org/all/20260406-alsa-interwave-pm-v1-0-6ffa6f317c8f@gmail.com/
---
Cássio Gabriel (3):
ALSA: tea6330t: move snd_tea6330t_detect() EXPORT_SYMBOL
ALSA: tea6330t: add mixer state restore helper
ALSA: interwave: add ISA and PnP suspend and resume callbacks
include/sound/tea6330t.h | 1 +
sound/i2c/tea6330t.c | 41 ++++++++++-
sound/isa/gus/interwave.c | 178 +++++++++++++++++++++++++++++++++++++++-------
3 files changed, 191 insertions(+), 29 deletions(-)
---
base-commit: e051f09ba003f8b93dda4a8d55a1bff797235c0b
change-id: 20260406-alsa-interwave-pm-609259dbdf02
Best regards,
--
Cássio Gabriel <cassiogabrielcontato@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 1/3] ALSA: tea6330t: move snd_tea6330t_detect() EXPORT_SYMBOL 2026-04-07 15:35 [PATCH v2 0/3] ALSA: add suspend/resume support for InterWave ISA cards Cássio Gabriel @ 2026-04-07 15:35 ` Cássio Gabriel 2026-04-07 15:35 ` [PATCH v2 2/3] ALSA: tea6330t: add mixer state restore helper Cássio Gabriel ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: Cássio Gabriel @ 2026-04-07 15:35 UTC (permalink / raw) To: Takashi Iwai, Jaroslav Kysela Cc: linux-sound, linux-kernel, Cássio Gabriel Move the remaining standalone snd_tea6330t_detect() EXPORT_SYMBOL() declaration next to its function definition so tea6330t.c follows the usual layout. No functional change intended. Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> --- sound/i2c/tea6330t.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c index e8c50a036bea..5341907b85d1 100644 --- a/sound/i2c/tea6330t.c +++ b/sound/i2c/tea6330t.c @@ -51,6 +51,7 @@ int snd_tea6330t_detect(struct snd_i2c_bus *bus, int equalizer) snd_i2c_unlock(bus); return res; } +EXPORT_SYMBOL(snd_tea6330t_detect); #if 0 static void snd_tea6330t_set(struct tea6330t *tea, @@ -356,5 +357,4 @@ int snd_tea6330t_update_mixer(struct snd_card *card, return err; } -EXPORT_SYMBOL(snd_tea6330t_detect); EXPORT_SYMBOL(snd_tea6330t_update_mixer); -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] ALSA: tea6330t: add mixer state restore helper 2026-04-07 15:35 [PATCH v2 0/3] ALSA: add suspend/resume support for InterWave ISA cards Cássio Gabriel 2026-04-07 15:35 ` [PATCH v2 1/3] ALSA: tea6330t: move snd_tea6330t_detect() EXPORT_SYMBOL Cássio Gabriel @ 2026-04-07 15:35 ` Cássio Gabriel 2026-04-07 15:35 ` [PATCH v2 3/3] ALSA: interwave: add ISA and PnP suspend and resume callbacks Cássio Gabriel 2026-04-08 8:51 ` [PATCH v2 0/3] ALSA: add suspend/resume support for InterWave ISA cards Takashi Iwai 3 siblings, 0 replies; 5+ messages in thread From: Cássio Gabriel @ 2026-04-07 15:35 UTC (permalink / raw) To: Takashi Iwai, Jaroslav Kysela Cc: linux-sound, linux-kernel, Cássio Gabriel The InterWave STB variant uses a TEA6330T mixer on its private I2C bus. The mixer state is cached in software, but there is no helper to push that register image back to hardware after system resume. Add a small restore helper that reapplies the cached TEA6330T register image to the device so board drivers can restore the external mixer state as part of their PM resume path. Take snd_i2c_lock() around the full device lookup and restore sequence so the bus device list traversal is also protected. Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> --- include/sound/tea6330t.h | 1 + sound/i2c/tea6330t.c | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/include/sound/tea6330t.h b/include/sound/tea6330t.h index 1c77b78f6533..3a34033d2aa3 100644 --- a/include/sound/tea6330t.h +++ b/include/sound/tea6330t.h @@ -12,5 +12,6 @@ int snd_tea6330t_detect(struct snd_i2c_bus *bus, int equalizer); int snd_tea6330t_update_mixer(struct snd_card *card, struct snd_i2c_bus *bus, int equalizer, int fader); +int snd_tea6330t_restore_mixer(struct snd_i2c_bus *bus); #endif /* __SOUND_TEA6330T_H */ diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c index 5341907b85d1..39c5e87c6ab0 100644 --- a/sound/i2c/tea6330t.c +++ b/sound/i2c/tea6330t.c @@ -356,5 +356,42 @@ int snd_tea6330t_update_mixer(struct snd_card *card, snd_i2c_device_free(device); return err; } - EXPORT_SYMBOL(snd_tea6330t_update_mixer); + +int snd_tea6330t_restore_mixer(struct snd_i2c_bus *bus) +{ + struct snd_i2c_device *device; + struct tea6330t *tea; + unsigned char bytes[7]; + unsigned int idx; + int err; + + if (!bus) + return -EINVAL; + + snd_i2c_lock(bus); + list_for_each_entry(device, &bus->devices, list) { + if (device->addr != TEA6330T_ADDR) + continue; + + tea = device->private_data; + if (!tea) { + err = -EINVAL; + goto unlock; + } + + bytes[0] = TEA6330T_SADDR_VOLUME_LEFT; + for (idx = 0; idx < 6; idx++) + bytes[idx + 1] = tea->regs[idx]; + err = snd_i2c_sendbytes(device, bytes, 7); + err = err < 0 ? err : 0; + goto unlock; + } + + err = -ENODEV; + +unlock: + snd_i2c_unlock(bus); + return err; +} +EXPORT_SYMBOL(snd_tea6330t_restore_mixer); -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] ALSA: interwave: add ISA and PnP suspend and resume callbacks 2026-04-07 15:35 [PATCH v2 0/3] ALSA: add suspend/resume support for InterWave ISA cards Cássio Gabriel 2026-04-07 15:35 ` [PATCH v2 1/3] ALSA: tea6330t: move snd_tea6330t_detect() EXPORT_SYMBOL Cássio Gabriel 2026-04-07 15:35 ` [PATCH v2 2/3] ALSA: tea6330t: add mixer state restore helper Cássio Gabriel @ 2026-04-07 15:35 ` Cássio Gabriel 2026-04-08 8:51 ` [PATCH v2 0/3] ALSA: add suspend/resume support for InterWave ISA cards Takashi Iwai 3 siblings, 0 replies; 5+ messages in thread From: Cássio Gabriel @ 2026-04-07 15:35 UTC (permalink / raw) To: Takashi Iwai, Jaroslav Kysela Cc: linux-sound, linux-kernel, Cássio Gabriel interwave still leaves both its ISA and PnP PM callbacks disabled even though the shared GUS suspend and resume path now exists. This board needs InterWave-specific glue around the shared GUS PM path. The attached WSS codec has its own register image that must be saved and restored across suspend, the InterWave-specific GF1 compatibility, decode, MPU401, and emulation settings must be rewritten after the shared GF1 resume path reinitializes the chip, and the probe-detected InterWave memory layout must be restored without rerunning the destructive DRAM/ROM detection path. Track the optional STB TEA6330T bus at probe time, restore its cached mixer state after resume, add resume-safe helpers for the InterWave register and memory-configuration state, and wire both the ISA and PnP front-ends up to the shared GUS PM helpers. The resume path intentionally restores only the cached hardware setup. It does not attempt to preserve sample RAM contents across suspend. Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> --- sound/isa/gus/interwave.c | 178 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 151 insertions(+), 27 deletions(-) diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 18adcd35e117..616c11e51a2f 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -96,6 +96,7 @@ struct snd_interwave { struct snd_gus_card *gus; struct snd_wss *wss; #ifdef SNDRV_STB + struct snd_i2c_bus *i2c_bus; struct resource *i2c_res; #endif unsigned short gus_status_reg; @@ -363,18 +364,30 @@ struct rom_hdr { /* 511 */ unsigned char csum; }; -static void snd_interwave_detect_memory(struct snd_gus_card *gus) +static const unsigned int snd_interwave_memory_configs[] = { + 0x00000001, 0x00000101, 0x01010101, 0x00000401, + 0x04040401, 0x00040101, 0x04040101, 0x00000004, + 0x00000404, 0x04040404, 0x00000010, 0x00001010, + 0x10101010 +}; + +static int snd_interwave_find_memory_config(unsigned int lmct) { - static const unsigned int lmc[13] = - { - 0x00000001, 0x00000101, 0x01010101, 0x00000401, - 0x04040401, 0x00040101, 0x04040101, 0x00000004, - 0x00000404, 0x04040404, 0x00000010, 0x00001010, - 0x10101010 - }; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(snd_interwave_memory_configs); i++) { + if (lmct == snd_interwave_memory_configs[i]) + return i; + } + + return -EINVAL; +} +static void snd_interwave_detect_memory(struct snd_gus_card *gus) +{ int bank_pos, pages; unsigned int i, lmct; + int lmc_cfg; int psizes[4]; unsigned char iwave[8]; unsigned char csum; @@ -399,17 +412,20 @@ static void snd_interwave_detect_memory(struct snd_gus_card *gus) #if 0 dev_dbg(gus->card->dev, "lmct = 0x%08x\n", lmct); #endif - for (i = 0; i < ARRAY_SIZE(lmc); i++) - if (lmct == lmc[i]) { + lmc_cfg = snd_interwave_find_memory_config(lmct); + if (lmc_cfg >= 0) { #if 0 - dev_dbg(gus->card->dev, "found !!! %i\n", i); + dev_dbg(gus->card->dev, "found !!! %i\n", lmc_cfg); #endif - snd_gf1_write16(gus, SNDRV_GF1_GW_MEMORY_CONFIG, (snd_gf1_look16(gus, SNDRV_GF1_GW_MEMORY_CONFIG) & 0xfff0) | i); - snd_interwave_bank_sizes(gus, psizes); - break; - } - if (i >= ARRAY_SIZE(lmc) && !gus->gf1.enh_mode) - snd_gf1_write16(gus, SNDRV_GF1_GW_MEMORY_CONFIG, (snd_gf1_look16(gus, SNDRV_GF1_GW_MEMORY_CONFIG) & 0xfff0) | 2); + snd_gf1_write16(gus, SNDRV_GF1_GW_MEMORY_CONFIG, + (snd_gf1_look16(gus, SNDRV_GF1_GW_MEMORY_CONFIG) & 0xfff0) | + lmc_cfg); + snd_interwave_bank_sizes(gus, psizes); + } else if (!gus->gf1.enh_mode) { + snd_gf1_write16(gus, SNDRV_GF1_GW_MEMORY_CONFIG, + (snd_gf1_look16(gus, SNDRV_GF1_GW_MEMORY_CONFIG) & 0xfff0) | + 2); + } for (i = 0; i < 4; i++) { gus->gf1.mem_alloc.banks_8[i].address = gus->gf1.mem_alloc.banks_16[i].address = i << 22; @@ -454,24 +470,66 @@ static void snd_interwave_detect_memory(struct snd_gus_card *gus) snd_interwave_reset(gus); } +static void __snd_interwave_restore_regs(struct snd_gus_card *gus) +{ + snd_gf1_write8(gus, SNDRV_GF1_GB_COMPATIBILITY, 0x1f); + snd_gf1_write8(gus, SNDRV_GF1_GB_DECODE_CONTROL, 0x49); + snd_gf1_write8(gus, SNDRV_GF1_GB_VERSION_NUMBER, 0x11); + snd_gf1_write8(gus, SNDRV_GF1_GB_MPU401_CONTROL_A, 0x00); + snd_gf1_write8(gus, SNDRV_GF1_GB_MPU401_CONTROL_B, 0x30); + snd_gf1_write8(gus, SNDRV_GF1_GB_EMULATION_IRQ, 0x00); +} + +static void snd_interwave_restore_regs(struct snd_gus_card *gus) +{ + scoped_guard(spinlock_irqsave, &gus->reg_lock) + __snd_interwave_restore_regs(gus); +} + +static void snd_interwave_restore_memory(struct snd_gus_card *gus) +{ + unsigned short mem_cfg; + unsigned int lmct = 0; + int i, lmc_cfg; + + if (!gus->gf1.memory) + return; + + for (i = 0; i < 4; i++) + lmct |= (gus->gf1.mem_alloc.banks_16[i].size >> 18) << (i * 8); + + lmc_cfg = snd_interwave_find_memory_config(lmct); + if (lmc_cfg < 0) { + if (!gus->gf1.enh_mode) { + lmc_cfg = 2; + } else { + dev_warn(gus->card->dev, + "cannot restore InterWave memory layout 0x%08x\n", + lmct); + return; + } + } + + scoped_guard(spinlock_irqsave, &gus->reg_lock) { + mem_cfg = snd_gf1_look16(gus, SNDRV_GF1_GW_MEMORY_CONFIG); + mem_cfg = (mem_cfg & 0xfff0) | lmc_cfg; + mem_cfg = (mem_cfg & 0xff1f) | (4 << 5); + snd_gf1_write16(gus, SNDRV_GF1_GW_MEMORY_CONFIG, mem_cfg); + } +} + static void snd_interwave_init(int dev, struct snd_gus_card *gus) { - /* ok.. some InterWave specific initialization */ + /* Probe-time setup also clears the timer control register. */ scoped_guard(spinlock_irqsave, &gus->reg_lock) { snd_gf1_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, 0x00); - snd_gf1_write8(gus, SNDRV_GF1_GB_COMPATIBILITY, 0x1f); - snd_gf1_write8(gus, SNDRV_GF1_GB_DECODE_CONTROL, 0x49); - snd_gf1_write8(gus, SNDRV_GF1_GB_VERSION_NUMBER, 0x11); - snd_gf1_write8(gus, SNDRV_GF1_GB_MPU401_CONTROL_A, 0x00); - snd_gf1_write8(gus, SNDRV_GF1_GB_MPU401_CONTROL_B, 0x30); - snd_gf1_write8(gus, SNDRV_GF1_GB_EMULATION_IRQ, 0x00); + __snd_interwave_restore_regs(gus); } gus->equal_irq = 1; gus->codec_flag = 1; gus->interwave = 1; gus->max_flag = 1; gus->joystick_dac = joystick_dac[dev]; - } static const struct snd_kcontrol_new snd_interwave_controls[] = { @@ -724,6 +782,7 @@ static int snd_interwave_probe(struct snd_card *card, int dev, err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1); if (err < 0) return err; + iwcard->i2c_bus = i2c_bus; } #endif @@ -828,10 +887,59 @@ static int snd_interwave_isa_probe(struct device *pdev, return 0; } +#ifdef CONFIG_PM +static int snd_interwave_card_suspend(struct snd_card *card) +{ + struct snd_interwave *iwcard = card->private_data; + + iwcard->wss->suspend(iwcard->wss); + return snd_gus_suspend(iwcard->gus); +} + +static int snd_interwave_card_resume(struct snd_card *card) +{ + struct snd_interwave *iwcard = card->private_data; + int err; + + err = snd_gus_resume(iwcard->gus); + if (err < 0) + return err; + + snd_interwave_restore_regs(iwcard->gus); + snd_interwave_restore_memory(iwcard->gus); + iwcard->wss->resume(iwcard->wss); +#ifdef SNDRV_STB + if (iwcard->i2c_bus) { + err = snd_tea6330t_restore_mixer(iwcard->i2c_bus); + if (err < 0) + dev_warn(card->dev, + "failed to restore TEA6330T mixer state: %d\n", + err); + } +#endif + + return 0; +} + +static int snd_interwave_isa_suspend(struct device *pdev, unsigned int dev, + pm_message_t state) +{ + return snd_interwave_card_suspend(dev_get_drvdata(pdev)); +} + +static int snd_interwave_isa_resume(struct device *pdev, unsigned int dev) +{ + return snd_interwave_card_resume(dev_get_drvdata(pdev)); +} +#endif + static struct isa_driver snd_interwave_driver = { .match = snd_interwave_isa_match, .probe = snd_interwave_isa_probe, - /* FIXME: suspend,resume */ +#ifdef CONFIG_PM + .suspend = snd_interwave_isa_suspend, + .resume = snd_interwave_isa_resume, +#endif .driver = { .name = INTERWAVE_DRIVER }, @@ -871,12 +979,28 @@ static int snd_interwave_pnp_detect(struct pnp_card_link *pcard, return 0; } +#ifdef CONFIG_PM +static int snd_interwave_pnpc_suspend(struct pnp_card_link *pcard, + pm_message_t state) +{ + return snd_interwave_card_suspend(pnp_get_card_drvdata(pcard)); +} + +static int snd_interwave_pnpc_resume(struct pnp_card_link *pcard) +{ + return snd_interwave_card_resume(pnp_get_card_drvdata(pcard)); +} +#endif + static struct pnp_card_driver interwave_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = INTERWAVE_PNP_DRIVER, .id_table = snd_interwave_pnpids, .probe = snd_interwave_pnp_detect, - /* FIXME: suspend,resume */ +#ifdef CONFIG_PM + .suspend = snd_interwave_pnpc_suspend, + .resume = snd_interwave_pnpc_resume, +#endif }; #endif /* CONFIG_PNP */ -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/3] ALSA: add suspend/resume support for InterWave ISA cards 2026-04-07 15:35 [PATCH v2 0/3] ALSA: add suspend/resume support for InterWave ISA cards Cássio Gabriel ` (2 preceding siblings ...) 2026-04-07 15:35 ` [PATCH v2 3/3] ALSA: interwave: add ISA and PnP suspend and resume callbacks Cássio Gabriel @ 2026-04-08 8:51 ` Takashi Iwai 3 siblings, 0 replies; 5+ messages in thread From: Takashi Iwai @ 2026-04-08 8:51 UTC (permalink / raw) To: Cássio Gabriel Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-kernel On Tue, 07 Apr 2026 17:35:40 +0200, Cássio Gabriel wrote: > > This 3-patch series wires up suspend and resume support for the > InterWave ISA drivers and their PnP front-end around the shared > GUS PM helpers. > > The first patch moves the remaining standalone > snd_tea6330t_detect() EXPORT_SYMBOL() declaration next to its > function definition as a requested small cleanup. > > The second patch adds a small TEA6330T helper so the InterWave STB > variant can restore its cached external mixer state after resume. > > The third patch adds ISA and PnP PM callbacks to snd-interwave and > restores the remaining InterWave-specific state that the generic GUS > resume path does not cover, including the GF1 board registers and the > detected memory layout. > > The resume path intentionally does not rerun probe-time DRAM/ROM > detection. As with the shared GUS PM support, this does not guarantee > preservation of sample RAM contents across suspend. > > Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> > --- > Changes in v2: > - Add a separate tea6330t cleanup patch moving the standalone > snd_tea6330t_detect() EXPORT_SYMBOL() next to its function. > - Extend snd_i2c_lock() to cover the full device lookup/list traversal > in snd_tea6330t_restore_mixer(). > - Renumber the InterWave PM patch to 3/3 after splitting out the > cleanup patch. > - Link to v1: https://lore.kernel.org/all/20260406-alsa-interwave-pm-v1-0-6ffa6f317c8f@gmail.com/ > > --- > Cássio Gabriel (3): > ALSA: tea6330t: move snd_tea6330t_detect() EXPORT_SYMBOL > ALSA: tea6330t: add mixer state restore helper > ALSA: interwave: add ISA and PnP suspend and resume callbacks Applied all patches to for-next branch now. Thanks. Takashi ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-08 8:51 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-04-07 15:35 [PATCH v2 0/3] ALSA: add suspend/resume support for InterWave ISA cards Cássio Gabriel 2026-04-07 15:35 ` [PATCH v2 1/3] ALSA: tea6330t: move snd_tea6330t_detect() EXPORT_SYMBOL Cássio Gabriel 2026-04-07 15:35 ` [PATCH v2 2/3] ALSA: tea6330t: add mixer state restore helper Cássio Gabriel 2026-04-07 15:35 ` [PATCH v2 3/3] ALSA: interwave: add ISA and PnP suspend and resume callbacks Cássio Gabriel 2026-04-08 8:51 ` [PATCH v2 0/3] ALSA: add suspend/resume support for InterWave ISA cards Takashi Iwai
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox