ALSA: hda - via - fix master mute and automute with VT1812/VT2002P
PATCH 1/1 ALSA: hda - via - fix master mute and automute with VT1812/VT2002P
On VIA VT1812/VT2002P, the "Master Front Playback Switch" doesn't mute first line-out. This is an issue, for example I saw a laptop with VT1812 and only one line-out (main speaker) that doesn't mute main speaker, because the master switch doesn't act on first line-out, and first line-out nid in array is assigned to speaker as expected by autoconfig code.
But there is one more issue also: main switches and automute code deal with mute on same Amp-Outs, which can cause conflicts, thus if you mute "Master Front Playback Switch" and remove headphone for example, it will not respect the mixer setting. To solve it, we can change the pin type instead of muting Amp-Out, which is done here.
--- sound/pci/hda/patch_via.c | 23 +++++++++-------------- 1 files changed, 9 insertions(+), 14 deletions(-)
Hi, I'm attaching the codec file of the laptop with the issue, this is kernel log relevant info:
autoconfig: line_outs=1 (0x24/0x0/0x0/0x0/0x0)
speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
hp_outs=1 (0x33/0x0/0x0/0x0/0x0)
mono: mono_out=0x0
inputs: mic=0x29, fmic=0x2b, line=0x0, fline=0x0, cd=0x0, aux=0x0
sound/pci/hda/patch_via.c +9 -14
@@ -295,8 +295,6 @@ static int analog_input_switch_put(struct snd_kcontrol *kcontrol, .put = analog_input_switch_put, \ .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) } -static void via_hp_bind_automute (struct hda_codec *codec); -static int bind_pin_switch_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -343,13 +341,10 @@ static int bind_pin_switch_put(struct snd_kcontrol *kcontrol,snd_hda_codec_amp_stereo ( codec, spec->autocfg.speaker_pins[i],HDA_OUTPUT ,0 ,HDA_AMP_MUTE ,0 ); -/* unmute */ -via_hp_bind_automute (codec); - }else {if (lmute) {/* Mute all left channels */ -for (i =1 ; i < spec->autocfg.line_outs; i++) +for (i =0 ; i < spec->autocfg.line_outs; i++) snd_hda_codec_amp_update( codec, spec->autocfg.line_out_pins[i],
@@ -364,7 +359,7 @@ static int bind_pin_switch_put(struct snd_kcontrol *kcontrol, }if (rmute) {/* mute all right channels */ -for (i =1 ; i < spec->autocfg.line_outs; i++) +for (i =0 ; i < spec->autocfg.line_outs; i++) snd_hda_codec_amp_update( codec, spec->autocfg.line_out_pins[i],
@@ -2129,18 +2124,18 @@ static void via_hp_bind_automute(struct hda_codec *codec)if (!spec->hp_independent_mode) {/* Mute Line-Outs */ for (i =0 ; i < spec->autocfg.line_outs; i++) -snd_hda_codec_amp_stereo ( - codec, spec->autocfg.line_out_pins[i], -HDA_OUTPUT ,0 , -HDA_AMP_MUTE , hp_present ?HDA_AMP_MUTE :0 ); +snd_hda_codec_write (codec, + spec->autocfg.line_out_pins[i], +0 ,AC_VERB_SET_PIN_WIDGET_CONTROL , + hp_present ?0 :PIN_OUT );if (hp_present) present = hp_present; }/* Speakers */ for (i =0 ; i < spec->autocfg.speaker_outs; i++) -snd_hda_codec_amp_stereo ( - codec, spec->autocfg.speaker_pins[i],HDA_OUTPUT ,0 , -HDA_AMP_MUTE , present ?HDA_AMP_MUTE :0 ); +snd_hda_codec_write (codec, spec->autocfg.speaker_pins[i],0 , +AC_VERB_SET_PIN_WIDGET_CONTROL , + present ?0 :PIN_OUT ); }
Signature · 1 line
1.7.0.4
Codec: VIA VT1812
Address: 0
Function Id: 0x1
Vendor Id: 0x11060448
Subsystem Id: 0x15584120
Revision Id: 0x100000
No Modem Function Group found
Default PCM:
rates [0x0]:
bits [0x0]:
formats [0x0]:Default Amp-In caps: N/A
Default Amp-Out caps: N/A
GPIO: io=0, o=0, i=0, unsolicited=0, wake=0
Node 0x08 [Audio Output] wcaps 0x41d: Stereo Amp-Out
Control: name="Master Front Playback Volume", index=0, device=0
Device: name="VT1812 Analog", type="Audio", device=0 Amp-Out caps: ofs=0x2a, nsteps=0x2a, stepsize=0x05, mute=0 Amp-Out vals: [0x2a 0x2a]
Converter: stream=0, channel=0
PCM:
rates [0x5e0]: 44100 48000 88200 96000 192000
bits [0xe]: 16 20 24
formats [0x1]: PCM Power states: D0 D1 D2 D3 EPSS
Power: setting=D0, actual=D0
Node 0x09 [Audio Output] wcaps 0x41d: Stereo Amp-Out
Control: name="Headphone Playback Volume", index=0, device=0 Amp-Out caps: ofs=0x2a, nsteps=0x2a, stepsize=0x05, mute=0 Amp-Out vals: [0x21 0x21]
Converter: stream=0, channel=0
PCM:
rates [0x5e0]: 44100 48000 88200 96000 192000
bits [0xe]: 16 20 24
formats [0x1]: PCM Power states: D0 D1 D2 D3 EPSS
Power: setting=D0, actual=D0
Node 0x0a [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x0b [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x0c [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x0d [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x0e [Audio Output] wcaps 0x611: Stereo Digital
Converter: stream=0, channel=0
Digital:
Digital category: 0x0
PCM:
rates [0x5e0]: 44100 48000 88200 96000 192000
bits [0xe]: 16 20 24
formats [0x1]: PCM Power states: D0 D1 D2 D3 EPSS
Power: setting=D0, actual=D0
Node 0x0f [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x10 [Audio Input] wcaps 0x10051b: Stereo Amp-In
Control: name="Capture Volume", index=0, device=0
Control: name="Capture Switch", index=0, device=0
Device: name="VT1812 Analog", type="Audio", device=0 Amp-In caps: ofs=0x0b, nsteps=0x1f, stepsize=0x05, mute=1 Amp-In vals: [0x1e 0x1e]
Converter: stream=0, channel=0
SDI-Select: 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
Connection: 1
0x1eNode 0x11 [Audio Input] wcaps 0x10051b: Stereo Amp-In
Control: name="Capture Volume", index=1, device=0
Control: name="Capture Switch", index=1, device=0 Amp-In caps: ofs=0x0b, nsteps=0x1f, stepsize=0x05, mute=1 Amp-In vals: [0x1e 0x1e]
Converter: stream=0, channel=0
SDI-Select: 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
Connection: 1
0x1fNode 0x12 [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x13 [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x14 [Audio Mixer] wcaps 0x20050b: Stereo Amp-In
Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-In vals: [0x00 0x00] [0x00 0x00]
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Connection: 2
0x34 0x21
Node 0x15 [Audio Mixer] wcaps 0x20050b: Stereo Amp-In
Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-In vals: [0x00 0x00] [0x00 0x00]
Power states: D0 D1 D2 D3
Power: setting=D3, actual=D3
Connection: 2
0x35 0x21
Node 0x16 [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x17 [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x18 [Audio Mixer] wcaps 0x20050b: Stereo Amp-In
Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-In vals: [0x00 0x00] [0x00 0x00]
Power states: D0 D1 D2 D3
Power: setting=D3, actual=D3
Connection: 2
0x38 0x21
Node 0x19 [Audio Mixer] wcaps 0x20050b: Stereo Amp-In
Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-In vals: [0x80 0x80] [0x80 0x80]
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Connection: 2
0x39 0x21
Node 0x1a [Audio Mixer] wcaps 0x20050b: Stereo Amp-In
Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-In vals: [0x80 0x80] [0x80 0x80]
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Connection: 2
0x3a 0x21
Node 0x1b [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x1c [Audio Mixer] wcaps 0x20050b: Stereo Amp-In
Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-In vals: [0x00 0x00] [0x00 0x00]
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Connection: 2
0x3c 0x21
Node 0x1d [Audio Mixer] wcaps 0x20050b: Stereo Amp-In
Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-In vals: [0x00 0x00] [0x00 0x00]
Power states: D0 D1 D2 D3
Power: setting=D3, actual=D3
Connection: 2
0x3d 0x21
Node 0x1e [Audio Selector] wcaps 0x300501: Stereo
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Connection: 7
0x2b* 0x2a 0x29 0x28 0x25 0x21 0x30
Node 0x1f [Audio Selector] wcaps 0x300501: Stereo
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Connection: 7
0x2b* 0x2a 0x29 0x28 0x25 0x21 0x30
Node 0x20 [Vendor Defined Widget] wcaps 0xf00000: Mono
Node 0x21 [Audio Mixer] wcaps 0x20050b: Stereo Amp-In
Control: name="Mic Playback Volume", index=0, device=0
Control: name="Mic Playback Switch", index=0, device=0
Control: name="Front Mic Playback Volume", index=0, device=0
Control: name="Front Mic Playback Switch", index=0, device=0
Control: name="Stereo Mixer Playback Volume", index=0, device=0
Control: name="Stereo Mixer Playback Switch", index=0, device=0 Amp-In caps: ofs=0x17, nsteps=0x1f, stepsize=0x05, mute=1 Amp-In vals: [0x9e 0x9e] [0x80 0x80] [0x9e 0x9e] [0x80 0x80] [0x80 0x80] Power states: D0 D1 D2 D3
Power: setting=D3, actual=D3
Connection: 5
0x2b 0x2a 0x29 0x28 0x25
Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out
Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x00]
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Node 0x23 [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x24 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
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 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: 1
0x14
Node 0x25 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-Out vals: [0x80 0x80]
Pincap 0x0001003c: IN OUT HP EAPD Detect
EAPD 0x2: EAPD
Pin Default 0x422140f0: [N/A] HP Out at Ext Front
Conn = 1/8, Color = Green
DefAssociation = 0xf, Sequence = 0x0
Pin-ctls: 0x00:
Unsolicited: tag=04, enabled=1
Power states: D0 D1 D2 D3 EPSS
Power: setting=D3, actual=D3
Connection: 1
0x15
Node 0x26 [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x27 [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x28 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
Control: name="Master Front Playback Switch", index=0, device=0 Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-Out vals: [0x80 0x80]
Pincap 0x0000233c: IN OUT HP Detect
Vref caps: HIZ 50 100
Pin Default 0x410140f0: [N/A] Line Out at Ext Rear
Conn = 1/8, Color = Green
DefAssociation = 0xf, Sequence = 0x0
Pin-ctls: 0x00: VREF_HIZ
Unsolicited: tag=24, enabled=1
Power states: D0 D1 D2 D3 EPSS
Power: setting=D3, actual=D3
Connection: 1
0x18Node 0x29 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
Control: name="Front Mic Boost Capture Volume", index=0, device=0 Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-Out vals: [0x80 0x80]
Pincap 0x0000233c: IN OUT HP Detect
Vref caps: HIZ 50 100
Pin Default 0x90a701f0: [Fixed] Mic at Int N/A
Conn = Analog, Color = Unknown
DefAssociation = 0xf, Sequence = 0x0
Misc = NO_PRESENCE
Pin-ctls: 0x21: IN VREF_50
Unsolicited: tag=04, enabled=1
Power states: D0 D1 D2 D3 EPSS
Power: setting=D0, actual=D0
Connection: 1
0x19Node 0x2a [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-Out vals: [0x80 0x80]
Pincap 0x0000233c: IN OUT HP Detect
Vref caps: HIZ 50 100
Pin Default 0x418130f8: [N/A] Line In at Ext Rear
Conn = 1/8, Color = Blue
DefAssociation = 0xf, Sequence = 0x8
Pin-ctls: 0x00: VREF_HIZ
Unsolicited: tag=04, enabled=1
Power states: D0 D1 D2 D3 EPSS
Power: setting=D3, actual=D3
Connection: 1
0x1a
Node 0x2b [Pin Complex] wcaps 0x400481: Stereo
Control: name="Mic Boost Capture Volume", index=0, device=0
Pincap 0x00002324: IN Detect
Vref caps: HIZ 50 100 Pin Default 0x01a190f0: [Jack] Mic at Ext Rear
Conn = 1/8, Color = Pink
DefAssociation = 0xf, Sequence = 0x0
Pin-ctls: 0x21: IN VREF_50
Unsolicited: tag=04, enabled=1
Power states: D0 D1 D2 D3 EPSS
Power: setting=D3, actual=D3
Node 0x2c [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x2d [Pin Complex] wcaps 0x400701: Stereo Digital
Pincap 0x00000010: OUT
Pin Default 0x474411f0: [N/A] SPDIF Out at Ext Rear Panel
Conn = RCA, Color = Black
DefAssociation = 0xf, Sequence = 0x0
Misc = NO_PRESENCE
Pin-ctls: 0x40: OUT
Power states: D0 D1 D2 D3 EPSS
Power: setting=D0, actual=D0
Connection: 1
0x0e
Node 0x2e [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x2f [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x30 [Pin Complex] wcaps 0x40040b: Stereo Amp-In
Amp-In caps: ofs=0x00, nsteps=0x03, stepsize=0x2f, mute=0 Amp-In vals: [0x00 0x00]
Pincap 0x00000020: IN
Pin Default 0x50a601f0: [N/A] Mic at Int N/A
Conn = Digital, Color = Unknown
DefAssociation = 0xf, Sequence = 0x0
Misc = NO_PRESENCE
Pin-ctls: 0x00:
Power states: D0 D1 D2 D3 EPSS
Power: setting=D0, actual=D0
Node 0x31 [Pin Complex] wcaps 0x40050c: Mono Amp-Out
Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-Out vals: [0x00]
Pincap 0x00000010: OUT
Pin Default 0x501701f0: [N/A] Speaker at Int N/A
Conn = Analog, Color = Unknown
DefAssociation = 0xf, Sequence = 0x0
Misc = NO_PRESENCE
Pin-ctls: 0x00:
Power states: D0 D1 D2 D3 EPSS
Power: setting=D3, actual=D3
Connection: 1
0x3e
Node 0x32 [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x33 [Pin Complex] wcaps 0x40058d: Stereo Amp-Out
Control: name="Headphone Playback Switch", index=0, device=0 Amp-Out caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1 Amp-Out vals: [0x80 0x80]
Pincap 0x0000001c: OUT HP Detect
Pin Default 0x0221401f: [Jack] HP Out at Ext Front
Conn = 1/8, Color = Green
DefAssociation = 0x1, Sequence = 0xf
Pin-ctls: 0xc0: OUT HP
Unsolicited: tag=24, enabled=1
Power states: D0 D1 D2 D3 EPSS
Power: setting=D3, actual=D3
Connection: 1
0x1d
Node 0x34 [Audio Selector] wcaps 0x300501: Stereo
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Connection: 2
0x08* 0x09
Node 0x35 [Audio Selector] wcaps 0x300501: Stereo
Power states: D0 D1 D2 D3
Power: setting=D3, actual=D3
Connection: 2
0x08* 0x09
Node 0x36 [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x37 [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x38 [Audio Selector] wcaps 0x300501: Stereo
Power states: D0 D1 D2 D3
Power: setting=D3, actual=D3
Connection: 2
0x08* 0x09
Node 0x39 [Audio Selector] wcaps 0x300501: Stereo
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Connection: 2
0x08* 0x09
Node 0x3a [Audio Selector] wcaps 0x300501: Stereo
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Connection: 2
0x08* 0x09
Node 0x3b [Vendor Defined Widget] wcaps 0xf00000: Mono Node 0x3c [Audio Selector] wcaps 0x300501: Stereo
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Connection: 2
0x08* 0x09
Node 0x3d [Audio Selector] wcaps 0x300501: Stereo
Power states: D0 D1 D2 D3
Power: setting=D3, actual=D3
Connection: 2
0x08* 0x09
Node 0x3e [Audio Mixer] wcaps 0x200500: Mono
Power states: D0 D1 D2 D3
Power: setting=D0, actual=D0
Connection: 1
0x1c
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At Tue, 13 Apr 2010 15:38:53 -0300,
Quoted 8 lines · Herton Ronaldo Krzesinski
On VIA VT1812/VT2002P, the "Master Front Playback Switch" doesn't mute first line-out. This is an issue, for example I saw a laptop with VT1812 and only one line-out (main speaker) that doesn't mute main speaker, because the master switch doesn't act on first line-out, and first line-out nid in array is assigned to speaker as expected by autoconfig code.
Quoted 5 lines
But there is one more issue also: main switches and automute code deal with mute on same Amp-Outs, which can cause conflicts, thus if you mute "Master Front Playback Switch" and remove headphone for example, it will not respect the mixer setting. To solve it, we can change the pin type instead of muting Amp-Out, which is done here.
The problem is rather that "Master Front" is a misleading name. "Master Front" volume control exists for other VIA codecs because there is another "Front" volume that is assigned to a pin widget. So, this "Master" isn't really a master control.
IMO, a better way would be to rename this "Master Front" to either a pin-specific one ("Speaker", etc), and make a vmaster control to bind both this and headphone controls, like other codecs.
I'm going to try to implement it...
thanks,
Takashi
At Wed, 14 Apr 2010 14:42:44 +0200,
Quoted 22 lines · I wrote:
At Tue, 13 Apr 2010 15:38:53 -0300,
Quoted 8 lines · Herton Ronaldo Krzesinski
On VIA VT1812/VT2002P, the "Master Front Playback Switch" doesn't mute first line-out. This is an issue, for example I saw a laptop with VT1812 and only one line-out (main speaker) that doesn't mute main speaker, because the master switch doesn't act on first line-out, and first line-out nid in array is assigned to speaker as expected by autoconfig code.
Quoted 5 lines
But there is one more issue also: main switches and automute code deal with mute on same Amp-Outs, which can cause conflicts, thus if you mute "Master Front Playback Switch" and remove headphone for example, it will not respect the mixer setting. To solve it, we can change the pin type instead of muting Amp-Out, which is done here.
The problem is rather that "Master Front" is a misleading name. "Master Front" volume control exists for other VIA codecs because there is another "Front" volume that is assigned to a pin widget. So, this "Master" isn't really a master control.
Quoted 5 lines
IMO, a better way would be to rename this "Master Front" to either a pin-specific one ("Speaker", etc), and make a vmaster control to bind both this and headphone controls, like other codecs.
I'm going to try to implement it...
Something like below.
BTW, I fixed another bugs in patch_via.c, which should go to 2.6.34. They are included in the latest sound git tree or alsa-driver snapshot.
Give it a try.
thanks,
Takashi
---
sound/pci/hda/patch_via.c +174 -154
@@ -157,6 +157,11 @@ struct via_spec {#ifdef CONFIG_SND_HDA_POWER_SAVE struct hda_loopback_check loopback;#endif + +/* for virtual master */ +hda_nid_t vmaster_nid; +const char **slave_vols; +const char **slave_sws; };static struct via_spec *via_new_spec (struct hda_codec *codec)
@@ -1881,11 +1886,35 @@ static struct hda_pcm_stream vt1708_pcm_digital_capture = { .channels_max = 2, }; +/* +* slave controls for virtual master +*/ +static const char *via_slave_vols[] = { +"Front Playback Volume" , +"Surround Playback Volume" , +"Center Playback Volume" , +"LFE Playback Volume" , +"Side Playback Volume" , +"Headphone Playback Volume" , +NULL , +}; + +static const char *via_slave_sws[] = { +"Front Playback Switch" , +"Surround Playback Switch" , +"Center Playback Switch" , +"LFE Playback Switch" , +"Side Playback Switch" , +"Headphone Playback Switch" , +NULL , +}; +static int via_build_controls (struct hda_codec *codec) {struct via_spec *spec = codec->spec;struct snd_kcontrol *kctl;struct snd_kcontrol_new *knew; +const char **slave;int err, i;for (i =0 ; i < spec->num_mixers; i++) {
@@ -1911,6 +1940,31 @@ static int via_build_controls(struct hda_codec *codec)return err; } +/* if we have no master control, let's create it */ +if (!snd_hda_find_mixer_ctl (codec,"Master Playback Volume" )) { +unsigned int vmaster_tlv[4 ]; +snd_hda_set_vmaster_tlv (codec, spec->vmaster_nid, +HDA_OUTPUT , vmaster_tlv); +if (spec->slave_vols) + slave = spec->slave_vols; +else + slave = via_slave_vols; + err =snd_hda_add_vmaster (codec,"Master Playback Volume" , + vmaster_tlv, slave); +if (err <0 ) +return err; + } +if (!snd_hda_find_mixer_ctl (codec,"Master Playback Switch" )) { +if (spec->slave_vols) + slave = spec->slave_sws; +else + slave = via_slave_sws; + err =snd_hda_add_vmaster (codec,"Master Playback Switch" , +NULL , slave); +if (err <0 ) +return err; + } +/* assign Capture Source enums to NID */ kctl =snd_hda_find_mixer_ctl (codec,"Input Source" );for (i =0 ; kctl && i < kctl->count; i++) {
@@ -2268,6 +2322,19 @@ static int vt1708_auto_fill_dac_nids(struct via_spec *spec,return 0 ; } +static const char *get_line_out_label (const struct auto_pin_cfg *cfg, +int can_be_master) +{ +if (can_be_master && !cfg->speaker_pins[0 ] && !cfg->hp_pins[0 ]) +return "Master" ; +else if (cfg->line_out_type ==AUTO_PIN_SPEAKER_OUT ) +return "Speaker" ; +else if (cfg->line_out_type ==AUTO_PIN_HP_OUT ) +return "Headphone" ; +else +return "Line-Out" ; +} +/* add playback controls from the parsed DAC table */ static int vt1708_auto_create_multi_out_ctls (struct via_spec *spec,const struct auto_pin_cfg *cfg)
@@ -2311,44 +2378,36 @@ static int vt1708_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { -/* add control to mixer index 0 */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - -/* add control to PW3 */ + }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;sprintf (name,"%s Playback Switch" , chname[i]); err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; - }else { -sprintf (name,"%s Playback Volume" , chname[i]); +if (i !=AUTO_SEQ_FRONT ) +continue ; + +/* add control to PW3 */ +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; -sprintf (name,"%s Playback Switch" , chname[i]); +sprintf (name,"%s Playback Switch" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;
@@ -2923,35 +2982,9 @@ static int vt1709_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { -/* ADD control to mixer index 0 */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - -/* add control to PW3 */ -sprintf (name,"%s Playback Volume" , chname[i]); - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , -HDA_OUTPUT )); -if (err <0 ) -return err; -sprintf (name,"%s Playback Switch" , chname[i]); - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , -HDA_OUTPUT )); -if (err <0 ) -return err; - }else if (i ==AUTO_SEQ_SURROUND ) { + }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0,
@@ -2964,16 +2997,21 @@ static int vt1709_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_SIDE ) { -sprintf (name,"%s Playback Volume" , chname[i]); +if (i !=AUTO_SEQ_FRONT ) +continue ; + +/* add control to PW3 */ +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; -sprintf (name,"%s Playback Switch" , chname[i]); +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;
@@ -3504,44 +3542,36 @@ static int vt1708B_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { -/* add control to mixer index 0 */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - -/* add control to PW3 */ + }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;sprintf (name,"%s Playback Switch" , chname[i]); err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; - }else { -sprintf (name,"%s Playback Volume" , chname[i]); +if (i !=AUTO_SEQ_FRONT ) +continue ; + +/* add control to PW3 */ +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; -sprintf (name,"%s Playback Switch" , chname[i]); +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;
@@ -3966,22 +3996,9 @@ static int vt1708S_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { -/* add control to mixer index 0 */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , -HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , -HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - -/* Front */ + }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0,
@@ -3995,14 +4012,18 @@ static int vt1708S_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else { -sprintf (name,"%s Playback Volume" , chname[i]); +if (i !=AUTO_SEQ_FRONT ) +continue ; + +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name,HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; -sprintf (name,"%s Playback Switch" , chname[i]); +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, HDA_COMPOSE_AMP_VAL(nid_mute, 3, 0,
@@ -4366,31 +4387,33 @@ static int vt1702_auto_fill_dac_nids(struct via_spec *spec,static int vt1702_auto_create_line_out_ctls (struct via_spec *spec,const struct auto_pin_cfg *cfg) { +char name[32 ];int err;if (!cfg->line_out_pins[0 ])return -1 ; + spec->vmaster_nid =0x1a ;/* add control to mixer index 0 */ err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , +"Front Playback Volume" ,HDA_COMPOSE_AMP_VAL (0x1A ,3 ,0 ,HDA_INPUT ));if (err <0 )return err; err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , +"Front Playback Switch" ,HDA_COMPOSE_AMP_VAL (0x1A ,3 ,0 ,HDA_INPUT ));if (err <0 )return err;/* Front */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Front Playback Volume" , +sprintf (name,"%s Playback Volume" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name,HDA_COMPOSE_AMP_VAL (0x10 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Front Playback Switch" , +sprintf (name,"%s Playback Switch" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name,HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;
@@ -4793,22 +4816,9 @@ static int vt1718S_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { -/* Front */ -sprintf (name,"%s Playback Volume" , chname[i]); - err =via_add_control ( - spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT )); -if (err <0 ) -return err; -sprintf (name,"%s Playback Switch" , chname[i]); - err =via_add_control ( - spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid_mute,3 ,0 , -HDA_OUTPUT )); -if (err <0 ) -return err; }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err = via_add_control( spec, VIA_CTL_WIDGET_VOL, name,
@@ -5279,21 +5289,9 @@ static int vt1716S_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { - - err =via_add_control ( - spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , -HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 ,HDA_INPUT )); -if (err <0 ) -return err; - err =via_add_control ( - spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , -HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 ,HDA_INPUT )); -if (err <0 ) -return err; - + }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err = via_add_control( spec, VIA_CTL_WIDGET_VOL, name,
@@ -5307,18 +5305,19 @@ static int vt1716S_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else { -sprintf (name,"%s Playback Volume" , chname[i]); - err =via_add_control ( - spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT )); +if (i !=AUTO_SEQ_FRONT ) +continue ; + +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); + err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, +HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 ,HDA_INPUT ));if (err <0 )return err; -sprintf (name,"%s Playback Switch" , chname[i]); - err =via_add_control ( - spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid_mute,3 ,0 , -HDA_OUTPUT )); +sprintf (name,"%s Playback Switch" , +get_line_out_label (cfg,0 )); + err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, +HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 ,HDA_INPUT ));if (err <0 )return err; }
@@ -5646,24 +5645,41 @@ static int vt2002P_auto_fill_dac_nids(struct via_spec *spec,return 0 ; } +static const char *vt2002_slave_vols[] = { +"Headphone Playback Volume" , +"Speaker Playback Volume" , +"Line-Out Playback Volume" , +NULL , +}; + +static const char *vt2002_slave_sws[] = { +"Headphone Playback Switch" , +"Speaker Playback Switch" , +"Line-Out Playback Switch" , +NULL , +}; +/* add playback controls from the parsed DAC table */ static int vt2002P_auto_create_multi_out_ctls (struct via_spec *spec,const struct auto_pin_cfg *cfg) { +char name[32 ];int err;if (!cfg->line_out_pins[0 ])return -1 ; - + spec->vmaster_nid =0x08 ; + spec->slave_vols = vt2002_slave_vols; + spec->slave_sws = vt2002_slave_sws;/* Line-Out: PortE */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , +sprintf (name,"%s Playback Volume" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name,HDA_COMPOSE_AMP_VAL (0x8 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; - err =via_add_control (spec,VIA_CTL_WIDGET_BIND_PIN_MUTE , -"Master Front Playback Switch" , +sprintf (name,"%s Playback Switch" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_BIND_PIN_MUTE , name,HDA_COMPOSE_AMP_VAL (0x26 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;
@@ -6000,19 +6016,23 @@ static int vt1812_auto_fill_dac_nids(struct via_spec *spec,static int vt1812_auto_create_multi_out_ctls (struct via_spec *spec,const struct auto_pin_cfg *cfg) { +char name[32 ];int err;if (!cfg->line_out_pins[0 ])return -1 ; + spec->vmaster_nid =0x08 ; + spec->slave_vols = vt2002_slave_vols; + spec->slave_sws = vt2002_slave_sws;/* Line-Out: PortE */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Front Playback Volume" , +sprintf (name,"%s Playback Volume" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name,HDA_COMPOSE_AMP_VAL (0x8 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; - err =via_add_control (spec,VIA_CTL_WIDGET_BIND_PIN_MUTE , -"Front Playback Switch" , +sprintf (name,"%s Playback Switch" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_BIND_PIN_MUTE , name,HDA_COMPOSE_AMP_VAL (0x28 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;
Em Qua 14 Abr 2010, às 10:40:58, Takashi Iwai escreveu:
Quoted 28 lines
At Wed, 14 Apr 2010 14:42:44 +0200,
Quoted 26 lines · I wrote:
At Tue, 13 Apr 2010 15:38:53 -0300,
Quoted 8 lines · Herton Ronaldo Krzesinski
On VIA VT1812/VT2002P, the "Master Front Playback Switch" doesn't mute first line-out. This is an issue, for example I saw a laptop with VT1812 and only one line-out (main speaker) that doesn't mute main speaker, because the master switch doesn't act on first line-out, and first line-out nid in array is assigned to speaker as expected by autoconfig code.
Quoted 5 lines
But there is one more issue also: main switches and automute code deal with mute on same Amp-Outs, which can cause conflicts, thus if you mute "Master Front Playback Switch" and remove headphone for example, it will not respect the mixer setting. To solve it, we can change the pin type instead of muting Amp-Out, which is done here.
The problem is rather that "Master Front" is a misleading name. "Master Front" volume control exists for other VIA codecs because there is another "Front" volume that is assigned to a pin widget. So, this "Master" isn't really a master control.
IMO, a better way would be to rename this "Master Front" to either a pin-specific one ("Speaker", etc), and make a vmaster control to bind both this and headphone controls, like other codecs.
Quoted 7 lines
Quoted 1 line
I'm going to try to implement it...
Something like below.
BTW, I fixed another bugs in
patch_via.c, which should go to 2.6.34. They are included in the latest sound git tree or alsa-driver snapshot.
Hi Takashi,
I was testing with 2.6.33. Now I built and tested latest sound-2.6 tree with your patch below, but still the problem exists. It now creates virtual master control, but it does nothing because it doesn't mute speaker pin. Also there is still the problem that the automute code conflicts with master control. I agree that it was needing the virtual master control, and should need create control for speaker, which it now does, just the mute switch points to wrong nid. I made following diff on top of yours to fix the issues:
sound/pci/hda/patch_via.c +16 -17
@@ -300,8 +300,6 @@ static int analog_input_switch_put(struct snd_kcontrol *kcontrol, .put = analog_input_switch_put, \ .private_value = HDA_COMPOSE_AMP_VAL(0, 3, 0, 0) } -static void via_hp_bind_automute (struct hda_codec *codec); -static int bind_pin_switch_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -348,9 +346,6 @@ static int bind_pin_switch_put(struct snd_kcontrol *kcontrol,snd_hda_codec_amp_stereo ( codec, spec->autocfg.speaker_pins[i],HDA_OUTPUT ,0 ,HDA_AMP_MUTE ,0 ); -/* unmute */ -via_hp_bind_automute (codec); - }else {if (lmute) {/* Mute all left channels */
@@ -2190,18 +2185,18 @@ static void via_hp_bind_automute(struct hda_codec *codec)if (!spec->hp_independent_mode) {/* Mute Line-Outs */ for (i =0 ; i < spec->autocfg.line_outs; i++) -snd_hda_codec_amp_stereo ( - codec, spec->autocfg.line_out_pins[i], -HDA_OUTPUT ,0 , -HDA_AMP_MUTE , hp_present ?HDA_AMP_MUTE :0 ); +snd_hda_codec_write (codec, + spec->autocfg.line_out_pins[i], +0 ,AC_VERB_SET_PIN_WIDGET_CONTROL , + hp_present ?0 :PIN_OUT );if (hp_present) present = hp_present; }/* Speakers */ for (i =0 ; i < spec->autocfg.speaker_outs; i++) -snd_hda_codec_amp_stereo ( - codec, spec->autocfg.speaker_pins[i],HDA_OUTPUT ,0 , -HDA_AMP_MUTE , present ?HDA_AMP_MUTE :0 ); +snd_hda_codec_write (codec, spec->autocfg.speaker_pins[i],0 , +AC_VERB_SET_PIN_WIDGET_CONTROL , + present ?0 :PIN_OUT ); }
@@ -4414,7 +4409,8 @@ static int vt1702_auto_create_line_out_ctls(struct via_spec *spec,return err;sprintf (name,"%s Playback Switch" ,get_line_out_label (cfg,1 )); err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 ,HDA_OUTPUT )); +HDA_COMPOSE_AMP_VAL (cfg->line_out_pins[0 ], +3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;
@@ -5679,8 +5675,9 @@ static int vt2002P_auto_create_multi_out_ctls(struct via_spec *spec,if (err <0 )return err;sprintf (name,"%s Playback Switch" ,get_line_out_label (cfg,1 )); - err =via_add_control (spec,VIA_CTL_WIDGET_BIND_PIN_MUTE , name, -HDA_COMPOSE_AMP_VAL (0x26 ,3 ,0 ,HDA_OUTPUT )); + err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, +HDA_COMPOSE_AMP_VAL (cfg->line_out_pins[0 ], +3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;
@@ -6032,8 +6029,9 @@ static int vt1812_auto_create_multi_out_ctls(struct via_spec *spec,if (err <0 )return err;sprintf (name,"%s Playback Switch" ,get_line_out_label (cfg,1 )); - err =via_add_control (spec,VIA_CTL_WIDGET_BIND_PIN_MUTE , name, -HDA_COMPOSE_AMP_VAL (0x28 ,3 ,0 ,HDA_OUTPUT )); + err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, +HDA_COMPOSE_AMP_VAL (cfg->line_out_pins[0 ], +3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;
@@ -6050,6 +6048,7 @@ static int vt1812_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) spec->multiout.hp_nid =0x9 ; spec->hp_independent_mode_index =1 ; +/* FIXME: check that we really have hp pin connected to hp_nid */ err = via_add_control(spec, VIA_CTL_WIDGET_VOL, "Headphone Playback Volume",
So, the following problems are fixed by above:
- Speaker mute switch pointing to wrong nid (via_add_control change on *auto_create_multi_out_ctls, I changed for vt2002p/vt1702 also, which seems to need same change
- switch to pin type switch for automute as mixer controls already deals with same amp-outs and cause conflict
- Remove use of VIA_CTL_WIDGET_BIND_PIN_MUTE, replace to VIA_CTL_WIDGET_MUTE, since it's uneeded now with virtual master control addition (otherwise when you mute speaker on mixer, instead of muting just speaker it mutes all outputs... because of bind_pin_switch_put function
I think we should remove VIA_CTL_WIDGET_BIND_PIN_MUTE and related code?)
And I noticed a problem with headphone volume mixer setting:
- TODO (FIXME comment I added): removal of independent hp missed code addition for automatically make hp_nid to receive audio from Audio Output 0x9, we must check in codec that audio selector before hp pin selects nid 0x09, by default it's 0x08 which is selected, and headphone volume slider doesn't have any effect, as acts on 0x09 audio output.
Please comment on those.
Quoted 543 lines
Give it a try.
thanks,
Takashi
---
sound/pci/hda/patch_via.c +174
-154@@ -157,6 +157,11 @@ struct via_spec {#ifdef CONFIG_SND_HDA_POWER_SAVE struct hda_loopback_check loopback;#endif + +/* for virtual master */ +hda_nid_t vmaster_nid; +const char **slave_vols; +const char **slave_sws; };static struct via_spec *via_new_spec (struct hda_codec *codec)@@ -1881,11 +1886,35 @@ static struct hda_pcm_stream vt1708_pcm_digital_capture = { .channels_max = 2, }; +/* +* slave controls for virtual master +*/ +static const char *via_slave_vols[] = { +"Front Playback Volume" , +"Surround Playback Volume" , +"Center Playback Volume" , +"LFE Playback Volume" , +"Side Playback Volume" , +"Headphone Playback Volume" , +NULL , +}; + +static const char *via_slave_sws[] = { +"Front Playback Switch" , +"Surround Playback Switch" , +"Center Playback Switch" , +"LFE Playback Switch" , +"Side Playback Switch" , +"Headphone Playback Switch" , +NULL , +}; +static int via_build_controls (struct hda_codec *codec) {struct via_spec *spec = codec->spec;struct snd_kcontrol *kctl;struct snd_kcontrol_new *knew; +const char **slave;int err, i;for (i =0 ; i < spec->num_mixers; i++) {@@ -1911,6 +1940,31 @@ static int via_build_controls(struct hda_codec *codec)return err; } +/* if we have no master control, let's create it */ +if (!snd_hda_find_mixer_ctl (codec,"Master Playback Volume" )) { +unsigned int vmaster_tlv[4 ]; +snd_hda_set_vmaster_tlv (codec, spec->vmaster_nid, +HDA_OUTPUT , vmaster_tlv); +if (spec->slave_vols) + slave = spec->slave_vols; +else + slave = via_slave_vols; + err =snd_hda_add_vmaster (codec,"Master Playback Volume" , + vmaster_tlv, slave); +if (err <0 ) +return err; + } +if (!snd_hda_find_mixer_ctl (codec,"Master Playback Switch" )) { +if (spec->slave_vols) + slave = spec->slave_sws; +else + slave = via_slave_sws; + err =snd_hda_add_vmaster (codec,"Master Playback Switch" , +NULL , slave); +if (err <0 ) +return err; + } +/* assign Capture Source enums to NID */ kctl =snd_hda_find_mixer_ctl (codec,"Input Source" );for (i =0 ; kctl && i < kctl->count; i++) {@@ -2268,6 +2322,19 @@ static int vt1708_auto_fill_dac_nids(struct via_spec *spec,return 0 ; } +static const char *get_line_out_label (const struct auto_pin_cfg *cfg, +int can_be_master) +{ +if (can_be_master && !cfg->speaker_pins[0 ] && !cfg->hp_pins[0 ]) +return "Master" ; +else if (cfg->line_out_type ==AUTO_PIN_SPEAKER_OUT ) +return "Speaker" ; +else if (cfg->line_out_type ==AUTO_PIN_HP_OUT ) +return "Headphone" ; +else +return "Line-Out" ; +} +/* add playback controls from the parsed DAC table */ static int vt1708_auto_create_multi_out_ctls (struct via_spec *spec,const struct auto_pin_cfg *cfg)@@ -2311,44 +2378,36 @@ static int vt1708_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { -/* add control to mixer index 0 */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - -/* add control to PW3 */ + }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;sprintf (name,"%s Playback Switch" , chname[i]); err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; - }else { -sprintf (name,"%s Playback Volume" , chname[i]); +if (i !=AUTO_SEQ_FRONT ) +continue ; + +/* add control to PW3 */ +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; -sprintf (name,"%s Playback Switch" , chname[i]); +sprintf (name,"%s Playback Switch" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;@@ -2923,35 +2982,9 @@ static int vt1709_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { -/* ADD control to mixer index 0 */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - -/* add control to PW3 */ -sprintf (name,"%s Playback Volume" , chname[i]); - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , -HDA_OUTPUT )); -if (err <0 ) -return err; -sprintf (name,"%s Playback Switch" , chname[i]); - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , -HDA_OUTPUT )); -if (err <0 ) -return err; - }else if (i ==AUTO_SEQ_SURROUND ) { + }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0,@@ -2964,16 +2997,21 @@ static int vt1709_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_SIDE ) { -sprintf (name,"%s Playback Volume" , chname[i]); +if (i !=AUTO_SEQ_FRONT ) +continue ; + +/* add control to PW3 */ +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; -sprintf (name,"%s Playback Switch" , chname[i]); +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;@@ -3504,44 +3542,36 @@ static int vt1708B_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { -/* add control to mixer index 0 */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - -/* add control to PW3 */ + }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;sprintf (name,"%s Playback Switch" , chname[i]); err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; - }else { -sprintf (name,"%s Playback Volume" , chname[i]); +if (i !=AUTO_SEQ_FRONT ) +continue ; + +/* add control to PW3 */ +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; -sprintf (name,"%s Playback Switch" , chname[i]); +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 , +HDA_COMPOSE_AMP_VAL (nid,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;@@ -3966,22 +3996,9 @@ static int vt1708S_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { -/* add control to mixer index 0 */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , -HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , -HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 , -HDA_INPUT )); -if (err <0 ) -return err; - -/* Front */ + }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0,@@ -3995,14 +4012,18 @@ static int vt1708S_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else { -sprintf (name,"%s Playback Volume" , chname[i]); +if (i !=AUTO_SEQ_FRONT ) +continue ; + +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name,HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; -sprintf (name,"%s Playback Switch" , chname[i]); +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); err = via_add_control(spec, VIA_CTL_WIDGET_MUTE, name, HDA_COMPOSE_AMP_VAL(nid_mute, 3, 0,@@ -4366,31 +4387,33 @@ static int vt1702_auto_fill_dac_nids(struct via_spec *spec,static int vt1702_auto_create_line_out_ctls (struct via_spec *spec,const struct auto_pin_cfg *cfg) { +char name[32 ];int err;if (!cfg->line_out_pins[0 ])return -1 ; + spec->vmaster_nid =0x1a ;/* add control to mixer index 0 */ err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , +"Front Playback Volume" ,HDA_COMPOSE_AMP_VAL (0x1A ,3 ,0 ,HDA_INPUT ));if (err <0 )return err; err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , +"Front Playback Switch" ,HDA_COMPOSE_AMP_VAL (0x1A ,3 ,0 ,HDA_INPUT ));if (err <0 )return err;/* Front */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Front Playback Volume" , +sprintf (name,"%s Playback Volume" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name,HDA_COMPOSE_AMP_VAL (0x10 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; - err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , -"Front Playback Switch" , +sprintf (name,"%s Playback Switch" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name,HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;@@ -4793,22 +4816,9 @@ static int vt1718S_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { -/* Front */ -sprintf (name,"%s Playback Volume" , chname[i]); - err =via_add_control ( - spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT )); -if (err <0 ) -return err; -sprintf (name,"%s Playback Switch" , chname[i]); - err =via_add_control ( - spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid_mute,3 ,0 , -HDA_OUTPUT )); -if (err <0 ) -return err; }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err = via_add_control( spec, VIA_CTL_WIDGET_VOL, name,@@ -5279,21 +5289,9 @@ static int vt1716S_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else if (i ==AUTO_SEQ_FRONT ) { - - err =via_add_control ( - spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , -HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 ,HDA_INPUT )); -if (err <0 ) -return err; - err =via_add_control ( - spec,VIA_CTL_WIDGET_MUTE , -"Master Front Playback Switch" , -HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 ,HDA_INPUT )); -if (err <0 ) -return err; - + }else { +if (!spec->vmaster_nid) + spec->vmaster_nid = nid_vol;sprintf (name,"%s Playback Volume" , chname[i]); err = via_add_control( spec, VIA_CTL_WIDGET_VOL, name,@@ -5307,18 +5305,19 @@ static int vt1716S_auto_create_multi_out_ctls(struct via_spec *spec, HDA_OUTPUT));if (err <0 )return err; - }else { -sprintf (name,"%s Playback Volume" , chname[i]); - err =via_add_control ( - spec,VIA_CTL_WIDGET_VOL , name, -HDA_COMPOSE_AMP_VAL (nid_vol,3 ,0 ,HDA_OUTPUT )); +if (i !=AUTO_SEQ_FRONT ) +continue ; + +sprintf (name,"%s Playback Volume" , +get_line_out_label (cfg,0 )); + err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name, +HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 ,HDA_INPUT ));if (err <0 )return err; -sprintf (name,"%s Playback Switch" , chname[i]); - err =via_add_control ( - spec,VIA_CTL_WIDGET_MUTE , name, -HDA_COMPOSE_AMP_VAL (nid_mute,3 ,0 , -HDA_OUTPUT )); +sprintf (name,"%s Playback Switch" , +get_line_out_label (cfg,0 )); + err =via_add_control (spec,VIA_CTL_WIDGET_MUTE , name, +HDA_COMPOSE_AMP_VAL (0x16 ,3 ,0 ,HDA_INPUT ));if (err <0 )return err; }@@ -5646,24 +5645,41 @@ static int vt2002P_auto_fill_dac_nids(struct via_spec *spec,return 0 ; } +static const char *vt2002_slave_vols[] = { +"Headphone Playback Volume" , +"Speaker Playback Volume" , +"Line-Out Playback Volume" , +NULL , +}; + +static const char *vt2002_slave_sws[] = { +"Headphone Playback Switch" , +"Speaker Playback Switch" , +"Line-Out Playback Switch" , +NULL , +}; +/* add playback controls from the parsed DAC table */ static int vt2002P_auto_create_multi_out_ctls (struct via_spec *spec,const struct auto_pin_cfg *cfg) { +char name[32 ];int err;if (!cfg->line_out_pins[0 ])return -1 ; - + spec->vmaster_nid =0x08 ; + spec->slave_vols = vt2002_slave_vols; + spec->slave_sws = vt2002_slave_sws;/* Line-Out: PortE */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Master Front Playback Volume" , +sprintf (name,"%s Playback Volume" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name,HDA_COMPOSE_AMP_VAL (0x8 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; - err =via_add_control (spec,VIA_CTL_WIDGET_BIND_PIN_MUTE , -"Master Front Playback Switch" , +sprintf (name,"%s Playback Switch" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_BIND_PIN_MUTE , name,HDA_COMPOSE_AMP_VAL (0x26 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;@@ -6000,19 +6016,23 @@ static int vt1812_auto_fill_dac_nids(struct via_spec *spec,static int vt1812_auto_create_multi_out_ctls (struct via_spec *spec,const struct auto_pin_cfg *cfg) { +char name[32 ];int err;if (!cfg->line_out_pins[0 ])return -1 ; + spec->vmaster_nid =0x08 ; + spec->slave_vols = vt2002_slave_vols; + spec->slave_sws = vt2002_slave_sws;/* Line-Out: PortE */ - err =via_add_control (spec,VIA_CTL_WIDGET_VOL , -"Front Playback Volume" , +sprintf (name,"%s Playback Volume" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_VOL , name,HDA_COMPOSE_AMP_VAL (0x8 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err; - err =via_add_control (spec,VIA_CTL_WIDGET_BIND_PIN_MUTE , -"Front Playback Switch" , +sprintf (name,"%s Playback Switch" ,get_line_out_label (cfg,1 )); + err =via_add_control (spec,VIA_CTL_WIDGET_BIND_PIN_MUTE , name,HDA_COMPOSE_AMP_VAL (0x28 ,3 ,0 ,HDA_OUTPUT ));if (err <0 )return err;
Signature · 2 lines
[]'s Herton