From patchwork Tue May 13 08:36:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Henningsson X-Patchwork-Id: 4163391 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9C6FCBFF02 for ; Tue, 13 May 2014 08:37:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE66A2034E for ; Tue, 13 May 2014 08:37:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 3D6472024C for ; Tue, 13 May 2014 08:37:11 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 38F34265472; Tue, 13 May 2014 10:37:10 +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 986D8265451; Tue, 13 May 2014 10:36:57 +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 9C222265452; Tue, 13 May 2014 10:36:56 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by alsa0.perex.cz (Postfix) with ESMTP id 9C2A726538B for ; Tue, 13 May 2014 10:36:48 +0200 (CEST) Received: from hd9483857.selulk5.dyn.perspektivbredband.net ([217.72.56.87] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1Wk8Cd-0007H4-LJ; Tue, 13 May 2014 08:36:47 +0000 From: David Henningsson To: tiwai@suse.de, hui.wang@canonical.com, alsa-devel@alsa-project.org Date: Tue, 13 May 2014 10:36:46 +0200 Message-Id: <1399970206-10269-1-git-send-email-david.henningsson@canonical.com> X-Mailer: git-send-email 1.9.1 Cc: David Henningsson Subject: [alsa-devel] [RFC PATCH] 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 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. In case a quirk matches both the pci ssid quirk and this type of quirk, then the pci ssid quirk is chosen. Signed-off-by: David Henningsson --- Hi Takashi, Do you think this could be working? If so I'll ask Hui to move some machines over and come up with a patch for that. Two questions: 1) I'm unsure if the "name" entry makes sense here - I mean, since the same quirk hopefully matches many machines, we can't use the machine name here. Should I just skip it? 2) Should I make a macro (like SND_PCI_QUIRK) to make the actual pinquirk tables look more compact? sound/pci/hda/hda_auto_parser.c | 39 ++++++++++++++++++++++++++++++++++----- sound/pci/hda/hda_local.h | 27 +++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c index 90d2fda..6904779 100644 --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c @@ -839,10 +839,22 @@ void snd_hda_apply_fixup(struct hda_codec *codec, int action) } EXPORT_SYMBOL_GPL(snd_hda_apply_fixup); -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) +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 hda_model_fixup *models, + const struct snd_pci_quirk *quirk, + const struct snd_hda_pin_quirk *pin_quirk, + const struct hda_fixup *fixlist) { const struct snd_pci_quirk *q; int id = -1; @@ -889,10 +901,27 @@ void snd_hda_pick_fixup(struct hda_codec *codec, } } + if (id < 0 && pin_quirk) { + const struct snd_hda_pin_quirk *pq; + 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)) { + id = pq->value; +#ifdef CONFIG_SND_DEBUG_VERBOSE + name = pq->name; +#endif + break; + } + } + } + codec->fixup_id = id; if (id >= 0) { codec->fixup_list = fixlist; codec->fixup_name = name; } } -EXPORT_SYMBOL_GPL(snd_hda_pick_fixup); +EXPORT_SYMBOL_GPL(snd_hda_pick_pin_fixup); diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index e51d155..41a6817 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -425,15 +425,34 @@ enum { HDA_FIXUP_ACT_FREE, }; +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 */ +}; + int snd_hda_add_verbs(struct hda_codec *codec, const struct hda_verb *list); void snd_hda_apply_verbs(struct hda_codec *codec); void snd_hda_apply_pincfgs(struct hda_codec *codec, const struct hda_pintbl *cfg); void snd_hda_apply_fixup(struct hda_codec *codec, int action); -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 hda_model_fixup *models, + const struct snd_pci_quirk *quirk, + const struct snd_hda_pin_quirk *pin_quirk, + const struct hda_fixup *fixlist); + +static inline 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) +{ + snd_hda_pick_pin_fixup(codec, models, quirk, NULL, fixlist); +} /* * unsolicited event handler