Commit 17314379 authored by Lydia Wang's avatar Lydia Wang Committed by Takashi Iwai

ALSA: HDA VIA: Add low current mode for power saving.

For VT1708B, VT1708S and VT1702, enter low current mode if no analog
stream is opened and all aa path mute.
Signed-off-by: default avatarLydia Wang <lydiawang@viatech.com.cn>
Signed-off-by: default avatarLogan Li <loganli@viatech.com.cn>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent f5271101
...@@ -783,6 +783,10 @@ static int via_playback_pcm_open(struct hda_pcm_stream *hinfo, ...@@ -783,6 +783,10 @@ static int via_playback_pcm_open(struct hda_pcm_stream *hinfo,
struct snd_pcm_substream *substream) struct snd_pcm_substream *substream)
{ {
struct via_spec *spec = codec->spec; struct via_spec *spec = codec->spec;
int idle = substream->pstr->substream_opened == 1
&& substream->ref_count == 0;
analog_low_current_mode(codec, idle);
return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
hinfo); hinfo);
} }
...@@ -1089,6 +1093,11 @@ static int via_build_controls(struct hda_codec *codec) ...@@ -1089,6 +1093,11 @@ static int via_build_controls(struct hda_codec *codec)
if (err < 0) if (err < 0)
return err; return err;
} }
/* init power states */
set_jack_power_state(codec);
analog_low_current_mode(codec, 1);
via_free_kctls(codec); /* no longer needed */ via_free_kctls(codec); /* no longer needed */
return 0; return 0;
} }
...@@ -2312,6 +2321,17 @@ static struct hda_verb vt1708B_uniwill_init_verbs[] = { ...@@ -2312,6 +2321,17 @@ static struct hda_verb vt1708B_uniwill_init_verbs[] = {
{ } { }
}; };
static int via_pcm_open_close(struct hda_pcm_stream *hinfo,
struct hda_codec *codec,
struct snd_pcm_substream *substream)
{
int idle = substream->pstr->substream_opened == 1
&& substream->ref_count == 0;
analog_low_current_mode(codec, idle);
return 0;
}
static struct hda_pcm_stream vt1708B_8ch_pcm_analog_playback = { static struct hda_pcm_stream vt1708B_8ch_pcm_analog_playback = {
.substreams = 2, .substreams = 2,
.channels_min = 2, .channels_min = 2,
...@@ -2320,7 +2340,8 @@ static struct hda_pcm_stream vt1708B_8ch_pcm_analog_playback = { ...@@ -2320,7 +2340,8 @@ static struct hda_pcm_stream vt1708B_8ch_pcm_analog_playback = {
.ops = { .ops = {
.open = via_playback_pcm_open, .open = via_playback_pcm_open,
.prepare = via_playback_multi_pcm_prepare, .prepare = via_playback_multi_pcm_prepare,
.cleanup = via_playback_multi_pcm_cleanup .cleanup = via_playback_multi_pcm_cleanup,
.close = via_pcm_open_close
}, },
}; };
...@@ -2342,8 +2363,10 @@ static struct hda_pcm_stream vt1708B_pcm_analog_capture = { ...@@ -2342,8 +2363,10 @@ static struct hda_pcm_stream vt1708B_pcm_analog_capture = {
.channels_max = 2, .channels_max = 2,
.nid = 0x13, /* NID to query formats and rates */ .nid = 0x13, /* NID to query formats and rates */
.ops = { .ops = {
.open = via_pcm_open_close,
.prepare = via_capture_pcm_prepare, .prepare = via_capture_pcm_prepare,
.cleanup = via_capture_pcm_cleanup .cleanup = via_capture_pcm_cleanup,
.close = via_pcm_open_close
}, },
}; };
...@@ -2800,7 +2823,8 @@ static struct hda_pcm_stream vt1708S_pcm_analog_playback = { ...@@ -2800,7 +2823,8 @@ static struct hda_pcm_stream vt1708S_pcm_analog_playback = {
.ops = { .ops = {
.open = via_playback_pcm_open, .open = via_playback_pcm_open,
.prepare = via_playback_pcm_prepare, .prepare = via_playback_pcm_prepare,
.cleanup = via_playback_pcm_cleanup .cleanup = via_playback_pcm_cleanup,
.close = via_pcm_open_close
}, },
}; };
...@@ -2810,8 +2834,10 @@ static struct hda_pcm_stream vt1708S_pcm_analog_capture = { ...@@ -2810,8 +2834,10 @@ static struct hda_pcm_stream vt1708S_pcm_analog_capture = {
.channels_max = 2, .channels_max = 2,
.nid = 0x13, /* NID to query formats and rates */ .nid = 0x13, /* NID to query formats and rates */
.ops = { .ops = {
.open = via_pcm_open_close,
.prepare = via_capture_pcm_prepare, .prepare = via_capture_pcm_prepare,
.cleanup = via_capture_pcm_cleanup .cleanup = via_capture_pcm_cleanup,
.close = via_pcm_open_close
}, },
}; };
...@@ -3236,7 +3262,8 @@ static struct hda_pcm_stream vt1702_pcm_analog_playback = { ...@@ -3236,7 +3262,8 @@ static struct hda_pcm_stream vt1702_pcm_analog_playback = {
.ops = { .ops = {
.open = via_playback_pcm_open, .open = via_playback_pcm_open,
.prepare = via_playback_multi_pcm_prepare, .prepare = via_playback_multi_pcm_prepare,
.cleanup = via_playback_multi_pcm_cleanup .cleanup = via_playback_multi_pcm_cleanup,
.close = via_pcm_open_close
}, },
}; };
...@@ -3246,8 +3273,10 @@ static struct hda_pcm_stream vt1702_pcm_analog_capture = { ...@@ -3246,8 +3273,10 @@ static struct hda_pcm_stream vt1702_pcm_analog_capture = {
.channels_max = 2, .channels_max = 2,
.nid = 0x12, /* NID to query formats and rates */ .nid = 0x12, /* NID to query formats and rates */
.ops = { .ops = {
.open = via_pcm_open_close,
.prepare = via_capture_pcm_prepare, .prepare = via_capture_pcm_prepare,
.cleanup = via_capture_pcm_cleanup .cleanup = via_capture_pcm_cleanup,
.close = via_pcm_open_close
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment