[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220927135807.4097052-1-brent.lu@intel.com>
Date: Tue, 27 Sep 2022 21:58:07 +0800
From: Brent Lu <brent.lu@...el.com>
To: alsa-devel@...a-project.org
Cc: Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
Kai Vehmanen <kai.vehmanen@...ux.intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
Mohan Kumar <mkumard@...dia.com>,
Ville Syrjälä
<ville.syrjala@...ux.intel.com>, Brent Lu <brent.lu@...el.com>,
Yong Zhi <yong.zhi@...el.com>, linux-kernel@...r.kernel.org
Subject: [PATCH] ALSA: hda/hdmi: run eld notify in delay work
During resolution change, display driver would disable HDMI audio then
enable it in a short time. There is possibility that eld notify for
HDMI audio enable is called when previous runtime suspend is still
running. In this case, the elf nofity just returns and not updating the
status of corresponding HDMI pin/port. Here we move the eld nofity to
a delay work so we don't lose it.
Signed-off-by: Brent Lu <brent.lu@...el.com>
---
sound/pci/hda/patch_hdmi.c | 38 +++++++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 6c209cd26c0c..a4c305ee8ff9 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -2907,13 +2907,21 @@ static int intel_port2pin(struct hda_codec *codec, int port)
return spec->port_map[port];
}
-static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
+struct pin_eld_notify {
+ void *audio_ptr;
+ int port;
+ int pipe;
+ struct delayed_work notify_work;
+};
+
+static void pin_eld_notify_work(struct work_struct *work)
{
- struct hda_codec *codec = audio_ptr;
+ struct pin_eld_notify *notify = container_of(work, struct pin_eld_notify, notify_work.work);
+ struct hda_codec *codec = notify->audio_ptr;
int pin_nid;
- int dev_id = pipe;
+ int dev_id = notify->pipe;
- pin_nid = intel_port2pin(codec, port);
+ pin_nid = intel_port2pin(codec, notify->port);
if (!pin_nid)
return;
/* skip notification during system suspend (but not in runtime PM);
@@ -2922,13 +2930,33 @@ static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND)
return;
/* ditto during suspend/resume process itself */
- if (snd_hdac_is_in_pm(&codec->core))
+ if (snd_hdac_is_in_pm(&codec->core)) {
+ schedule_delayed_work(¬ify->notify_work, msecs_to_jiffies(10));
return;
+ }
snd_hdac_i915_set_bclk(&codec->bus->core);
check_presence_and_report(codec, pin_nid, dev_id);
}
+static void intel_pin_eld_notify(void *audio_ptr, int port, int pipe)
+{
+ struct hda_codec *codec = audio_ptr;
+ struct device *dev = hda_codec_dev(codec);
+ struct pin_eld_notify *notify;
+
+ notify = devm_kzalloc(dev, sizeof(struct pin_eld_notify), GFP_KERNEL);
+ if (!notify)
+ return;
+
+ notify->audio_ptr = audio_ptr;
+ notify->port = port;
+ notify->pipe = pipe;
+ INIT_DELAYED_WORK(¬ify->notify_work, pin_eld_notify_work);
+
+ schedule_delayed_work(¬ify->notify_work, 0);
+}
+
static const struct drm_audio_component_audio_ops intel_audio_ops = {
.pin2port = intel_pin2port,
.pin_eld_notify = intel_pin_eld_notify,
--
2.25.1
Powered by blists - more mailing lists