ALSA: hda - Support advanced power state controls
authorTakashi Iwai <tiwai@suse.de>
Mon, 16 Mar 2015 20:32:11 +0000 (21:32 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 18 Mar 2015 08:22:28 +0000 (09:22 +0100)
commite6feb5d08509be1af2ebc894dae35f32f7b92ab6
treed5f993a6e71646577c2ec824a89500a386a39e07
parentfb83b6351052bf78686df2559f7ea6b10e596850
ALSA: hda - Support advanced power state controls

This patch enables the finer power state control of each widget
depending on the jack plug state and streaming state in addition to
the existing power_down_unused power optimization.  The new feature is
enabled only when codec->power_mgmt flag is set.

Two new flags, pin_enabled and stream_enabled, are introduced in
nid_path struct for marking the two individual power states: the pin
plug/unplug and DAC/ADC stream, respectively.  They can be set
statically in case they are static routes (e.g. some mixer paths),
too.

The power up and down events for each pin are triggered via the
standard hda_jack table.  The call order is hard-coded, relying on the
current implementation of jack event chain (a la FILO/stack order).

One point to be dealt carefully is that DAC/ADC cannot be powered
on/off while streaming.  They are pinned as long as the stream is
running.  For controlling the power of DAC/ADC, a new patch_ops is
added.  The generic parser provides the default callback for that.

As of this patch, only IDT/Sigmatel codec driver enables the flag.
The support on other codecs will follow.

An assumption we made in this code is that the widget state (e.g. amp,
pinctl, connections) remains after the widget power transition (not
about FG power transition).  This is true for IDT codecs, at least.
But if the widget state is lost at widget power transition, we'd need
to implement additional code to sync the cached amp/verbs for the
specific NID.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_codec.h
sound/pci/hda/hda_generic.c
sound/pci/hda/hda_generic.h
sound/pci/hda/patch_sigmatel.c