[PATCH-V2 2/2] ALSA:hda - reset display codec when power on

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Lu, Han" <han.lu@xxxxxxxxx>

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.
The reset step when power on is:
    enable codec wakeup -> azx_init_chip() -> disable codec wakeup

The callback is defined in drivers/gpu/drm/i915/.
The caller is in sound/pci/hda/.

Signed-off-by: Lu, Han <han.lu@xxxxxxxxx>

diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
index 3052a2b..e5ebedc 100644
--- a/sound/pci/hda/hda_i915.c
+++ b/sound/pci/hda/hda_i915.c
@@ -33,6 +33,23 @@
 #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;
+
+	dev_dbg(&hda->chip.pci->dev, "%s codec wakeup\n",
+		enable ? "enable" : "disable");
+	if (enable)
+		acomp->ops->enable_codec_wakeup(acomp->dev);
+	else
+		acomp->ops->disable_codec_wakeup(acomp->dev);
+
+	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..b0f2490 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -819,6 +819,8 @@ static int azx_resume(struct device *dev)
 	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
 		hda_display_power(hda, true);
 		haswell_set_bclk(hda);
+		/* generate codec wakeup signal */
+		hda_set_codec_wakeup(hda, true);
 	}
 	if (chip->msi)
 		if (pci_enable_msi(pci) < 0)
@@ -829,6 +831,10 @@ static int azx_resume(struct device *dev)
 
 	azx_init_chip(chip, true);
 
+	/* disable codec wakeup signal */
+	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
+		hda_set_codec_wakeup(hda, false);
+
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 	return 0;
 }
@@ -888,6 +894,8 @@ 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);
+		/* generate codec wakeup signal */
+		hda_set_codec_wakeup(hda, true);
 	}
 
 	/* Read STATESTS before controller reset */
@@ -896,6 +904,10 @@ static int azx_runtime_resume(struct device *dev)
 	azx_init_pci(chip);
 	azx_init_chip(chip, true);
 
+	/* disable codec wakeup signal */
+	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
+		hda_set_codec_wakeup(hda, false);
+
 	bus = chip->bus;
 	if (status && bus) {
 		list_for_each_codec(codec, bus)
@@ -1450,6 +1462,7 @@ static int azx_first_init(struct azx *chip)
 	int dev = chip->dev_index;
 	struct pci_dev *pci = chip->pci;
 	struct snd_card *card = chip->card;
+	struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
 	int err;
 	unsigned short gcap;
 	unsigned int dma_bits = 64;
@@ -1582,14 +1595,17 @@ static int azx_first_init(struct azx *chip)
 	azx_init_pci(chip);
 
 	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
-		struct hda_intel *hda;
-
-		hda = container_of(chip, struct hda_intel, chip);
 		haswell_set_bclk(hda);
+		/* generate codec wakeup signal */
+		hda_set_codec_wakeup(hda, true);
 	}
 
 	azx_init_chip(chip, (probe_only[dev] & 2) == 0);
 
+	/* disable codec wakeup signal */
+	if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
+		hda_set_codec_wakeup(hda, false);
+
 	/* codec detection */
 	if (!chip->codec_mask) {
 		dev_err(card->dev, "no codecs found!\n");
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@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux