Skip to content

Commit b33115b

Browse files
mkumardtiwai
authored andcommitted
ALSA: hda: Jack detection poll in suspend state
HDA Jack detection logic doesn't work when the HDACODEC in runtime suspended state as unsol event won't be triggered during D3 state. As pulseaudio server in userspace rely on the jack mixer control status to show the audio devices in gui and any display sink device hotplug event during D3 state will never updates the jack status which will result in no audio device option available in userspace settings. The possible option available to resolve this issue is to run Jack polling worker thread even after codec suspend state. The choice can be made based on compromise between power saving or Jack detection in suspend state. Signed-off-by: Mohan Kumar <mkumard@nvidia.com> Link: https://lore.kernel.org/r/20220411073210.23445-2-mkumard@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent b2405aa commit b33115b

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

include/sound/hda_codec.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ struct hda_bus {
5959
unsigned int no_response_fallback:1; /* don't fallback at RIRB error */
6060
unsigned int bus_probing :1; /* during probing process */
6161
unsigned int keep_power:1; /* keep power up for notification */
62+
unsigned int jackpoll_in_suspend:1; /* keep jack polling during
63+
* runtime suspend
64+
*/
6265

6366
int primary_dig_out_type; /* primary digital out PCM type */
6467
unsigned int mixer_assigned; /* codec addr for mixer name */

sound/pci/hda/hda_codec.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2935,7 +2935,9 @@ static int hda_codec_runtime_suspend(struct device *dev)
29352935
if (!codec->card)
29362936
return 0;
29372937

2938-
cancel_delayed_work_sync(&codec->jackpoll_work);
2938+
if (!codec->bus->jackpoll_in_suspend)
2939+
cancel_delayed_work_sync(&codec->jackpoll_work);
2940+
29392941
state = hda_call_codec_suspend(codec);
29402942
if (codec->link_down_at_suspend ||
29412943
(codec_has_clkstop(codec) && codec_has_epss(codec) &&
@@ -2984,6 +2986,9 @@ static void hda_codec_pm_complete(struct device *dev)
29842986

29852987
static int hda_codec_pm_suspend(struct device *dev)
29862988
{
2989+
struct hda_codec *codec = dev_to_hda_codec(dev);
2990+
2991+
cancel_delayed_work_sync(&codec->jackpoll_work);
29872992
dev->power.power_state = PMSG_SUSPEND;
29882993
return pm_runtime_force_suspend(dev);
29892994
}
@@ -2996,6 +3001,9 @@ static int hda_codec_pm_resume(struct device *dev)
29963001

29973002
static int hda_codec_pm_freeze(struct device *dev)
29983003
{
3004+
struct hda_codec *codec = dev_to_hda_codec(dev);
3005+
3006+
cancel_delayed_work_sync(&codec->jackpoll_work);
29993007
dev->power.power_state = PMSG_FREEZE;
30003008
return pm_runtime_force_suspend(dev);
30013009
}
@@ -3038,6 +3046,7 @@ void snd_hda_codec_shutdown(struct hda_codec *codec)
30383046
if (!codec->registered)
30393047
return;
30403048

3049+
cancel_delayed_work_sync(&codec->jackpoll_work);
30413050
list_for_each_entry(cpcm, &codec->pcm_list_head, list)
30423051
snd_pcm_suspend_all(cpcm->pcm);
30433052

0 commit comments

Comments
 (0)