alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/hdmi: run eld notify in delay work
@ 2022-09-27 13:58 Brent Lu
  2022-09-27 14:11 ` Takashi Iwai
  0 siblings, 1 reply; 8+ messages in thread
From: Brent Lu @ 2022-09-27 13:58 UTC (permalink / raw)
  To: alsa-devel
  Cc: Kai Vehmanen, linux-kernel, Pierre-Louis Bossart, Takashi Iwai,
	Brent Lu, Mohan Kumar, Ville Syrjälä,
	Yong Zhi

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@intel.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(&notify->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(&notify->notify_work, pin_eld_notify_work);
+
+	schedule_delayed_work(&notify->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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-10-05  9:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27 13:58 [PATCH] ALSA: hda/hdmi: run eld notify in delay work Brent Lu
2022-09-27 14:11 ` Takashi Iwai
2022-09-28  2:06   ` Lu, Brent
2022-09-28  7:14     ` Takashi Iwai
2022-09-28  8:09       ` Takashi Iwai
2022-09-28  8:37         ` Takashi Iwai
2022-10-05  8:14           ` Lu, Brent
2022-10-05  9:45             ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).