From: han.lu@intel.com
To: daniel.vetter@intel.com, tiwai@suse.de, jani.nikula@intel.com,
libin.yang@intel.com, mengdong.lin@intel.com,
intel-gfx@lists.freedesktop.org
Cc: "Lu, Han" <han.lu@intel.com>
Subject: [PATCH-V3 2/2] ALSA:hda - reset display codec when power on
Date: Wed, 29 Apr 2015 17:49:26 +0800 [thread overview]
Message-ID: <1430300966-19331-2-git-send-email-han.lu@intel.com> (raw)
In-Reply-To: <1430300966-19331-1-git-send-email-han.lu@intel.com>
From: "Lu, Han" <han.lu@intel.com>
In SKL, HDMI/DP codec and PCH HD Audio Controller are in different power wells,
so it's necessary to reset display audio codecs when power well on, otherwise
display audio codecs will disappear when resume from low power state.
Reset steps when power on:
enable codec wakeup -> azx_init_chip() -> disable codec wakeup
The callback for codec wakeup enable/disable is in drivers/gpu/drm/i915/.
Signed-off-by: Lu, Han <han.lu@intel.com>
diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
index 3052a2b..fe4f979a 100644
--- a/sound/pci/hda/hda_i915.c
+++ b/sound/pci/hda/hda_i915.c
@@ -33,6 +33,27 @@
#define AZX_REG_EM4 0x100c
#define AZX_REG_EM5 0x1010
+int hda_set_codec_wakeup(struct hda_intel *hda, bool enable)
+{
+ struct i915_audio_component *acomp = &hda->audio_component;
+
+ if (!acomp->ops)
+ return -ENODEV;
+
+ if (!acomp->ops->codec_wake_override) {
+ dev_warn(&hda->chip.pci->dev,
+ "Invalid codec wake callback\n");
+ return 0;
+ }
+
+ dev_dbg(&hda->chip.pci->dev, "%s codec wakeup\n",
+ enable ? "enable" : "disable");
+
+ acomp->ops->codec_wake_override(acomp->dev, enable);
+
+ return 0;
+}
+
int hda_display_power(struct hda_intel *hda, bool enable)
{
struct i915_audio_component *acomp = &hda->audio_component;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 34040d2..f4ed12d 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -491,6 +491,17 @@ static void azx_init_pci(struct azx *chip)
}
}
+static void hda_intel_init_chip(struct azx *chip, bool full_reset)
+{
+ struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
+
+ if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
+ hda_set_codec_wakeup(hda, true);
+ azx_init_chip(chip, full_reset);
+ if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
+ hda_set_codec_wakeup(hda, false);
+}
+
/* calculate runtime delay from LPIB */
static int azx_get_delay_from_lpib(struct azx *chip, struct azx_dev *azx_dev,
unsigned int pos)
@@ -827,7 +838,7 @@ static int azx_resume(struct device *dev)
return -EIO;
azx_init_pci(chip);
- azx_init_chip(chip, true);
+ hda_intel_init_chip(chip, true);
snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0;
@@ -888,13 +899,16 @@ static int azx_runtime_resume(struct device *dev)
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
hda_display_power(hda, true);
haswell_set_bclk(hda);
+ /* toggle codec wakeup bit for STATESTS read */
+ hda_set_codec_wakeup(hda, true);
+ hda_set_codec_wakeup(hda, false);
}
/* Read STATESTS before controller reset */
status = azx_readw(chip, STATESTS);
azx_init_pci(chip);
- azx_init_chip(chip, true);
+ hda_intel_init_chip(chip, true);
bus = chip->bus;
if (status && bus) {
@@ -1588,7 +1602,7 @@ static int azx_first_init(struct azx *chip)
haswell_set_bclk(hda);
}
- azx_init_chip(chip, (probe_only[dev] & 2) == 0);
+ hda_intel_init_chip(chip, (probe_only[dev] & 2) == 0);
/* codec detection */
if (!chip->codec_mask) {
diff --git a/sound/pci/hda/hda_intel.h b/sound/pci/hda/hda_intel.h
index d5231f7..5d2bb07 100644
--- a/sound/pci/hda/hda_intel.h
+++ b/sound/pci/hda/hda_intel.h
@@ -48,11 +48,16 @@ struct hda_intel {
};
#ifdef CONFIG_SND_HDA_I915
+int hda_set_codec_wakeup(struct hda_intel *hda, bool enable);
int hda_display_power(struct hda_intel *hda, bool enable);
void haswell_set_bclk(struct hda_intel *hda);
int hda_i915_init(struct hda_intel *hda);
int hda_i915_exit(struct hda_intel *hda);
#else
+static inline int hda_set_codec_wakeup(struct hda_intel *hda, bool enable)
+{
+ return 0;
+}
static inline int hda_display_power(struct hda_intel *hda, bool enable)
{
return 0;
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-04-29 9:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-29 9:49 [PATCH-V3 1/2] drm/i915/audio: add codec wakeup override enabled/disable callback han.lu
2015-04-29 9:49 ` han.lu [this message]
2015-04-30 18:29 ` [PATCH-V3 2/2] ALSA:hda - reset display codec when power on shuang.he
2015-04-30 14:21 ` [PATCH-V3 1/2] drm/i915/audio: add codec wakeup override enabled/disable callback Takashi Iwai
2015-05-04 0:32 ` Lu, Han
2015-05-04 7:49 ` Jani Nikula
2015-05-04 7:51 ` Yang, Libin
2015-05-04 12:28 ` 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=1430300966-19331-2-git-send-email-han.lu@intel.com \
--to=han.lu@intel.com \
--cc=daniel.vetter@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=libin.yang@intel.com \
--cc=mengdong.lin@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox