From patchwork Wed Mar 25 07:43:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "W. Trevor King" X-Patchwork-Id: 6089001 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2B85BBF90F for ; Wed, 25 Mar 2015 07:46:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 223FC2037F for ; Wed, 25 Mar 2015 07:46:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id AC5FC201E4 for ; Wed, 25 Mar 2015 07:46:00 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9DC54265104; Wed, 25 Mar 2015 08:45:59 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 77852261AED; Wed, 25 Mar 2015 08:45:55 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 89197261B0E; Wed, 25 Mar 2015 08:45:54 +0100 (CET) Received: from resqmta-po-05v.sys.comcast.net (resqmta-po-05v.sys.comcast.net [96.114.154.164]) by alsa0.perex.cz (Postfix) with ESMTP id 56072261AA3 for ; Wed, 25 Mar 2015 08:45:48 +0100 (CET) Received: from resomta-po-19v.sys.comcast.net ([96.114.154.243]) by resqmta-po-05v.sys.comcast.net with comcast id 7jlm1q0035FMDhs01jlmhR; Wed, 25 Mar 2015 07:45:46 +0000 Received: from odin.tremily.us ([67.168.81.176]) by resomta-po-19v.sys.comcast.net with comcast id 7jjm1q0013oF5yT01jjmSL; Wed, 25 Mar 2015 07:43:47 +0000 Received: by odin.tremily.us (Postfix, from userid 1000) id 5F06216E93A5; Wed, 25 Mar 2015 00:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin; t=1427269425; bh=NltVQCjyIOSmT4TG1xBfmuPa2bUgFGia4ozjwJvo7PA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PtxRtVsfC/C96XX1Vxb6u8DgH4Z/TVuLl+JgPEH+73kx+vT6rf2na54oqCOrV4O+t 4GfGjl5n81ZDZsj4KY9JJq9ce3FA0phgqLfx3ddCtSvR7bIcaXhC84ie/xPXxwhuPM xG0Y2m2Py3Egr9B0XTuYJnIAjGCVHvA9Q4+ds1qU= From: "W. Trevor King" To: alsa-devel@alsa-project.org Date: Wed, 25 Mar 2015 00:43:42 -0700 Message-Id: <75dc1612e1a507e7f89549e70f83e303d78370dc.1427269200.git.wking@tremily.us> X-Mailer: git-send-email 2.0.5 In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1427269546; bh=KscqwNUkRpZCHrvQ6aJVx9GsdadMePI/f2B007WtVrA=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=NihikdwUiLQLX3GwWRak1/FUug/dDGTcFB8GFj7EOTOOWr0EUBYJo+J3lR6UuH8pY 3qeNY7hD73IxPqupLPfVgFmobAWHlHXNjC8rwa03wrTY/K0fZ/OJTpsh4ZEPcX3UVV 89kHuuWvke5BbtNuQpoZv5oaqje0UztD2t+SHNFEhjT5QSUvOVA8lPge8hjh1MJPDH 4kGeWQk/fLGKeNnkJ5W//keICD7Eka0RybDSzl1QQ2QVGK7Y4w3nLqKCabAGGvBmaF 4KxNCoFhi1Oe1++tSPVVK+xKLd1yXP/59m0ZkB9wLgITxOmwjy9fB8wS03OLYHkNaG 3rhgk2QJsOqeQ== Cc: Takashi Iwai , Raymond Yau , "W. Trevor King" Subject: [alsa-devel] [PATCH v2] ALSA: hda/via - Add beep controls to VIA codecs X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;