From patchwork Mon May 26 08:22:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 4240441 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 67B049F1E7 for ; Mon, 26 May 2014 08:24:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8267D201DE for ; Mon, 26 May 2014 08:24:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 42B272017E for ; Mon, 26 May 2014 08:24:01 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 67F0F26510F; Mon, 26 May 2014 10:24:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id D01D8261B2A; Mon, 26 May 2014 10:23:25 +0200 (CEST) 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 2AE62264F03; Mon, 26 May 2014 10:23:25 +0200 (CEST) Received: from mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by alsa0.perex.cz (Postfix) with ESMTP id D00D926087D for ; Mon, 26 May 2014 10:23:17 +0200 (CEST) Received: by mail-pb0-f44.google.com with SMTP id rq2so7370795pbb.17 for ; Mon, 26 May 2014 01:23:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FHMObx1ttLapK4Ha1JHBsZsmlXS9giakZoKi+7llhsQ=; b=R4ITqY3pRSRz3modMW5OYDN06APt8db8uDPFFYk0+fxV6KWu+HfbkgYBPx2XdU/nNF y2UdeygPUsAiLntA3Fj1rYwCheLDm8cyzp9+JNQD9jOpc421eAYa14VoSOSPzKQ5rgWz SiA08QOnrRhys210zLL0fbkOyb9DdygFhfexMX7fEI0uAj64nG/TZMLev6o/FccGpAYr dwtoWxT0IH3Q3oYO8eZB9TjQKkYQTuXVXi4NkkU/CzveihsZyj5aDsWPNs+sYyFYi6FW zGOmQmpfyZY5f/nWxYWVW/vpJ+gFamxSZi4nlnY7vBHpbqJAIXJI2YbdQOs3t5D79pKd 2WpQ== X-Gm-Message-State: ALoCoQmxxDR0rROM8oVkHZstiaQgc7wvgW5lyRb4/hvVxejdtmSUm8f40qD4r1Cizpqz5G8uGNZ6 X-Received: by 10.66.155.227 with SMTP id vz3mr21163730pab.26.1401092596346; Mon, 26 May 2014 01:23:16 -0700 (PDT) Received: from localhost.localdomain ([116.213.97.190]) by mx.google.com with ESMTPSA id ov4sm16964840pbc.46.2014.05.26.01.23.13 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 May 2014 01:23:15 -0700 (PDT) From: Hui Wang To: tiwai@suse.de, alsa-devel@alsa-project.org Date: Mon, 26 May 2014 16:22:41 +0800 Message-Id: <1401092564-14293-2-git-send-email-hui.wang@canonical.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1401092564-14293-1-git-send-email-hui.wang@canonical.com> References: <1401092564-14293-1-git-send-email-hui.wang@canonical.com> Cc: hui.wang@canonical.com, david.henningsson@canonical.com Subject: [alsa-devel] [PATCH 2/5] ALSA: hda - Add a new quirk match based on default pin configuration 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 From: David Henningsson Normally, we match on pci ssid only. This works but needs new code for every machine. To catch more machines in the same quirk, let's add a new type of quirk, where we match on 1) PCI Subvendor ID (i e, not device, just vendor) 2) Codec ID 3) Pin configuration default If all these three match, we could be reasonably certain that the quirk should apply to the machine even though it might not be the exact same device. Signed-off-by: David Henningsson --- sound/pci/hda/hda_auto_parser.c | 37 +++++++++++++++++++++++++++++++++++++ sound/pci/hda/hda_local.h | 14 ++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c index 36961ab..a142753 100644 --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c @@ -839,6 +839,43 @@ void snd_hda_apply_fixup(struct hda_codec *codec, int action) } EXPORT_SYMBOL_GPL(snd_hda_apply_fixup); +static bool pin_config_match(struct hda_codec *codec, + const struct hda_pintbl *pins) +{ + for (; pins->nid; pins++) { + u32 def_conf = snd_hda_codec_get_pincfg(codec, pins->nid); + if (pins->val != def_conf) + return false; + } + return true; +} + +void snd_hda_pick_pin_fixup(struct hda_codec *codec, + const struct snd_hda_pin_quirk *pin_quirk, + const struct hda_fixup *fixlist) +{ + const struct snd_hda_pin_quirk *pq; + + if (codec->fixup_forced) + return; + + for (pq = pin_quirk; pq->subvendor; pq++) { + if (codec->bus->pci->subsystem_vendor != pq->subvendor) + continue; + if (codec->vendor_id != pq->codec) + continue; + if (pin_config_match(codec, pq->pins)) { + codec->fixup_id = pq->value; +#ifdef CONFIG_SND_DEBUG_VERBOSE + codec->fixup_name = pq->name; +#endif + codec->fixup_list = fixlist; + return; + } + } +} +EXPORT_SYMBOL_GPL(snd_hda_pick_pin_fixup); + void snd_hda_pick_fixup(struct hda_codec *codec, const struct hda_model_fixup *models, const struct snd_pci_quirk *quirk, diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index e51d155..ebd1fa6 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -407,6 +407,16 @@ struct hda_fixup { } v; }; +struct snd_hda_pin_quirk { + unsigned int codec; /* Codec vendor/device ID */ + unsigned short subvendor; /* PCI subvendor ID */ + const struct hda_pintbl *pins; /* list of matching pins */ +#ifdef CONFIG_SND_DEBUG_VERBOSE + const char *name; +#endif + int value; /* quirk value */ +}; + /* fixup types */ enum { HDA_FIXUP_INVALID, @@ -434,6 +444,10 @@ void snd_hda_pick_fixup(struct hda_codec *codec, const struct hda_model_fixup *models, const struct snd_pci_quirk *quirk, const struct hda_fixup *fixlist); +void snd_hda_pick_pin_fixup(struct hda_codec *codec, + const struct snd_hda_pin_quirk *pin_quirk, + const struct hda_fixup *fixlist); + /* * unsolicited event handler