Skip to content

Commit

Permalink
ALSA: hda - Support advanced power state controls
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Takashi Iwai committed Mar 18, 2015
1 parent fb83b63 commit e6feb5d
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 48 deletions.
4 changes: 4 additions & 0 deletions sound/pci/hda/hda_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,8 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
if (!p)
return;

if (codec->patch_ops.stream_pm)
codec->patch_ops.stream_pm(codec, nid, true);
if (codec->pcm_format_first)
update_pcm_format(codec, p, nid, format);
update_pcm_stream_id(codec, p, nid, stream_tag, channel_id);
Expand Down Expand Up @@ -1570,6 +1572,8 @@ static void really_cleanup_stream(struct hda_codec *codec,
);
memset(q, 0, sizeof(*q));
q->nid = nid;
if (codec->patch_ops.stream_pm)
codec->patch_ops.stream_pm(codec, nid, false);
}

/* clean up the all conflicting obsolete streams */
Expand Down
2 changes: 2 additions & 0 deletions sound/pci/hda/hda_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ struct hda_codec_ops {
int (*check_power_status)(struct hda_codec *codec, hda_nid_t nid);
#endif
void (*reboot_notify)(struct hda_codec *codec);
void (*stream_pm)(struct hda_codec *codec, hda_nid_t nid, bool on);
};

/* record for amp information cache */
Expand Down Expand Up @@ -370,6 +371,7 @@ struct hda_codec {
unsigned int cached_write:1; /* write only to caches */
unsigned int dp_mst:1; /* support DP1.2 Multi-stream transport */
unsigned int dump_coef:1; /* dump processing coefs in codec proc file */
unsigned int power_mgmt:1; /* advanced PM for each widget */
#ifdef CONFIG_PM
unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */
atomic_t in_pm; /* suspend/resume being performed */
Expand Down
Loading

0 comments on commit e6feb5d

Please sign in to comment.