Bug 195305

Summary: Dual ALC1220 causes duplicate sound-controls causing problems with ALSA simple control (GA-AX370-Gaming 5)
Product: Drivers Reporter: Killian De Volder (killian.de.volder)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: NEW ---    
Severity: normal CC: ar, herb, tiwai, vovochka13
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.10.8 Subsystem:
Regression: No Bisected commit-id:
Attachments: ALSA-info

Description Killian De Volder 2017-04-09 20:12:34 UTC
Created attachment 255795 [details]
ALSA-info

Some motherboards use some sort of joined 2 ALC1220 chipsets. 1 for the front, and 1 for the back connectors. This is causing some troubles:

Output from the kernel:
-----------------------
[    2.099326] ALSA device list:
[    2.099528]   No soundcards found.
[    2.100373] snd_hda_codec_realtek hdaudioC1D0: autoconfig for ALC1220: line_outs=3 (0x14/0x15/0x16/0x0/0x0) type:line
[    2.100736] snd_hda_codec_realtek hdaudioC1D0:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    2.100946] snd_hda_codec_realtek hdaudioC1D0:    hp_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    2.101160] snd_hda_codec_realtek hdaudioC1D0:    mono: mono_out=0x0
[    2.101366] snd_hda_codec_realtek hdaudioC1D0:    dig-out=0x1e/0x0
[    2.101572] snd_hda_codec_realtek hdaudioC1D0:    inputs:
[    2.101782] snd_hda_codec_realtek hdaudioC1D0:      Mic=0x18
[    2.101986] snd_hda_codec_realtek hdaudioC1D0:      Line=0x1a
[    2.113019] snd_hda_codec_realtek hdaudioC1D1: autoconfig for ALC1220: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:hp
[    2.113380] snd_hda_codec_realtek hdaudioC1D1:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    2.113589] snd_hda_codec_realtek hdaudioC1D1:    hp_outs=0 (0x0/0x0/0x0/0x0/0x0)
[    2.113796] snd_hda_codec_realtek hdaudioC1D1:    mono: mono_out=0x0
[    2.114001] snd_hda_codec_realtek hdaudioC1D1:    inputs:
[    2.114204] snd_hda_codec_realtek hdaudioC1D1:      Mic=0x1a
[    2.120516] snd_hda_intel 0000:12:00.3: control 2:0:0:Master Playback Volume:0 is already present
[    2.120874] snd_hda_intel 0000:12:00.3: control 2:0:0:Master Playback Switch:0 is already present
[    2.121234] snd_hda_intel 0000:12:00.3: control 2:0:0:Loopback Mixing:0 is already present
[    2.121446] snd_hda_intel 0000:12:00.3: control 2:0:0:Mic Playback Volume:0 is already present
[    2.121802] snd_hda_intel 0000:12:00.3: control 2:0:0:Mic Playback Switch:0 is already present
[    2.122159] snd_hda_intel 0000:12:00.3: control 2:0:0:Capture Volume:0 is already present
[    2.122370] snd_hda_intel 0000:12:00.3: control 2:0:0:Capture Switch:0 is already present
[    2.122580] snd_hda_intel 0000:12:00.3: control 2:0:0:Mic Boost Volume:0 is already present

When running alsamixer:
-----------------------
ALSA lib /var/tmp/paludis/media-libs-alsa-lib-1.1.2/work/alsa-lib-1.1.2/src/mixer/simple_none.c:1550:(simple_add1) helem (MIXER,'Master Playback Switch',0,1,0) appears twice or more
amixer: Mixer default load error: Invalid argument
I have also seen:
ALSA lib /var/tmp/paludis/media-libs-alsa-lib-1.1.2/work/alsa-lib-1.1.2/src/mixer/simple_none.c:1550:(simple_add1) helem (MIXER,'Master Playback Volume',0,1,0) appears twice or more
amixer: Mixer default load error: Invalid argument


For ALSA debug info see:
------------------------
http://www.alsa-project.org/db/?f=2c51de8ef5da00764421f9c8ce32c4c44b884449
Comment 1 Herb Miller Jr. 2017-04-09 21:31:03 UTC
Same issue for me on a Gigabyte GA-AX370 Gaming 5 motherboard (ALC1220 chipset). Gentoo OS. Kernel 4.11-rc5.

ALSA Debug info:
-------------------------
http://www.alsa-project.org/db/?f=292532ff9495371972a7e7eae74a6dabab76cd75
Comment 2 Takashi Iwai 2017-04-21 09:00:12 UTC
OK, it's not quite trivial to work around it.  I've create a few patches to make the driver working in topic/hda-dual-codecs branch of sound git tree:
  git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

Could you give it a try to see whether the driver is loaded?

For making the stuff properly working, you'd need to create a UCM profile.
With the patch above and with the latest alsa-lib git version, you can create a UCM profile like:
  /usr/share/alsa/ucm/HDAudio-Gigabyte-ALC1120DualCodecs/HDAudio-Gigabyte-ALC1120DualCodecs.conf

And there the PCM streams for the headphone and for the speakers can be defined, as well as the jack control to allow PulseAudio automatically switching between them.  Ditto for the microphones.
Comment 3 Herb Miller Jr. 2017-04-23 17:32:23 UTC
Your patch made alsamixer stop crashing. I can see my mixer channels now. When I boot up into KDE Plasma, kmix still can't see the card though. I don't use PulseAudio on this rig, so I can't be much help there at the moment.

Haven't created a UCM profile just yet.
Comment 4 Takashi Iwai 2017-04-23 18:38:00 UTC
Could you give alsa-info.sh output after the patches?

For your machine, a system like PA is mandatory because it requires the switching of multiple PCM streams unlike other normal HD-audio boards.
Comment 5 Herb Miller Jr. 2017-04-24 03:28:00 UTC
Sure thing: http://www.alsa-project.org/db/?f=acaf9b130747599a547a74d2be3115e899486a3f

I use this rig for live audio recording with jackd and such so PA is an absolute no-go. I can always create a second install that is using PA for testing purposes when I get a chance, though. Can the streams be set up by hand using that UCM profile stuff you mentioned?

Looks like I might be in the market for a discreet audio card.
Comment 6 Takashi Iwai 2017-04-28 13:36:00 UTC
As mentioned, there will be multiple PCM streams depending on which jack you use.  That is, when you use JACK, you'd need to start with the proper PCM (e.g. hw:0,4 or such) for some jacks.  The PA and UCM are needed when you'd like to switch the streams on the fly, but for the systems like JACK, it doesn't matter.

In anyway, the patchset was merged to upstream, and will be included in 4.12-rc1.

Could you identify which I/O (jack, speaker, etc) correspond to which PCM streams (hw:0,0 and hw:0,4)?
Comment 7 Robert Gerus 2017-05-19 09:43:28 UTC
In my case (a similiar board, Gigabyte GA-AX370 Gaming K7), 4.12.0-rc1 solves the "helem … appears twice or more" problem; ,0 device is the rear output (on motherboard) and ,4 is the front panel.

Output of alsa-info.sh on that system:
http://www.alsa-project.org/db/?f=fda0d4b4837e5a7d4538c7819e5d573865718a02
Comment 8 Killian De Volder 2017-06-07 13:56:32 UTC
I'm not entirely sure if I should add this to this ticket.
However:
There is still a problem left / defaults not set / control input not present.
To enable microphone input on the front I need to manually change it using hda-analyser.py

Node 0x08 [Audio Input] wcaps 0x10051b: Stereo Amp-In
  Device: name="ALC1220 Analog", type="Audio", device=4
  Control: name="Front-Panel Capture Volume", index=0, device=0
    ControlAmp: chs=3, dir=1, idx=0, ofs=0
  Control: name="Front-Panel Capture Switch", index=0, device=0
    ControlAmp: chs=3, dir=1, idx=0, ofs=0
  Amp-In caps: ofs=0x17, nsteps=0x3f, stepsize=0x02, mute=1
  Amp-In vals: [0x3f 0x3f]
  Converter: stream=0, channel=0
  SDI-Select: 0
  PCM:
    rates [0x7e0]: 44100 48000 88200 96000 176400 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power: setting=D0, actual=D0
  Connection: 1
     0x23

And unmute it.

The same for the back:
Node 0x08 [Audio Input] wcaps 0x10051b: Stereo Amp-In
  Device: name="ALC1220 Analog", type="Audio", device=0
  Control: name="Rear-Panel Capture Volume", index=0, device=0
    ControlAmp: chs=3, dir=1, idx=0, ofs=0
  Control: name="Rear-Panel Capture Switch", index=0, device=0
    ControlAmp: chs=3, dir=1, idx=0, ofs=0
  Amp-In caps: ofs=0x17, nsteps=0x3f, stepsize=0x02, mute=1
  Amp-In vals: [0x3f 0x3f]
  Converter: stream=1, channel=0
  SDI-Select: 0
  PCM:
    rates [0x7e0]: 44100 48000 88200 96000 176400 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power: setting=D0, actual=D0
  Connection: 1
     0x23
Comment 9 Takashi Iwai 2017-06-07 14:00:22 UTC
There must be "Front-Panel Capture Switch" and "Rear-Panel Capture Switch" mixer switches.  They correspond to them.
Comment 10 Killian De Volder 2017-06-08 08:28:23 UTC
Please read full post, are there are few different topics in this.

--1--
Ok found it, for those foolish enough like me:
If your alsamixer looks like this:
│   ┌──┐     ┌──┐     ┌──┐     ┌──┐
│   │▒▒│     │▒▒│     │▒▒│     │▒▒│
│   │▒▒│     │▒▒│     │▒▒│     │▒▒│
│   │▒▒│     │▒▒│     │▒▒│     │▒▒│
│   └──┘     └──┘     └──┘     └──┘
│          -------           -------
│ 100<>100 100<>100 100<>100 100<>100
│<Front Mi>Front-Pa Line Boo Capture

The ------ lines are still a form of mute, to un-mute use the space bar not the M key. (Sorry my old soundcard used the OO/MM interface).

--2--
About the question:
Could you identify which I/O (jack, speaker, etc) correspond to which PCM streams (hw:0,0 and hw:0,4)?

The current names in ALSAMixer seem right.
To be fair I don't know where Capture 1 would be located, there are no more plug on this PC, maybe one on the motherboard.

--3--
There seems to some sound-ticking bug, at first I suspected buffer underrun, until I looked at the recording.
A sine wave of 850HZ recorded at 96Khz occasionally looks like this: (Half the screen and made it a triangle wave).
*
|*
|.*
|..*
|...*
|....*
*
|..*
*
|*
*

So just a few samples are occasionally pulled to 0, I have also seen it being pulled up.
Is this something I should make a ticket for or not ?

--4--
From the motherboard manual ""If you want to install a Side Speaker, you need to retask either the Line in or Mic in jack to be Side Speaker out using the HD Audio Manager application."" Don't anything about theses things so might work or not.