Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: mengdong.lin@intel.com
To: alsa-devel@alsa-project.org, tiwai@suse.de
Cc: Mengdong Lin <mengdong.lin@intel.com>
Subject: [PATCH v2 3/3] ALSA: hda - implement a refcount for i915 power well switch
Date: Tue, 28 Apr 2015 20:43:19 +0800	[thread overview]
Message-ID: <1430224999-22271-1-git-send-email-mengdong.lin@intel.com> (raw)
In-Reply-To: <4530387c0b63ccfafb5dbb3399a39b4093651c48.1429880424.git.mengdong.lin@intel.com>

From: Mengdong Lin <mengdong.lin@intel.com>

This is to check the refcount of audio driver and reduce calling to i915.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>

diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
index 52a85d8..e831691 100644
--- a/sound/pci/hda/hda_i915.c
+++ b/sound/pci/hda/hda_i915.c
@@ -42,11 +42,16 @@ int hda_display_power(struct hda_intel *hda, bool enable)
 
 	dev_dbg(&hda->chip.pci->dev, "display power %s\n",
 		enable ? "enable" : "disable");
-	if (enable)
-		acomp->ops->get_power(acomp->dev);
-	else
-		acomp->ops->put_power(acomp->dev);
-
+	mutex_lock(&hda->display_power.lock);
+	if (enable) {
+		if (!hda->display_power.use_count++)
+			acomp->ops->get_power(acomp->dev);
+	} else {
+		WARN_ON(!hda->display_power.use_count);
+		if (!--hda->display_power.use_count)
+			acomp->ops->put_power(acomp->dev);
+	}
+	mutex_unlock(&hda->display_power.lock);
 	return 0;
 }
 
@@ -171,6 +176,8 @@ int hda_i915_init(struct hda_intel *hda)
 
 	dev_dbg(dev, "bound to i915 component master\n");
 
+	mutex_init(&hda->display_power.lock);
+
 	return 0;
 out_master_del:
 	component_master_del(dev, &hda_component_master_ops);
diff --git a/sound/pci/hda/hda_intel.h b/sound/pci/hda/hda_intel.h
index 2069898..3ca000a 100644
--- a/sound/pci/hda/hda_intel.h
+++ b/sound/pci/hda/hda_intel.h
@@ -19,6 +19,11 @@
 #include <drm/i915_component.h>
 #include "hda_controller.h"
 
+struct i915_display_power {
+	struct mutex lock;
+	int use_count;
+};
+
 struct hda_intel {
 	struct azx chip;
 
@@ -46,6 +51,7 @@ struct hda_intel {
 
 	/* i915 component interface */
 	struct i915_audio_component audio_component;
+	struct i915_display_power display_power;
 };
 
 #ifdef CONFIG_SND_HDA_I915
-- 
1.9.1

  parent reply	other threads:[~2015-04-28 12:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-24 13:01 [RFC PATCH 1/2] ALSA: hda - divide controller and codec dependency on i915 gfx power well mengdong.lin
2015-04-24 13:02 ` [RFC PATCH 2/2] ALSA: hda - remove controller dependency on i915 power well for Baytrail/Braswell mengdong.lin
2015-04-24 13:53 ` [RFC PATCH 1/2] ALSA: hda - divide controller and codec dependency on i915 gfx power well Takashi Iwai
2015-04-27  7:20   ` Lin, Mengdong
2015-04-28 12:43 ` [PATCH v2 1/3] " mengdong.lin
2015-04-28 12:59   ` Takashi Iwai
2015-04-28 15:03     ` Lin, Mengdong
2015-04-28 12:43 ` [PATCH v2 2/3] ALSA: hda - remove controller dependency on i915 power well for Baytrail/Braswell mengdong.lin
2015-04-28 12:43 ` mengdong.lin [this message]
2015-04-28 13:01   ` [PATCH v2 3/3] ALSA: hda - implement a refcount for i915 power well switch Takashi Iwai
2015-04-28 15:09     ` Lin, Mengdong

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=1430224999-22271-1-git-send-email-mengdong.lin@intel.com \
    --to=mengdong.lin@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --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