Skip to content

Commit 9fc91a6

Browse files
soyersoyertiwai
authored andcommitted
ALSA: hda/tas2781: restore power state after system_resume
After system_resume the amplifers will remain off, even if they were on before system_suspend. Use playback_started bool to save the playback state, and restore power state based on it. Fixes: 5be27f1 ("ALSA: hda/tas2781: Add tas2781 HDA driver") Signed-off-by: Gergo Koteles <soyer@irl.hu> Signed-off-by: Takashi Iwai <tiwai@suse.de> Message-ID: <1742b61901781826f6e6212ffe1d21af542d134a.1709918447.git.soyer@irl.hu>
1 parent 5f51de7 commit 9fc91a6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sound/pci/hda/tas2781_hda_i2c.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,13 @@ static void tas2781_hda_playback_hook(struct device *dev, int action)
160160
pm_runtime_get_sync(dev);
161161
mutex_lock(&tas_hda->priv->codec_lock);
162162
tasdevice_tuning_switch(tas_hda->priv, 0);
163+
tas_hda->priv->playback_started = true;
163164
mutex_unlock(&tas_hda->priv->codec_lock);
164165
break;
165166
case HDA_GEN_PCM_ACT_CLOSE:
166167
mutex_lock(&tas_hda->priv->codec_lock);
167168
tasdevice_tuning_switch(tas_hda->priv, 1);
169+
tas_hda->priv->playback_started = false;
168170
mutex_unlock(&tas_hda->priv->codec_lock);
169171

170172
pm_runtime_mark_last_busy(dev);
@@ -666,6 +668,7 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)
666668
tasdevice_save_calibration(tas_priv);
667669

668670
tasdevice_tuning_switch(tas_hda->priv, 0);
671+
tas_hda->priv->playback_started = true;
669672

670673
out:
671674
mutex_unlock(&tas_hda->priv->codec_lock);
@@ -837,6 +840,9 @@ static int tas2781_runtime_suspend(struct device *dev)
837840

838841
mutex_lock(&tas_hda->priv->codec_lock);
839842

843+
/* The driver powers up the amplifiers at module load time.
844+
* Stop the playback if it's unused.
845+
*/
840846
if (tas_hda->priv->playback_started) {
841847
tasdevice_tuning_switch(tas_hda->priv, 1);
842848
tas_hda->priv->playback_started = false;
@@ -876,7 +882,8 @@ static int tas2781_system_suspend(struct device *dev)
876882
mutex_lock(&tas_hda->priv->codec_lock);
877883

878884
/* Shutdown chip before system suspend */
879-
tasdevice_tuning_switch(tas_hda->priv, 1);
885+
if (tas_hda->priv->playback_started)
886+
tasdevice_tuning_switch(tas_hda->priv, 1);
880887

881888
mutex_unlock(&tas_hda->priv->codec_lock);
882889

@@ -908,6 +915,10 @@ static int tas2781_system_resume(struct device *dev)
908915
* calibrated data inside algo.
909916
*/
910917
tasdevice_apply_calibration(tas_hda->priv);
918+
919+
if (tas_hda->priv->playback_started)
920+
tasdevice_tuning_switch(tas_hda->priv, 0);
921+
911922
mutex_unlock(&tas_hda->priv->codec_lock);
912923

913924
return 0;

0 commit comments

Comments
 (0)