Bug 66621 - Line in and Mic on HDA + AD1986A on Asus M2NPV-VM shorted
Line in and Mic on HDA + AD1986A on Asus M2NPV-VM shorted
Status: NEEDINFO
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA)
x86-64 Linux
: P1 normal
Assigned To: Jaroslav Kysela
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-05 14:59 UTC by William
Modified: 2014-02-07 02:15 UTC (History)
2 users (show)

See Also:
Kernel Version: 3.12.0
Tree: Mainline
Regression: Yes


Attachments
amixer output under 3.11.7 (4.63 KB, text/plain)
2013-12-05 14:59 UTC, William
Details
Alsa info for kernal 3.11.7 (30.53 KB, text/plain)
2013-12-05 17:16 UTC, William
Details
Alsa info for kernel 3.12.0 (26.62 KB, application/octet-stream)
2013-12-05 17:18 UTC, William
Details
Alsa info for kernel 3.12.0 - (corrected type) (26.62 KB, text/plain)
2013-12-05 17:29 UTC, William
Details
Alsa info for kernel 3.13-rc2 (28.75 KB, text/plain)
2013-12-05 19:13 UTC, William
Details
Fix patch #1 on 3.13-rc3 (3.71 KB, patch)
2013-12-10 16:49 UTC, Takashi Iwai
Details | Diff
Fix patch #2 on 3.13-rc3 (1.81 KB, patch)
2013-12-10 16:49 UTC, Takashi Iwai
Details | Diff
alsa-info.txt-SL14.1-3.11.9 no line in. (30.20 KB, text/plain)
2013-12-13 13:02 UTC, William
Details
alsa-info.txt-SL14.1-3.13-rc3-plain no line in (28.58 KB, application/octet-stream)
2013-12-13 13:03 UTC, William
Details
alsa-info.txt-SL14.1-3.13-rc3+patches no line in (28.48 KB, application/octet-stream)
2013-12-13 13:04 UTC, William
Details
fix pin for ad1986a 3stack (736 bytes, patch)
2013-12-14 13:17 UTC, Raymond
Details | Diff
alsa-info.txt-SL14.1-3.13-rc3-plain with modified user_pins (30.83 KB, text/plain)
2013-12-14 20:57 UTC, William
Details
perform impedance measurement of the jacks (1.49 KB, text/plain)
2013-12-16 14:20 UTC, Raymond
Details
hda_jack_sense_test.py (1.50 KB, text/plain)
2013-12-17 03:22 UTC, Raymond
Details
alsa-info (29.68 KB, text/plain)
2013-12-21 21:05 UTC, William
Details
alsa-info.txt-SL14.1-3.13-rc4-plain with early patching ad1986a.fw.001 (30.69 KB, text/plain)
2013-12-22 21:19 UTC, William
Details
Patch to correct 3stack pin configs (1.23 KB, patch)
2014-01-07 17:20 UTC, Takashi Iwai
Details | Diff
Patch to avoid the duplicated loopback controls (1.71 KB, patch)
2014-01-07 17:21 UTC, Takashi Iwai
Details | Diff
alsa-info.txt for SL14.1, with 3.13-rc7+ two patches from attachments 121221, 121231 (30.06 KB, text/plain)
2014-01-08 19:35 UTC, William
Details
alsa-info for SL14.1 with 3.14-rc1-1 (29.89 KB, text/plain)
2014-02-04 20:22 UTC, William
Details

Description William 2013-12-05 14:59:26 UTC
Created attachment 117601 [details]
amixer output under 3.11.7

Alsa Line in and Mic on HDA + AD1986A failed under 3.12.0 onwards

------------------------------------

Hardware Asus M2NPV-VM with HDA + AD1986A with 3 rear panel jacks
- "Line In", "Line out", "Mic" (+headphone, mic on front).

For all versions I am using "options snd-hda-intel model=3stack"

First noticed under Slackware-14.0 when I changed from kernel 3.11.7
to kernel 3.12.0.

------------------------------------

Under Slackware-14.1 but with kernel 3.12.1 + two patches from bug
id 64971 had these results :-

no "line in"
no "mic"
The line in, mic are there but no mute or gain control and no signal.
It actually physically short "line in" and "mic" [the device driving
the input recovers when the jack is pulled out].

no "cd"
The "cd" is there but no mute or gain control and nothing heard playback,
but can capture from "cd" OK.

Can work around the CD with "mplayer cdda://", but have no work around for
"line in" and "mic".

Pcm, Beep Ok

Initially no headphone output .... until I enabled "loopback mix" then ok.

Initially no "Stereo Mix" ... To get "Stereo mixer" I did :-

hw_device=/sys/devices/pci0000:00/0000:00:10.1/sound/card0/hwC0D0
echo "add_stereo_mix_input=true" > ${hw_device}/hints
echo "1"                         > ${hw_device}/reconfig

And then can capture PCM (and even "beep") ok.

------------------------------

Re-tested under Slackware-14.1 but with kernel 3.13-rc2 :-

CD input now works ok.

Pcm, Beep Ok

Again no headphone output until "loopback mix" is enabled - then OK

Again need to do the "add_stereo_mix_input" workaround.

The line in, mic are there and are now complete with mute and gain controls.
But again there is a physical short on "line in" and "mic" - so these
inputs are still unusable.
Comment 1 William 2013-12-05 15:01:51 UTC
amixer output under 3.13-rc2 after hints workaround :-

Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 31
  Mono: Playback 19 [61%] [-18.00dB] [on]
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 31 [100%] [0.00dB] [on]
  Front Right: Playback 31 [100%] [0.00dB] [on]
Simple mixer control 'PCM',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 255
  Mono:
  Front Left: Playback 195 [76%] [-12.00dB]
  Front Right: Playback 195 [76%] [-12.00dB]
Simple mixer control 'Front',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 31 [100%] [0.00dB] [on]
  Front Right: Playback 31 [100%] [0.00dB] [on]
Simple mixer control 'Center',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 31
  Mono: Playback 31 [100%] [0.00dB] [on]
Simple mixer control 'LFE',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 31
  Mono: Playback 31 [100%] [0.00dB] [on]
Simple mixer control 'Line',0
  Capabilities: pvolume pswitch cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Playback channels: Front Left - Front Right
  Capture channels: Mono
  Limits: Playback 0 - 31
  Mono: Capture [off]
  Front Left: Playback 0 [0%] [-34.50dB] [off]
  Front Right: Playback 0 [0%] [-34.50dB] [off]
Simple mixer control 'CD',0
  Capabilities: pvolume pswitch cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Playback channels: Front Left - Front Right
  Capture channels: Mono
  Limits: Playback 0 - 31
  Mono: Capture [off]
  Front Left: Playback 27 [87%] [6.00dB] [on]
  Front Right: Playback 27 [87%] [6.00dB] [on]
Simple mixer control 'Mic',0
  Capabilities: pvolume pswitch cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Playback channels: Front Left - Front Right
  Capture channels: Mono
  Limits: Playback 0 - 31
  Mono: Capture [off]
  Front Left: Playback 0 [0%] [-34.50dB] [off]
  Front Right: Playback 0 [0%] [-34.50dB] [off]
Simple mixer control 'Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]
Simple mixer control 'IEC958',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'IEC958 Default PCM',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Beep',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 15
  Mono: Playback 8 [53%] [-21.00dB] [on]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 15
  Front Left: Capture 1 [7%] [1.50dB] [on]
  Front Right: Capture 1 [7%] [1.50dB] [on]
Simple mixer control 'Auto-Mute Mode',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Enabled'
Simple mixer control 'Digital',0
  Capabilities: cvolume
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 120
  Front Left: Capture 56 [47%] [-2.00dB]
  Front Right: Capture 56 [47%] [-2.00dB]
Simple mixer control 'Independent HP',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Disabled'
Simple mixer control 'Loopback Mixing',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Disabled'
Simple mixer control 'Stereo Mix',0
  Capabilities: cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Capture channels: Mono
  Mono: Capture [on]
Comment 2 Takashi Iwai 2013-12-05 15:12:13 UTC
The fact that you had to use the model option was already a problem.  This should have been reported earlier.

In anyway, please give alsa-info.sh outputs on both 3.11 and 3.12 kernels.

The lack of analog loopback mixer elements was already fixed in the upstream 3.13-rc2.  The patch will be backported to the upcoming 3.12.y stable kernel, too.  So, if your interest is about that, try 3.13-rc2.
Comment 3 William 2013-12-05 17:16:14 UTC
Created attachment 117611 [details]
Alsa info for kernal 3.11.7
Comment 4 William 2013-12-05 17:18:05 UTC
Created attachment 117621 [details]
Alsa info for kernel 3.12.0
Comment 5 William 2013-12-05 17:29:14 UTC
Created attachment 117631 [details]
Alsa info for kernel 3.12.0 - (corrected type)
Comment 6 Takashi Iwai 2013-12-05 17:36:49 UTC
And is your request about the lack of loopback mixer elements?  If so, it was already fixed in the upstream code.  Give it a try.
Comment 7 William 2013-12-05 19:13:43 UTC
Created attachment 117661 [details]
Alsa info for kernel 3.13-rc2
Comment 8 William 2013-12-05 19:27:08 UTC
Yes 3.13-rc2 is an improvement on 3.12.2 but not fully fixed.

Although the mixer controls look acceptable under 3.13-rc2
the "Line in" and "Mic" inputs are still shorted. For example
when I plug the output of a radio into the "line in", the 
radio itself goes silent.

Also still need to do the add_stereo_mix_input hint thing to
get the mixer loopback capture control.This features simply
worked prior to 3.12.0.
Comment 9 Takashi Iwai 2013-12-05 20:17:00 UTC
The loopback mixer can be turned on/off now via "Loopback Mixing" mixer switch.
Maybe this is still off on your machine.

This is set OFF as default, and it might be confusing for AD codec users.  I'm going to make it ON as default for AD codecs later.

The stereo-mix feature is just a matter to align with other codec drivers.
Now AD codecs are using the very same code base.
Comment 10 William 2013-12-06 21:52:34 UTC
Just checked through the "line in" and "mic" a bit more.
When I said "inputs are shorted" I should say :- 

  The "Rear panel line in" and "Rear panel mic" inputs are very low impedance
  when the PC is first powered up before Linux has booted. In this state any
  external device (eg radio) connected to them may itself be very muted.

  When an "older" kernel up to and including 3.11.9 is booted these two inputs
  appear go to a higher impedance and, any device connected to them then
  operates normally, and these inputs (with suitable mixer settings) can be,
  heard through the rear panel line-out and/or front panel headphone sockets,
  and/or captured.

  When kernel 3.12.x or 3.13-rc2 is booted these two inputs remain in the
  very low impedance state and no playback/capture of them is possible.
  As these two are [in principle] multipurpose jacks I also checked that
  there is no detectable audio output or DC bias from them. (I'm not
  interested in the 5.1 - though others may be - 2 channel stereo is
  enough for me).

  The front panel mic input works ok under all the kernels mentioned.

  [Just as an aside - the AD1986A's rear panel "line out" socket is also
  designed to drive headphones if required, and I can confirm this works ok].

  The only BIOS sound settings are an HDA enable/disable and MIDI port,IRQ
  settings.
Comment 11 Takashi Iwai 2013-12-07 09:13:31 UTC
OK, understood.  The mixer controls for VREF setups appear when add_jack_modes=1 hint is given.  Maybe I can enable this back automatically for AD codecs when the machine is no standard laptop style.

The multi-channel setup doesn't always work on AD1986A depending on the pin assignment because of half-fixed wiring of AD1986A codec.  I'm going to implement a workaround later.
Comment 12 William 2013-12-07 20:49:10 UTC
First something I failed to notice yesterday. When booted up in 3.12.x or
3.13-rc2 with just the defaults. Plug in a front panel mic, and mic controls
work as expected ..but... if "Line in" gain is changed then it too starts to
affect the microphone gain and likewise from then on "Line in" mute affects
the microphone. ie effective_mic_gain = boost + mic_gain + line_in_gain
                                        + front_gain + master_gain

On repeating with 3.13-rc3 I got much the same result - except that I had to
enable "Loopback Mixing" in order to hear anything.

          -------

I tried your suggested hint and then a few other likely looking ones under
3.13-rc2. The only one which improved the rear panel "line in" and "mic"
problem was "inv_jack_detect=1" which removed the low impedance condition
from the rear panel "line in", "mic" sockets. However I could still not get
any playback/capture from "line in" or rear "mic".

On repeating with 3.13-rc3 "inv_jack_detect=1" had no apparent effect.
Comment 13 Takashi Iwai 2013-12-10 16:48:52 UTC
Could you try two patches below on top of 3.13-rc3?  The "Loopback Mixing" should disappear now and it's always used.

The requirement of inv_jack_detect is still a question.  At least, normal AD1986A implementation shouldn't need it.  Maybe there is some broken revision (e.g. Lenovo N100 has such a chip), and if this option is needed on yours, too, I'd like to add it statically.
Comment 14 Takashi Iwai 2013-12-10 16:49:07 UTC
Created attachment 117991 [details]
Fix patch #1 on 3.13-rc3
Comment 15 Takashi Iwai 2013-12-10 16:49:20 UTC
Created attachment 118001 [details]
Fix patch #2 on 3.13-rc3
Comment 16 Raymond 2013-12-11 10:02:06 UTC
channel mode still missing 

it is a bug of the fixup to add surround/clfe to motherboard with 3 audio jacks at rear panel 

+ [AD1986A_FIXUP_3STACK] = {
+ .type = HDA_FIXUP_PINS,
+ .v.pins = (const struct hda_pintbl[]) {
+ { 0x1a, 0x02214021 }, /* headphone */
+ { 0x1b, 0x01014011 }, /* front */
+ { 0x1c, 0x01013012 }, /* surround */
+ { 0x1d, 0x01019015 }, /* clfe */
+ { 0x1e, 0x411111f0 }, /* N/A */
+ { 0x1f, 0x02a190f0 }, /* mic */
+ { 0x20, 0x018130f0 }, /* line-in */
+ {}
+ },
+ },

 static const struct snd_pci_quirk ad1986a_fixup_tbl[] = {
+ SND_PCI_QUIRK_MASK(0x1043, 0xff00, 0x8100, "ASUS P5", AD1986A_FIXUP_3STACK),
Comment 17 Takashi Iwai 2013-12-11 10:04:38 UTC
Please submit a patch in a standard procedure.
Comment 18 William 2013-12-11 11:21:14 UTC
RE Comment 13, 14, 15
Thanks - I tried 3.13-rc3 with your two alsa patches (attachments 117991
and 118001) :-

  I got the same result as with plain 3.13-rc3 - except to confirm that
  now "Loopback Mixing" is no longer needed and is gone.

        -------

Just to clarify / correct the effect of line_in controls on front panel
mic (this applies to 3.12.x and 3.13-rc3 plain and patched) :-

  The effect of line_in_mute on mic lasts until the mic_mute is cycled
  off and then back on again. Likewise the effect of line_in_gain on mic is
  real but can be cancelled by waggling mic_gain a bit".
Comment 19 Raymond 2013-12-12 00:58:41 UTC
if it works well with previous static config, 

0x1c and 0x1d are those retaskable pins in auto parser

there difference are those line in selector , mic selector and MIC_1/2 Swap nodes

static const struct hda_verb ad1986a_ch2_init[] = {
	/* Surround out -> Line In */
	{ 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
 	/* Line-in selectors */
	{ 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
	/* CLFE -> Mic in */
	{ 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
	/* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
	{ 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
	{ } /* end */
};

static const struct hda_verb ad1986a_ch4_init[] = {
	/* Surround out -> Surround */
	{ 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
	{ 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
	/* CLFE -> Mic in */
	{ 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
	{ 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
	{ } /* end */
};

static const struct hda_verb ad1986a_ch6_init[] = {
	/* Surround out -> Surround out */
	{ 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
	{ 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
	/* CLFE -> CLFE */
	{ 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
	{ 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
	{ } /* end */
};


0x0F Microphone Selector
Chooses the microphone inputs between the MIC_1/2 and
C/LFE pins. Contains the microphone gain boost amplifier.

0x10 Line In selector
Chooses the line in inputs between the line in, surround and
MIC_1/2 pins.

node 0x11 MIC_1/2 Swap
Swaps the left/right association of MIC_1/2 on the input pins
only. Allows up mix, spreading one microphone to both left
and right output channels.

Node 0x0f [Audio Selector] wcaps 0x30010d: Stereo Amp-Out
  Control: name="Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-Out vals:  [0x00 0x00]
  Connection: 8
     0x1f* 0x20 0x1d 0x1d 0x27 0x28 0x29 0x2a
Node 0x10 [Audio Selector] wcaps 0x300101: Stereo
  Connection: 3
     0x20* 0x1c 0x1f
Node 0x11 [Audio Selector] wcaps 0x300941: Stereo R/L
  Connection: 2
     0x0f* 0x2b
  Processing caps: benign=0, ncoeff=0
Comment 20 Raymond 2013-12-12 01:22:04 UTC
do jack detection works ? 

did you obtain alsa-info after you plugged "Line in" ?

	control.29 {
		iface CARD
		name 'Mic Jack'
		value false
		comment {
			access read
			type BOOLEAN
			count 1
		}
	}
	control.30 {
		iface CARD
		name 'Line Jack'
		value false
		comment {
			access read
			type BOOLEAN
			count 1
		}
	}
	control.32 {
		iface CARD
		name 'Line Out Front Jack'
		value true
		comment {
			access read
			type BOOLEAN
			count 1
		}
	}
	control.33 {
		iface CARD
		name 'Line Out Surround Jack'
		value false
		comment {
			access read
			type BOOLEAN
			count 1
		}
	}
	control.34 {
		iface CARD
		name 'Line Out CLFE Jack'
		value false
		comment {
			access read
			type BOOLEAN
			count 1
		}
	}
	control.35 {
		iface CARD
		name 'Front Headphone Jack'
		value false
		comment {
			access read
			type BOOLEAN
			count 1
		}
	}
Comment 21 Raymond 2013-12-12 03:43:22 UTC
eem missing rear mic for 5.1 support 

you have to verify all pin complexes with pincap DETECT by using hda-verb GET_PIN_SENSE

the driver require three pins at same location


/sys/class/sound/hwC0D0/init_pin_configs:
0x1a 0x02214021
0x1b 0x01014011  <---- Line Out at Ext Rear
0x1c 0x01013012
0x1d 0x01019015
0x1e 0x501700f0
0x1f 0x02a190f0  <---- Mic at Ext Front
0x20 0x018130f0  <---- Line in at Ext Rear
0x21 0x509700f0
0x22 0x993310f0
0x23 0x50b700f0
0x24 0x90f700f0
0x25 0x014510f0
Comment 22 Raymond 2013-12-12 08:06:11 UTC
the front mic and rear mic 

https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/?id=1aba2bc32144ed13f1c0e581471fe943e738ff42

[ALSA] hda-codec - Fix front/rear mic inputs on AD1986A codec
Fix the front/rear mic inputs on ASUS M2NPV-VM board with AD1986A codec chip (3stack model).

 /* additional verbs for 3-stack model */
static struct hda_verb ad1986a_3st_init_verbs[] = {
- /* Mic and line-in selectors */
- {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
+ /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
+ {0x0f, AC_VERB_SET_CONNECT_SEL, 0x4},
+ /* Line-in selectors */
{0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
{ } /* end */
};
Comment 23 William 2013-12-13 13:02:20 UTC
Created attachment 118251 [details]
alsa-info.txt-SL14.1-3.11.9  no line in.
Comment 24 William 2013-12-13 13:03:43 UTC
Created attachment 118261 [details]
alsa-info.txt-SL14.1-3.13-rc3-plain no line in
Comment 25 William 2013-12-13 13:04:56 UTC
Created attachment 118271 [details]
alsa-info.txt-SL14.1-3.13-rc3+patches no line in
Comment 26 William 2013-12-13 13:12:39 UTC
RE comments 19-22 :-

I re-tested with initially just the rear panel line out and front panel
headphone plugged in (see attached info's comment 23-25).

For 3.11.9 there was no difference in info output when the rear panel
line in was plugged in.

For 3.13-rc3 plain and patched there was one difference in
info output when the rear panel line in was plugged in :-

        control.34 {
                iface CARD
                name 'Line Out CLFE Jack'
                value false       // Changes to true when line in plugged in
                comment {
                        access read
                        type BOOLEAN
                        count 1
                }
Comment 27 Raymond 2013-12-14 01:00:17 UTC
http://git.alsa-project.org/?p=alsa-tools.git;a=blob;f=hda-verb/README;hb=HEAD


you have to use hda-verb 


sudo hda-verb /dev/snd/hwC0D0 0x1c GET_PIN_SENSE 0


the value return 0x80000000 when line in jack is plugged in and return 0 when line in jack is unplugged if node 0x1c is Line in jack


the node of the three input jacks(front mic, rear mic and line in) must be verify 

do you have a HDA front audio panel support jack detection ?

do plug-in of headphone automute Line out or speaker ?

Like AC97, it only has one Mic Boost volume for mic1 and mic2 ) 


once you found the five audio jacks

you have to fix the pin fixup of AD1986A_FIXUP_3STACK in patch_analog.c

or 

use hdajackretask to overwrite the jack and remove those redudant pins by retask it as  0x411111f0 [N/A]


http://git.alsa-project.org/?p=alsa-tools.git;a=blob;f=hdajackretask/README;hb=HEAD
Comment 28 Raymond 2013-12-14 02:06:34 UTC

refer to ad1986a data sheet

0x1C Surround Out
SURROUND pin drivers. Contains the output amplifier for
surround gain control. Supports multitasking as either the
surround outputs or can be configured as the LINE_IN inputs.


0x1D C/LFE Out
C/LFE pin drivers. Contains the output amplifier for C/LFE
gain control. Supports the left/right channel swap function.
Supports multitasking as either the C/LFE outputs or can be
configured as the MIC1/2 inputs. Supports microphone bias
(VREF_OUT).

0x1F MIC_1/2 In
MIC_1/2 IN pin driver. Can be configured as a microphone or
Line_In input.

0x20 Line In
LINE_IN pin driver. Can be configured as a Line_In or
microphone input.





0x27 MIC / C/LFE Mixer
Mixes the MIC1/2_IN and C/LFE input signals together to
support simultaneous microphones on front and rear panels.
Multiple microphones do not have individual gain controls.

0x28 MIC / Line In Mixer
Mixes the MIC1/2_IN and LINE_IN input signals together to
support simultaneous microphones on front and rear panels.
Multiple microphones do not have individual gain controls.

0x29 C/LFE / Line In Mixer
Mixes the C/LFE and LINE_IN input signals together to
support simultaneous microphones on front and rear panels.
Multiple microphones do not have individual gain controls.

0x2A MIC/Line In/C/LFE Mixer
Mixes the MIC1/2_IN, LINE_IN and C/LFE input signals to
support simultaneous microphones on front and rear panels.
Multiple microphones do not have individual gain controls.

0x2B MIC_1/2 Mixer
Mixes the left and right channels of the selected microphone
input into a mono stream. This signal drives both the left and
right channels of the following circuitry. Used to mix two
mono microphones on separate jacks. Left and right
microphones can be programmed with separate gain boost
(0 dB, 10 dB, 20 dB, or 30 dB), but do not have any other gain
or mute controls.
Comment 29 Raymond 2013-12-14 03:38:15 UTC
https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/pci/hda/patch_analog.c?id=632408adfe70be6706cb89522b0d5b3dce188d84

- HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
- HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
- HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
- HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
- HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT),


0x0F Microphone Selector
Chooses the microphone inputs between the MIC_1/2 and
C/LFE pins. Contains the microphone gain boost amplifier.


0x13 Microphone MixAmp 
The microphone amplifier input to the analog mixer.


0x17 Line In MixAmp 
The line in amplifier input to the analog mixer.
Comment 30 Raymond 2013-12-14 13:17:29 UTC
Created attachment 118361 [details]
fix pin for ad1986a 3stack

only fix pincfg of 3stack model for ad1986a

still need other fixup of the single mic boost and mic playback volume controls
Comment 31 William 2013-12-14 14:10:01 UTC
Result of the hda verb tests :-
################
# ## all unplugged
# hda-verb-0.4/hda-verb  /dev/snd/hwC0D0 0x1b GET_PIN_SENSE 0
nid = 0x1b, verb = 0xf09, param = 0x0
value = 0xab2c
# 
# ## Now with rear panel "line OUT" plugged in
# hda-verb-0.4/hda-verb  /dev/snd/hwC0D0 0x1b GET_PIN_SENSE 0
nid = 0x1b, verb = 0xf09, param = 0x0
value = 0x8000ab2c
#
# ## all unplugged
# hda-verb-0.4/hda-verb  /dev/snd/hwC0D0 0x1c GET_PIN_SENSE 0
nid = 0x1c, verb = 0xf09, param = 0x0
value = 0xfec7
# 
# ## now plug in rear panel "line IN"
# hda-verb-0.4/hda-verb  /dev/snd/hwC0D0 0x1c GET_PIN_SENSE 0
nid = 0x1c, verb = 0xf09, param = 0x0
value = 0x8000fec7
# 
# 
# ## all unplugged
# hda-verb-0.4/hda-verb  /dev/snd/hwC0D0 0x1d GET_PIN_SENSE 0
nid = 0x1d, verb = 0xf09, param = 0x0
value = 0x89c6
# 
# ## now plug in rear panel "mic"
# hda-verb-0.4/hda-verb  /dev/snd/hwC0D0 0x1d GET_PIN_SENSE 0
nid = 0x1d, verb = 0xf09, param = 0x0
value = 0x800089c6
################

I tried front panel mic and headphones with a range of nid's but
there were no value changes.  So, as far as I can see, there
is no front panel jack detection. That is possibly down to the
actual front panel sub assembly rather than the Asus M2NPV-VM
motherboard.

The front panel headphone socket and rear panel "line out"
act independently under all kernel versions. Plugging headphones
into the front panel headphone socket has no effect on "line out".
(which is ok by me).

As you say the front panel mic and rear panel mic are summed
and then go through common controls (that's the way it works
under kernels up to and including 3.11.9 - which is ok by me).


So have just the two multipurpose sockets which are on the
rear panel :-

Light blue  "Line in" / "Surround sound out"

Pink         "Mic in" / "Centre/LFE"

The lime coloured rear panel "line out" socket is (I assume)
not switched but can be thought of as "line out" or
as "Front Speakers of a 4 or 6 speaker set up".

-------------
When it gets to the patch_analog.c file I'm "out of my depth".
Comment 32 William 2013-12-14 17:02:37 UTC
Progress !
Thanks, those pins look promising. Created file pin-raymond-2-att-118361.txt :-

0x1a 0x02214021  /* headphone */
0x1b 0x01014011  /* front */
0x1c 0x01813030  /* line-in */
0x1d 0x01a19020  /* rear mic */
0x1e 0x411111f0  /* N/A */
0x1f 0x02a190f0  /* front mic */
0x20 0x411111f0  /* N/A */

Then running under 3.13-rc3 with two patches (att 117991, 118001) :-

hw_device=/sys/devices/pci0000:00/0000:00:10.1/sound/card0/hwC0D0
echo "1"                         > ${hw_device}/clear
cat ~wjf/alsa-info/pin-raymond-2-att-118361.txt |while read key val; do  echo "$key $val" > ${hw_device}/user_pin_configs; done
echo "add_stereo_mix_input=1"    > ${hw_device}/hints
echo "1"                         > ${hw_device}/reconfig

I now get a working rear panel "line in" and rear panel mic.

The only problem is that front mic does not work and that there are separate front an rear mic gain controls both of which affect the rear mic.

Should I be testing against plain 3.13-rc3 ?

[My cd drive is playing up so I'll have to sort that out before continuing].
Comment 33 William 2013-12-14 20:57:25 UTC
Created attachment 118471 [details]
alsa-info.txt-SL14.1-3.13-rc3-plain with modified user_pins
Comment 34 William 2013-12-14 21:03:25 UTC
More fully tested against 3.13-rc3 unpatched

Confirmed line in, cd, beep, pcm, and capture ok.

Only problem is as noted in comment 32 that front mic does not work and that there are separate front an rear mic gain controls both of which affect the rear mic.
Comment 35 Raymond 2013-12-15 00:28:54 UTC
seem bug in jack retasking since unsolcited event was still enabled after node 0x20 retasked as N/A if you are using dynamic configuration

/sys/class/sound/hwC0D0/user_pin_configs:
0x20 0x411111f0


Node 0x20 [Pin Complex] wcaps 0x400081: Stereo
  Pincap 0x00001727: IN Detect Trigger ImpSense
    Vref caps: HIZ 50 GRD 80
  Pin Default 0x018130f0: [Jack] Line In at Ext Rear
    Conn = 1/8, Color = Blue
    DefAssociation = 0xf, Sequence = 0x0
  Pin-ctls: 0x20: IN VREF_HIZ
  Unsolicited: tag=03, enabled=1
Comment 36 Raymond 2013-12-15 00:58:37 UTC


Node 0x12 [Audio Selector] wcaps 0x30010d: Stereo Amp-Out
  Control: name="Capture Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="Capture Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x00, nsteps=0x0f, stepsize=0x05, mute=1
  Amp-Out vals:  [0x04 0x04]
  Connection: 8
     0x11 0x22* 0x00 0x21 0x10 0x07 0x08 0x23

These two nodes support  R/L (swap of left and right channel)

Node 0x11 [Audio Selector] wcaps 0x300941: Stereo R/L
  Connection: 2
     0x0f* 0x2b

Center/LFE swapping supporting all vendor speakers

Node 0x1d [Pin Complex] wcaps 0x400985: Stereo Amp-Out R/L



-static const struct hda_input_mux ad1986a_capture_source = {
- .num_items = 7,
- .items = {
- { "Mic", 0x0 },
- { "CD", 0x1 },
- { "Aux", 0x3 },
- { "Line", 0x4 },
- { "Mix", 0x5 },
- { "Mono", 0x6 },
- { "Phone", 0x7 },
- },
-};




0x07 Analog Mixer   
Mixes analog input signals into line out audio.

0x08 Mono Mixer
Mixes the left/right channels from the analog mixer into a
mono signal.

0x09 Surround to Stereo Down Mix
Mixes 5.1 stereo to 4.0 or 2.0 on front channels
Comment 37 Raymond 2013-12-16 07:37:00 UTC
refer to Table 85. Microphone Selector

1 OMS[2:0] To select the alternate pins as a microphone source, see the OMS [2:0] bit (Register 0x74).
2 MMIX To mix the left/right MIC channels, see MMIX bit (Register 0x7A).
3 2CMIC For dual MIC recording, see 2CMIC bit (Register 0x76) to enable simultaneous recording into L/R channels.
4 MS To swap left/right MIC channels, see the MS bit (Register 0x20) for MIC_1/2 selection.
5 The MONO_OUT pin can be connected to the left channel of the microphone selector and is affected by these bits.


register 7a

OMS [2:0] Left Channel Selector
000 MIC pins Default
001 LINE_IN pins
01x C/LFE pins
100 Mix of MIC and C/LFE pins
101 Mix of MIC and LINE_IN pins
110 Mix of LINE_IN and C/LFE pins
111 Mix of MIC, LINE_IN and C/LFE pins

seem same as connection list of node 0x0f

Node 0x0f [Audio Selector] wcaps 0x30010d: Stereo Amp-Out
  Control: name="Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-Out vals:  [0x00 0x00]
  Connection: 8
     0x1f* 0x20 0x1d 0x1d 0x27 0x28 0x29 0x2a
Comment 38 Raymond 2013-12-16 14:20:33 UTC
Created attachment 118601 [details]
perform impedance measurement of the jacks

require hda-codec.py in alsa-tools/hda-analyser


your ad1986a also support ImpSense 


may need to adjust the sleep time to wait for the impedance measurement is steady
Comment 39 Raymond 2013-12-17 03:22:30 UTC
Created attachment 118731 [details]
hda_jack_sense_test.py
Comment 40 Raymond 2013-12-18 04:54:16 UTC
the previous 3stack model use 0x27 for mixing front mic and rear mic when select mic as capture source

> get 26
26 Capture Source:0
ITEM: 0:Mic, 1:CD, 2:Aux, 3:Line, 4:Mix, 5:Mono, 6:Phone, VAL: [CD]
> set 26 0
send: NID=0x12, VERB=0x701(set_connect_sel), PARM=0x0
> route 0x6
Pin[1d] -- Mix[27] -> Sel[0f] -> Sel[11] -> Sel[12] -> In [06]
Pin[1f] -- Mix[27] -> Sel[0f] -> Sel[11] -> Sel[12] -> In [06]


> set 26 3
send: NID=0x12, VERB=0x701(set_connect_sel), PARM=0x4
> route 0x6 
Pin[1c] -> Sel[10] -> Sel[12] -> In [06]

> set 26 4
send: NID=0x12, VERB=0x701(set_connect_sel), PARM=0x5
> route 0x6
Pin[1c] -> Sel[10] -> Sel[17] -- Mix[07] -> Sel[12] -> In [06]
Pin[22] -> Sel[15] -- Mix[07] -> Sel[12] -> In [06]
Pin[1d] -- Mix[27] -> Sel[0f] -> Sel[11] -> Sel[13] -- Mix[07] -> Sel[12] -> In [06]
Pin[1f] -- Mix[27] -> Sel[0f] -> Sel[11] -> Sel[13] -- Mix[07] -> Sel[12] -> In [06]
Out[05] -- Mix[09] -- Mix[07] -> Sel[12] -> In [06]
Out[04] -- Mix[09] -- Mix[07] -> Sel[12] -> In [06]
Out[03] -- Mix[07] -> Sel[12] -> In [06]

> set 26 5
send: NID=0x12, VERB=0x701(set_connect_sel), PARM=0x6
> route 0x6
Pin[1c] -> Sel[10] -> Sel[17] -- Mix[07] -- Mix[08] -> Sel[12] -> In [06]
Pin[22] -> Sel[15] -- Mix[07] -- Mix[08] -> Sel[12] -> In [06]
Pin[1d] -- Mix[27] -> Sel[0f] -> Sel[11] -> Sel[13] -- Mix[07] -- Mix[08] -> Sel[12] -> In [06]
Pin[1f] -- Mix[27] -> Sel[0f] -> Sel[11] -> Sel[13] -- Mix[07] -- Mix[08] -> Sel[12] -> In [06]
Out[05] -- Mix[09] -- Mix[07] -- Mix[08] -> Sel[12] -> In [06]
Out[04] -- Mix[09] -- Mix[07] -- Mix[08] -> Sel[12] -> In [06]
Out[03] -- Mix[07] -- Mix[08] -> Sel[12] -> In [06]
Comment 41 William 2013-12-18 12:28:46 UTC
Re comment 38 as amended by comment 39 :-

Took hda_jack_sense_test.py From bug id 66621 attachment 118731 [details]
Using hda_codec.py from hda-analyzer alsa-5bcf62d of 2013-05-30.
Using Python 2.7.5

Tested with kernels 3.11.9 and 3.13-rc4 with no patches.

Plugged in tests are with, all 3 rear, and both front jacks plugged in
with (fairly) suitable devices (I have a shortage of mikes).

::::::::::::::
hda_jack_sense_log-3.11.9-unplugged
::::::::::::::
Pin 0x1a [Jack] HP Out Ext at Front (Green) [] : PD=0 Imp=18848
Pin 0x1b [Jack] Line Out Ext at Rear (Green) [] : PD=0 Imp=34720
Pin 0x1c [Jack] Line Out Ext at Rear (Blue) [] : PD=0 Imp=24800
Pin 0x1d [Jack] Line Out Ext at Rear (Pink) [] : PD=0 Imp=2800
Pin 0x1e [N/A] Speaker Int at N/A (Unknown) [] :         
Pin 0x1f [Jack] Mic Ext at Front (Pink) [] : PD=0 Imp=2900
Pin 0x20 [Jack] Line In Ext at Rear (Blue) [] : PD=0 Imp=14880
Pin 0x21 [N/A] Aux Int at N/A (Unknown) [] : PD=0 Imp=62496
Pin 0x22 [Fixed] CD Int at ATAPI (Black) [] :         
Pin 0x23 [N/A] Telephony Int at N/A (Unknown) [] :         
Pin 0x24 [Fixed] Other Int at N/A (Unknown) [] :         
Pin 0x25 [Jack] SPDIF Out Ext at Rear (Black) [] :         
::::::::::::::

hda_jack_sense_log-3.11.9-plugged-in-all
::::::::::::::
Pin 0x1a [Jack] HP Out Ext at Front (Green) [] : PD=0 Imp=120
Pin 0x1b [Jack] Line Out Ext at Rear (Green) [] : PD=1 Imp=23808
Pin 0x1c [Jack] Line Out Ext at Rear (Blue) [] : PD=1 Imp=2400
Pin 0x1d [Jack] Line Out Ext at Rear (Pink) [] : PD=1 Imp=100
Pin 0x1e [N/A] Speaker Int at N/A (Unknown) [] :         
Pin 0x1f [Jack] Mic Ext at Front (Pink) [] : PD=0 Imp=62
Pin 0x20 [Jack] Line In Ext at Rear (Blue) [] : PD=0 Imp=13888
Pin 0x21 [N/A] Aux Int at N/A (Unknown) [] : PD=0 Imp=62496
Pin 0x22 [Fixed] CD Int at ATAPI (Black) [] :         
Pin 0x23 [N/A] Telephony Int at N/A (Unknown) [] :         
Pin 0x24 [Fixed] Other Int at N/A (Unknown) [] :         
Pin 0x25 [Jack] SPDIF Out Ext at Rear (Black) [] :         
::::::::::::::

hda_jack_sense_log-3.13-rc4-plain-unplugged
::::::::::::::
Pin 0x1a [Jack] HP Out Ext at Front (Green) [] : PD=0 Imp=18848
Pin 0x1b [Jack] Line Out Ext at Rear (Green) [] : PD=0 Imp=34720
Pin 0x1c [Jack] Line Out Ext at Rear (Blue) [] : PD=0 Imp=34720
Pin 0x1d [Jack] Line Out Ext at Rear (Pink) [] : PD=0 Imp=2900
Pin 0x1e [N/A] Speaker Int at N/A (Unknown) [] :         
Pin 0x1f [Jack] Mic Ext at Front (Pink) [] : PD=0 Imp=2900
Pin 0x20 [Jack] Line In Ext at Rear (Blue) [] : PD=0 Imp=62496
Pin 0x21 [N/A] Aux Int at N/A (Unknown) [] : PD=0 Imp=62496
Pin 0x22 [Fixed] CD Int at ATAPI (Black) [] :         
Pin 0x23 [N/A] Telephony Int at N/A (Unknown) [] :         
Pin 0x24 [Fixed] Other Int at N/A (Unknown) [] :         
Pin 0x25 [Jack] SPDIF Out Ext at Rear (Black) [] :         
::::::::::::::

hda_jack_sense_log-3.13-rc4-plain-plugged-in-all
::::::::::::::
Pin 0x1a [Jack] HP Out Ext at Front (Green) [] : PD=0 Imp=120
Pin 0x1b [Jack] Line Out Ext at Rear (Green) [] : PD=1 Imp=23808
Pin 0x1c [Jack] Line Out Ext at Rear (Blue) [] : PD=1 Imp=2400
Pin 0x1d [Jack] Line Out Ext at Rear (Pink) [] : PD=1 Imp=100
Pin 0x1e [N/A] Speaker Int at N/A (Unknown) [] :         
Pin 0x1f [Jack] Mic Ext at Front (Pink) [] : PD=0 Imp=63
Pin 0x20 [Jack] Line In Ext at Rear (Blue) [] : PD=0 Imp=62496
Pin 0x21 [N/A] Aux Int at N/A (Unknown) [] : PD=0 Imp=62496
Pin 0x22 [Fixed] CD Int at ATAPI (Black) [] :         
Pin 0x23 [N/A] Telephony Int at N/A (Unknown) [] :         
Pin 0x24 [Fixed] Other Int at N/A (Unknown) [] :         
Pin 0x25 [Jack] SPDIF Out Ext at Rear (Black) [] :         
::::::::::::::
Comment 42 Raymond 2013-12-19 07:15:45 UTC
http://mailman.alsa-project.org/pipermail/alsa-devel/2013-December/070280.html

the patch seem fix your problem in hda-emulator

 need to fix up those incorrect pins for those have hda front audio panel which support jack detection

		.v.pins = (const struct hda_pintbl[]) {
			{ 0x1c, 0x01813030 }, /* line-in */
			{ 0x1d, 0x01a19020 }, /* rear mic */
			{ 0x20, 0x411111f0 }, /* N/A */
			{}
		},

if the front audio panel does not support jack detection , need to set misc bit for the front panel jacks

0x1a 0x02214121  /* headphone */
0x1f 0x02a191f0  /* front mic */
Comment 43 Raymond 2013-12-19 12:46:57 UTC
Pin 0x1a [Jack] HP Out Ext at Front (Green) [] : PD=0 Imp=120
Pin 0x1f [Jack] Mic Ext at Front (Pink) [] : PD=0 Imp=63

have you check the front audio panel connector and your chassis specifcation
your front audio panel seem not support jack detection 

should hide the impendance measurement when pd=0



Pin 0x1b [Jack] Line Out Ext at Rear (Green) [] : PD=1 Imp=23808
Pin 0x1c [Jack] Line Out Ext at Rear (Blue) [] : PD=1 Imp=2400
Pin 0x1d [Jack] Line Out Ext at Rear (Pink) [] : PD=1 Imp=100


it is strange that the impedance of mic is lower than the others jack

0x1a should be the headphone jack if the headphone volume affect the headphone
0x1b should be the line out jack if the front volume affect the line out

speaker-test -c6 -t wav -Dhw:0,0 

0x1c and 0x1d should be line in and rear mic if surroun51 work when channel mode switch to 6ch 

the only issue is whether the front mic jack is really 0x1f ?
Comment 44 William 2013-12-20 21:06:42 UTC
Re comment 42 :-

Tried these user_pin_config values (with kernel 3.13-rc4) :-

0x1a 0x02214121  /* headphone */
0x1b 0x01014011  /* front */
0x1c 0x01813030  /* line-in */
0x1d 0x01a19020  /* rear mic */
0x1e 0x411111f0  /* N/A */
0x1f 0x02a191f0  /* front mic */
0x20 0x411111f0  /* N/A */

Similar result again. Rear panel ok except that front mic controls affect
rear mic operation.  Front panel mic and headphone do not work.

Output of hda_jack_sense_test.py with all unplugged :-

Pin 0x1a [Jack] HP Out Ext at Front (Green) [] : PD=0 Imp=18848
Pin 0x1b [Jack] Line Out Ext at Rear (Green) [] : PD=0 Imp=34720
Pin 0x1c [Jack] Line Out Ext at Rear (Blue) [] : PD=0 Imp=24800
Pin 0x1d [Jack] Line Out Ext at Rear (Pink) [] : PD=0 Imp=2800
Pin 0x1e [N/A] Speaker Int at N/A (Unknown) [] :         
Pin 0x1f [Jack] Mic Ext at Front (Pink) [] : PD=0 Imp=3000
Pin 0x20 [Jack] Line In Ext at Rear (Blue) [] : PD=0 Imp=13888
Pin 0x21 [N/A] Aux Int at N/A (Unknown) [] : PD=0 Imp=62496
Pin 0x22 [Fixed] CD Int at ATAPI (Black) [] :         
Pin 0x23 [N/A] Telephony Int at N/A (Unknown) [] :         
Pin 0x24 [Fixed] Other Int at N/A (Unknown) [] :         
Pin 0x25 [Jack] SPDIF Out Ext at Rear (Black) [] : 

------------

Re comment 43 :-

The header on the motherboard for front panel audio connection has 10 pins
Of these 10, only 9 are named in the board's manual, the other one is presumably
unused.  Of these 9 only 7 are used in the front panel cable - the
"presence#" and "sense send" are not connected. The ones connected are
port1L port1R port2R port2L gnd sense1_return sense2_return.
Comment 45 Raymond 2013-12-21 01:03:00 UTC
if bios setup did not have any option for you to select the front audio panel type : HDA or AC97

you need to set bit 8 of pin default of headphone (MISC=NO_PRESENCE)
which disable the creation of jack detection control of headphone and "auto mute mode" control



Simple mixer control 'Auto-Mute Mode',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Enabled'

automic is disabled when your have more than two pins to be used as input sources


the alternative is to use hint to disable all jacks detection 

jack_detect=0
Comment 46 Raymond 2013-12-21 03:56:00 UTC
>  Similar result again. Rear panel ok except that front mic controls affect
rear mic operation.  Front panel mic and headphone do not work.


can you post the output of alsa-info.sh ?

the patch seem fix the "rear mic boost" to "mic boost" only

Node 0x0f [Audio Selector] wcaps 0x30010d: Stereo Amp-Out
  Control: name="Mic Boost Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-Out vals:  [0x00 0x00]
  Connection: 8
     0x1f 0x20 0x1d* 0x1d 0x27 0x28 0x29 0x2a


the driver still create two playback volume controls and playback switches at node 0x13


Node 0x13 [Audio Selector] wcaps 0x30010d: Stereo Amp-Out
  Control: name="Rear Mic Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="Rear Mic Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="Front Mic Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="Front Mic Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-Out caps: ofs=0x17, nsteps=0x1f, stepsize=0x05, mute=1
  Amp-Out vals:  [0x80 0x80]
  Connection: 1
     0x11
Comment 47 William 2013-12-21 21:05:08 UTC
Created attachment 119211 [details]
alsa-info
Comment 48 William 2013-12-21 21:09:31 UTC
RE comments 45, 46

The BIOS has an "HDA Audio" enable/disable setting but if it is disabled
it disables the whole on board sound.

The motherboard manual says the board's front panel header can be used for
HDA/Azalia or AC97 front panels but recommends HDA. I think AC97 has a front
panel mic which is mono only. When it works the front panel mic on my PC is
definitely stereo.

--------------

With the previous pin settings (see comment 42) and 3.13-rc4, I tried
the "jack_detect=0" - now the front panel headphones work ok and the 3 rear
panel sockets ok but the front panel mic is still dead (and there is still
the weird interaction of the mic controls on the rear mic).

For this configuration alsa-info attached as attachment 119211 [details].
Comment 49 Raymond 2013-12-22 03:25:39 UTC
!!Module: snd_hda_intel
	patch : (null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)

you better use early patching to fix the pin and hints instead of dynamic reconfiguration since unsolicited event should be disabled after it is retasked as [N/A]

may be this bug force you to use jack-detect=0 since the controls are removed and recreated when using dynamic reconfigration


your motherboard also have midi/game port (enabled in bios setup) which you can load snd-mpu401 to connect external midi devices

Enhanced feature

Integrated parametric speaker equalizer
Stereo microphone with up to 30 dB gain boost
Jack sense with autotopology switching
Auto-down mix and channel spreading
Microphone-to-mono output for speakerphone
Stereo microphone pass-through to mixer
Built-in microphone/center/LFE/line-in sharing
Built-in SURROUND/LINE_IN sharing
Center/LFE swapping supporting all vendor speakers
Microphone left/right swapping


REDUCED SUPPORT COMPONENTS

Multiple Microphone Sourcing: 
The MIC_1/2, LINE_IN and C/LFE pins can all be selected as sources for
microphone input (boost amplifier).

Multiple VREF_OUT Pins: 
Each microphone-capable pin group (MIC_1/2, LINE_IN and C/LFE) has separate,
software controllable VREF_OUT pins, reducing the need for external biasing components.

Internal Microphone Mixing: 
Any combination of the MIC_1/2, LINE_IN and C/LFE pins can be summed to
produce the microphone input. This removes the need for external mixing components in applications that externally mix microphone sources.

Advanced Jack Presence Detection: 
Using two codec pins, eight resistors and isolated switch jacks, the AD1986A can
detect jack insertion on eight separate jacks.

Internal Microphone/Line In/C/LFE Sharing: 
On systems that share the microphone with the C/LFE jack no external components are required. The microphone selector can select the LINE_IN pins when the microphone and line input devices are swapped.

Internal Line In/Microphone/Surround Sharing: 
On systems that share the line in with the surround jack no external components are required.

you can use hda-analyzer to change R/L or connection of those connections 0xf, 0x11, 0x2b, ... in  Table 85. Microphone Selector and Figure 3. Microphone Selection/Mixing Block Diagram, Figure 1 Functional Block Diagram




loopback path: depth=5 :1d:0f:11:13:07
input path: depth=5 :1d:0f:11:12:06

loopback path: depth=5 :1f:0f:11:13:07
input path: depth=5 :1f:0f:11:12:06

loopback path: depth=4 :1c:10:17:07
input path: depth=4 :1c:10:12:06

loopback path: depth=3 :22:15:07
input path: depth=3 :22:12:06

input path: depth=3 :07:12:06
Comment 50 William 2013-12-22 21:19:55 UTC
Created attachment 119301 [details]
alsa-info.txt-SL14.1-3.13-rc4-plain with early patching ad1986a.fw.001
Comment 51 William 2013-12-22 21:22:41 UTC
RE Comment 49 :-

Yes "early patching" is an improvement in that jack_detect=0 is no longer
needed to make the headphones work. 

The rear panel mic is still dependent on the front mic controls and the
front panel mic still does not work.

For alsa-info see attachment 119301 [details]

Listing of /etc/modprobe.d/alsa.conf

options snd-hda-intel patch=ad1986a.fw

Listing of /lib/firmware/ad1986a.fw

[codec]
  0x11d41986 0x104381b3 0

[hint]
  add_stereo_mix_input=true

[pincfg]
  0x1a 0x02214121  /* headphone */
  0x1b 0x01014011  /* front */
  0x1c 0x01813030  /* line-in */
  0x1d 0x01a19020  /* rear mic */
  0x1e 0x411111f0  /* N/A */
  0x1f 0x02a191f0  /* front mic */
  0x20 0x411111f0  /* N/A */
Comment 52 Raymond 2014-01-06 09:49:05 UTC
the upmix function require ADI Specific verb


Table 46. ADI Specific Verb Support    


Processing State  

Get 0xF03 N/A (0)  Processing State 
Controls the up-mix function of the MIC_1/2 swap widget. Up-Mix will spread the selected left channel (see the left/right swap feature of the enable EAPD/BTL verb description) to both the left and right channel outputs of this stereo widget.       

Value Processing State Up-Mix Spreading       
0x00 Off Off       
0x01 Benign On       
0x02 Benign On  

Set 0x703 Processing State 8 N/A (0) 

Note that the AD1986 considers both on and benign states as benign. If the on state is set, the AD1986 will set and return the benign state
Comment 53 Raymond 2014-01-07 05:37:31 UTC
struct hda_gen_spec {

	hda_nid_t mixer_nid;		/* analog-mixer NID */
	hda_nid_t mixer_merge_nid;	/* aamix merge-point NID (optional) */
+	hda_nid_t swap_center_lfe_nid;  /* swap center lfe NID */
	const char *input_labels[HDA_MAX_NUM_INPUTS];


	unsigned int have_aamix_ctl:1;
	unsigned int hp_mic_jack_modes:1;
+	unsigned int swap_center_lfe:1;







static void set_pin_lrswap(struct hda_codec *codec, hda_nid_t nid, bool enable)
{
	if ((get_wcaps(codec, nid) & AC_WCAP_LR_SWAP) != AC_WCAP_LR_SWAP)
		return;
	snd_hda_codec_update_cache(codec, nid, 0,
				   AC_VERB_SET_EAPD_BTLENABLE,
				   enable ? AC_EAPDBTL_LR_SWAP : 0x00);
}

static int swap_center_lfe_info(struct snd_kcontrol *kcontrol,
			 struct snd_ctl_elem_info *uinfo)
{
	return snd_hda_enum_bool_helper_info(kcontrol, uinfo);
}

static int swap_center_lfe_get(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
	struct hda_gen_spec *spec = codec->spec;
	ucontrol->value.enumerated.item[0] = spec->swap_center_lfe;
	return 0;
}


static int swap_center_lfe_put(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
	struct hda_gen_spec *spec = codec->spec;
	unsigned int select = ucontrol->value.enumerated.item[0];
	int ret;
	ret = 0;
	if (select != spec->swap_center_lfe) {
		set_pin_lrswap(codec, spec->swap_center_lfe_nid, select);
		spec->swap_center_lfe = select;
		ret = 1;	
	}
	return ret;
}

static const struct snd_kcontrol_new swap_center_lfe_enum = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Swap Center/LFE Playback Switch",
	.info = swap_center_lfe_info,
	.get = swap_center_lfe_get,
	.put = swap_center_lfe_put,
};

static int create_swap_center_lfe_ctl(struct hda_codec *codec, struct nid_path *path)
{
	struct hda_gen_spec *spec = codec->spec;
	int i;
	for (i = path->depth - 1; i >= 0; i--) {
		if (get_wcaps(codec, path->path[i]) & AC_WCAP_LR_SWAP) {
			spec->swap_center_lfe_nid = path->path[i];
		}
	}
	if (!spec->swap_center_lfe_nid)
		return 0;
        if (!snd_hda_gen_add_kctl(spec, NULL, &swap_center_lfe_enum))
		return -ENOMEM;
	return 0;
}






static int create_multi_out_ctls(struct hda_codec *codec,
				 const struct auto_pin_cfg *cfg)
{


		name = get_line_out_pfx(codec, i, &index, NID_PATH_MUTE_CTL);
		if (!name || !strcmp(name, "CLFE")) {
			err = add_sw_ctl(codec, "Center", 0, 1, path);
			if (err < 0)
				return err;
			err = add_sw_ctl(codec, "LFE", 0, 2, path);
			if (err < 0)
				return err;
+			create_swap_center_lfe_ctl(codec, path);
Comment 54 Takashi Iwai 2014-01-07 17:19:49 UTC
OK, so the two patches below should fix major issues:

- correct pin configs for ASUS 3stack
- remove duplicated controls for front and rear mics

The control names will be still "Rear Mic" although they affect both front and rear mics.  This should be fixed later.

But, a remaining question is why the front mic doesn't work properly.
Do you mean that the recording from the front mic doesn't work although the analog-loopback works, or both recording and analog-loopback doesn't work?

Note that the analog loopback of front mic would work only when the front mic is selected as a capture source.  This is a limitation due to a strange design of this codec.

Try the two patches, then you can remove the pincfg section of early patching.  With the latest sound git tree, the add_stereo_mix_input hint can be removed, too.

If it's confirmed that the front mic still doesn't work (recording and/or loopback), please give alsa-info.sh output while testing the front mic.
Comment 55 Takashi Iwai 2014-01-07 17:20:41 UTC
Created attachment 121221 [details]
Patch to correct 3stack pin configs
Comment 56 Takashi Iwai 2014-01-07 17:21:08 UTC
Created attachment 121231 [details]
Patch to avoid the duplicated loopback controls
Comment 57 Raymond 2014-01-08 01:08:02 UTC
do "Stereo Downmix" work well in 4.0/5.1 (kernel 3.11)  ? 

Simple mixer control 'Stereo Downmix',0
  Capabilities: pswitch
  Playback channels: Front Left - Front Right
  Mono:
  Front Left: Playback [off]
  Front Right: Playback [off]
Comment 58 Raymond 2014-01-08 07:11:38 UTC
Node 0x09 [Audio Mixer] wcaps 0x20010e: Mono Amp-In Amp-Out
  Control: name="Stereo Downmix Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-In vals:  [0x80] [0x80]
  Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-Out vals:  [0x80]
  Connection: 2
     0x04 0x05


struct hda_gen_spec {

	hda_nid_t downmix_nid;		/* downmix NID */


	unsigned int downmix_enabled:1;




static int downmix_info(struct snd_kcontrol *kcontrol,
			 struct snd_ctl_elem_info *uinfo)
{
	return snd_hda_enum_bool_helper_info(kcontrol, uinfo);
}

static int downmix_get(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
	struct hda_gen_spec *spec = codec->spec;
	ucontrol->value.enumerated.item[0] = spec->downmix_enabled;
	return 0;
}


static int downmix_put(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
	struct hda_gen_spec *spec = codec->spec;
	unsigned int select = ucontrol->value.enumerated.item[0];
	int ret, i, conn_len;
	ret = 0;
	if (select != spec->downmix_enabled) {
		conn_len = snd_hda_get_num_raw_conns(codec, spec->downmix_nid);
		for (i = 0; i < conn_len; i++) 
			snd_hda_codec_amp_update(codec, spec->downmix_nid, 0, 
				HDA_INPUT, i, HDA_AMP_MUTE, select ? 0 : HDA_AMP_MUTE);
		snd_hda_codec_amp_update(codec, spec->downmix_nid, 0, 
			HDA_OUTPUT, 0, HDA_AMP_MUTE, select ? 0 : HDA_AMP_MUTE);
		spec->downmix_enabled = select;
		ret = 1;	
	}
	return ret;
}

static const struct snd_kcontrol_new downmix_enum = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Downmix 5.1 to stereo Playback Switch",
	.info = downmix_info,
	.get = downmix_get,
	.put = downmix_put,
};

static int create_downmix_ctl(struct hda_codec *codec)
{
	struct hda_gen_spec *spec = codec->spec;
	struct nid_path *path;
	int i, conn_len;

	if (!spec->mixer_nid)
		return 0;
	if (!spec->downmix_nid)
		return 0;
	if (spec->multiout.num_dacs < 3)
		return 0;
	if (!is_reachable_path(codec, spec->downmix_nid, spec->mixer_nid))
		return 0;
	for (i = 1; i < 3; i++)
		if (!is_reachable_path(codec, spec->multiout.dac_nids[i],
			spec->downmix_nid))
			return 0;	
	path = snd_hda_add_new_path(codec,  spec->downmix_nid, spec->mixer_nid, 0);
	if (!path)
		return -EINVAL;
	print_nid_path("downmix", path);
        if (!snd_hda_gen_add_kctl(spec, NULL, &downmix_enum))
		return -ENOMEM;
	conn_len = snd_hda_get_num_raw_conns(codec, spec->downmix_nid);
	for (i = 0; i < conn_len; i++) 
		snd_hda_codec_amp_update(codec, spec->downmix_nid, 0, 
			HDA_INPUT, i, HDA_AMP_MUTE, HDA_AMP_MUTE);
	snd_hda_codec_amp_update(codec, spec->downmix_nid, 0, 
			HDA_OUTPUT, 0, HDA_AMP_MUTE, HDA_AMP_MUTE);
	return 0;
}




static int create_multi_out_ctls(struct hda_codec *codec,
				 const struct auto_pin_cfg *cfg)
{




			create_swap_center_lfe_ctl(codec, path);
+			create_downmix_ctl(codec);
		} else {
			err = add_stereo_sw(codec, name, index, path);
			if (err < 0)
				return err;
Comment 59 William 2014-01-08 19:35:58 UTC
Created attachment 121321 [details]
alsa-info.txt for SL14.1, with 3.13-rc7+ two patches from attachments 121221, 121231
Comment 60 William 2014-01-08 19:39:25 UTC
RE: Comments 54, 55, 56

Using kernel 3.13-rc7 + two patches 121221, 121231

cat  /lib/firmware/ad1986a.fw

[codec]
  0x11d41986 0x104381b3 0
[hint]
  add_stereo_mix_input=true

Looks much better. Front Mic playback and capture now work....

However selecting capture on rear mic silences front mic until front mic
capture is selected (which likewise silences rear mic until rear mic capture
has been selected again). Selecting, say, Line or CD capture has no effect on
state of the mics. On startup rear mic capture is selected so initially front
mic does not function.

alsa-info as attachment 121321 [details].
Comment 61 William 2014-01-08 19:42:08 UTC
RE Comment #57

Yes under Kernel 3.11.9 "Stereo Downmix" works fine. So basically I can record
whatever is playing back through the speakers / headphones (which can be, say,
a mix of PCM, Line and Mic). The level recorded is a function of the 'input'
gains (eg PCM, Line etc) and the "Capture", "digital" gains - it is independent
of the "Front", "Master", "Headphone" gains.  

Under Kernel 3.11.9 the resulting mic signal is just the sum of the "rear mic"
and "front mic".
Comment 62 Takashi Iwai 2014-01-08 20:14:26 UTC
Currently the generic parser prefers the exclusive input route than the sum of multiple sources, so that you can choose one of front or rear mics.  Otherwise it's impossible to operate, e.g. when a laptop has two inputs, an internal mic as a rear pin and an external mic jack as a front pin.

It'd be relatively easy to make the parser handling the mixed sum as the primary source.  In that case, you'll see no difference between rear and front mics but there will be only one "Mic".

The fact that either front or rear mic can be routed at the same time is, as mentioned earlier, the design issue of AD1986A codec.  Other codecs don't behave like that, but this one is a bit strange design as a preliminary model.
Comment 63 Raymond 2014-01-09 03:51:29 UTC
Auto-down mix and channel spreading

Table 36. Downmix
NID  Name TID Type Description
0x09 Surround to Stereo Down Mix 0x2 Audio Mixer Mixes 5.1 stereo to 4.0 or 2.0 on front channels.







if you are talking about stereo mix as record source

the ability to change PCM volume/mute when you use stereo mix as input is lost 
in the current implementation


it is not easy to test if you don't have stereo microphone to test left/right swapping 

Stereo microphone pass-through to mixer
Microphone left/right swapping
Comment 64 Raymond 2014-01-09 08:40:17 UTC
+ /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
+ {0x0f, AC_VERB_SET_CONNECT_SEL, 0x4},




it is possible to add back the connection to node 0x27 


static int create_input_ctls(struct hda_codec *codec)
{




	err = parse_capture_source(codec, 0x27, 0x98, num_adcs,	
					   "Mic Mix", 0);
	if (err < 0)
		return err;
}



> get 21
21 Capture Source:0
ITEM: 0:Rear Mic, 1:Front Mic, 2:Line, 3:CD, 4:Mic Mix, 5:Stereo Mix, VAL: [Rear Mic]
> set 21 4
send: NID=0x12, VERB=0x701(set_connect_sel), PARM=0x0
send: NID=0x11, VERB=0x701(set_connect_sel), PARM=0x0
send: NID=0xf, VERB=0x701(set_connect_sel), PARM=0x4
Comment 65 Takashi Iwai 2014-01-09 08:57:42 UTC
It's what I mentioned in the previous comment.  Using 0x27 leaves you no choice of front and rear mics as a capture source.  They are always mixed when routed through NID 0x27.
Comment 66 Raymond 2014-01-10 05:58:56 UTC
https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/?id=67e9f4b68c9d1820132c559c0f9b296dafdf631e

seem ac97 can spread stream by hardware 


why do the driver still call hda_codec_cleanup_stream for NID=0x4
and  NID=0x5 ?



> PCM 0 p 44100 2 16
Open PCM AD1986A Analog for play
Available PCM parameters:
  channels: 2/6
  formats: S16_LE
  rates: 44100 48000
Prepare PCM, rate=44100, channels=2, format=16 bits
PCM format_val = 0x4011
send: NID=0x2, VERB=0xa00(get_stream_format), PARM=0x0
receive: 0x0
hda_codec_setup_stream: NID=0x2, stream=0x1, channel=0, format=0x4011
send: NID=0x2, VERB=0xf06(get_channel_streamid), PARM=0x0
receive: 0x0
send: NID=0x2, VERB=0x706(set_channel_streamid), PARM=0x10
send: NID=0x2, VERB=0xa00(get_stream_format), PARM=0x0
receive: 0x0
send: NID=0x2, VERB=0x240(set_stream_format), PARM=0x11
hda_codec_setup_stream: NID=0x3, stream=0x1, channel=0, format=0x4011
send: NID=0x3, VERB=0xf06(get_channel_streamid), PARM=0x0
receive: 0x0
send: NID=0x3, VERB=0x706(set_channel_streamid), PARM=0x10
send: NID=0x3, VERB=0xa00(get_stream_format), PARM=0x0
receive: 0x0
send: NID=0x3, VERB=0x240(set_stream_format), PARM=0x11
PCM Clean up
hda_codec_cleanup_stream: NID=0x3
send: NID=0x3, VERB=0x706(set_channel_streamid), PARM=0x0
send: NID=0x3, VERB=0x200(set_stream_format), PARM=0x0
hda_codec_cleanup_stream: NID=0x4
hda_codec_cleanup_stream: NID=0x5
hda_codec_cleanup_stream: NID=0x3
hda_codec_cleanup_stream: NID=0x2
send: NID=0x2, VERB=0x706(set_channel_streamid), PARM=0x0
send: NID=0x2, VERB=0x200(set_stream_format), PARM=0x0
Close PCM
Comment 67 Raymond 2014-01-30 02:41:37 UTC
how do the downix work ?

does it add surround DAC and center/lfe using left or right channels of the downmix switch ?


http://mailman.alsa-project.org/pipermail/alsa-devel/2014-January/071791.html
Comment 68 William 2014-02-04 20:22:11 UTC
Created attachment 124501 [details]
alsa-info for SL14.1 with 3.14-rc1-1
Comment 69 William 2014-02-04 20:25:00 UTC
Re-tested using kernel 3.14-rc1 (with no extra patches, and no firmware
config file).

alsa-info as attachment 124501 [details]

Playback :-
--------

Can successfully playback, "line", "cd", "beep", and either "front mic" or
"rear mic".

However selection between front/rear mic for playback is done via the
"Front mic" and "Rear mic" "capture" controls - which is not intuitive.

Capture
-------

Capture of "line", "cd", "front mic", "rear mic", or "Stereo mix" ok.
Comment 70 Raymond 2014-02-07 02:14:38 UTC
https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/?id=cd262518a3ae4465e8e51c29641d98c4ed0651a1

can you specify dump_coef=1 to dump the value of coefficients and check whether it is different from windows driver ADIHdAud.inf ?
Comment 71 Raymond 2014-02-07 02:15:52 UTC
Node 0x03 [Audio Output] wcaps 0x44d: Stereo Amp-Out
  Device: name="AD1986A Analog", type="Audio", device=0
  Amp-Out caps: ofs=0x17, nsteps=0x1f, stepsize=0x05, mute=1
  Amp-Out vals:  [0x17 0x17]
  Converter: stream=0, channel=0
  Power states:  D0 D3
  Power: setting=D0, actual=D0
  Processing caps: benign=1, ncoeff=70

Note You need to log in before you can comment on or make changes to this bug.