Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3507812rdb; Wed, 13 Sep 2023 14:23:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBjaXy1Ebf0UGNaWlkJ13I3vIVwebCxmo9hYrJThoEIS3F6D9KnRvrb1rvT8yrZkQJskVq X-Received: by 2002:a05:6870:e305:b0:1d5:8f11:ee94 with SMTP id z5-20020a056870e30500b001d58f11ee94mr4223120oad.39.1694640201582; Wed, 13 Sep 2023 14:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694640201; cv=none; d=google.com; s=arc-20160816; b=Bxy/5/9xzPSp3eKzFdNilsgZsa2yeG63Yd3vf1n50k7j+6icyGKifdoQjNG95P2phf wSviOIp1/k9lt87LG0dYrau96Sq/zow/5k3UQ9zb7ibT6MdG4uZCaRXzsaGLnAPc//8q cnQzs5BF1bQRvEKWmgsQwVpgcnux0lVpry7GV+CZQ/k6wG0x+Wisp9VvIgl2rL12aHnr 40MXvQPapQD/SDbU5TKfjd7sSB1OTzEiQYOUsK4ndCwz9uCndRVA4moEwKcf4eYH5+84 fomImRvN+Xj9WplMdK4g1SYleFiLKY0nv26cP8vjoh0N3GiLV2q3VfeuTP5hgMcxlbg/ tYiQ== 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=Rr6lXL3LtOXOlIrtorpBwjgzzvf6AwbEgVb5NSht5y8=; fh=BVyRkeWQgbLHHjD2wsZRKNYbtMse/+APTjljLzZQ3qo=; b=nCrNmsIWfZHFtueTH/LoWw3I28qjbI20kUbhq+FV7XxcaQpoJBY3X9bVXnKra5QWkx bytRSzixcdjq6hh0Hsol9kITc4+ilY+AZ6gRxZD64vv6kg0CrBSzOdsbVlaSClo9Ukq4 aDeEee9Br6Tqq+kKBwCBFcRRgA6+lfV0EthG9UeDQXsvWGhTDBH+tpH0y3pMakS1QQKZ gzNTcRfkwdQ/MTC5g/Kzh3MrnZw+0xJ+kuscPBEufFsyQw4UBKVhELje3q1fTeQp9dEc yPz4lc8BcYXCvPrlF1kZYYP0TIob77tdHynONIP8JTl41owCYm91p+Q+/0i32epUcH9Y os7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=qpYV6TEQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id r142-20020a632b94000000b0056433b221b9si10755760pgr.477.2023.09.13.14.23.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 14:23:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=qpYV6TEQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 6CC8D8032006; Tue, 12 Sep 2023 09:32:27 -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 S236801AbjILQc2 (ORCPT + 99 others); Tue, 12 Sep 2023 12:32:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229833AbjILQc1 (ORCPT ); Tue, 12 Sep 2023 12:32:27 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39783115 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 38CFSmv8002448; Tue, 12 Sep 2023 11:32:10 -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=Rr6lXL3LtOXOlIrtorpBwjgzzvf6AwbEgVb5NSht5y8=; b= qpYV6TEQfr6faHaHkgmQTJjwRPvahx6fYNeJKX7slRj77mlE3KRbszsZYn40ubX8 1cekwg7OzWdzk5HcCDWCB1tHQHOdI7UU4kmVAEhE7Kqur8y/yEMyUo3lUOCx5Txo G6/TtZQ6jjReC5TnP4ERCa0l/ixOglmpqC87fa6UCxLVST9tPw+fT9SivFWG6WeL 2++WHo5BCqgvL+J9AI8qfFEe/ponJQph9AQFzbIJVDO5G6YPbpsx6ErAf5k9+MJK Y5Om0MnuL/61atGkBOvEYg8v1L35i4vIc+vjw61dAarVZbJzHrVBZi2hXXhSdzUV KGyFNsh9qAm52p4242wWsA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3t0p3xkxdb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Sep 2023 11:32:10 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) 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 F19A115B6; Tue, 12 Sep 2023 16:32:07 +0000 (UTC) From: Richard Fitzgerald To: , , , , CC: , , , Richard Fitzgerald Subject: [PATCH 2/4] ASoC: SOF: Pass PCI SSID to machine driver Date: Tue, 12 Sep 2023 17:32:05 +0100 Message-ID: <20230912163207.3498161-3-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: OfR6-QC06i1vuM7mxdr9uE_5p7vc3GuM X-Proofpoint-GUID: OfR6-QC06i1vuM7mxdr9uE_5p7vc3GuM 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:27 -0700 (PDT) Pass the PCI SSID of the audio interface through to the machine driver. This allows the machine driver to use the SSID to uniquely identify the specific hardware configuration and apply any platform-specific configuration. struct snd_sof_pdata is passed around inside the SOF code, but it then passes configuration information to the machine driver through struct snd_soc_acpi_mach and struct snd_soc_acpi_mach_params. So SSID information has been added to both snd_sof_pdata and snd_soc_acpi_mach_params. PCI does not define 0x0000 as an invalid value so we can't use zero to indicate that the struct member was not written. Instead a flag is included to indicate that a value has been written to the subsystem_vendor and subsystem_device members. sof_pci_probe() creates the struct snd_sof_pdata. It is passed a struct pci_dev so it can fill in the SSID value. sof_machine_check() finds the appropriate struct snd_soc_acpi_mach. It copies the SSID information across to the struct snd_soc_acpi_mach_params. This done before calling any custom set_mach_params() so that it could be used by the set_mach_params() callback to apply variant params. The machine driver receives the struct snd_soc_acpi_mach as its platform_data. Signed-off-by: Richard Fitzgerald --- include/sound/soc-acpi.h | 7 +++++++ include/sound/sof.h | 8 ++++++++ sound/soc/sof/sof-audio.c | 7 +++++++ sound/soc/sof/sof-pci-dev.c | 8 ++++++++ 4 files changed, 30 insertions(+) diff --git a/include/sound/soc-acpi.h b/include/sound/soc-acpi.h index 6d31d535e8f6..23d6d6bfb073 100644 --- a/include/sound/soc-acpi.h +++ b/include/sound/soc-acpi.h @@ -68,6 +68,10 @@ static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg) * @i2s_link_mask: I2S/TDM links enabled on the board * @num_dai_drivers: number of elements in @dai_drivers * @dai_drivers: pointer to dai_drivers, used e.g. in nocodec mode + * @subsystem_vendor: optional PCI SSID vendor value + * @subsystem_device: optional PCI SSID device value + * @subsystem_id_set: true if a value has been written to + * subsystem_vendor and subsystem_device. */ struct snd_soc_acpi_mach_params { u32 acpi_ipc_irq_index; @@ -80,6 +84,9 @@ struct snd_soc_acpi_mach_params { u32 i2s_link_mask; u32 num_dai_drivers; struct snd_soc_dai_driver *dai_drivers; + unsigned short subsystem_vendor; + unsigned short subsystem_device; + bool subsystem_id_set; }; /** diff --git a/include/sound/sof.h b/include/sound/sof.h index d3c41f87ac31..51294f2ba302 100644 --- a/include/sound/sof.h +++ b/include/sound/sof.h @@ -64,6 +64,14 @@ struct snd_sof_pdata { const char *name; const char *platform; + /* + * PCI SSID. As PCI does not define 0 as invalid, the subsystem_id_set + * flag indicates that a value has been written to these members. + */ + unsigned short subsystem_vendor; + unsigned short subsystem_device; + bool subsystem_id_set; + struct device *dev; /* diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index e7ef77012c35..9c2359d10ecf 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -1031,6 +1031,13 @@ int sof_machine_check(struct snd_sof_dev *sdev) mach = snd_sof_machine_select(sdev); if (mach) { sof_pdata->machine = mach; + + if (sof_pdata->subsystem_id_set) { + mach->mach_params.subsystem_vendor = sof_pdata->subsystem_vendor; + mach->mach_params.subsystem_device = sof_pdata->subsystem_device; + mach->mach_params.subsystem_id_set = true; + } + snd_sof_set_mach_params(mach, sdev); return 0; } diff --git a/sound/soc/sof/sof-pci-dev.c b/sound/soc/sof/sof-pci-dev.c index f5ece43d0ec2..146d25983b08 100644 --- a/sound/soc/sof/sof-pci-dev.c +++ b/sound/soc/sof/sof-pci-dev.c @@ -214,6 +214,14 @@ int sof_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) return ret; sof_pdata->name = pci_name(pci); + + /* PCI defines a vendor ID of 0xFFFF as invalid. */ + if (pci->subsystem_vendor != 0xFFFF) { + sof_pdata->subsystem_vendor = pci->subsystem_vendor; + sof_pdata->subsystem_device = pci->subsystem_device; + sof_pdata->subsystem_id_set = true; + } + sof_pdata->desc = desc; sof_pdata->dev = dev; -- 2.30.2