Bug 106771

Summary: Headphone/spdif jack not working
Product: Drivers Reporter: ezstyles88
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: NEW ---    
Severity: normal CC: hovardslill, superquad.vortex2, tiwai
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.2.0-16-generic Subsystem:
Regression: No Bisected commit-id:

Description ezstyles88 2015-10-28 07:54:15 UTC
Headphone/spdif jack not working. Sound continues to play through built-in speakers. If needed, a summary of troubleshooting steps taken can be found in the first post here: http://ubuntuforums.org/showthread.php?t=2300693
Here is some AlsaInfo: 
http://www.alsa-project.org/db/?f=2a467ef47af598c8ef450abf4b42d6d06e494d03

This is happening on:
Ubuntu 15.10
Kernel 4.2.0-16-generic and 4.0.1-040001-generic
Realtek ALC668
Asus G751-JM

I can provide any information I may have left out.
Comment 1 Takashi Iwai 2015-10-28 08:19:29 UTC
BIOS doesn't seem to pass the proper pin configuration for your headphone jack.
You have to figure out by yourself, e.g. via hdajackretask or such utility, which pin corresponds to which actual I/O.
Comment 2 Raymond 2015-10-29 04:42:19 UTC
[   40.408038] snd_hda_codec_realtek hdaudioC1D0: autoconfig for ALC668: line_outs=1 (0x15/0x0/0x0/0x0/0x0) type:line
[   40.408040] snd_hda_codec_realtek hdaudioC1D0:    speaker_outs=2 (0x14/0x1a/0x0/0x0/0x0)
[   40.408041] snd_hda_codec_realtek hdaudioC1D0:    hp_outs=0 (0x0/0x0/0x0/0x0/0x0)
[   40.408042] snd_hda_codec_realtek hdaudioC1D0:    mono: mono_out=0x0
[   40.408043] snd_hda_codec_realtek hdaudioC1D0:    dig-out=0x1e/0x0
[   40.408044] snd_hda_codec_realtek hdaudioC1D0:    inputs:
[   40.408045] snd_hda_codec_realtek hdaudioC1D0:      Mic=0x18
[   40.408046] snd_hda_codec_realtek hdaudioC1D0:      Internal Mic=0x12

pulseaudio expect headphone jack must exist but yours seem have line out jack

try

hdajacksensetest -c1 -a

with headphone plug and unplug
Comment 3 Raymond 2015-10-29 04:46:11 UTC
do it mean driver does not support line out and speakerconfig since there is no auto mute control ?
Comment 4 ezstyles88 2015-10-29 05:09:33 UTC
I have 3 jacks. One is line out, one is mic and one is spdif. When setting options snd-hda-intel model=asus-mode5 I can use the line out as a headphone jack, but no other jacks work. 

I searched for hdajacksensetest and it appears it is packaged with snd-hda-tools but I can't find an actual current source. The repository I found returns error 404
Comment 7 Raymond 2015-10-29 16:20:12 UTC
can you confirm that node 0x16 is the headphone jack ?

the driver does not put headphone and line out mic jacks at same location to support multi channel
Comment 8 ezstyles88 2015-10-29 18:59:41 UTC
I'm not sure how to get any information running the hdajacksensetest command as shown. It simply returns command not found. However I can run ./hdajacksensetest but it only returns output for HDMI and I can find no manual, --help, or Readme. If helpful, hmdi output is:
Pin 0x05 ( Digital Out, HDMI): present = No
Pin 0x06 ( Digital Out, HDMI): present = No
Pin 0x07 ( Digital Out, HDMI): present = No

I am not sure how to confirm what node is for the headphone jack but hdajackretask shows "Internal SPDIF Out" Pin ID 0x1e
Comment 9 Raymond 2015-10-30 04:08:07 UTC
./hdajacksensetest -c1 -a

try to find out whether node 0x16 report present=yes when HP plug and present=no when HP unplug

use hdajackretask to overwrite the unconnected pin node 0x16 to HP

Set as boot default and reboot

as the driver does not put HP and Line Out of same location (Ext Front) for multichannel output

HP jack can auto mute Line Out and Internal speakers

you have to retask the HP jack to Line Out and Mic jack to line out for surround 5.1
Comment 10 Raymond 2015-10-30 16:20:09 UTC
your line out,speaker and subwoofer already used three audio output

three playback volume controls have to be shared between four output pins and mio pin



ode 0x02 [Audio Output] wcaps 0x41d: Stereo Amp-Out
  Control: name="Line Out Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Device: name="ALC668 Analog", type="Audio", device=0
  Amp-Out caps: ofs=0x57, nsteps=0x57, stepsize=0x02, mute=0
  Amp-Out vals:  [0x3e 0x3e]
  Converter: stream=5, channel=0
  PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
Node 0x03 [Audio Output] wcaps 0x41d: Stereo Amp-Out
  Control: name="Speaker Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x57, nsteps=0x57, stepsize=0x02, mute=0
  Amp-Out vals:  [0x3e 0x3e]
  Converter: stream=5, channel=0
  PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
Node 0x04 [Audio Output] wcaps 0x41d: Stereo Amp-Out
  Control: name="Bass Speaker Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x57, nsteps=0x57, stepsize=0x02, mute=0
  Amp-Out vals:  [0x3e 0x3e]
  Converter: stream=0, channel=0
  PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
Comment 11 ezstyles88 2015-10-31 02:32:32 UTC
I had tried running ./hdajacksensetest -c1 -a but it returns: Option parsing failed: Cannot parse integer value '-a' for -c. 

I had previously tried hdajackretask but I ran into issues getting it to function properly. You can see a run down of troubleshooting steps I took on this post here: http://ubuntuforums.org/showthread.php?t=2300693&p=13381269#post13381269 that links to instances I found
Comment 12 ezstyles88 2015-10-31 02:51:00 UTC
So I tried again with hdajackretask and selected "Advanced override" then set  unconnected pin node 0x16 to HP and clicked Apply now and it worked! I'm not sure why ticking the Advanced override box makes a difference but it is now working.
Comment 13 Raymond 2015-10-31 15:52:21 UTC
you have to post output of alsa-info.sh after you retask HP

seem only line out jack support EAPD

subwoofer need bass speaker playck volume control

do the subwoofer use left, right or both channels since your mic jack can be retask to support center/lfe? 


speaker-test -c4 -t wav -D hw:1,0


Node 0x15 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
  Control: name="Line Out Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x00 0x00]
  Pincap 0x0001001c: OUT HP EAPD Detect
  EAPD 0x2: EAPD
  Pin Default 0x04011020: [Jack] Line Out at Ext Right
    Conn = 1/8, Color = Black
    DefAssociation = 0x2, Sequence = 0x0
  Pin-ctls: 0x40: OUT
  Unsolicited: tag=01, enabled=1
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 3
     0x0c* 0x0d 0x0e
Node 0x16 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x80 0x80]
  Pincap 0x0000001c: OUT HP Detect
  Pin Default 0x4000c000: [N/A] Line Out at Ext N/A
    Conn = Unknown, Color = UNKNOWN
    DefAssociation = 0x0, Sequence = 0x0
  Pin-ctls: 0x00:
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 3
     0x0c 0x0d 0x0e*
Node 0x17 [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x18 [Pin Complex] wcaps 0x40058f: Stereo Amp-In Amp-Out
  Control: name="Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x80 0x80]
  Pincap 0x0000373c: IN OUT HP Detect
    Vref caps: HIZ 50 GRD 80 100
  Pin Default 0x04a11060: [Jack] Mic at Ext Right
    Conn = 1/8, Color = Black
    DefAssociation = 0x6, Sequence = 0x0
  Pin-ctls: 0x24: IN VREF_80
  Unsolicited: tag=02, enabled=1
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 3
     0x0c* 0x0d 0x0e
Comment 14 Raymond 2015-11-01 01:33:23 UTC
there are only three playback volume controls but five output pin complex



0x14 [Pin Complex] wcaps 0x40058f: Stereo Amp-In Amp-Out
  Control: name="Speaker Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-In caps: N/A
  Amp-In vals:  [0x00 0x00]
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x00 0x00]
  Pincap 0x0001003c: IN OUT HP EAPD Detect
  EAPD 0x2: EAPD
  Pin Default 0x90170110: [Fixed] Speaker at Int N/A
    Conn = Analog, Color = Unknown
    DefAssociation = 0x1, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x40: OUT
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 3
     0x0c 0x0d* 0x0e

Node 0x1a [Pin Complex] wcaps 0x40058f: Stereo Amp-In Amp-Out
  Control: name="Bass Speaker Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x00 0x00]
  Pincap 0x0000373c: IN OUT HP Detect
    Vref caps: HIZ 50 GRD 80 100
  Pin Default 0x90170130: [Fixed] Speaker at Int N/A
    Conn = Analog, Color = Unknown
    DefAssociation = 0x3, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x40: OUT VREF_HIZ
  Unsolicited: tag=00, enabled=0
  Power states:  D0 D1 D2 D3 EPSS
  Power: setting=D0, actual=D0
  Connection: 3
     0x0c 0x0d 0x0e*
Comment 15 ezstyles88 2015-11-01 22:27:36 UTC
Here is AlsaInfo after retasking HP

http://www.alsa-project.org/db/?f=c0300c2cf39b579b534efc732e479f28ee92c72f

Running speaker-test -c4 -t wav -D hw:1,0

I hear Rear Right and Rear Left.
Comment 16 Raymond 2015-11-02 01:18:42 UTC
your internal speaker and subeoofer are connected to same audio output after you added the headphone pins

itis a bug of driver in support 4 channels based on the number of speaker pins



[   41.349012] snd_hda_codec_realtek hdaudioC1D0: autoconfig for ALC668: line_outs=1 (0x15/0x0/0x0/0x0/0x0) type:line
[   41.349016] snd_hda_codec_realtek hdaudioC1D0:    speaker_outs=2 (0x14/0x1a/0x0/0x0/0x0)
[   41.349017] snd_hda_codec_realtek hdaudioC1D0:    hp_outs=1 (0x16/0x0/0x0/0x0/0x0)
[   41.349018] snd_hda_codec_realtek hdaudioC1D0:    mono: mono_out=0x0
[   41.349019] snd_hda_codec_realtek hdaudioC1D0:    dig-out=0x1e/0x0
[   41.349020] snd_hda_codec_realtek hdaudioC1D0:    inputs:
[   41.349021] snd_hda_codec_realtek hdaudioC1D0:      Mic=0x18
[   41.349022] snd_hda_codec_realtek hdaudioC1D0:      Internal Mic=0x12
Comment 17 Raymond 2015-11-06 11:16:04 UTC
fix max channel which depend on number of unique DAC instead of number of speaker pins



diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index c6e8a65..9323886 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -4757,6 +4757,22 @@ void snd_hda_gen_stream_pm(struct hda_codec *codec, hda_nid_t nid, bool on)
 }
 EXPORT_SYMBOL_GPL(snd_hda_gen_stream_pm);
 
+int extra_out_unique_dacs(struct hda_gen_spec *spec, int num_out)
+{
+    int i, j, num;
+    bool unique;
+    num = 0;
+    for (i=0; i < num_out; i++) {
+        unique = true;
+        for (j=0; j<num; j++)
+            if (spec->multiout.extra_out_nid[j] == spec->multiout.extra_out_nid[i])
+                unique = false;
+        if (unique) 
+            num++;
+    }
+    return num;
+}
+
 /**
  * snd_hda_gen_parse_auto_config - Parse the given BIOS configuration and
  * set up the hda_gen_spec
@@ -4848,7 +4864,7 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec,
     /* check the multiple speaker and headphone pins */
     if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
         spec->const_channel_count = max(spec->const_channel_count,
-                        cfg->speaker_outs * 2);
+                extra_out_unique_dacs(spec, cfg->speaker_outs) * 2);
     if (cfg->line_out_type != AUTO_PIN_HP_OUT)
         spec->const_channel_count = max(spec->const_channel_count,
                         cfg->hp_outs * 2);
Comment 18 Raymond 2015-11-06 11:22:39 UTC
if HP and Line Out are at same location, put both jacks at cfg->line_outs or cfg->hp_outs for support multi channels



diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c
index 7f57a14..f3631aa 100644
--- a/sound/pci/hda/hda_auto_parser.c
+++ b/sound/pci/hda/hda_auto_parser.c
@@ -367,7 +367,21 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
             cfg->line_out_type = AUTO_PIN_HP_OUT;
 
     }
-
+
+    if ((cfg->hp_outs == cfg->line_outs) && (cfg->hp_outs == 1)) {
+        if ( get_defcfg_location(snd_hda_codec_get_pincfg(codec, cfg->hp_pins[0])) == 
+            get_defcfg_location(snd_hda_codec_get_pincfg(codec, cfg->line_out_pins[0]))) {
+/*
+            hp_out[1] = line_out[0];
+            cfg->hp_outs++;
+            cfg->line_outs = 0;
+*/
+            line_out[1] = hp_out[0];
+            cfg->line_outs++;
+            cfg->hp_outs = 0;
+        }
+    }
+
     /* sort by sequence */
     sort_pins_by_sequence(cfg->line_out_pins, line_out, cfg->line_outs);
     sort_pins_by_sequence(cfg->speaker_pins, speaker_out,
Comment 19 Raymond 2015-11-06 11:52:14 UTC
to ensure bass speaker volume control, assign specific DAC for the subwoofer node 0x1a


static hda_nid_t preferred_pairs[] = {
		0x2, 0x1a,
		0
	};

	spec->gen.preferred_dacs = preferred_pairs;
Comment 20 Håvard Skjetne Lilleheie 2018-10-10 10:06:17 UTC
Hi!

The issue with the heaphone jack not working seems to be related to the BIOS not reporting pin 0x16 as a headphone jack.

We have commited a patch to fix this that will hopefully reach the 4.20 kernel.
http://mailman.alsa-project.org/pipermail/alsa-devel/2018-October/140818.html

This issue seems similar to this one:
https://bugzilla.kernel.org/show_bug.cgi?id=190681

Thank you!