summaryrefslogtreecommitdiff
path: root/sound/pci/hda/hda_i915.c
diff options
context:
space:
mode:
authorMengdong Lin <mengdong.lin@intel.com>2015-04-29 17:43:12 +0800
committerTakashi Iwai <tiwai@suse.de>2015-04-29 12:27:52 +0200
commitd4b7b13e19258a848da920502e27526f36c5a59d (patch)
treefd2a55f49787b4621511bfd6b9aca7475f7a88d4 /sound/pci/hda/hda_i915.c
parent0dd76f36efa43fa75a568b0d24736a9e51d51170 (diff)
ALSA: hda - implement a refcount for i915 power well switch
This is to check the refcount of audio driver and reduce calling to i915. Signed-off-by: Mengdong Lin <mengdong.lin@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_i915.c')
-rw-r--r--sound/pci/hda/hda_i915.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
index 52a85d87c23c..b648928b6415 100644
--- a/sound/pci/hda/hda_i915.c
+++ b/sound/pci/hda/hda_i915.c
@@ -42,10 +42,15 @@ 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);
+
+ if (enable) {
+ if (!hda->i915_power_refcount++)
+ acomp->ops->get_power(acomp->dev);
+ } else {
+ WARN_ON(!hda->i915_power_refcount);
+ if (!--hda->i915_power_refcount)
+ acomp->ops->put_power(acomp->dev);
+ }
return 0;
}
@@ -183,6 +188,11 @@ out_err:
int hda_i915_exit(struct hda_intel *hda)
{
struct device *dev = &hda->chip.pci->dev;
+ struct i915_audio_component *acomp = &hda->audio_component;
+
+ WARN_ON(hda->i915_power_refcount);
+ if (hda->i915_power_refcount > 0 && acomp->ops)
+ acomp->ops->put_power(acomp->dev);
component_master_del(dev, &hda_component_master_ops);