Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4792848rdb; Fri, 15 Sep 2023 12:23:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmrt5YeGsNYuVFsdeYXU0DKMZseytv75k+vCQp5Ofr6KRgbZJrsF/PY94cLu0Xu+IHWIfI X-Received: by 2002:a05:6a00:3014:b0:68f:cdb8:ae33 with SMTP id ay20-20020a056a00301400b0068fcdb8ae33mr8589547pfb.10.1694805815458; Fri, 15 Sep 2023 12:23:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694805815; cv=none; d=google.com; s=arc-20160816; b=TN9Awd8w5fMTA/B0KQ9LxtobCnsNwxIBWqYbYTY7Oc2dUHBMDvPFQEx4D41R4Es53R w1kOuficFPT8dUgnsxZiz2FB7Rl+jqt2p2a8WgBddKJRFKPp4AWZ8rDkcfE6khWVtMdz WpdBxTCAVBAWEX4HnPbcGYyJotWnvgi57Gjk6o/rinIT7E7p5DqwNjla1Na1QsyjQkG4 G9ANIXyosloGGNYtMaNqh9zlmLzWyh7601uyKsyniX1RHCwDsBxLryZIGwuC+k4h9AFA eJMkYQekW1nGyc+Rs3ubOUQPEzTMkq/K1f875o3yeBUp0vNZjMm1eLtfnVlztexf1qY4 r13A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LxwutN87p/YTQslmoL4H29D/NJFBnq596ExIrTGFS10=; fh=BVyRkeWQgbLHHjD2wsZRKNYbtMse/+APTjljLzZQ3qo=; b=uvaD74TgRjMcoqUB5iPcCNuAhdSyMXO8Gijq1jU+fpNvkbyXo4ZUoiqslZt1Z1IGA1 +uQtH40B9GT8pNxXNt/upn/PWll7v9I6JtZ8Idl9zAFWJjsxqdAca0Uoee+6N6ab2hHT Fa+DY9UwGTjC86Fh7oPwUzLxzmkmcnzXjbSLQ68U6DVZWMmIwkQ2w8WH+FwklndyRL+M N6CzLwehL9iHs5RLt3zpyfV1JqpVM3yx2lz4T8zTukJqmba9fRmjTTXgRgc7zJMMR+9C co+f2Z6AvF08klg/cKHB47FoDvY7OP7K4/o0elSvUznkQVz3/OLUi1RQOo5aVkElGs8+ oPAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=M7KUyZ+A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id s6-20020a656446000000b005694eb03d2dsi3722655pgv.713.2023.09.15.12.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 12:23:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=M7KUyZ+A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 74636803200C; Tue, 12 Sep 2023 09:32:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236842AbjILQcd (ORCPT + 99 others); Tue, 12 Sep 2023 12:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233207AbjILQc2 (ORCPT ); Tue, 12 Sep 2023 12:32:28 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 696A6E7A for ; Tue, 12 Sep 2023 09:32:24 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 38CFSmvA002448; Tue, 12 Sep 2023 11:32:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PODMain02222019; bh=LxwutN87p/YTQslmoL4H29D/NJFBnq596ExIrTGFS10=; b= M7KUyZ+A/t/8DvJ88xBq9vcEM2SRiOSueIhTThShHAU8bDeiJYYdyMH3q1BEwlQm R9DLhTtPvF6V002hIhDsaYNnY+3pfmpBeTab7FyX5wRYiIeXQeHQEt8lObcycyiR wcILIwPhPbSquFTQ46SnGRr7iauADdLWyv79Ff8C/VqOc5SxpTungMs/OgV+Ss3c Oyf4xheuiTF0nabtCcNCDppfSNB4slGTQPEc6W0e6T7KFIB4isXOmibQlVpAI9FN EludVnzedB/sNyEwfO77eHBylmAxyTta7IeXz6U/WUVBrAxsK1H6LGm9+EJ/JWtY Q7YrtWQ1IZ3x+gvb3N8dmQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3t0p3xkxda-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 11:32:11 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Tue, 12 Sep 2023 17:32:08 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.37 via Frontend Transport; Tue, 12 Sep 2023 17:32:08 +0100 Received: from edi-sw-dsktp-006.ad.cirrus.com (edi-sw-dsktp-006.ad.cirrus.com [198.90.251.125]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id EA94F3563; Tue, 12 Sep 2023 16:32:07 +0000 (UTC) From: Richard Fitzgerald To: , , , , CC: , , , Richard Fitzgerald Subject: [PATCH 1/4] ASoC: soc-card: Add storage for PCI SSID Date: Tue, 12 Sep 2023 17:32:04 +0100 Message-ID: <20230912163207.3498161-2-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230912163207.3498161-1-rf@opensource.cirrus.com> References: <20230912163207.3498161-1-rf@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: 1Myw40n5eyviP4fUwG9rRQjvdJVbi8Xh X-Proofpoint-GUID: 1Myw40n5eyviP4fUwG9rRQjvdJVbi8Xh X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 12 Sep 2023 09:32:35 -0700 (PDT) Add members to struct snd_soc_card to store the PCI subsystem ID (SSID) of the soundcard. The PCI specification provides two registers to store a vendor-specific SSID that can be read by drivers to uniquely identify a particular "soundcard". This is defined in the PCI specification to distinguish products that use the same silicon (and therefore have the same silicon ID) so that product-specific differences can be applied. PCI only defines 0xFFFF as an invalid value. 0x0000 is not defined as invalid. So the usual pattern of zero-filling the struct and then assuming a zero value unset will not work. A flag is included to indicate when the SSID information has been filled in. Unlike DMI information, which has a free-format entirely up to the vendor, the PCI SSID has a strictly defined format and a registry of vendor IDs. It is usual in Windows drivers that the SSID is used as the sole identifier of the specific end-product and the Windows driver contains tables mapping that to information about the hardware setup, rather than using ACPI properties. This SSID is important information for ASoC components that need to apply hardware-specific configuration on PCI-based systems. As the SSID is a generic part of the PCI specification and is treated as identifying the "soundcard", it is reasonable to include this information in struct snd_soc_card, instead of components inventing their own custom ways to pass this information around. Signed-off-by: Richard Fitzgerald --- include/sound/soc-card.h | 37 +++++++++++++++++++++++++++++++++++++ include/sound/soc.h | 11 +++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/sound/soc-card.h b/include/sound/soc-card.h index fc94dfb0021f..e8ff2e089cd0 100644 --- a/include/sound/soc-card.h +++ b/include/sound/soc-card.h @@ -59,6 +59,43 @@ int snd_soc_card_add_dai_link(struct snd_soc_card *card, void snd_soc_card_remove_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); +#ifdef CONFIG_PCI +static inline void snd_soc_card_set_pci_ssid(struct snd_soc_card *card, + unsigned short vendor, + unsigned short device) +{ + card->pci_subsystem_vendor = vendor; + card->pci_subsystem_device = device; + card->pci_subsystem_set = true; +} + +static inline int snd_soc_card_get_pci_ssid(struct snd_soc_card *card, + unsigned short *vendor, + unsigned short *device) +{ + if (!card->pci_subsystem_set) + return -ENOENT; + + *vendor = card->pci_subsystem_vendor; + *device = card->pci_subsystem_device; + + return 0; +} +#else /* !CONFIG_PCI */ +static inline void snd_soc_card_set_pci_ssid(struct snd_soc_card *card, + unsigned short vendor, + unsigned short device) +{ +} + +static inline int snd_soc_card_get_pci_ssid(struct snd_soc_card *card, + unsigned short *vendor, + unsigned short *device) +{ + return -ENOENT; +} +#endif /* CONFIG_PCI */ + /* device driver data */ static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card, void *data) diff --git a/include/sound/soc.h b/include/sound/soc.h index 509386ff5212..81ed08c5c67d 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -929,6 +929,17 @@ struct snd_soc_card { #ifdef CONFIG_DMI char dmi_longname[80]; #endif /* CONFIG_DMI */ + +#ifdef CONFIG_PCI + /* + * PCI does not define 0 as invalid, so pci_subsystem_set indicates + * whether a value has been written to these fields. + */ + unsigned short pci_subsystem_vendor; + unsigned short pci_subsystem_device; + bool pci_subsystem_set; +#endif /* CONFIG_PCI */ + char topology_shortname[32]; struct device *dev; -- 2.30.2