aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-11-11 03:34:25 -0500
committerTakashi Iwai <tiwai@suse.de>2009-11-11 03:37:08 -0500
commita2f6309e8392e2c14c04594fca8b4876c8c9bc36 (patch)
tree78db71701660196181768b898bcc80db8bc10009 /sound/pci/hda/hda_codec.c
parent8f217a226cfa7b960b8a6c00cef6b4de2c5dd030 (diff)
ALSA: hda - Add power on/off counter
Added the power on/off counter and expose via sysfs files. The sysfs files, power_on_acct and power_off_acct, are created under each codec hwdep sysfs directory (e.g. /sys/class/sound/hwC0D0). The files show the msec length of the codec power-on and power-off, respectively. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r--sound/pci/hda/hda_codec.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 2b787b013e93..444d9039c1ac 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -515,6 +515,7 @@ static int snd_hda_bus_dev_register(struct snd_device *device)
515 struct hda_codec *codec; 515 struct hda_codec *codec;
516 list_for_each_entry(codec, &bus->codec_list, list) { 516 list_for_each_entry(codec, &bus->codec_list, list) {
517 snd_hda_hwdep_add_sysfs(codec); 517 snd_hda_hwdep_add_sysfs(codec);
518 snd_hda_hwdep_add_power_sysfs(codec);
518 } 519 }
519 return 0; 520 return 0;
520} 521}
@@ -2452,9 +2453,11 @@ static void hda_call_codec_suspend(struct hda_codec *codec)
2452 codec->afg ? codec->afg : codec->mfg, 2453 codec->afg ? codec->afg : codec->mfg,
2453 AC_PWRST_D3); 2454 AC_PWRST_D3);
2454#ifdef CONFIG_SND_HDA_POWER_SAVE 2455#ifdef CONFIG_SND_HDA_POWER_SAVE
2456 snd_hda_update_power_acct(codec);
2455 cancel_delayed_work(&codec->power_work); 2457 cancel_delayed_work(&codec->power_work);
2456 codec->power_on = 0; 2458 codec->power_on = 0;
2457 codec->power_transition = 0; 2459 codec->power_transition = 0;
2460 codec->power_jiffies = jiffies;
2458#endif 2461#endif
2459} 2462}
2460 2463
@@ -3191,6 +3194,17 @@ static void hda_keep_power_on(struct hda_codec *codec)
3191{ 3194{
3192 codec->power_count++; 3195 codec->power_count++;
3193 codec->power_on = 1; 3196 codec->power_on = 1;
3197 codec->power_jiffies = jiffies;
3198}
3199
3200void snd_hda_update_power_acct(struct hda_codec *codec)
3201{
3202 unsigned long delta = jiffies - codec->power_jiffies;
3203 if (codec->power_on)
3204 codec->power_on_acct += delta;
3205 else
3206 codec->power_off_acct += delta;
3207 codec->power_jiffies += delta;
3194} 3208}
3195 3209
3196void snd_hda_power_up(struct hda_codec *codec) 3210void snd_hda_power_up(struct hda_codec *codec)
@@ -3201,7 +3215,9 @@ void snd_hda_power_up(struct hda_codec *codec)
3201 if (codec->power_on || codec->power_transition) 3215 if (codec->power_on || codec->power_transition)
3202 return; 3216 return;
3203 3217
3218 snd_hda_update_power_acct(codec);
3204 codec->power_on = 1; 3219 codec->power_on = 1;
3220 codec->power_jiffies = jiffies;
3205 if (bus->ops.pm_notify) 3221 if (bus->ops.pm_notify)
3206 bus->ops.pm_notify(bus); 3222 bus->ops.pm_notify(bus);
3207 hda_call_codec_resume(codec); 3223 hda_call_codec_resume(codec);