From patchwork Wed Feb 1 20:57:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Soller X-Patchwork-Id: 9552671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C96DB60236 for ; Thu, 2 Feb 2017 17:19:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE9C128411 for ; Thu, 2 Feb 2017 17:19:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B32DF2849C; Thu, 2 Feb 2017 17:19:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F52128411 for ; Thu, 2 Feb 2017 17:19:26 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2C58C2678F3; Thu, 2 Feb 2017 18:15:22 +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 4274A267501; Wed, 1 Feb 2017 21:57:20 +0100 (CET) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by alsa0.perex.cz (Postfix) with ESMTP id 61BB52674E2 for ; Wed, 1 Feb 2017 21:57:15 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 0997A20BE9 for ; Wed, 1 Feb 2017 15:57:14 -0500 (EST) Received: from web2 ([10.202.2.212]) by compute1.internal (MEProxy); Wed, 01 Feb 2017 15:57:14 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=smtpout; bh=AOG1A+FKCkeTi7/SEzg5Jmme+ ko=; b=ihvObG4D7VBFeqpFegoOyKvbhWau43PSCh3/Kn4RuopqGWreXkfCWLT7E Xhs7IBpdJN24exKN368OAvjVcOZYvXf9kxa/03V63AJBL/MKWZ2f2b5+zZnF093w Vg6yD3HJRIDNcYl3sT/JJlMaQzlZotWSMXjcPKnEWvnkMGfwXs= X-ME-Sender: Received: by mailuser.nyi.internal (Postfix, from userid 99) id D4F9D62719; Wed, 1 Feb 2017 15:57:13 -0500 (EST) Message-Id: <1485982633.3862207.867226728.4BAFFCC3@webmail.messagingengine.com> From: Jeremy Soller To: alsa-devel@alsa-project.org MIME-Version: 1.0 X-Mailer: MessagingEngine.com Webmail Interface - ajax-e9b51b02 Date: Wed, 01 Feb 2017 13:57:13 -0700 X-Mailman-Approved-At: Thu, 02 Feb 2017 18:15:18 +0100 Subject: [alsa-devel] [PATCH] Add support for Sabre HiFi on System76 and Clevo laptops 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for the ESS Sabre HiFi DAC found on some System76 and Clevo laptops. These devices can be identified using the Clevo subvendor id, and the Realtek ALC898 codec vendor ID. When a connection is detected on the ESS DAC, identified by GPIO pin 2 being set low, the 0x1b pin VREF should be set to 80%. Otherwise, it should be set to HIZ. Testing has been performed on the current System76 line of laptops, with and without DACs, no regressions have been found. --- sound/pci/hda/patch_realtek.c | 53 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) + break; + } +} + static void alc_fixup_bass_chmap(struct hda_codec *codec, const struct hda_fixup *fix, int action); @@ -2195,6 +2233,10 @@ static const struct hda_fixup alc882_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_bass_chmap, }, + [ALC898_FIXUP_CLEVO_SPDIF] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc898_fixup_clevo, + }, }; static const struct snd_pci_quirk alc882_fixup_tbl[] = { @@ -2271,6 +2313,10 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), {} }; +static const struct snd_pci_quirk alc898_fixup_tbl[] = { + SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC898_FIXUP_CLEVO_SPDIF), + {} +}; static const struct hda_model_fixup alc882_fixup_models[] = { {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, @@ -2310,6 +2356,11 @@ static int patch_alc882(struct hda_codec *codec) case 0x10ec0885: case 0x10ec0900: break; + case 0x10ec0898: + case 0x10ec0899: + snd_hda_pick_fixup(codec, NULL, alc898_fixup_tbl, + alc882_fixups); + break; default: /* ALC883 and variants */ alc_fix_pll_init(codec, 0x20, 0x0a, 10); @@ -4357,7 +4408,7 @@ static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec, struct alc_spec *spec = codec->spec; spec->parse_flags |= HDA_PINCFG_HEADSET_MIC; alc255_set_default_jack_type(codec); - } + } else alc_fixup_headset_mode(codec, fix, action); } diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 7d660ee..ed15317 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1797,6 +1797,7 @@ enum { ALC882_FIXUP_NO_PRIMARY_HP, ALC887_FIXUP_ASUS_BASS, ALC887_FIXUP_BASS_CHMAP, + ALC898_FIXUP_CLEVO_SPDIF, }; static void alc889_fixup_coef(struct hda_codec *codec, @@ -1956,6 +1957,43 @@ static void alc882_fixup_no_primary_hp(struct hda_codec *codec, } } +static void alc898_clevo_dac_hook(struct hda_codec *codec, + struct hda_jack_callback *jack) +{ + int val; + + // Read ESS DAC status + snd_hda_codec_write(codec, codec->core.afg, 0, AC_VERB_SET_GPIO_MASK, 4); + snd_hda_codec_write(codec, codec->core.afg, 0, AC_VERB_SET_GPIO_DIRECTION, 0); + val = snd_hda_codec_read(codec, codec->core.afg, 0, AC_VERB_GET_GPIO_DATA, 0); + val &= 0x04; + + if (val == 0) { + // Set VREF on headphone pin to 80% + val = snd_hda_codec_get_pin_target(codec, 0x1b); + val |= AC_PINCTL_VREF_80; + snd_hda_set_pin_ctl(codec, 0x1b, val); + } else { + // Set VREF on headphone pin to HIZ + val = snd_hda_codec_get_pin_target(codec, 0x1b); + val = val & 0xfff8; + snd_hda_set_pin_ctl(codec, 0x1b, val); + } +} + +static void alc898_fixup_clevo(struct hda_codec *codec, + const struct hda_fixup *fix, int action) +{ + switch (action) { + case HDA_FIXUP_ACT_PRE_PROBE: + snd_hda_jack_detect_enable_callback(codec, 0x1b, alc898_clevo_dac_hook); + break; + case HDA_FIXUP_ACT_INIT: + snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4);