Bug 65641 - hda with ad1981: Lost analog mixing
hda with ad1981: Lost analog mixing
Status: RESOLVED CODE_FIX
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA)
All Linux
: P1 normal
Assigned To: Jaroslav Kysela
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-24 18:07 UTC by Michael Karcher
Modified: 2013-12-12 03:42 UTC (History)
2 users (show)

See Also:
Kernel Version: 3.13-rc1
Tree: Mainline
Regression: No


Attachments
Codec dump for AD1981HD (9.14 KB, application/octet-stream)
2013-11-24 18:07 UTC, Michael Karcher
Details
Codec dump for AD1981HD, this time with better mime type (9.14 KB, text/plain)
2013-11-24 18:10 UTC, Michael Karcher
Details
Fix aamix controls for AD codecs (4.15 KB, patch)
2013-11-28 10:27 UTC, Takashi Iwai
Details | Diff

Description Michael Karcher 2013-11-24 18:07:18 UTC
Created attachment 115821 [details]
Codec dump for AD1981HD

On my Thinkpad T60, I lost the functionality of mixing analog sources (like microphone) directly into the analog output (like speaker/headphone). In earlier kernel versions, it was possible to control the analog mixing using a control in the alsamixer "playback" view named "microphone".
I did not bisect the bug, but there are reasons to believe that this might be caused by removal of the static AD1981HD configuration in commit bd450dcc357646cc277c560ab24b35f940efa585 which contained appropriate mixer settings and routing the output through the "mixing" node.
Attaching codec dump from the current kernel.
Comment 1 Michael Karcher 2013-11-24 18:10:35 UTC
Created attachment 115831 [details]
Codec dump for AD1981HD, this time with better mime type
Comment 2 Takashi Iwai 2013-11-25 09:51:57 UTC
For the hardware information, please give alsa-info.sh output at best.  Run it with --no-upload option, and attach the output.

In anyway, the cause of this behavior change is due to the movement to the generic parse, as you pointed.  The generic parser tries to avoid the stereo mixing input for simplifying the operation as much as possible (e.g. enabling the automatic mic switching).

You can still enable the stereo mixing by specifying via a hint string.  For example, try to create a file /lib/firmware/alsa/tp-stereo containing the following lines:

[codec]
0x11d41981 0x17aa2025 0

[hint]
add_stereo_mix_input = 1


Then pass "patch" option to snd-hda-intel module (e.g. creating a file /etc/modprobe.d/50-tp-stereo.conf)
   options snd-hda-intel patch=alsa/tp-stereo

Some brief information is found in Documentation/sound/alsa/HD-Audio.txt, but I should write more detailed instructions there...
Comment 3 Michael Karcher 2013-11-27 21:37:48 UTC
Thank you for your quick response, but this is not what I was asking for. Possibly I was not clear enough about what I want:
I want to be able to hear the microphone input signal without CPU processing and any associated delay in on the speaker/headphone output, by routing the output channel through the analog mixer node 0x0E instead of connecting the DAC 0x03 directly to the output pin 0x05, so I can have a "Mic Playback Volume" and "Mic Playback Switch" controlling node 0x12 routing the output of the microphone input pin 0x08 to the analog output.
I did not find a way to provide a hint for that, and after skimming over the entire hda_generic.c source code file, I see no obvious way to modify the output routing algorithm to not use the direct path. Also I see no obvious way to get playback controls for input pins. Is there some more elaborate way of forcing codec/mixer configuration to get the requested functionality?
In my case, the use case is rehearsing vocal music using headphones. For that, I need to hear my own voice on the headphones mixed with the background played by some audio playing application.
Comment 4 Raymond 2013-11-28 02:29:42 UTC
seem missing headphone node


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

-static const struct snd_kcontrol_new ad1981_mixers[] = {
- HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
- HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
- HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
- HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),


port A should be headphone


the driver should move 

spec->gen.indep_hp = 1; 

from ad198x_parse_auto_config() to patch_ad1988 

or

disable indep hp for any hda_codecs with 1 DAC
Comment 5 Raymond 2013-11-28 02:45:52 UTC
seem alway select out path without aamix when there is a direct connection from DAC to output pin

		path = snd_hda_add_new_path(codec, dac, pin, -spec->mixer_nid);
		if (!path && !i && spec->mixer_nid) {
			/* try with aamix */
			path = snd_hda_add_new_path(codec, dac, pin, 0);
		}
Comment 6 Takashi Iwai 2013-11-28 10:26:35 UTC
Thanks, now it's clear what's really missing.  Actually this is a case the current driver looked over.

The fix patch below should add the proper loopback controls back.
You'll have "Loopback Mixing" mixer control to turn on/off the loopback, and each loopback volume/mute like "Mic" and "CD".
Comment 7 Takashi Iwai 2013-11-28 10:27:31 UTC
Created attachment 116531 [details]
Fix aamix controls for AD codecs
Comment 8 Raymond 2013-11-29 01:57:48 UTC
but node 0x05 still connect to node 0x03 instead of audio mixer

Node 0x05 [Pin Complex] wcaps 0x400187: Stereo Amp-In Amp-Out
  Control: name="Master Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="Master Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="Speaker Phantom Jack", index=0, device=0
  Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x27, mute=0
  Amp-In vals:  [0x00 0x00]
  Amp-Out caps: ofs=0x3d, nsteps=0x3f, stepsize=0x05, mute=1
  Amp-Out vals:  [0xbf 0xbf]
  Pincap 0x0001173f: IN OUT HP EAPD Detect Trigger ImpSense
    Vref caps: HIZ 50 GRD 80
  EAPD 0x2: EAPD
  Pin Default 0xc3014110: [Both] Line Out at Ext Left
    Conn = 1/8, Color = Green
    DefAssociation = 0x1, Sequence = 0x0
    Misc = NO_PRESENCE
  Pin-ctls: 0x40: OUT VREF_HIZ
  Unsolicited: tag=00, enabled=0
  Connection: 2
     0x03* 0x0e

strange the driver only evaluate the mixer path when indep_hp=1 and use spec->mixer_nid instead of -spec->mixer_nid


==> lo_type=1, wired=1, mio=1, badness=0x10
multi_outs = 5/0/0/0 : 3/0/0/0 (type SP)
  out path: depth=2 :03:05
  mix path: depth=4 :03:11:0e:05
==> lo_type=1, wired=1, mio=0, badness=0x10
multi_outs = 5/0/0/0 : 3/0/0/0 (type SP)
  out path: depth=2 :03:05
  mix path: depth=4 :03:11:0e:05
==> lo_type=1, wired=0, mio=1, badness=0x10
multi_outs = 5/0/0/0 : 3/0/0/0 (type SP)
  out path: depth=4 :03:11:0e:05
==> lo_type=1, wired=0, mio=0, badness=0x10
multi_outs = 5/0/0/0 : 3/0/0/0 (type SP)
  out path: depth=4 :03:11:0e:05
==> restoring best_cfg
==> Best config: lo_type=1, wired=1, mio=1
multi_outs = 5/0/0/0 : 3/0/0/0 (type SP)
  out path: depth=2 :03:05
  mix path: depth=4 :03:11:0e:05
Comment 9 Takashi Iwai 2013-11-29 06:28:16 UTC
It's connected dynamically when "Loopback Mixing" mixer element is enabled.  You see two paths are shown as the result in the log you pasted.
Comment 10 Raymond 2013-12-05 01:21:13 UTC
previous version allow user to mute signal from DAC and just use those Input Jacks for the Output


- HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
- HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),

Node 0x11 [Audio Selector] wcaps 0x30010d: Stereo Amp-Out
  Amp-Out caps: ofs=0x17, nsteps=0x1f, stepsize=0x05, mute=1
  Amp-Out vals:  [0x17 0x17]
  Connection: 1
     0x03
Comment 11 Takashi Iwai 2013-12-10 16:46:08 UTC
The patch has been merged to the upstream.
Comment 12 Raymond 2013-12-12 03:42:04 UTC
seem missing mic at ext rear 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

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