From patchwork Thu Sep 4 12:21:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Henningsson X-Patchwork-Id: 4845661 X-Patchwork-Delegate: tiwai@suse.de 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 6BBA2C0338 for ; Thu, 4 Sep 2014 13:28:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 477A620270 for ; Thu, 4 Sep 2014 13:28:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A9BE02026D for ; Thu, 4 Sep 2014 13:28:00 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4065826573F; Thu, 4 Sep 2014 15:27:59 +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,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id A0637265815; Thu, 4 Sep 2014 15:07:39 +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 CE747265810; Thu, 4 Sep 2014 15:07:38 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by alsa0.perex.cz (Postfix) with ESMTP id 1CFF82658A0 for ; Thu, 4 Sep 2014 14:21:07 +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 1XPW2C-0001P1-Mp; Thu, 04 Sep 2014 12:21:04 +0000 From: David Henningsson To: alsa-devel@alsa-project.org, tiwai@suse.de Date: Thu, 4 Sep 2014 14:21:03 +0200 Message-Id: <1409833267-9778-2-git-send-email-david.henningsson@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409833267-9778-1-git-send-email-david.henningsson@canonical.com> References: <1409833267-9778-1-git-send-email-david.henningsson@canonical.com> Cc: David Henningsson Subject: [alsa-devel] [PATCH 1/5] hda-emu: Deal with two cards with one codec each 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 When using the -i switch to specify an index, we need to deal with two common cases: 1) All codecs belong to one card 2) There are as many cards as there are codecs This patch makes sure we pick the correct pci ID and SSID for the second case, too. Signed-off-by: David Henningsson --- hda-parse.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hda-parse.c b/hda-parse.c index 8d9a3c7..d9fc311 100644 --- a/hda-parse.c +++ b/hda-parse.c @@ -481,21 +481,21 @@ static int parse_codec_recursive(const char *buffer) } /* check the extra information from alsa-info output */ -static void check_alsa_info(char *line) +static int check_alsa_info(char *line, int override) { int dummy, classid, vendor, id, rev; if (sscanf(line, "%02x:%02x.%1d %04x: %04x:%04x (rev %02x)", &dummy, &dummy, &dummy, &classid, &vendor, &id, &rev) == 7) { - if (classid == 0x0403 && !codec->pci_vendor) { + if (classid == 0x0403 && (override || !codec->pci_vendor)) { codec->pci_vendor = vendor; codec->pci_device = id; codec->pci_revision = rev; } - return; + return 0; } if (sscanf(line, " Subsystem: %04x:%04x", &vendor, &id) == 2) { - if (!codec->pci_subvendor) { + if (override || !codec->pci_subvendor) { codec->pci_subvendor = vendor; codec->pci_subdevice = id; hda_log(HDA_LOG_INFO, "Getting PCI ID %04x:%04x (%04x:%04x) rev %02x\n", @@ -503,8 +503,9 @@ static void check_alsa_info(char *line) codec->pci_subvendor, codec->pci_subdevice, codec->pci_revision); } - return; + return 1; } + return 0; } static int add_sysfs_list(struct xhda_codec *codec, int *vals) @@ -612,7 +613,7 @@ static void clear_codec(struct xhda_codec *codec) int parse_codec_proc(FILE *fp, struct xhda_codec *codecp, int codec_index) { char buffer[256], *p; - int curidx = -1; + int curidx = -1, pciidx = 0; int err = 0; codec = codecp; @@ -625,7 +626,8 @@ int parse_codec_proc(FILE *fp, struct xhda_codec *codecp, int codec_index) again: if (parse_mode == PARSE_START) { if (!strmatch(buffer, "Codec: ")) { - check_alsa_info(buffer); + if (check_alsa_info(buffer, pciidx == codec_index)) + pciidx++; continue; } curidx++;