Skip to content

Commit 65cc4ad

Browse files
Stefan Bindingtiwai
authored andcommitted
ALSA: hda/cs8409: Set PMSG_ON earlier inside cs8409 driver
For cs8409, it is required to run Jack Detect on resume. Jack Detect on cs8409+cs42l42 requires an interrupt from cs42l42 to be sent to cs8409 which is propogated to the driver via an unsolicited event. However, the hda_codec drops unsolicited events if the power_state is not set to PMSG_ON. Which is set at the end of the resume call. This means there is a race condition between setting power_state to PMSG_ON and receiving the interrupt. To solve this, we can add an API to set the power_state earlier and call that before we start Jack Detect. This does not cause issues, since we know inside our driver that we are already initialized, and ready to handle the unsolicited events. Signed-off-by: Stefan Binding <[email protected]> Signed-off-by: Vitaly Rodionov <[email protected]> Cc: <[email protected]> # v5.15+ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent dcd46eb commit 65cc4ad

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

sound/pci/hda/hda_local.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,15 @@ int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid,
438438
#define for_each_hda_codec_node(nid, codec) \
439439
for ((nid) = (codec)->core.start_nid; (nid) < (codec)->core.end_nid; (nid)++)
440440

441+
/* Set the codec power_state flag to indicate to allow unsol event handling;
442+
* see hda_codec_unsol_event() in hda_bind.c. Calling this might confuse the
443+
* state tracking, so use with care.
444+
*/
445+
static inline void snd_hda_codec_allow_unsol_events(struct hda_codec *codec)
446+
{
447+
codec->core.dev.power.power_state = PMSG_ON;
448+
}
449+
441450
/*
442451
* get widget capabilities
443452
*/

sound/pci/hda/patch_cs8409.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,11 @@ static void cs42l42_resume(struct sub_codec *cs42l42)
750750
if (cs42l42->full_scale_vol)
751751
cs8409_i2c_write(cs42l42, 0x2001, 0x01);
752752

753+
/* we have to explicitly allow unsol event handling even during the
754+
* resume phase so that the jack event is processed properly
755+
*/
756+
snd_hda_codec_allow_unsol_events(cs42l42->codec);
757+
753758
cs42l42_enable_jack_detect(cs42l42);
754759
}
755760

0 commit comments

Comments
 (0)