All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>,
	tiwai@suse.de,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Hui Wang <hui.wang@canonical.com>,
	Clarex Zhou <clarex.zhou@intel.com>,
	broonie@kernel.org, Jaska Uimonen <jaska.uimonen@linux.intel.com>
Subject: [PATCH 02/13] ASoC: intel/skl/hda - set autosuspend timeout for hda codecs
Date: Thu,  9 Apr 2020 13:58:16 -0500	[thread overview]
Message-ID: <20200409185827.16255-3-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20200409185827.16255-1-pierre-louis.bossart@linux.intel.com>

From: Hui Wang <hui.wang@canonical.com>

On some Lenovo and HP laptops, if both codec driver and SOF driver
are in runtime suspend mode, we plug a headset to the audio jack,
the headphone could be detected but Mic couldn't.

That is because when plugging, the headphone triggers a unsol event
first, and about 0.7s later (on the Lenovo X1 Carbon 7th), the Mic
triggers a unsol event. But if the codec driver enters runtime suspend
within 0.7s, the Mic can't trigger the unsol event.

If we don't set autosuspend_delay to a non-zero value for the hda codec
driver, it will enter runtime suspend immediately after the headphone
triggers the unsol event.

Follow the sequence of legacy hda driver and set a autosuspend delay
of 1sec after card registration (refer to pci/hda/hda_intel.c and
pci/hda/hda_codec.c).

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Co-developed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Co-developed-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Signed-off-by: Jaska Uimonen <jaska.uimonen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Clarex Zhou <clarex.zhou@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/boards/skl_hda_dsp_generic.c | 29 +++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c
index 3be764299ab0..64197b010e7d 100644
--- a/sound/soc/intel/boards/skl_hda_dsp_generic.c
+++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c
@@ -113,6 +113,8 @@ static char hda_soc_components[30];
 #define IDISP_ROUTE_COUNT	(IDISP_DAI_COUNT * 2)
 #define IDISP_CODEC_MASK	0x4
 
+#define HDA_CODEC_AUTOSUSPEND_DELAY_MS 1000
+
 static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params)
 {
 	struct snd_soc_card *card = &hda_soc_card;
@@ -168,6 +170,27 @@ static int skl_hda_fill_card_info(struct snd_soc_acpi_mach_params *mach_params)
 	return 0;
 }
 
+static void skl_set_hda_codec_autosuspend_delay(struct snd_soc_card *card)
+{
+	struct snd_soc_pcm_runtime *rtd =
+		list_first_entry(&card->rtd_list,
+				 struct snd_soc_pcm_runtime, list);
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct hdac_hda_priv *hda_pvt;
+
+	if (!codec_dai)
+		return;
+
+	/*
+	 * all codecs are on the same bus, so it's sufficient
+	 * to lookup the first runtime and its codec, and set
+	 * power save defaults for all codecs on the bus
+	 */
+	hda_pvt = snd_soc_component_get_drvdata(codec_dai->component);
+	snd_hda_set_power_save(hda_pvt->codec.bus,
+			       HDA_CODEC_AUTOSUSPEND_DELAY_MS);
+}
+
 static int skl_hda_audio_probe(struct platform_device *pdev)
 {
 	struct snd_soc_acpi_mach *mach;
@@ -206,7 +229,11 @@ static int skl_hda_audio_probe(struct platform_device *pdev)
 		hda_soc_card.components = hda_soc_components;
 	}
 
-	return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card);
+	ret = devm_snd_soc_register_card(&pdev->dev, &hda_soc_card);
+	if (!ret)
+		skl_set_hda_codec_autosuspend_delay(&hda_soc_card);
+
+	return ret;
 }
 
 static struct platform_driver skl_hda_audio = {
-- 
2.20.1


  parent reply	other threads:[~2020-04-09 19:01 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-09 18:58 [PATCH 00/13] ASoC: Intel: machine drivers update for 5.8 Pierre-Louis Bossart
2020-04-09 18:58 ` [PATCH 01/13] ASoC: Intel: sof_da7219_max98373: Add BE dailink for dmic16k Pierre-Louis Bossart
2020-04-14 14:48   ` Applied "ASoC: Intel: sof_da7219_max98373: Add BE dailink for dmic16k" to the asoc tree Mark Brown
2020-04-09 18:58 ` Pierre-Louis Bossart [this message]
2020-04-14 14:48   ` Applied "ASoC: intel/skl/hda - set autosuspend timeout for hda codecs" " Mark Brown
2020-04-09 18:58 ` [PATCH 03/13] ALSA: hda: Add ElkhartLake HDMI codec vid Pierre-Louis Bossart
2020-04-11 10:29   ` Takashi Iwai
2020-04-14 16:09     ` Kai Vehmanen
2020-04-14 16:32       ` Takashi Iwai
2020-04-14 16:36       ` Pierre-Louis Bossart
2020-04-14 14:48   ` Applied "ALSA: hda: Add ElkhartLake HDMI codec vid" to the asoc tree Mark Brown
2020-04-09 18:58 ` [PATCH 04/13] ASoC: SOF: Intel: add PCI ID for ElkhartLake Pierre-Louis Bossart
2020-04-14 14:48   ` Applied "ASoC: SOF: Intel: add PCI ID for ElkhartLake" to the asoc tree Mark Brown
2020-04-09 18:58 ` [PATCH 05/13] ASoC: Intel: boards: support Elkhart Lake with rt5660 Pierre-Louis Bossart
2020-04-14 14:48   ` Applied "ASoC: Intel: boards: support Elkhart Lake with rt5660" to the asoc tree Mark Brown
2020-04-09 18:58 ` [PATCH 06/13] ASoC: intel: sof_sdw: init all aggregated codecs Pierre-Louis Bossart
2020-04-14 14:47   ` Applied "ASoC: intel: sof_sdw: init all aggregated codecs" to the asoc tree Mark Brown
2020-04-09 18:58 ` [PATCH 07/13] ASoC: Intel: sof-da7219-max98373: add DMIC widget and route Pierre-Louis Bossart
2020-04-14 14:47   ` Applied "ASoC: Intel: sof-da7219-max98373: add DMIC widget and route" to the asoc tree Mark Brown
2020-04-09 18:58 ` [PATCH 08/13] ASoC: Intel: sof_sdw_hdmi: fix compilation issue in fallback mode Pierre-Louis Bossart
2020-04-14 14:47   ` Applied "ASoC: Intel: sof_sdw_hdmi: fix compilation issue in fallback mode" to the asoc tree Mark Brown
2020-04-09 18:58 ` [PATCH 09/13] ASoC: Intel: sof_sdw_hdmi: remove codec_dai use Pierre-Louis Bossart
2020-04-14 14:47   ` Applied "ASoC: Intel: sof_sdw_hdmi: remove codec_dai use" to the asoc tree Mark Brown
2020-04-09 18:58 ` [PATCH 10/13] ASoC: Intel: sof_sdw_rt1308: remove codec dai use Pierre-Louis Bossart
2020-04-14 14:47   ` Applied "ASoC: Intel: sof_sdw_rt1308: remove codec dai use" to the asoc tree Mark Brown
2020-04-09 18:58 ` [PATCH 11/13] ASoC: Intel: sof_sdw_rt5682: remove codec_dai use Pierre-Louis Bossart
2020-04-14 14:47   ` Applied "ASoC: Intel: sof_sdw_rt5682: remove codec_dai use" to the asoc tree Mark Brown
2020-04-09 18:58 ` [PATCH 12/13] ASoC: Intel: sof_sdw_rt700: remove codec_dai use Pierre-Louis Bossart
2020-04-14 14:47   ` Applied "ASoC: Intel: sof_sdw_rt700: remove codec_dai use" to the asoc tree Mark Brown
2020-04-09 18:58 ` [PATCH 13/13] ASoC: Intel: sof_sdw_rt711: remove codec_dai use Pierre-Louis Bossart
2020-04-14 14:47   ` Applied "ASoC: Intel: sof_sdw_rt711: remove codec_dai use" to the asoc tree Mark Brown

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=20200409185827.16255-3-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=clarex.zhou@intel.com \
    --cc=hui.wang@canonical.com \
    --cc=jaska.uimonen@linux.intel.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=tiwai@suse.de \
    /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.