All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brent Lu <brent.lu@intel.com>
To: alsa-devel@alsa-project.org
Cc: "Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"Mohan Kumar" <mkumard@nvidia.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Brent Lu" <brent.lu@intel.com>, "Yong Zhi" <yong.zhi@intel.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] ALSA: hda/hdmi: run eld notify in delay work
Date: Tue, 27 Sep 2022 21:58:07 +0800	[thread overview]
Message-ID: <20220927135807.4097052-1-brent.lu@intel.com> (raw)

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


WARNING: multiple messages have this Message-ID (diff)
From: Brent Lu <brent.lu@intel.com>
To: alsa-devel@alsa-project.org
Cc: "Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	linux-kernel@vger.kernel.org,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"Takashi Iwai" <tiwai@suse.com>, "Brent Lu" <brent.lu@intel.com>,
	"Mohan Kumar" <mkumard@nvidia.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Yong Zhi" <yong.zhi@intel.com>
Subject: [PATCH] ALSA: hda/hdmi: run eld notify in delay work
Date: Tue, 27 Sep 2022 21:58:07 +0800	[thread overview]
Message-ID: <20220927135807.4097052-1-brent.lu@intel.com> (raw)

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


             reply	other threads:[~2022-09-27 14:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27 13:58 Brent Lu [this message]
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-27 14:11   ` Takashi Iwai
2022-09-28  2:06   ` Lu, Brent
2022-09-28  2:06     ` Lu, Brent
2022-09-28  7:14     ` Takashi Iwai
2022-09-28  7:14       ` Takashi Iwai
2022-09-28  8:09       ` Takashi Iwai
2022-09-28  8:09         ` Takashi Iwai
2022-09-28  8:37         ` Takashi Iwai
2022-09-28  8:37           ` Takashi Iwai
2022-10-05  8:14           ` Lu, Brent
2022-10-05  8:14             ` Lu, Brent
2022-10-05  9:45             ` Takashi Iwai
2022-10-05  9:45               ` 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=20220927135807.4097052-1-brent.lu@intel.com \
    --to=brent.lu@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkumard@nvidia.com \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.com \
    --cc=ville.syrjala@linux.intel.com \
    --cc=yong.zhi@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.