Bug 217259

Summary: linux 6, dual monitors, no sound from hdmi after wake up again after screen off
Product: Drivers Reporter: viqbgrg
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: NEW ---    
Severity: normal CC: regressions, tiwai
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 6.1.18-1-lts Subsystem:
Regression: No Bisected commit-id:
Attachments: before turning off the screen
after waking up the screen
Test fix

Description viqbgrg 2023-03-28 08:32:39 UTC
Created attachment 304043 [details]
before turning off the screen

hdmi device 3 and device 7 swapping after screen restore

card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [PHL275E9]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [2481W]
  Subdevices: 1/1
  Subdevice #0: subdevice #0



card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [2481W]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [PHL275E9]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Comment 1 viqbgrg 2023-03-28 08:34:53 UTC
Created attachment 304044 [details]
after waking up the screen
Comment 2 The Linux kernel's regression tracker (Thorsten Leemhuis) 2023-03-29 09:34:26 UTC
Did this work in earlier kernel? Which one? 6.0? Or even earlier 6.1.y versions?
Comment 3 viqbgrg 2023-03-29 15:49:27 UTC
(In reply to The Linux kernel's regression tracker (Thorsten Leemhuis) from comment #2)
> Did this work in earlier kernel? Which one? 6.0? Or even earlier 6.1.y
> versions?

6.0.12-arch1-1 has sound, and 6.1.0-arch1-1 has no sound
Comment 4 Takashi Iwai 2023-03-29 16:04:06 UTC
(In reply to viqbgrg from comment #0)
> Created attachment 304043 [details]
> before turning off the screen
> 
> hdmi device 3 and device 7 swapping after screen restore
> 
> card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [PHL275E9]
>   Subdevices: 0/1
>   Subdevice #0: subdevice #0
> card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [2481W]
>   Subdevices: 1/1
>   Subdevice #0: subdevice #0
> 
> 
> 
> card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [2481W]
>   Subdevices: 0/1
>   Subdevice #0: subdevice #0
> card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [PHL275E9]
>   Subdevices: 1/1
>   Subdevice #0: subdevice #0

The graphics driver likely turns the audio device off at the screen off for power-saving or such.  The HDMI device assignment is dynamic, per design, hence this kind of change may happen.  IOW, this is still seen as the designed behavior.
Comment 5 Takashi Iwai 2023-03-29 16:05:44 UTC
So the question is what kind of sound backend you're using.  PulseAudio or pipewire should be able to parse the HDMI device state on the fly.
Comment 6 viqbgrg 2023-03-29 16:35:03 UTC
(In reply to Takashi Iwai from comment #5)
> So the question is what kind of sound backend you're using.  PulseAudio or
> pipewire should be able to parse the HDMI device state on the fly.

The pipewire I use, the pipewire does not switch automatically
Comment 7 Takashi Iwai 2023-03-30 07:44:38 UTC
Could you run "alsactl monitor" and check whether the Jack events are sent/handled when the device swap happens?
Also try "amixer -c0 events" for the same, too.
Comment 8 Takashi Iwai 2023-03-30 08:35:57 UTC
Also, when you re-select the right output, it starts working again, right?
That is, the problem is only the swap of devices?
Comment 9 viqbgrg 2023-03-30 09:32:59 UTC
(In reply to Takashi Iwai from comment #8)
> Also, when you re-select the right output, it starts working again, right?
> That is, the problem is only the swap of devices?

Yes, it works normally after I choose the correct device, do I need to install pipewire-jack? Another question is how does pipewire distinguish the difference between these two devices? Both device and node name have been exchanged.
Comment 10 Takashi Iwai 2023-03-30 12:30:14 UTC
OK, if it's only about the device assignment, a patch like below might help.
Comment 11 Takashi Iwai 2023-03-30 12:30:39 UTC
Created attachment 304057 [details]
Test fix
Comment 12 viqbgrg 2023-03-31 13:37:23 UTC
(In reply to Takashi Iwai from comment #11)
> Created attachment 304057 [details]
> Test fix

This patch works, thank you