git: 5581f8df7d6a - stable/15 - snd_hda: wake display audio and restore amplifier settings
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 19 Nov 2026 11:53:04 UTC
The branch stable/15 has been updated by christos:
URL: https://cgit.FreeBSD.org/src/commit/?id=5581f8df7d6accdb5f0840929d5ea5bbe40a486b
commit 5581f8df7d6accdb5f0840929d5ea5bbe40a486b
Author: David Bidner <david@crap.solutions>
AuthorDate: 2026-11-05 12:28:15 +0000
Commit: Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2026-11-19 11:52:35 +0000
snd_hda: wake display audio and restore amplifier settings
An Intel display-audio codec was observed to remain in D3 after monitor
sleep on DragonFly BSD. Starting a new stream then produced no sound,
and waking the codec alone left the output pin amplifier muted and other
function configuration unrestored.
Read the audio function power state at stream start. If its requested or
actual state is not D0, use the existing power-up routine before
configuring and starting the stream, then restore the function to a
known state:
Restore selectors, pins, EAPD, GPIO/GPO and direct codec patches, then
replay the cached gain and mute values once the pins are configured.
Split widget configuration out of hdaa_audio_commit() into
hdaa_audio_widget_commit() so the wake path can reuse it without
reinitializing the cached amplifier values. Preserve the existing
volume, mute and forced-mute values.
Re-enable unsolicited responses, refresh ELD, and run jack presence
handling for playback pins. Skip the full presence handler for recording
pins only: its recording path can drop the driver lock to update the
recording source, which is not safe while starting a stream with the
channel lock held. The playback path does not drop the driver lock, so
it is safe to run here, and it is what matters for display audio, whose
pins belong to playback associations.
GET_POWER_STATE reports the actual state in ACT (bits 7:4) and the
requested state in SET (bits 3:0). They can differ during a transition.
Checking both avoids skipping the D0 request when the function is still
actually in D0 but has been requested to power down, or when D0 has been
requested but the actual state has not reached D0 yet. The observed
post-sleep response on DragonFly was 0x233, with both fields reporting
D3.
Despite their names, HDAA_AMP_MUTE_DEFAULT (0xffffffff) and
HDAA_AMP_VOL_DEFAULT (-1) are sentinels meaning "keep the cached
setting" in hdaa_audio_ctl_amp_set(). Passing them leaves ctl->muted,
ctl->left and ctl->right unchanged, then writes the cached values to the
hardware while respecting ctl->forcemute. It does not select factory
defaults or unconditionally unmute the output.
Preserve the existing behavior when the power-state query returns
HDA_INVALID or both fields already report D0, and leave the D0 fast path
and invalid power-state query handling unchanged.
The observed wake-only silence and amplifier recovery were seen on
DragonFly BSD. This FreeBSD adaptation has not been validated on FreeBSD
hardware.
PR: 299139
MFC after: 2 weeks
Reviewed by: christos
Pull-Request: https://github.com/freebsd/freebsd-src/pull/2464
(cherry picked from commit 43bbd71ac785fcc4ee39a8c0ef29d59fcb8c2a3c)
---
sys/dev/sound/pci/hda/hdaa.c | 72 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 67 insertions(+), 5 deletions(-)
diff --git a/sys/dev/sound/pci/hda/hdaa.c b/sys/dev/sound/pci/hda/hdaa.c
index 0f81d114eb30..431bb545aea7 100644
--- a/sys/dev/sound/pci/hda/hdaa.c
+++ b/sys/dev/sound/pci/hda/hdaa.c
@@ -167,6 +167,7 @@ const static char *ossnames[] = SOUND_DEVICE_NAMES;
* Function prototypes
****************************************************************************/
static int hdaa_pcmchannel_setup(struct hdaa_chan *);
+static void hdaa_audio_wake(struct hdaa_devinfo *);
static void hdaa_widget_connection_select(struct hdaa_widget *, uint8_t);
static void hdaa_audio_ctl_amp_set(struct hdaa_audio_ctl *,
@@ -842,6 +843,38 @@ hdaa_sense_deinit(struct hdaa_devinfo *devinfo)
}
}
+static void
+hdaa_sense_wake(struct hdaa_devinfo *devinfo)
+{
+ struct hdaa_widget *w;
+ int i;
+
+ for (i = devinfo->startnode; i < devinfo->endnode; i++) {
+ w = hdaa_widget_get(devinfo, i);
+ if (w == NULL || w->enable == 0 || w->type !=
+ HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
+ continue;
+ if (w->unsol >= 0) {
+ hda_command(devinfo->dev,
+ HDA_CMD_SET_UNSOLICITED_RESPONSE(0, w->nid,
+ HDA_CMD_SET_UNSOLICITED_RESPONSE_ENABLE |
+ w->unsol));
+ }
+ /*
+ * Run jack presence handling for playback pins only. The
+ * recording path can drop the driver lock to update the
+ * recording source, which is not safe while starting a stream
+ * with the channel lock held. The playback path does not drop
+ * the driver lock.
+ */
+ if (devinfo->as[w->bindas].dir == HDAA_CTL_OUT)
+ hdaa_presence_handler(w);
+ if (HDA_PARAM_PIN_CAP_DP(w->wclass.pin.cap) ||
+ HDA_PARAM_PIN_CAP_HDMI(w->wclass.pin.cap))
+ hdaa_eld_handler(w);
+ }
+}
+
uint32_t
hdaa_widget_pin_patch(uint32_t config, const char *str)
{
@@ -2159,7 +2192,15 @@ static int
hdaa_channel_start(struct hdaa_chan *ch)
{
struct hdaa_devinfo *devinfo = ch->devinfo;
- uint32_t fmt;
+ uint32_t fmt, power;
+
+ power = hda_command(devinfo->dev,
+ HDA_CMD_GET_POWER_STATE(0, devinfo->nid));
+ if (power != HDA_INVALID &&
+ (HDA_CMD_GET_POWER_STATE_ACT(power) != HDA_CMD_POWER_STATE_D0 ||
+ HDA_CMD_GET_POWER_STATE_SET(power) != HDA_CMD_POWER_STATE_D0)) {
+ hdaa_audio_wake(devinfo);
+ }
fmt = hdaa_stream_format(ch);
ch->stripectl = fls(ch->stripecap & hdaa_allowed_stripes(fmt) &
@@ -5275,14 +5316,11 @@ hdaa_gpo_commit(struct hdaa_devinfo *devinfo)
}
static void
-hdaa_audio_commit(struct hdaa_devinfo *devinfo)
+hdaa_audio_widget_commit(struct hdaa_devinfo *devinfo)
{
struct hdaa_widget *w;
int i;
- /* Commit controls. */
- hdaa_audio_ctl_commit(devinfo);
-
/* Commit selectors, pins and EAPD. */
for (i = 0; i < devinfo->nodecnt; i++) {
w = &devinfo->widget[i];
@@ -5315,6 +5353,13 @@ hdaa_audio_commit(struct hdaa_devinfo *devinfo)
hdaa_gpo_commit(devinfo);
}
+static void
+hdaa_audio_commit(struct hdaa_devinfo *devinfo)
+{
+ hdaa_audio_ctl_commit(devinfo);
+ hdaa_audio_widget_commit(devinfo);
+}
+
static void
hdaa_powerup(struct hdaa_devinfo *devinfo)
{
@@ -5333,6 +5378,23 @@ hdaa_powerup(struct hdaa_devinfo *devinfo)
DELAY(1000);
}
+static void
+hdaa_audio_wake(struct hdaa_devinfo *devinfo)
+{
+ struct hdaa_audio_ctl *ctl;
+ int i;
+
+ hdaa_lockassert(devinfo);
+ hdaa_powerup(devinfo);
+ hdaa_audio_widget_commit(devinfo);
+ hdaa_patch_direct(devinfo);
+ i = 0;
+ while ((ctl = hdaa_audio_ctl_each(devinfo, &i)) != NULL)
+ hdaa_audio_ctl_amp_set(ctl, HDAA_AMP_MUTE_DEFAULT,
+ HDAA_AMP_VOL_DEFAULT, HDAA_AMP_VOL_DEFAULT);
+ hdaa_sense_wake(devinfo);
+}
+
static int
hdaa_pcmchannel_setup(struct hdaa_chan *ch)
{