No sound from line-out in Ubuntu 19.10 on ALC1220

TLDR:

  1. Cold-boot to Linux or change the sound driver in Windows;
  2. check you volume level for headphones in alsamixer.

To answer my own question, this behaviour seems to be caused by two different issues:

  • a collision between a Windows Realtek driver and a Linux HDA driver
  • alsamixer volume settings for headphones

After applying both of the fixes, I finally have sound from the "Line out" jack on Ubuntu 20.04 running Kernel 5.4:

ales@VIKING-ALES:~$ uname -a
Linux VIKING-ALES 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Collision between a Windows Realtek driver and a Linux HDA driver

After digging around, I found the following thread on level1techs.com: https://forum.level1techs.com/t/has-anybody-gotten-audio-working-in-linux-on-aorus-x570-master/154072/45

As suggested there, this might be happening exclusively in the dual-boot scenario when the Linux HDA driver might not be able to initialize the sound card in a state set by the Windows Realtek driver and refuses to produce sound (even after applying the second step with alsamixer).

One solution thus is to always cold-boot to Linux. The aforementioned forum alternatively suggests to switch from the Realtek driver to a Microsoft's HDA driver. I have tried and it indeed seems to have fixed the issue. Now the reboot (with the 2nd step mentioned below) keeps the sound.

Fun fact: After switching to the Microsoft HDA driver and rebooting, Windows was not playing any sound too. I had to cold-boot to Windows to reset the state of my sound card apparently set by the Realtek driver before the reboot. So it seems that it's not only the Linux's HDA driver that has problems with recovering from the sound card state, but the Microsoft's HDA driver as well.

AlsaMixer volume settings for headphones

Another issue is that the "Headphones" volume is set to 0. Apparently, Alsa has this connected with the rear jack for speakers.

The solution is described e.g. here: No sound in Headphone from front panel audio port in Ubuntu 18.04

The only remaining issue is that the volume of the "Headphones" is not persisted across reboots or after plugging actual headphones to the front panel jack. It is another issue but when I find a solution, I might add it here for the sake of completeness.