From: "Cássio Gabriel" <cassiogabrielcontato@gmail.com>
To: Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
"Cássio Gabriel" <cassiogabrielcontato@gmail.com>
Subject: [PATCH 1/2] ALSA: msnd: prepare system sleep support
Date: Thu, 09 Apr 2026 02:07:45 -0300 [thread overview]
Message-ID: <20260409-msnd-pm-support-v1-1-2abef720d0e7@gmail.com> (raw)
In-Reply-To: <20260409-msnd-pm-support-v1-0-2abef720d0e7@gmail.com>
System suspend cannot work for msnd today because the PCM trigger
paths reject SNDRV_PCM_TRIGGER_SUSPEND, and the driver has only
refcounted IRQ helpers.
Add the small helpers needed by the PM callbacks and restore master
volume from the cached ALSA mixer state when the DSP is
reinitialized.
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
---
sound/isa/msnd/msnd.c | 72 ++++++++++++++++++++++++------------
sound/isa/msnd/msnd.h | 1 +
sound/isa/msnd/msnd_pinnacle_mixer.c | 4 ++
3 files changed, 54 insertions(+), 23 deletions(-)
diff --git a/sound/isa/msnd/msnd.c b/sound/isa/msnd/msnd.c
index 5e350234d572..77367e102fda 100644
--- a/sound/isa/msnd/msnd.c
+++ b/sound/isa/msnd/msnd.c
@@ -127,11 +127,8 @@ int snd_msnd_upload_host(struct snd_msnd *dev, const u8 *bin, int len)
}
EXPORT_SYMBOL(snd_msnd_upload_host);
-int snd_msnd_enable_irq(struct snd_msnd *dev)
+static int __snd_msnd_enable_irq(struct snd_msnd *dev)
{
- if (dev->irq_ref++)
- return 0;
-
dev_dbg(dev->card->dev, LOGNAME ": Enabling IRQ\n");
guard(spinlock_irqsave)(&dev->lock);
@@ -152,17 +149,9 @@ int snd_msnd_enable_irq(struct snd_msnd *dev)
return -EIO;
}
-EXPORT_SYMBOL(snd_msnd_enable_irq);
-int snd_msnd_disable_irq(struct snd_msnd *dev)
+static int __snd_msnd_disable_irq(struct snd_msnd *dev)
{
- if (--dev->irq_ref > 0)
- return 0;
-
- if (dev->irq_ref < 0)
- dev_dbg(dev->card->dev, LOGNAME ": IRQ ref count is %d\n",
- dev->irq_ref);
-
dev_dbg(dev->card->dev, LOGNAME ": Disabling IRQ\n");
guard(spinlock_irqsave)(&dev->lock);
@@ -178,8 +167,39 @@ int snd_msnd_disable_irq(struct snd_msnd *dev)
return -EIO;
}
+
+int snd_msnd_enable_irq(struct snd_msnd *dev)
+{
+ if (dev->irq_ref++)
+ return 0;
+
+ return __snd_msnd_enable_irq(dev);
+}
+EXPORT_SYMBOL(snd_msnd_enable_irq);
+
+int snd_msnd_disable_irq(struct snd_msnd *dev)
+{
+ if (--dev->irq_ref > 0)
+ return 0;
+
+ if (dev->irq_ref < 0)
+ dev_dbg(dev->card->dev, LOGNAME ": IRQ ref count is %d\n",
+ dev->irq_ref);
+
+ return __snd_msnd_disable_irq(dev);
+}
EXPORT_SYMBOL(snd_msnd_disable_irq);
+int snd_msnd_force_irq(struct snd_msnd *dev, bool enable)
+{
+ if (!dev->irq_ref)
+ return 0;
+
+ return enable ? __snd_msnd_enable_irq(dev) :
+ __snd_msnd_disable_irq(dev);
+}
+EXPORT_SYMBOL(snd_msnd_force_irq);
+
static inline long get_play_delay_jiffies(struct snd_msnd *chip, long size)
{
long tmp = (size * HZ * chip->play_sample_size) / 8;
@@ -507,25 +527,27 @@ static int snd_msnd_playback_trigger(struct snd_pcm_substream *substream,
int cmd)
{
struct snd_msnd *chip = snd_pcm_substream_chip(substream);
- int result = 0;
- if (cmd == SNDRV_PCM_TRIGGER_START) {
+ switch (cmd) {
+ case SNDRV_PCM_TRIGGER_START:
dev_dbg(chip->card->dev, "%s(START)\n", __func__);
chip->banksPlayed = 0;
set_bit(F_WRITING, &chip->flags);
snd_msnd_DAPQ(chip, 1);
- } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
+ break;
+ case SNDRV_PCM_TRIGGER_STOP:
+ case SNDRV_PCM_TRIGGER_SUSPEND:
dev_dbg(chip->card->dev, "%s(STOP)\n", __func__);
- /* interrupt diagnostic, comment this out later */
clear_bit(F_WRITING, &chip->flags);
snd_msnd_send_dsp_cmd(chip, HDEX_PLAY_STOP);
- } else {
+ break;
+ default:
dev_dbg(chip->card->dev, "%s(?????)\n", __func__);
- result = -EINVAL;
+ return -EINVAL;
}
dev_dbg(chip->card->dev, "%s() ENDE\n", __func__);
- return result;
+ return 0;
}
static snd_pcm_uframes_t
@@ -589,17 +611,22 @@ static int snd_msnd_capture_trigger(struct snd_pcm_substream *substream,
{
struct snd_msnd *chip = snd_pcm_substream_chip(substream);
- if (cmd == SNDRV_PCM_TRIGGER_START) {
+ switch (cmd) {
+ case SNDRV_PCM_TRIGGER_START:
chip->last_recbank = -1;
set_bit(F_READING, &chip->flags);
if (snd_msnd_send_dsp_cmd(chip, HDEX_RECORD_START) == 0)
return 0;
clear_bit(F_READING, &chip->flags);
- } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
+ break;
+ case SNDRV_PCM_TRIGGER_STOP:
+ case SNDRV_PCM_TRIGGER_SUSPEND:
clear_bit(F_READING, &chip->flags);
snd_msnd_send_dsp_cmd(chip, HDEX_RECORD_STOP);
return 0;
+ default:
+ break;
}
return -EINVAL;
}
@@ -668,4 +695,3 @@ EXPORT_SYMBOL(snd_msnd_pcm);
MODULE_DESCRIPTION("Common routines for Turtle Beach Multisound drivers");
MODULE_LICENSE("GPL");
-
diff --git a/sound/isa/msnd/msnd.h b/sound/isa/msnd/msnd.h
index 3d7810ed9186..b25beca25c0d 100644
--- a/sound/isa/msnd/msnd.h
+++ b/sound/isa/msnd/msnd.h
@@ -280,6 +280,7 @@ int snd_msnd_upload_host(struct snd_msnd *chip,
const u8 *bin, int len);
int snd_msnd_enable_irq(struct snd_msnd *chip);
int snd_msnd_disable_irq(struct snd_msnd *chip);
+int snd_msnd_force_irq(struct snd_msnd *chip, bool enable);
void snd_msnd_dsp_halt(struct snd_msnd *chip, struct file *file);
int snd_msnd_DAPQ(struct snd_msnd *chip, int start);
int snd_msnd_DARQ(struct snd_msnd *chip, int start);
diff --git a/sound/isa/msnd/msnd_pinnacle_mixer.c b/sound/isa/msnd/msnd_pinnacle_mixer.c
index ec354483b9f8..8ca987221753 100644
--- a/sound/isa/msnd/msnd_pinnacle_mixer.c
+++ b/sound/isa/msnd/msnd_pinnacle_mixer.c
@@ -310,6 +310,10 @@ EXPORT_SYMBOL(snd_msndmix_new);
void snd_msndmix_setup(struct snd_msnd *dev)
{
+ writew(dev->left_levels[MSND_MIXER_VOLUME],
+ dev->SMA + SMA_wCurrMastVolLeft);
+ writew(dev->right_levels[MSND_MIXER_VOLUME],
+ dev->SMA + SMA_wCurrMastVolRight);
update_pot(MSND_MIXER_LINE, bInPotPos, HDEXAR_IN_SET_POTS);
update_potm(MSND_MIXER_AUX, bAuxPotPos, HDEXAR_AUX_SET_POTS);
update_volm(MSND_MIXER_PCM, wCurrPlayVol);
--
2.53.0
next prev parent reply other threads:[~2026-04-09 5:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 5:07 [PATCH 0/2] ALSA: msnd: add suspend/resume support Cássio Gabriel
2026-04-09 5:07 ` Cássio Gabriel [this message]
2026-04-09 5:07 ` [PATCH 2/2] ALSA: msnd: add ISA and PnP system sleep callbacks Cássio Gabriel
2026-04-09 10:02 ` [PATCH 0/2] ALSA: msnd: add suspend/resume support Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260409-msnd-pm-support-v1-1-2abef720d0e7@gmail.com \
--to=cassiogabrielcontato@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox