[alsa-devel] Missing beep controls for Via HDA codec (snd_hda_codec_via)
My VT1802 chip has a beep-generating node:
$ cat /proc/asound/card1/codec#0 Codec: VIA VT1802 ... Vendor Id: 0x11068446 Subsystem Id: 0x15587410 Revision Id: 0x100000 ... Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0 ...
But I'm missing the:
Control: name=...
entries that I think I need to manage this widget from alsamixer. For example, sambrian posts codec output for a CX20561 chip which has [1]:
Node 0x13 [Beep Generator Widget] wcaps 0x70000c: Mono Amp-Out Control: name="Beep Playback Volume", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Control: name="Beep Playback Switch", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Amp-Out caps: ofs=0x03, nsteps=0x03, stepsize=0x17, mute=0 Amp-Out vals: [0x00]
I can patch with something like this:
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 3de6d3d..85a0c08 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -1520,8 +1520,10 @@ static int patch_vt2002P(struct hda_codec *codec) spec->gen.mixer_nid = 0x21; override_mic_boost(codec, 0x2b, 0, 3, 40); override_mic_boost(codec, 0x29, 0, 3, 40); - if (spec->codec_type == VT1802) + if (spec->codec_type == VT1802) { + spec->gen.beep_nid = 0x22; fix_vt1802_connections(codec); + } add_secret_dac_path(codec);
snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups);
to get a dmesg entry like:
input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card1/hdaudioC1D0/input15
but that doesn't add the beep controls. Looking at patch_analog.c, patch_conexant.c, and patch_realtek.c for inspiration, I expect we'll need an HDA_CODEC_MUTE_BEEP(_MONO) entry, and possibly an HDA_CODEC_VOLUME(_MONO) entry, but I'm not sure if these should be mono or not, or if they should be inputs (following patch_realtek.c) or outputs (following patch_analog.c and patch_conexant.c). I've filled out Via's datasheet-request form [2], but I don't know how likely that is to be accepted.
Does anyone have a VT1802 datasheet that they're allowed to share (or some free time to fill in Via beep support on their own)? Or am I barking up the wrong tree? My only previous experience with this code-base was a beep-tweak for a previous box's Realtek chip [3], but I love my beeps and am happy to poke around with a datasheet until I get this working ;). Maybe folks with more experience can just guess the right code without needing to see specs for the VT1802?
Cheers, Trevor
[1]: http://forums.fedoraforum.org/archive/index.php/t-265822.html [2]: http://www.via.com.tw/en/support/contact_us/ [3]: http://thread.gmane.org/gmane.linux.alsa.devel/121300
At Sun, 22 Mar 2015 00:54:49 -0700, W. Trevor King wrote:
My VT1802 chip has a beep-generating node:
$ cat /proc/asound/card1/codec#0 Codec: VIA VT1802 ... Vendor Id: 0x11068446 Subsystem Id: 0x15587410 Revision Id: 0x100000 ... Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0 ...
But I'm missing the:
Control: name=...
entries that I think I need to manage this widget from alsamixer. For example, sambrian posts codec output for a CX20561 chip which has [1]:
Node 0x13 [Beep Generator Widget] wcaps 0x70000c: Mono Amp-Out Control: name="Beep Playback Volume", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Control: name="Beep Playback Switch", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Amp-Out caps: ofs=0x03, nsteps=0x03, stepsize=0x17, mute=0 Amp-Out vals: [0x00]
I can patch with something like this:
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 3de6d3d..85a0c08 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -1520,8 +1520,10 @@ static int patch_vt2002P(struct hda_codec *codec) spec->gen.mixer_nid = 0x21; override_mic_boost(codec, 0x2b, 0, 3, 40); override_mic_boost(codec, 0x29, 0, 3, 40);
if (spec->codec_type == VT1802)
if (spec->codec_type == VT1802) {
spec->gen.beep_nid = 0x22; fix_vt1802_connections(codec);
} add_secret_dac_path(codec); snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups);
to get a dmesg entry like:
input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card1/hdaudioC1D0/input15
but that doesn't add the beep controls. Looking at patch_analog.c, patch_conexant.c, and patch_realtek.c for inspiration, I expect we'll need an HDA_CODEC_MUTE_BEEP(_MONO) entry, and possibly an HDA_CODEC_VOLUME(_MONO) entry, but I'm not sure if these should be mono or not, or if they should be inputs (following patch_realtek.c) or outputs (following patch_analog.c and patch_conexant.c). I've filled out Via's datasheet-request form [2], but I don't know how likely that is to be accepted.
According to your output, the node 0x22 has:
Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a]
so this should mono and output.
Other codecs may have different controls because rather controlling in the input of the mixer widget or such.
Takashi
My VT1802 chip has a beep-generating node:
$ cat /proc/asound/card1/codec#0 Codec: VIA VT1802 ... Vendor Id: 0x11068446 Subsystem Id: 0x15587410 Revision Id: 0x100000 ... Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0 ...
But I'm missing the:
Control: name=...
entries that I think I need to manage this widget from alsamixer. For example, sambrian posts codec output for a CX20561 chip which has [1]:
Node 0x13 [Beep Generator Widget] wcaps 0x70000c: Mono Amp-Out Control: name="Beep Playback Volume", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Control: name="Beep Playback Switch", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Amp-Out caps: ofs=0x03, nsteps=0x03, stepsize=0x17, mute=0 Amp-Out vals: [0x00]
I can patch with something like this:
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 3de6d3d..85a0c08 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -1520,8 +1520,10 @@ static int patch_vt2002P(struct hda_codec
*codec)
spec->gen.mixer_nid = 0x21; override_mic_boost(codec, 0x2b, 0, 3, 40); override_mic_boost(codec, 0x29, 0, 3, 40);
if (spec->codec_type == VT1802)
if (spec->codec_type == VT1802) {
spec->gen.beep_nid = 0x22; fix_vt1802_connections(codec);
} add_secret_dac_path(codec); snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups);
to get a dmesg entry like:
input: HDA Digital PCBeep as
/devices/pci0000:00/0000:00:1b.0/sound/card1/hdaudioC1D0/input15
but that doesn't add the beep controls. Looking at patch_analog.c, patch_conexant.c, and patch_realtek.c for inspiration, I expect we'll need an HDA_CODEC_MUTE_BEEP(_MONO) entry, and possibly an HDA_CODEC_VOLUME(_MONO) entry, but I'm not sure if these should be mono or not, or if they should be inputs (following patch_realtek.c) or outputs (following patch_analog.c and patch_conexant.c). I've filled out Via's datasheet-request form [2], but I don't know how likely that is to be accepted.
According to your output, the node 0x22 has:
Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a]
so this should mono and output.
Other codecs may have different controls because rather controlling in the input of the mixer widget or such.
Why beep generator cannot automically found by auto parser ?
7.3.4.5 Audio Function Group Capabilities
The Audio Parameter returns a set of bit fields describing the audio capabilities of the Audio Function.
Parameter ID: 08h Response Format:
31:17 16 15:12 11:8 7:4 3:0 Rsvd Beep Gen Rsvd Input Delay Rsvd Output Delay
Figure 85. Audio Function Group Capabilities Response Format
BeepGen indicates the presence of an optional Beep Generator with this Audio Function Group
Bit 16 of Audio Function Group Capabilities Response
or using
end_nid = codec->start_nid + codec->num_nodes; for (nid = codec->start_nid; nid < end_nid; nid++) { unsigned int wid_caps = get_wcaps(codec, nid); unsigned int wid_type = get_wcaps_type(wid_caps); if (wid_type == AC_WID_BEEP) spec->gen.beep_nid = nid; }
At Sun, 22 Mar 2015 21:27:24 +0800, Raymond Yau wrote:
My VT1802 chip has a beep-generating node:
$ cat /proc/asound/card1/codec#0 Codec: VIA VT1802 ... Vendor Id: 0x11068446 Subsystem Id: 0x15587410 Revision Id: 0x100000 ... Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0 ...
But I'm missing the:
Control: name=...
entries that I think I need to manage this widget from alsamixer. For example, sambrian posts codec output for a CX20561 chip which has [1]:
Node 0x13 [Beep Generator Widget] wcaps 0x70000c: Mono Amp-Out Control: name="Beep Playback Volume", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Control: name="Beep Playback Switch", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Amp-Out caps: ofs=0x03, nsteps=0x03, stepsize=0x17, mute=0 Amp-Out vals: [0x00]
I can patch with something like this:
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 3de6d3d..85a0c08 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -1520,8 +1520,10 @@ static int patch_vt2002P(struct hda_codec
*codec)
spec->gen.mixer_nid = 0x21; override_mic_boost(codec, 0x2b, 0, 3, 40); override_mic_boost(codec, 0x29, 0, 3, 40);
if (spec->codec_type == VT1802)
if (spec->codec_type == VT1802) {
spec->gen.beep_nid = 0x22; fix_vt1802_connections(codec);
} add_secret_dac_path(codec); snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups);
to get a dmesg entry like:
input: HDA Digital PCBeep as
/devices/pci0000:00/0000:00:1b.0/sound/card1/hdaudioC1D0/input15
but that doesn't add the beep controls. Looking at patch_analog.c, patch_conexant.c, and patch_realtek.c for inspiration, I expect we'll need an HDA_CODEC_MUTE_BEEP(_MONO) entry, and possibly an HDA_CODEC_VOLUME(_MONO) entry, but I'm not sure if these should be mono or not, or if they should be inputs (following patch_realtek.c) or outputs (following patch_analog.c and patch_conexant.c). I've filled out Via's datasheet-request form [2], but I don't know how likely that is to be accepted.
According to your output, the node 0x22 has:
Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a]
so this should mono and output.
Other codecs may have different controls because rather controlling in the input of the mixer widget or such.
Why beep generator cannot automically found by auto parser ?
It can be, but it's not always connected to the right I/O in the topology, so left as codec-specific for now.
Takashi
2015-3-22 下午11:17 於 "Takashi Iwai" tiwai@suse.de 寫道:
At Sun, 22 Mar 2015 21:27:24 +0800, Raymond Yau wrote:
My VT1802 chip has a beep-generating node:
$ cat /proc/asound/card1/codec#0 Codec: VIA VT1802 ... Vendor Id: 0x11068446 Subsystem Id: 0x15587410 Revision Id: 0x100000 ... Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0 ...
But I'm missing the:
Control: name=...
entries that I think I need to manage this widget from alsamixer.
For
example, sambrian posts codec output for a CX20561 chip which has
[1]:
Node 0x13 [Beep Generator Widget] wcaps 0x70000c: Mono Amp-Out Control: name="Beep Playback Volume", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Control: name="Beep Playback Switch", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Amp-Out caps: ofs=0x03, nsteps=0x03, stepsize=0x17, mute=0 Amp-Out vals: [0x00]
I can patch with something like this:
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 3de6d3d..85a0c08 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -1520,8 +1520,10 @@ static int patch_vt2002P(struct hda_codec
*codec)
spec->gen.mixer_nid = 0x21; override_mic_boost(codec, 0x2b, 0, 3, 40); override_mic_boost(codec, 0x29, 0, 3, 40);
if (spec->codec_type == VT1802)
if (spec->codec_type == VT1802) {
spec->gen.beep_nid = 0x22; fix_vt1802_connections(codec);
} add_secret_dac_path(codec); snd_hda_pick_fixup(codec, NULL, vt2002p_fixups,
via_fixups);
to get a dmesg entry like:
input: HDA Digital PCBeep as
/devices/pci0000:00/0000:00:1b.0/sound/card1/hdaudioC1D0/input15
but that doesn't add the beep controls. Looking at patch_analog.c, patch_conexant.c, and patch_realtek.c for inspiration, I expect
we'll
need an HDA_CODEC_MUTE_BEEP(_MONO) entry, and possibly an HDA_CODEC_VOLUME(_MONO) entry, but I'm not sure if these should be mono or not, or if they should be inputs (following patch_realtek.c) or outputs (following patch_analog.c and patch_conexant.c). I've filled out Via's datasheet-request form [2], but I don't know how likely that is to be accepted.
According to your output, the node 0x22 has:
Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a]
so this should mono and output.
Other codecs may have different controls because rather controlling in the input of the mixer widget or such.
Why beep generator cannot automically found by auto parser ?
It can be, but it's not always connected to the right I/O in the topology, so left as codec-specific for now.
set_beep_amp() use beep_nid if beep generator widget has wcap Amp-Out
If the beep generator widget does not has wcap Amp-Out, it need to find out the node which has wcap Amp-Out and connect to beep generator widget
Node 0x0d [Audio Selector] wcaps 0x30010c: Mono Amp-Out Control: name="Beep Playback Volume", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Control: name="Beep Playback Switch", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Amp-Out caps: ofs=0x0f, nsteps=0x0f, stepsize=0x0b, mute=1 Amp-Out vals: [0x80] Connection: 2 0x10* 0x16
Node 0x10 [Beep Generator Widget] wcaps 0x700000: Mono
Node 0x14 [Power Widget] wcaps 0x500500: Mono Power states: D0 D3 Power: setting=D0, actual=D0 Connection: 13 0x0d 0x0e 0x0f 0x10 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1d
My codec has a beep-generating node:
$ cat /proc/asound/card1/codec#0 Codec: VIA VT1802 ... Vendor Id: 0x11068446 Subsystem Id: 0x15587410 Revision Id: 0x100000 ... Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0 ...
But I was missing the:
Control: name=...
entries that I need to manage this widget from alsamixer. With this patch (based on the similar Mono Amp-Out handling in patch_conexant.c), I get a new:
input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card1/hdaudioC1D0/input15
entry in dmesg and controls to manage that beep:
$ cat /proc/asound/card1/codec#0 | grep -A5 Beep Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Control: name="Beep Playback Volume", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Control: name="Beep Playback Switch", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x12] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0
Signed-off-by: W. Trevor King wking@tremily.us --- On Sun, Mar 22, 2015 at 09:27:24PM +0800, Raymond Yau wrote:
Why beep generator cannot automically found by auto parser ? … end_nid = codec->start_nid + codec->num_nodes; for (nid = codec->start_nid; nid < end_nid; nid++) { unsigned int wid_caps = get_wcaps(codec, nid); unsigned int wid_type = get_wcaps_type(wid_caps); if (wid_type == AC_WID_BEEP) spec->gen.beep_nid = nid; }
This is pretty much what patch_conexant.c's cx_auto_parse_beep() does, so I've just shifted that code over here to handle beeps in VIA codecs. It works on my VT1802, but I don't have any other VIA codecs around to check that it works on all of the VIA codecs (Takashi pointed out that they can be buggy [1]). Do I need to shift the auto_parse_beep() check into the VT1802-specific portion of patch_vt2002P(), or can I leave it here in the generic via_parse_auto_config()? Alternatively, we could wedge it into via_new_spec(), which would give the per-codec patches time to clear spec->gen.beep_nid for broken codecs before via_parse_auto_config() calls snd_hda_gen_parse_auto_config() which consumes beep_nid.
Cheers, Trevor
[1]: id:s5hpp813vva.wl-tiwai@suse.de http://thread.gmane.org/gmane.linux.alsa.devel/135819/focus=135823
sound/pci/hda/patch_via.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 3de6d3d..e4919f8 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -109,6 +109,8 @@ struct via_spec { int hp_work_active; int vt1708_jack_detect;
+ unsigned int beep_amp; + void (*set_widgets_power_state)(struct hda_codec *codec); unsigned int dac_stream_tag[4]; }; @@ -355,6 +357,59 @@ static const struct snd_kcontrol_new via_pin_power_ctl_enum[] = { {} /* terminator */ };
+#ifdef CONFIG_SND_HDA_INPUT_BEEP +static inline void set_beep_amp(struct via_spec *spec, hda_nid_t nid, + int idx, int dir) +{ + spec->gen.beep_nid = nid; + spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); +} +/* additional beep mixers; the actual parameters are overwritten at build */ +static const struct snd_kcontrol_new cxt_beep_mixer[] = { + HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), + HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), + { } /* end */ +}; + +/* create beep controls if needed */ +static int add_beep_ctls(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + int err; + + if (spec->beep_amp) { + const struct snd_kcontrol_new *knew; + for (knew = cxt_beep_mixer; knew->name; knew++) { + struct snd_kcontrol *kctl; + kctl = snd_ctl_new1(knew, codec); + if (!kctl) + return -ENOMEM; + kctl->private_value = spec->beep_amp; + err = snd_hda_ctl_add(codec, 0, kctl); + if (err < 0) + return err; + } + } + return 0; +} + +static void auto_parse_beep(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + hda_nid_t nid, end_nid; + + end_nid = codec->start_nid + codec->num_nodes; + for (nid = codec->start_nid; nid < end_nid; nid++) + if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { + set_beep_amp(spec, nid, 0, HDA_OUTPUT); + break; + } +} +#else +#define set_beep_amp(spec, nid, idx, dir) /* NOP */ +#define add_beep_ctls(codec) 0 +#define auto_parse_beep(codec) +#endif
/* check AA path's mute status */ static bool is_aa_path_mute(struct hda_codec *codec) @@ -441,6 +496,10 @@ static int via_build_controls(struct hda_codec *codec) if (err < 0) return err;
+ err = add_beep_ctls(codec); + if (err < 0) + return err; + if (spec->set_widgets_power_state) spec->mixers[spec->num_mixers++] = via_pin_power_ctl_enum;
@@ -631,6 +690,8 @@ static int via_parse_auto_config(struct hda_codec *codec) if (err < 0) return err;
+ auto_parse_beep(codec); + err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); if (err < 0) return err;
On Wed, Mar 25, 2015 at 12:01:04AM -0700, W. Trevor King wrote:
sound/pci/hda/patch_via.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 3de6d3d..e4919f8 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c
Oh, this patch was based on v3.19, but I'm happy to rebase it if it doesn't apply to whichever tip the ALSA development work is done in.
Cheers, Trevor
At Wed, 25 Mar 2015 00:01:04 -0700, W. Trevor King wrote:
My codec has a beep-generating node:
$ cat /proc/asound/card1/codec#0 Codec: VIA VT1802 ... Vendor Id: 0x11068446 Subsystem Id: 0x15587410 Revision Id: 0x100000 ... Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0 ...
But I was missing the:
Control: name=...
entries that I need to manage this widget from alsamixer. With this patch (based on the similar Mono Amp-Out handling in patch_conexant.c), I get a new:
input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card1/hdaudioC1D0/input15
entry in dmesg and controls to manage that beep:
$ cat /proc/asound/card1/codec#0 | grep -A5 Beep Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Control: name="Beep Playback Volume", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Control: name="Beep Playback Switch", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x12] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0
Signed-off-by: W. Trevor King wking@tremily.us
On Sun, Mar 22, 2015 at 09:27:24PM +0800, Raymond Yau wrote:
Why beep generator cannot automically found by auto parser ? … end_nid = codec->start_nid + codec->num_nodes; for (nid = codec->start_nid; nid < end_nid; nid++) { unsigned int wid_caps = get_wcaps(codec, nid); unsigned int wid_type = get_wcaps_type(wid_caps); if (wid_type == AC_WID_BEEP) spec->gen.beep_nid = nid; }
This is pretty much what patch_conexant.c's cx_auto_parse_beep() does, so I've just shifted that code over here to handle beeps in VIA codecs. It works on my VT1802, but I don't have any other VIA codecs around to check that it works on all of the VIA codecs (Takashi pointed out that they can be buggy [1]). Do I need to shift the auto_parse_beep() check into the VT1802-specific portion of patch_vt2002P(), or can I leave it here in the generic via_parse_auto_config()? Alternatively, we could wedge it into via_new_spec(), which would give the per-codec patches time to clear spec->gen.beep_nid for broken codecs before via_parse_auto_config() calls snd_hda_gen_parse_auto_config() which consumes beep_nid.
I guess it's OK as is. Not all VIA codecs seem to have the beep widget, and the codecs with the beep widget have all the same functionality (digital beep with the output amp).
Care to brush up your patch as a formal form to be merged to upstream? There are a few conflicts with the latest sound.git tree code, but I can manage to resolve them.
Later on, we can move the common code to the generic parser (with yet some behavior flag), but it can be done by another patch.
thanks,
Takashi
Cheers, Trevor
http://thread.gmane.org/gmane.linux.alsa.devel/135819/focus=135823
sound/pci/hda/patch_via.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 3de6d3d..e4919f8 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -109,6 +109,8 @@ struct via_spec { int hp_work_active; int vt1708_jack_detect;
- unsigned int beep_amp;
- void (*set_widgets_power_state)(struct hda_codec *codec); unsigned int dac_stream_tag[4];
}; @@ -355,6 +357,59 @@ static const struct snd_kcontrol_new via_pin_power_ctl_enum[] = { {} /* terminator */ };
+#ifdef CONFIG_SND_HDA_INPUT_BEEP +static inline void set_beep_amp(struct via_spec *spec, hda_nid_t nid,
int idx, int dir)
+{
- spec->gen.beep_nid = nid;
- spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir);
+} +/* additional beep mixers; the actual parameters are overwritten at build */ +static const struct snd_kcontrol_new cxt_beep_mixer[] = {
- HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT),
- HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT),
- { } /* end */
+};
+/* create beep controls if needed */ +static int add_beep_ctls(struct hda_codec *codec) +{
- struct via_spec *spec = codec->spec;
- int err;
- if (spec->beep_amp) {
const struct snd_kcontrol_new *knew;
for (knew = cxt_beep_mixer; knew->name; knew++) {
struct snd_kcontrol *kctl;
kctl = snd_ctl_new1(knew, codec);
if (!kctl)
return -ENOMEM;
kctl->private_value = spec->beep_amp;
err = snd_hda_ctl_add(codec, 0, kctl);
if (err < 0)
return err;
}
- }
- return 0;
+}
+static void auto_parse_beep(struct hda_codec *codec) +{
- struct via_spec *spec = codec->spec;
- hda_nid_t nid, end_nid;
- end_nid = codec->start_nid + codec->num_nodes;
- for (nid = codec->start_nid; nid < end_nid; nid++)
if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) {
set_beep_amp(spec, nid, 0, HDA_OUTPUT);
break;
}
+} +#else +#define set_beep_amp(spec, nid, idx, dir) /* NOP */ +#define add_beep_ctls(codec) 0 +#define auto_parse_beep(codec) +#endif
/* check AA path's mute status */ static bool is_aa_path_mute(struct hda_codec *codec) @@ -441,6 +496,10 @@ static int via_build_controls(struct hda_codec *codec) if (err < 0) return err;
- err = add_beep_ctls(codec);
- if (err < 0)
return err;
- if (spec->set_widgets_power_state) spec->mixers[spec->num_mixers++] = via_pin_power_ctl_enum;
@@ -631,6 +690,8 @@ static int via_parse_auto_config(struct hda_codec *codec) if (err < 0) return err;
- auto_parse_beep(codec);
- err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); if (err < 0) return err;
-- 2.1.0.60.g85f0837
My codec has a beep-generating node:
$ cat /proc/asound/card1/codec#0 Codec: VIA VT1802 ... Vendor Id: 0x11068446 Subsystem Id: 0x15587410 Revision Id: 0x100000 ... Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0 ...
But I was missing the:
Control: name=...
entries that I need to manage this widget from alsamixer. With this patch (based on the similar Mono Amp-Out handling in patch_conexant.c), I get a new:
input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card1/hdaudioC1D0/input15
entry in dmesg and controls to manage that beep:
$ cat /proc/asound/card1/codec#0 | grep -A5 Beep Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Control: name="Beep Playback Volume", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Control: name="Beep Playback Switch", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x12] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0
Signed-off-by: W. Trevor King wking@tremily.us --- On Wed, Mar 25, 2015 at 08:15:51AM +0100, Takashi Iwai wrote:
Care to brush up your patch as a formal form to be merged to upstream? There are a few conflicts with the latest sound.git tree code, but I can manage to resolve them.
Done. The only change since v1 is rebasing from v3.19 to the current sound.git master, resolving some trivial conflicts with 688b12cc (ALSA: hda - Use the new power control for VIA codecs, 2015-03-17). If you feel inclined to make further edits to my commit message, you have my permission.
Later on, we can move the common code to the generic parser (with yet some behavior flag), but it can be done by another patch.
Works for me.
sound/pci/hda/patch_via.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index a34d767..3f63c34f 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -107,6 +107,8 @@ struct via_spec { /* work to check hp jack state */ int hp_work_active; int vt1708_jack_detect; + + unsigned int beep_amp; };
static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec); @@ -266,6 +268,59 @@ static const struct snd_kcontrol_new via_pin_power_ctl_enum[] = { {} /* terminator */ };
+#ifdef CONFIG_SND_HDA_INPUT_BEEP +static inline void set_beep_amp(struct via_spec *spec, hda_nid_t nid, + int idx, int dir) +{ + spec->gen.beep_nid = nid; + spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir); +} +/* additional beep mixers; the actual parameters are overwritten at build */ +static const struct snd_kcontrol_new cxt_beep_mixer[] = { + HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT), + HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT), + { } /* end */ +}; + +/* create beep controls if needed */ +static int add_beep_ctls(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + int err; + + if (spec->beep_amp) { + const struct snd_kcontrol_new *knew; + for (knew = cxt_beep_mixer; knew->name; knew++) { + struct snd_kcontrol *kctl; + kctl = snd_ctl_new1(knew, codec); + if (!kctl) + return -ENOMEM; + kctl->private_value = spec->beep_amp; + err = snd_hda_ctl_add(codec, 0, kctl); + if (err < 0) + return err; + } + } + return 0; +} + +static void auto_parse_beep(struct hda_codec *codec) +{ + struct via_spec *spec = codec->spec; + hda_nid_t nid, end_nid; + + end_nid = codec->start_nid + codec->num_nodes; + for (nid = codec->start_nid; nid < end_nid; nid++) + if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { + set_beep_amp(spec, nid, 0, HDA_OUTPUT); + break; + } +} +#else +#define set_beep_amp(spec, nid, idx, dir) /* NOP */ +#define add_beep_ctls(codec) 0 +#define auto_parse_beep(codec) +#endif
/* check AA path's mute status */ static bool is_aa_path_mute(struct hda_codec *codec) @@ -352,6 +407,10 @@ static int via_build_controls(struct hda_codec *codec) if (err < 0) return err;
+ err = add_beep_ctls(codec); + if (err < 0) + return err; + spec->mixers[spec->num_mixers++] = via_pin_power_ctl_enum;
for (i = 0; i < spec->num_mixers; i++) { @@ -512,6 +571,8 @@ static int via_parse_auto_config(struct hda_codec *codec) if (err < 0) return err;
+ auto_parse_beep(codec); + err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); if (err < 0) return err;
At Wed, 25 Mar 2015 00:43:42 -0700, W. Trevor King wrote:
My codec has a beep-generating node:
$ cat /proc/asound/card1/codec#0 Codec: VIA VT1802 ... Vendor Id: 0x11068446 Subsystem Id: 0x15587410 Revision Id: 0x100000 ... Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x0a] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0 ...
But I was missing the:
Control: name=...
entries that I need to manage this widget from alsamixer. With this patch (based on the similar Mono Amp-Out handling in patch_conexant.c), I get a new:
input: HDA Digital PCBeep as /devices/pci0000:00/0000:00:1b.0/sound/card1/hdaudioC1D0/input15
entry in dmesg and controls to manage that beep:
$ cat /proc/asound/card1/codec#0 | grep -A5 Beep Node 0x22 [Beep Generator Widget] wcaps 0x70040c: Mono Amp-Out Control: name="Beep Playback Volume", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Control: name="Beep Playback Switch", index=0, device=0 ControlAmp: chs=1, dir=Out, idx=0, ofs=0 Amp-Out caps: ofs=0x0a, nsteps=0x12, stepsize=0x05, mute=1 Amp-Out vals: [0x12] Power states: D0 D1 D2 D3 Power: setting=D0, actual=D0
Signed-off-by: W. Trevor King wking@tremily.us
On Wed, Mar 25, 2015 at 08:15:51AM +0100, Takashi Iwai wrote:
Care to brush up your patch as a formal form to be merged to upstream? There are a few conflicts with the latest sound.git tree code, but I can manage to resolve them.
Done. The only change since v1 is rebasing from v3.19 to the current sound.git master, resolving some trivial conflicts with 688b12cc (ALSA: hda - Use the new power control for VIA codecs, 2015-03-17). If you feel inclined to make further edits to my commit message, you have my permission.
Later on, we can move the common code to the generic parser (with yet some behavior flag), but it can be done by another patch.
Works for me.
OK, I applied the patch with a slight modification.
thanks,
Takashi
sound/pci/hda/patch_via.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index a34d767..3f63c34f 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -107,6 +107,8 @@ struct via_spec { /* work to check hp jack state */ int hp_work_active; int vt1708_jack_detect;
- unsigned int beep_amp;
};
static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec); @@ -266,6 +268,59 @@ static const struct snd_kcontrol_new via_pin_power_ctl_enum[] = { {} /* terminator */ };
+#ifdef CONFIG_SND_HDA_INPUT_BEEP +static inline void set_beep_amp(struct via_spec *spec, hda_nid_t nid,
int idx, int dir)
+{
- spec->gen.beep_nid = nid;
- spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir);
+} +/* additional beep mixers; the actual parameters are overwritten at build */ +static const struct snd_kcontrol_new cxt_beep_mixer[] = {
- HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT),
- HDA_CODEC_MUTE_BEEP_MONO("Beep Playback Switch", 0, 1, 0, HDA_OUTPUT),
- { } /* end */
+};
+/* create beep controls if needed */ +static int add_beep_ctls(struct hda_codec *codec) +{
- struct via_spec *spec = codec->spec;
- int err;
- if (spec->beep_amp) {
const struct snd_kcontrol_new *knew;
for (knew = cxt_beep_mixer; knew->name; knew++) {
struct snd_kcontrol *kctl;
kctl = snd_ctl_new1(knew, codec);
if (!kctl)
return -ENOMEM;
kctl->private_value = spec->beep_amp;
err = snd_hda_ctl_add(codec, 0, kctl);
if (err < 0)
return err;
}
- }
- return 0;
+}
+static void auto_parse_beep(struct hda_codec *codec) +{
- struct via_spec *spec = codec->spec;
- hda_nid_t nid, end_nid;
- end_nid = codec->start_nid + codec->num_nodes;
- for (nid = codec->start_nid; nid < end_nid; nid++)
if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) {
set_beep_amp(spec, nid, 0, HDA_OUTPUT);
break;
}
+} +#else +#define set_beep_amp(spec, nid, idx, dir) /* NOP */ +#define add_beep_ctls(codec) 0 +#define auto_parse_beep(codec) +#endif
/* check AA path's mute status */ static bool is_aa_path_mute(struct hda_codec *codec) @@ -352,6 +407,10 @@ static int via_build_controls(struct hda_codec *codec) if (err < 0) return err;
err = add_beep_ctls(codec);
if (err < 0)
return err;
spec->mixers[spec->num_mixers++] = via_pin_power_ctl_enum;
for (i = 0; i < spec->num_mixers; i++) {
@@ -512,6 +571,8 @@ static int via_parse_auto_config(struct hda_codec *codec) if (err < 0) return err;
- auto_parse_beep(codec);
- err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); if (err < 0) return err;
-- 2.1.0.60.g85f0837
On Wed, Mar 25, 2015 at 09:01:38AM +0100, Takashi Iwai wrote:
OK, I applied the patch with a slight modification.
4738465c looks good to me. I should have thought to re-check patch_conexant.c to see if the code I'd copied had changed. I'm looking forward to having this all factored out into a generic location :).
Thanks, Trevor
At Wed, 25 Mar 2015 01:10:03 -0700, W. Trevor King wrote:
On Wed, Mar 25, 2015 at 09:01:38AM +0100, Takashi Iwai wrote:
OK, I applied the patch with a slight modification.
4738465c looks good to me. I should have thought to re-check patch_conexant.c to see if the code I'd copied had changed. I'm looking forward to having this all factored out into a generic location :).
Feel free to work on it by yourself, too ;)
Takashi
participants (3)
-
Raymond Yau
-
Takashi Iwai
-
W. Trevor King