Bug 70011

Summary: Regression: Input from Line-in / Mic can't be listened in the output anymore
Product: Drivers Reporter: Jarno Suni (j_suni)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: NEW ---    
Severity: normal CC: hancockrwd, superquad.vortex2, tiwai
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.11.0-15 Subsystem:
Regression: No Bisected commit-id:
Attachments: Fix patch
Another fix patch
fix get_line_out_pfx

Comment 1 Raymond 2014-02-05 03:11:10 UTC
https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/Documentation/sound/alsa/HD-Audio.txt

try early patching to add hint to set mixer_nid

mixer_nid = 0x0e


use amixer -c0 to enable loopback mixing

 Loopback Mixing:0
ITEM: 0:Disabled, 1:Enabled, VAL: [Enabled]


the second bug 

Playback volume and switch created at pin complex should use the name of the pin complex instead of PCM

Node 0x05 [Pin Complex] wcaps 0x400185: Stereo Amp-Out
  Control: name="PCM Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="PCM Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=Out, idx=0, ofs=0
  Control: name="Line Out Jack", index=0, device=0
  Amp-Out caps: ofs=0x3d, nsteps=0x3f, stepsize=0x05, mute=1
  Amp-Out vals: [0x3d 0x3d]
  Pincap 0x00000017: OUT Detect Trigger ImpSense
  Pin Default 0x01014010: [Jack] Line Out at Ext Rear
    Conn = 1/8, Color = Green
    DefAssociation = 0x1, Sequence = 0x0
Comment 2 Raymond 2014-02-05 03:34:42 UTC
you can record what is playing by select node 0xe as capture source since 0x11 is the front mix amp


Node 0x14 [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:  [0x01 0x01]
  Connection: 4
     0x0c* 0x0d 0x0e 0x0f

Node 0x0e [Audio Mixer] wcaps 0x200101: Stereo
  Connection: 3
     0x11 0x12 0x13

Node 0x11 [Audio Selector] wcaps 0x30010d: Stereo Amp-Out
  Amp-Out caps: ofs=0x17, nsteps=0x1f, stepsize=0x05, mute=1
  Amp-Out vals:  [0x97 0x97]
  Connection: 1
     0x03
Comment 3 Takashi Iwai 2014-02-05 06:35:31 UTC
> https://bugzilla.kernel.org/show_bug.cgi?id=70011

(In reply to Raymond from comment #1)
> https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/
> Documentation/sound/alsa/HD-Audio.txt
> 
> try early patching to add hint to set mixer_nid
> 
> mixer_nid = 0x0e

The patch below will be added to the upstream.
Comment 4 Takashi Iwai 2014-02-05 06:35:55 UTC
Created attachment 124581 [details]
Fix patch
Comment 5 Raymond 2014-02-05 07:06:47 UTC
just fix mixer_nid is not enough 

only one loopback path instead of two


==> Best config: lo_type=0, wired=1, mio=1
multi_outs = 5/0/0/0 : 3/0/0/0 (type LO)
  out path: depth=2 :03:05
hp_outs = 6/0/0/0 : 3/0/0/0
  hp  path: depth=2 :03:06
spk_outs = 7/0/0/0 : 3/0/0/0
  spk path: depth=4 :03:0b:0f:07
  mix path: depth=4 :03:11:0e:05
  mix path: depth=4 :03:11:0e:06
  mix path: depth=6 :03:11:0e:0b:0f:07


loopback path: depth=4 :08:0c:12:0e
Comment 6 Takashi Iwai 2014-02-05 07:17:19 UTC
Be more specific.
Comment 7 Raymond 2014-02-05 07:38:57 UTC
"Line Playback Volume" and "Line Playback Switch" is still missing in the emulator


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


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


autoconfig: line_outs=1 (0x5/0x0/0x0/0x0/0x0) type:line
   speaker_outs=1 (0x7/0x0/0x0/0x0/0x0)
   hp_outs=1 (0x6/0x0/0x0/0x0/0x0)
   mono: mono_out=0x0
   inputs:
     Mic=0x8
     Line=0x9

the emulator find three input path but only one loopback path

loopback path: depth=4 :08:0c:12:0e

input path: depth=4 :08:0c:14:04
input path: depth=4 :09:0c:14:04
input path: depth=3 :0e:14:04
Comment 8 Takashi Iwai 2014-02-05 07:53:53 UTC
OK, it's fixed by the patch below in addition.
Comment 9 Takashi Iwai 2014-02-05 07:54:22 UTC
Created attachment 124601 [details]
Another fix patch
Comment 10 Jarno Suni 2014-02-05 10:15:39 UTC
A little bit off-topic, but Raymond, as for comment 2, do you mean it gets a new capture source besides Mic and Line, that records everything that is mixed in output (like in Master)? What would that source be called?
Comment 11 Takashi Iwai 2014-02-05 10:54:50 UTC
It'll be "Stereo Mix".  This item appears automatically on 3.14 or later, or by adding the hint add_stereo_mix_input=1 in the earlier versions.  See Documentation/sound/alsa/HD-Audio.txt for a brief instruction.
Comment 12 Raymond 2014-02-05 11:01:55 UTC
-static const struct hda_input_mux ad1983_capture_source = {
-	.num_items = 4,
-	.items = {
-		{ "Mic", 0x0 },
-		{ "Line", 0x1 },
-		{ "Mix", 0x2 },
-		{ "Mix Mono", 0x3 },
-	},
-};
-

you can add it back by

spec->add_stereo_mix_input=1;

for your business desktop which don't need auto mic selection


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

but the volume control which allow you to change the recording  volume with stereo mix is lost in current implementation




there was mono mix input source too

Node 0x0f [Audio Mixer] wcaps 0x200100: Mono
  Connection: 1
     0x0b
Comment 13 Jarno Suni 2014-02-05 11:46:34 UTC
Takashi Iwai, I added the hint to /sys/class/sound/hwC0D0/hints, but I don't see a new capture item in alsamixer thereafter. I am using Linux release 3.11.0.

In which Linux release will the original bug be fixed?
Comment 14 Takashi Iwai 2014-02-05 12:00:03 UTC
You need to trigger the reconfigure after adding the hints.
Comment 15 Raymond 2014-02-06 03:35:05 UTC
-static const struct snd_kcontrol_new ad1983_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),
- HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
- HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),

https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/sound/pci/hda/hda_generic.c

need to pass the output path to function get_line_out_pfx() in order to name the volume control and switch 


==> Best config: lo_type=0, wired=1, mio=1
multi_outs = 5/0/0/0 : 3/0/0/0 (type LO)
  out path: depth=2 :03:05
hp_outs = 6/0/0/0 : 3/0/0/0
  hp  path: depth=2 :03:06
spk_outs = 7/0/0/0 : 3/0/0/0
  spk path: depth=4 :03:0b:0f:07

the codec ad1983 has amp out at each pin complexes  even when the three pin complex share the same audio output node 0x03

it is unlikely to deduce the name by cfg->line_outs , cfg->speaker_outs, cfg->hp_outs, spec->multiout.num_dacs  or spec->multi_ios to know whether the volume control is shared by different output pin complexes or not
Comment 16 Raymond 2014-02-06 03:50:24 UTC
the nid of the volume control is important to determine the name


  mix path: depth=4 :03:11:0e:05
  mix path: depth=4 :03:11:0e:06
  mix path: depth=6 :03:11:0e:0b:0f:07


the amp at node 0x11 is shared by the three output pins when loopback mixing is enabled  but each output complex has its own amp out
Comment 17 Raymond 2014-02-06 21:51:44 UTC
https://bugs.freedesktop.org/show_bug.cgi?id=70865#c10

static const char *get_line_out_pfx(struct hda_codec *codec, int ch,
				    int *index, int ctl_type)
{
	struct hda_gen_spec *spec = codec->spec;
	struct auto_pin_cfg *cfg = &spec->autocfg;
+	struct nid_path *path = snd_hda_get_path_from_idx(codec, spec->out_paths[ch]);
+	hda_nid_t nid = path->ctls[ctl_type] & 0x3f;
+ 	if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_PIN)
+		return channel_name[ch];
Comment 18 Raymond 2014-02-07 01:55:01 UTC
Created attachment 124971 [details]
fix get_line_out_pfx

Fix the name when vol or mute switch is at pin complex Line Out in function get_line_out_pfx()