Is watching the codec power up/down the only purpose? If so, the time for codec power on/off can be already checked in /sys/class/sound/hwC*D*/power_{on|off}_acct files. These are used by powertop, for example.
Hi Takashi,
My purpose is to enable runtime power management on HD audio. And I hope to base runtime PM on current power saving implementation.
The basic idea is: For the HD-A controller, runtime PM can be enabled on platforms than can provide acceptable latency on transition from D3 to D0. When both power saving and runtime PM are enabled by the user, and if all codec are suspended (in D3), the HD-A controller can also enter low-power state by triggering system runtime suspend. And on user operations or HW wakeup event, HD-A controller will be resumed before codecs.
In my test, I found the issue described in my patch. Such idle but unsuspended codecs prevent the controller from entering D3 at runtime. So I need a method to detect such idle codecs and suspend them. Even if runtime PM is not enabled, I hope this method can improve current power saving.
Thanks Mengdong