Skip to contentSkip to conversation

Missing beep controls for Via HDA codec (snd_hda_codec_via)

PATCH Superseded W. Trevor King 3 participants 12 messages Mar 22, 2015 – Mar 25, 2015 Sound

lore
Share & tools
lore
#0 lore raw

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

Signature · 2 lines
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
#1 lore raw

At Sun, 22 Mar 2015 00:54:49 -0700,

Quoted 55 lines · W. Trevor King

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

Quoted 8 lines

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

#2 lore raw
Quoted 32 lines
Quoted 32 lines

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]
Quoted 7 lines
Quoted 7 lines

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)

Quoted 10 lines
Quoted 10 lines
          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);
Quoted 5 lines
Quoted 5 lines
          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

Quoted 12 lines
Quoted 9 lines

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:

Quoted 10 lines
   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;

}

#3 lore raw

At Sun, 22 Mar 2015 21:27:24 +0800,

Quoted 73 lines · Raymond Yau
Quoted 33 lines
Quoted 33 lines

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]
Quoted 7 lines
Quoted 7 lines

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)

Quoted 10 lines
Quoted 10 lines
          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);
Quoted 5 lines
Quoted 5 lines
          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

Quoted 16 lines
Quoted 9 lines

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]
Quoted 8 lines
Quoted 6 lines

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

#4 lore raw

2015-3-22 下午11:17 於 "Takashi Iwai" <[email protected]> 寫道:

Quoted 26 lines

At Sun, 22 Mar 2015 21:27:24 +0800,

Quoted 23 lines · Raymond Yau
Quoted 23 lines
Quoted 23 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

example, sambrian posts codec output for a CX20561 chip which has

[1]:

Quoted 27 lines
Quoted 27 lines
Quoted 9 lines
Quoted 9 lines

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]
Quoted 7 lines
Quoted 7 lines

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)

Quoted 10 lines
Quoted 10 lines
          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);
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
          snd_hda_pick_fixup(codec, NULL, vt2002p_fixups,

via_fixups);

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

to get a dmesg entry like:

input: HDA Digital PCBeep as

/devices/pci0000:00/0000:00:1b.0/sound/card1/hdaudioC1D0/input15

Quoted 3 lines
Quoted 3 lines

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

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 6 lines

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.

Quoted 5 lines
Quoted 1 line

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

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw

PATCH 1/1 ALSA: hda/via - Add beep controls to VIA codecs

In reply to Raymond Yau

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

---

Quoted 9 lines · Raymond Yau

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:[email protected]

     http://thread.gmane.org/gmane.linux.alsa.devel/135819/focus=135823
 sound/pci/hda/patch_via.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
sound/pci/hda/patch_via.c +61 -0
index 3de6d3d..e4919f8 100644
@@ -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;
Signature · 6 lines
2.1.0.60.g85f0837

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#6 lore raw

Re: [PATCH] ALSA: hda/via - Add beep controls to VIA codecs

sound/pci/hda/patch_via.c

Quoted 7 lines · W. Trevor King
 sound/pci/hda/patch_via.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
sound/pci/hda/patch_via.c +0 -0
index 3de6d3d..e4919f8 100644

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

Signature · 2 lines
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
#7 lore raw

Re: [PATCH] ALSA: hda/via - Add beep controls to VIA codecs

In reply to W. Trevor King

At Wed, 25 Mar 2015 00:01:04 -0700,

Quoted 53 lines · W. Trevor King

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

---

Quoted 9 lines · Raymond Yau

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;

}

Quoted 11 lines

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

Quoted 106 lines

Cheers,
Trevor

[1]: id:[email protected]

     http://thread.gmane.org/gmane.linux.alsa.devel/135819/focus=135823
 sound/pci/hda/patch_via.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
sound/pci/hda/patch_via.c +61 -0
index 3de6d3d..e4919f8 100644
@@ -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;
Signature · 1 line
2.1.0.60.g85f0837

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#8 lore raw

PATCH v2 1/1 ALSA: hda/via - Add beep controls to VIA codecs

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

---

Quoted 3 lines · Takashi Iwai

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.

Quoted 2 lines

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(+)
sound/pci/hda/patch_via.c +61 -0
index a34d767..3f63c34f 100644
@@ -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;
Signature · 1 line
2.1.0.60.g85f0837
#9 lore raw

Re: [PATCH v2] ALSA: hda/via - Add beep controls to VIA codecs

At Wed, 25 Mar 2015 00:43:42 -0700,

Quoted 53 lines · W. Trevor King

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

---

Quoted 3 lines · Takashi Iwai

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.

Quoted 4 lines
Quoted 2 lines

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

Quoted 100 lines
 sound/pci/hda/patch_via.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
sound/pci/hda/patch_via.c +61 -0
index a34d767..3f63c34f 100644
@@ -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;
Signature · 1 line
2.1.0.60.g85f0837
#10 lore raw

Re: [PATCH v2] ALSA: hda/via - Add beep controls to VIA codecs

Quoted 1 line · Takashi Iwai

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

Signature · 2 lines
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
#11 lore raw

Re: [PATCH v2] ALSA: hda/via - Add beep controls to VIA codecs

At Wed, 25 Mar 2015 01:10:03 -0700,

Quoted 8 lines · W. Trevor King
Quoted 1 line · Takashi Iwai

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