From patchwork Fri Sep 13 09:06:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13803170 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2074.outbound.protection.outlook.com [40.107.96.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CF9B1D67AB; Fri, 13 Sep 2024 09:07:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726218424; cv=fail; b=vCKwDPa+Ha+sQrwzXjmPj9/5dfuKfgtkhgalBl/i/+IGsj7jP668IJ9+dVX51rE5my/iYezSKYu33qJXsViqBd8Ji6Dw7/tPAAQgf5WO2802zYt0f5xOgFrRbRuVzM+TeNrgDMsjhAo8XP+NEmY+vF3opbizuRSzXrwUqqwqq0U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726218424; c=relaxed/simple; bh=67QgmAMHmco+n8LJcc8yjIzjhmMa7X+JYsIcl4wRFZw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QfFKIaIPTQO0x6xn8VDIUJw4YIsN1HuxAuwqvNZ5FY6c3Nbf18O2vdItkxpinnr/Nnc1w8pj5thMbB4kXJPl8C31tzzCzw+Hi3w9mA8Pnf4DtjWCh1Xrt0364bSncgDGZLjvYXSt57Zy1oop4+nnvwE9i5uY5zgOIfOW1M10Kfw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=G5n5S/Am; arc=fail smtp.client-ip=40.107.96.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="G5n5S/Am" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=or27utf2W9jqaIcFxB2w8Ox9Kh6KNEZiyXvjAO02mQRAYp3Ii6deoFrqFIUOxValu1xumGh3GpGlLQFpfy3YI1RfViUJocIkZv2yy5Xl8HU7B/aVKmr0GDaUzrtjVA9iKbq0rF/81cFV7j9pInqU/CKlX3jBuMrBrzj7UjnbWVxJoGMx+r60HP5Ss6q9tAPWdy2F37cmPu0G7upH7jBihrmzKtjJC7gyMga8Qu6DVyy/z9uyd7qmBb19HOttf5txZFjnw2nXv03cgCXPSUdFrxICiIVm4Gz9fpigU0eEr+3lIyoafy2+jwNAG/IF2Zj7oECpNwAdJI9MGEb7jkPkxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JKJRG52gtc3gAAXgs1/Xvt5aYJVV5qg7RqE2NMVaod4=; b=XPlGT8tbTekcW9biWT/U1DzpJq0rr9C9nwB0Xs+ah1dgH0iHm5jjHvSurb25Ud7FPO8IM7plo7x1PvH6omrJBzDSOAzHs6lgwORTUv1CQpMrHyT6dFKSTepMJY4njt9QEC071fsLq61Yf302FQbsgcM1qno6UYWggj86WYLRQCWx9v4e4lIwSVu1FfCDgN0vUkUf4wfItfELFxp3uxLcKoj9RQPLLpaChelAv24iq+XmgHfavgXxpJ5pdi2SwlS73ImvpBio437cbNpheiOpZiDqKeDoW06hylU7aam8beKzjdOitMw/gffwSUWnFXUUm2oolm1lR9qwi6AcCH5wbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JKJRG52gtc3gAAXgs1/Xvt5aYJVV5qg7RqE2NMVaod4=; b=G5n5S/Amguqc8m2gZKn2yX125AzI373DGDTk9qlax0YDQ3krCoNsRxXh9A7+8SaXyFALUFrHwWHc/nhXYJCIvBTannBHUWf5mkGAekzn4L/kjdD6FRAYIDOtGy/zcHNj4HkFWAjrpsLZjpmQpDJFxvcarHCX7x7AV1ZOOpMHV/M= Received: from PH7P222CA0029.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:33a::31) by CY8PR12MB9034.namprd12.prod.outlook.com (2603:10b6:930:76::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.22; Fri, 13 Sep 2024 09:06:58 +0000 Received: from CY4PEPF0000EE34.namprd05.prod.outlook.com (2603:10b6:510:33a:cafe::41) by PH7P222CA0029.outlook.office365.com (2603:10b6:510:33a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.29 via Frontend Transport; Fri, 13 Sep 2024 09:06:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE34.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 13 Sep 2024 09:06:58 +0000 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 13 Sep 2024 04:06:52 -0500 From: Vijendar Mukunda To: CC: , , , , , , , , , , , , , , Vijendar Mukunda Subject: [PATCH 1/5] ASoC: intel: sof_sdw: rename soundwire endpoint and dailink structures Date: Fri, 13 Sep 2024 14:36:27 +0530 Message-ID: <20240913090631.1834543-2-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913090631.1834543-1-Vijendar.Mukunda@amd.com> References: <20240913090631.1834543-1-Vijendar.Mukunda@amd.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE34:EE_|CY8PR12MB9034:EE_ X-MS-Office365-Filtering-Correlation-Id: c7ba93d4-9eb8-4e09-5fc9-08dcd3d36bed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: x2ilpS4krt+Lgryks0dV0g8YiGDtxsjuDXCqUGgtKbM0JStbb4uliPiMNC0EiLbrZ+dV3avmy57L30bOrbrUEhmBdRzPGJr4a/WRXqv9CTJ4wPt3kq4UTeW1QrXEmSB3f2WvaZSn2gnkxWiFb8tpzC/fRLZBk++veMpuzrLu8iw1lZtyN38xT8LkhQPc1eMG8DSJaUztnle2zpkX9qbG14eF0czX7xwSFKvHNyVBdzFd7KKCwA7LqBpidNAvhL4Y1ZESOkXC/hEGFG8R1mLiRafidkJDD89692JjjgTJEbu7gUmOAXHMgXNPO+o9Nkfc+npW0YuzefFhUeTccryvLQYx3oI9UJSMEddUkZctlNC6hdPCZhzSWnqRtsysvxgD+L9h0A8Ov5Owiz5V0QbkaOrhsqSYrVdNJYPR0SgCQf3klxFXHnwLw38Jzbwl/4g5rq1beklKGm9gDrx6Wvk93/Sm3O6WCPVdxA/sVfwQvgh0TfvJ4n2XFulMM1D4mZCC87ukX8ZLYIryjuIjY48e3wjeHtKOxbX+i2uqOUjT0208P3b2n9/1SMa83zGyN91k2uX02npfNOnlz2XBf6iVL6lWBR8OeeGFVyiGD/7yTBUM0H9fv6+w+QQ7urK+gOIASsQmgNJf6UxigPnfYZWPZz7htTr2Y2mCivgT2eWJ3jcjAK8QB4Hv4BqIgNm2dF2N0oAgZU0ztFnLaLAC6scxb4+qqR76hdsUDYSNuiX0INGKQghpj/imc7pHso+majHngR/2sx9476V/YAQZAzFdJC6lnWiMiv3wnAFkjCI8BYM9hVXkR0zyKCxtTXsl5lCvfmySZMbdNwx0sa5WToOLPsUjUlG1uuPmqWW1D4IuoZ6Vj7tdyniA/lgEwFYegf2pIzaWk02zANi4bA5BGDFztzSrHyHe5O+FHXv4zRXTVW5lI0u5XuRZY3lDFPNZbg0U3dTU76hqAmUDkoLX4e0MiQOKDlTWr9qaLJM/yY28tcZkmD9hhCqUc1mxJF5siMvszkkEGkTJ0YodtexP7+Sn17um1kgxc5X4+wsv5jnHDwxyYR1Ban1sRdj7gc7wpe5u6IZDdOgZu6MyT/NzqiIPGykIekUmreMzy+cS4hmARC3/4R19xZWXiui/hrI55ixjyTEPKJg/cZYVnFmB6hv+HPTvmkSQ0x0JY3NhynfkhNLfP3LceYhZYG2s5Vk2k0NCFVZ1tzRhLorGU10AbKQb2oxAYOZuwV6eEEf27aC74W74ulORvtZdgHbLUYFkv82Uo8olTlJZZUIfhCIOl6PcqRqXFf0z2OETDY5Xn4Gx0AtN4457USrYrFtMqpn57tpwDO1LkZEgAVqbilZ3MSUtCXofAtCnkpr+A4mLnS2GPTvsJtvilNrpmRSh86KKPpsZVjEy73WMfdX8UqNaR9VbpG/wTw86dDLgucNQeNwYB0JREujJk5GPG7Fcx4n75VVn X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 09:06:58.0171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7ba93d4-9eb8-4e09-5fc9-08dcd3d36bed X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE34.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB9034 Rename SoundWire endpoint and dai link structures with asoc tag to make it generic. Signed-off-by: Vijendar Mukunda Reviewed-by: Bard Liao --- sound/soc/intel/boards/sof_sdw.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index f10ed95770ea..6eeddced1f6f 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -617,7 +617,7 @@ static const struct snd_soc_ops sdw_ops = { .shutdown = asoc_sdw_shutdown, }; -struct sof_sdw_endpoint { +struct asoc_sdw_endpoint { struct list_head list; u32 link_mask; @@ -629,7 +629,7 @@ struct sof_sdw_endpoint { const struct asoc_sdw_dai_info *dai_info; }; -struct sof_sdw_dailink { +struct asoc_sdw_dailink { bool initialised; u8 group_id; @@ -660,8 +660,8 @@ static int count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *nu return 0; } -static struct sof_sdw_dailink *find_dailink(struct sof_sdw_dailink *dailinks, - const struct snd_soc_acpi_endpoint *new) +static struct asoc_sdw_dailink *find_dailink(struct asoc_sdw_dailink *dailinks, + const struct snd_soc_acpi_endpoint *new) { while (dailinks->initialised) { if (new->aggregated && dailinks->group_id == new->group_id) @@ -678,8 +678,8 @@ static struct sof_sdw_dailink *find_dailink(struct sof_sdw_dailink *dailinks, } static int parse_sdw_endpoints(struct snd_soc_card *card, - struct sof_sdw_dailink *sof_dais, - struct sof_sdw_endpoint *sof_ends, + struct asoc_sdw_dailink *sof_dais, + struct asoc_sdw_endpoint *sof_ends, int *num_devs) { struct device *dev = card->dev; @@ -687,7 +687,7 @@ static int parse_sdw_endpoints(struct snd_soc_card *card, struct snd_soc_acpi_mach *mach = dev_get_platdata(dev); struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params; const struct snd_soc_acpi_link_adr *adr_link; - struct sof_sdw_endpoint *sof_end = sof_ends; + struct asoc_sdw_endpoint *sof_end = sof_ends; int num_dais = 0; int i, j; int ret; @@ -738,7 +738,7 @@ static int parse_sdw_endpoints(struct snd_soc_card *card, for (j = 0; j < adr_dev->num_endpoints; j++) { const struct snd_soc_acpi_endpoint *adr_end; const struct asoc_sdw_dai_info *dai_info; - struct sof_sdw_dailink *sof_dai; + struct asoc_sdw_dailink *sof_dai; int stream; adr_end = &adr_dev->endpoints[j]; @@ -799,14 +799,14 @@ static int parse_sdw_endpoints(struct snd_soc_card *card, } static int create_sdw_dailink(struct snd_soc_card *card, - struct sof_sdw_dailink *sof_dai, + struct asoc_sdw_dailink *sof_dai, struct snd_soc_dai_link **dai_links, int *be_id, struct snd_soc_codec_conf **codec_conf) { struct device *dev = card->dev; struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card); struct intel_mc_ctx *intel_ctx = (struct intel_mc_ctx *)ctx->private; - struct sof_sdw_endpoint *sof_end; + struct asoc_sdw_endpoint *sof_end; int stream; int ret; @@ -845,7 +845,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, continue; sof_end = list_first_entry(&sof_dai->endpoints, - struct sof_sdw_endpoint, list); + struct asoc_sdw_endpoint, list); *be_id = sof_end->dai_info->dailink[stream]; if (*be_id < 0) { @@ -936,7 +936,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, static int create_sdw_dailinks(struct snd_soc_card *card, struct snd_soc_dai_link **dai_links, int *be_id, - struct sof_sdw_dailink *sof_dais, + struct asoc_sdw_dailink *sof_dais, struct snd_soc_codec_conf **codec_conf) { struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card); @@ -1104,8 +1104,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params; struct snd_soc_codec_conf *codec_conf; struct asoc_sdw_codec_info *ssp_info; - struct sof_sdw_endpoint *sof_ends; - struct sof_sdw_dailink *sof_dais; + struct asoc_sdw_endpoint *sof_ends; + struct asoc_sdw_dailink *sof_dais; int num_devs = 0; int num_ends = 0; struct snd_soc_dai_link *dai_links; From patchwork Fri Sep 13 09:06:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13803171 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2053.outbound.protection.outlook.com [40.107.223.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C28731D58AF; Fri, 13 Sep 2024 09:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726218433; cv=fail; b=MWyI/6y0Yi7Fk+CXISHZOipWy8PnntVcGtmnlq4DXwWRzc3OsgWNj3IgoysbX6KOvCzIELx7l+yr4Y+pYe4e48mXixeuEnn7qnld01HWRSabb2AHLN2P8ObJ7iXAv40BZCJ23zVh8AgB3LKwY1TmEk4daP0mjCdvM8VLdHHk1TI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726218433; c=relaxed/simple; bh=akWy9Jc7+hF8GsuZFH9CGA48tSlEyDt4Hgfa1IFYXJc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dvBk1Di8O8g3CSx9GaiEuWmMSld0/Tg3oXwmyBO9WGqhhmQ2ynEdcsxoPhfbF2JxWKW9pQMIYRpPWrZ2r1TkthkEVdSbiB8/7ag5lMfBwMihAcj4wOVmV9YjrrOcG8pvyFfmTMFI6mZaxHGTS+gy13cQoDUgspU4SeaJDmwXC18= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=XE7XSnef; arc=fail smtp.client-ip=40.107.223.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="XE7XSnef" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ir2ihDnq5F2PLbYeSLSzTwfWRKC+J6SoyFxAgmUJH9xYyDtFikpIB/42ZbspBXB+SNHbdM5zMGsS1dzfVVO9f4Z7980qQeSCvuN5awZYgcWjUjvvs/UZ9n365qPqHpAiT1zlfyCnT3WpHT+Uz9bpMuapogTbZH6v+oK9mtjXS2aM69MpXbFKPek8GlRpM9T8vxkfSpYMOOA33JHFJ7eVYuMFP5shdx7gZ2/1TrAcL4gA/FW7hUO8eHfIWsI5GAin4imI882QdQtRMMmbqYSWOJLs/qB48j9r4AZ8/IQHqxHeCS+PdzzZjDrpDiDDbEqT9WL1PDp5RqQKvf70n8LJPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=19q26TQkLNuoRQJYZM+DRc1DluH0Dy5Xu3w7aezap6U=; b=IHQUiZROGl6SR0+CvpTJyyaCqy+pl8/U66bPESFXx9fAGHDz63sfMH28EPBpBlNvmSRpQMAehzVPEOlQr7Y/bazxMvLcQtJmyqSdbJIHPsoeDqdyYlH/RcuvSWQWYbasY1k1HTox44PUiMl7a8pfDsOAmDjzVMMmJKKi8dmOEBcDiu6wrn/m/pTKaVkOsL4isJU5xE4IRTOkAbRDObcN2jUQlMa8PzLaTT9Ln57lHuBHh22PmmN+BXhCXFvitRaXl2cEVCgaKTQXeQIfW0VMrhkyWcSndNKhOxKEnHKbhCJIkDyA+bvhhROEVouiqY51sorO71S0AiE1owfxcPYCrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=19q26TQkLNuoRQJYZM+DRc1DluH0Dy5Xu3w7aezap6U=; b=XE7XSnefelBxcnu+1b20kR+aKDZg+0oupXq0FNuie1i8IQhY7bon2Y+CgHSe2Hg8uuUL18JWu26Zv7V4qWerb4yKGs8FQVhPSOTWJ2LW1AsXE4LCB4xB4gYEvlVWijd7I1DqPJK25bktUDvzbZMbyRpANGYJxtgt/5XGJs03/so= Received: from PH8PR02CA0007.namprd02.prod.outlook.com (2603:10b6:510:2d0::18) by SJ0PR12MB6781.namprd12.prod.outlook.com (2603:10b6:a03:44b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Fri, 13 Sep 2024 09:07:08 +0000 Received: from CY4PEPF0000EE35.namprd05.prod.outlook.com (2603:10b6:510:2d0:cafe::3d) by PH8PR02CA0007.outlook.office365.com (2603:10b6:510:2d0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23 via Frontend Transport; Fri, 13 Sep 2024 09:07:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE35.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 13 Sep 2024 09:07:07 +0000 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 13 Sep 2024 04:06:57 -0500 From: Vijendar Mukunda To: CC: , , , , , , , , , , , , , , Vijendar Mukunda Subject: [PATCH 2/5] ASoC: intel: sof_sdw: rename soundwire parsing helper functions Date: Fri, 13 Sep 2024 14:36:28 +0530 Message-ID: <20240913090631.1834543-3-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913090631.1834543-1-Vijendar.Mukunda@amd.com> References: <20240913090631.1834543-1-Vijendar.Mukunda@amd.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE35:EE_|SJ0PR12MB6781:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c1cbc95-1138-4b17-7a2e-08dcd3d37179 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: KGEIbOXqNHLupUyBUDju1r0mYuV0QOdG8VzkRH9eHlFVsblnWgCr/6hXzbdBtG+jI/NQ0lGeI8oDuNM1gD26jnC/h5bYjk5zyKNK13BxWRYZZSCLj5iPO1noaQGaDFiBx9QpJKL3AffCSgWGyXBh04qPgc3Ij0xUKCRhazPTOusOccRzhX5lMLE5XVeO5NrGrK1IGyBEpny1eMyWBkK+QhSURgdcST/zOgutwEjxFFrSaa3d6jeKUjEA1FQt3GP9ckIJM3pBOwDx3tTdd0eLY7rrz2lBfyz4+X9xnvUbFuL9T1evK8/iN7ULUUthugrlyh2QLiRSC+JSsogW1DBv5Nl4F4GqnFrEbqOgkfAw4ZMgA6OBRu+VX1Z0hNabwHEWvbmZEAg4lymQiQHEknASqtf/BdKLUeBcbqRxeDn/S0Hux+iDQS2CRQ+BgoviHLZjFIL0rmZNYxshQGeU8eIwLpM7mcXdGEYSDv8DQjBJokxWxYNLWkS6IMo20ZhJ7uvLNVo3o8v+Ags+Rf68qDpHPm7vHTT8RQ1ixN5j4xrE3OYewqG2eqDgMAodEVpyHfPg+jG88hguSLX2ozBhJtWsENVH5QDWBzhaoTLTM0pU/Cew89sab+NnOY++4BseUzSR8nuZkx77ZtXvpzLBRsyQHU0fbR15Cj9Psgy6OzfGPLRBIgag5qrMasRWC2Yfh+cBkvf9aM0MQIScBiR02JKSvjJd4JecL7+Oorsh+65YAU36eM3siMW8xaefa3FnVmBASxape+eZkrnDjGzSQUcO+jjCowISHfWUE4XQnaC5lY3zAuap9nAYjgJljt+ixZb274u4r/jPVr2KS5M2/kdOsfHA1l5vESsyrMPueIXyWtqJCv6szRT5kQWaPLd0bR1rC4ghrN4Jrbqz5oB5H3Z7bEeS/Yvh/uRrB7yxLLVerLRedDOrbMqNX3aR9n71RtEXXYZ9OVXB2RT5biMDlXbhiGqnx73OdAxgm8w2oZMSK4IR30VNajti2FShQ3p6e3VJuUFibU5wLFVZ/qBDJ7bjojKHzX78kNpsJG+t5eWhsAQFgUd0SSbBJ0Bkmfs0SICrsu8Nb+zS0BYXcvGID85xbIo17rRlkIXVC9dpfzShqxqQRtEIu/akmM4I1nsPZjmb1Wq7+RWKgbdExVvYzxmOAeQaYrvfrttkPPVG8glFrZJKQG/SXCdTASkFXhirFqTCjXt0wMw/1gVRDa9UgSUZYCEmVW87It73Gfv4crpy2GXajY3MFvBd+OL2U0nn2UVHAX3FBQi2gjJzD6XTLmforjwKmSkNF/8FAKSpp3twvvUTio5H3BoqWPjsmgU6qRs2pOr75fDN0wtvbATfiWr2X50INlLL3xWZBONTpaI6BJ7f9dtd3J3B4x7PosIVyL9baDfMCn73ZWMFqOHhYPQS9ildi9LbdTF7DJgzgXaDS3fQ07yvq2uF7JE99z/Jm5Z4 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 09:07:07.3239 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c1cbc95-1138-4b17-7a2e-08dcd3d37179 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE35.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6781 Rename SoundWire parsing helper functions with 'asoc_sdw' tag to make it generic. Signed-off-by: Vijendar Mukunda Reviewed-by: Bard Liao --- sound/soc/intel/boards/sof_sdw.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index 6eeddced1f6f..222cf4a37707 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -640,7 +640,7 @@ struct asoc_sdw_dailink { static const char * const type_strings[] = {"SimpleJack", "SmartAmp", "SmartMic"}; -static int count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends) +static int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends) { struct device *dev = card->dev; struct snd_soc_acpi_mach *mach = dev_get_platdata(dev); @@ -660,8 +660,8 @@ static int count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *nu return 0; } -static struct asoc_sdw_dailink *find_dailink(struct asoc_sdw_dailink *dailinks, - const struct snd_soc_acpi_endpoint *new) +static struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks, + const struct snd_soc_acpi_endpoint *new) { while (dailinks->initialised) { if (new->aggregated && dailinks->group_id == new->group_id) @@ -677,10 +677,10 @@ static struct asoc_sdw_dailink *find_dailink(struct asoc_sdw_dailink *dailinks, return dailinks; } -static int parse_sdw_endpoints(struct snd_soc_card *card, - struct asoc_sdw_dailink *sof_dais, - struct asoc_sdw_endpoint *sof_ends, - int *num_devs) +static int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card, + struct asoc_sdw_dailink *sof_dais, + struct asoc_sdw_endpoint *sof_ends, + int *num_devs) { struct device *dev = card->dev; struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card); @@ -743,7 +743,7 @@ static int parse_sdw_endpoints(struct snd_soc_card *card, adr_end = &adr_dev->endpoints[j]; dai_info = &codec_info->dais[adr_end->num]; - sof_dai = find_dailink(sof_dais, adr_end); + sof_dai = asoc_sdw_find_dailink(sof_dais, adr_end); if (dai_info->quirk && !(dai_info->quirk & sof_sdw_quirk)) continue; @@ -1115,7 +1115,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) unsigned long ssp_mask; int ret; - ret = count_sdw_endpoints(card, &num_devs, &num_ends); + ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends); if (ret < 0) { dev_err(dev, "failed to count devices/endpoints: %d\n", ret); return ret; @@ -1133,7 +1133,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) goto err_dai; } - ret = parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs); + ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs); if (ret < 0) goto err_end; From patchwork Fri Sep 13 09:06:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13803172 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2087.outbound.protection.outlook.com [40.107.223.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 486731D7E21; Fri, 13 Sep 2024 09:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726218436; cv=fail; b=H8SmWUJsEa8yW/oMTMKrQq9jjEdSj+S5T0CiT3E3HQ2ylzdCF050f14KxGIR6p9O/qZ9cMfPGNOpNavxkuPFTqribPuYnxr2k2VH7LO+P52liu33jhVtZ3yYDgTcnKFi5u7IwYUmqfXZtKekLyAq7jTaQc1RdfsBxymhyGOSHqM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726218436; c=relaxed/simple; bh=2Lc4GiLB8K1mdzeTgxlYGhsrGSETeSJTaQUqJMgN+WE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TNxMNiJt+WiEOrjLJ7rOc/K/TGhzXdHX48cWliBniZvmPjlWmhWAIV0QX1R28Oi0JON5Rd82PooBZJ0eIREQR+43Ln7eY+87/tJiDLfZd55aFRm/HtI6ycOMKsDU9YAY0aMaoECeXH0nNBE8eWetDFws+lHgxCajNPPiwKj5oio= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=LH+x8Ulr; arc=fail smtp.client-ip=40.107.223.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="LH+x8Ulr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AOuEJ5Yxw9AEgZwoL8EQ/2ZIQoervGaaT0jqoGqiwKCg8UqXf6L7D1BoYdMgP8LVOEcYwiuNADJDQPcwhckvr/nCjORTdZKTP0ZVCcYfeqHkZ5PidG0h/Xjws85NYd+MW+zsOQ0NdL3ZNClqMr57WawZqdJsNW9Zpz1SBAXRMp6bs/sGTaT2yXE953q0aDJ/SPnRje8HwcuSSYxzLKmI4Rl1ZcsKceT9cV3BxJfTsvLVBYXDhQy8y8H1Li8kcTpjJ+63ic2HdSQa8R0o5eQqP0YMF9Hxw7T/RoX1X9AYgfvPjkqvhNY3eXG4AmPFi1Y0ZAnSa7BgLQjG0sn+gj9+1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2TGVG1rAtIOo6XDRP4na37RieCa1dYr9ZKoZRy2HGPk=; b=wcKmobwM0OZpYXwIheCZBIuxoslmJNleWr/pNjoKYYQwjndp2gtY3kIeXBOn8n3vZ+zZtPRiwYIZ2Zy2Zg4mZHtWpeme4SdgPoref6NnrtyirM27T7lQLWCvYuCFCJlebzkMvfKzvmUibFr57WB8Z78WKh3oHGfGmLsFX4BEqfvgUScUnDSFxm2q081pf9qd9vE6i9M/MexUp8MEdwHm2AfrvevkxxZu0E80U8IaLQ9KKMHlKyShvb+TWjLFaHF5eO7RRkC9851in4WCXzMTuXV9tWWQ9u+B7sz9R5frExlbZjadizcpPAeQUTub783erRBFYmYaKe9w3cPo/73N1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2TGVG1rAtIOo6XDRP4na37RieCa1dYr9ZKoZRy2HGPk=; b=LH+x8Ulr7yroSbLJgiOuA39uUkUbfOCiwNA4JACRpfk9bqb19b/y51jPpfaSL5kVVGLf6mlgGxBqZsdnrfNkPwzr3aVPH5Am2pzIiNoS9xCZ/k1h7e9wl19vhI+Vzu4QBziJXs5foTkNQ4r9MgcOe7QACgga0wpTp1hkWOPmJxw= Received: from PH8PR02CA0014.namprd02.prod.outlook.com (2603:10b6:510:2d0::6) by SJ2PR12MB7944.namprd12.prod.outlook.com (2603:10b6:a03:4c5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Fri, 13 Sep 2024 09:07:11 +0000 Received: from CY4PEPF0000EE35.namprd05.prod.outlook.com (2603:10b6:510:2d0:cafe::dc) by PH8PR02CA0014.outlook.office365.com (2603:10b6:510:2d0::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23 via Frontend Transport; Fri, 13 Sep 2024 09:07:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE35.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 13 Sep 2024 09:07:11 +0000 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 13 Sep 2024 04:07:02 -0500 From: Vijendar Mukunda To: CC: , , , , , , , , , , , , , , Vijendar Mukunda Subject: [PATCH 3/5] ASoC: sdw_util/intel: move soundwire endpoint and dai link structures Date: Fri, 13 Sep 2024 14:36:29 +0530 Message-ID: <20240913090631.1834543-4-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913090631.1834543-1-Vijendar.Mukunda@amd.com> References: <20240913090631.1834543-1-Vijendar.Mukunda@amd.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE35:EE_|SJ2PR12MB7944:EE_ X-MS-Office365-Filtering-Correlation-Id: 8671b957-db5d-4a71-d2dc-08dcd3d373fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: IoNyGWLD/SvzZY+WTV+aQi3G2GBkqkSY8ifbGmOP/1D3ZtzQjqAlpILs52AL/Acnh1QIT7WI25QGMzMbeI5ngjqgLEhwbTsaHNIOGW1JcTCo29cGaMxCaZQlo4U6BEsk9iTSg+QBy9yiaqHeFmsFUK09pGS3zhz37QakSt5qBk9/2aDzS8+YHh0xDAtF2TTNBvhMI4oWfAbMswVJAb5sHgrQZXa4n6GpIMAOSxwwqOlbK0OAHZEsyPqwdFCG/aSxtTu94Lu2gSoM+lEPUEizL3fzi7MWH/5Y3chp0gaRSmPfC4KOiHB5LPvY+Zn12UwMp6VIJ0NP0n4xkbueXizxzWbIiq1Lp58J7lYCTmPdiPeYTAGNNlfdWxsx0qccMtcDylPxVLiVbcLekLE29n6zr/WFh9z1JOBbiEc66sECagDEVBM87yaqifoGUTryJoMqonE+AO3TxP2r2YoNDwgoMOQkeV3UHKH01EpSciGZmPstinbojrAMYtN0HU/T5aNve7brSDNl+pcY6iuUuZByrhPssY1gEQKTrjm7D47+gZCLeZ1gWfdfUHinSfU8PRCZWCCLPQyfHkIDUooTX6kF90s/xR9S/pBYl4KjS0ZTJGi0wH887mybesxGEnmaJWS1LLoLrihix9KlfFjDHN5L0xZulyDc+QHZvdNxkSUT8TfDx3jFdeowDaElfxmvogiXSYsgLuwktZQoT1T4j0jDLwYC0jvJMCkanFdpiBCWVsyg/6SxL39CGYClZi3AImnDZbFyueYG3RxrEGqYkfc11DWQ9SC82tV4dCD1YDGsuGRhVp3LpatbM88hFFHZ7RjHwRrDJ4aaHDpN5QJ63gxT/szEiNq25VpuIwGEc3++wPGc7QfTR02AcOsiLRwCJc7LuxGpdG/Tn11BSwyXu+5DOzDTzHsB1GaVazFb8s5uS7RxI7ozVve/LW9RzjdmkoSGulTgfC7VMBbh6GXAQQAE7obZfc+QPSJ66gFJ0ptDpqEot0m8t5E144POHoTBh8PECd+EmUgol4xZKnubXQtkoOTMS9kGHbqn41GoVZNs9XQAL3bnyRC8QfGRws8zXs7J9RVgGTqt6JGFzD4LdklBN21U/Uh6MY4gF1bx3G0XDz93BBKsOoQBDJyAtahXizfQqL2vH8GNA90llwzIgOH5RV3ZqwmZQ4sy1YqexhS9uLdMUeGilR509kGAd4BttyW5O5TQ7YvCshCd7FkmbPBMJpFAZvlQlYf78Q6ti/kknGTS5FajKorWmEMi3f6frUFHQsKfdeig+YAYW63hknReamiNTftdlghWS3/KEqCTTJN/BhWrjdlJP5Wpcvvt0Af2e2kSymyZGSKgN2MTc9kiUt2xy8U4N/rLV+dHsAG2AveRuN9wqgz97prr1qkpAC4pzMplWKg1I9lVvfGnDmstHr31pZiVeORu+c1/0I08rIYxpQ6t2+o3jkt49HNstRPs X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 09:07:11.5270 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8671b957-db5d-4a71-d2dc-08dcd3d373fa X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE35.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7944 Move Soundwire endpoint and dai link structures from Intel generic machine driver code to common place holder(soc_sdw_utils.h). These structures will be used in other platform SoundWire machine driver code. Signed-off-by: Vijendar Mukunda Reviewed-by: Bard Liao --- include/sound/soc_sdw_utils.h | 21 +++++++++++++++++++++ sound/soc/intel/boards/sof_sdw.c | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/sound/soc_sdw_utils.h b/include/sound/soc_sdw_utils.h index e366b7968c2d..e3482720a3eb 100644 --- a/include/sound/soc_sdw_utils.h +++ b/include/sound/soc_sdw_utils.h @@ -93,6 +93,27 @@ struct asoc_sdw_mc_private { int codec_info_list_count; }; +struct asoc_sdw_endpoint { + struct list_head list; + + u32 link_mask; + const char *codec_name; + const char *name_prefix; + bool include_sidecar; + + struct asoc_sdw_codec_info *codec_info; + const struct asoc_sdw_dai_info *dai_info; +}; + +struct asoc_sdw_dailink { + bool initialised; + + u8 group_id; + u32 link_mask[SNDRV_PCM_STREAM_LAST + 1]; + int num_devs[SNDRV_PCM_STREAM_LAST + 1]; + struct list_head endpoints; +}; + extern struct asoc_sdw_codec_info codec_info_list[]; int asoc_sdw_get_codec_info_list_count(void); diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index 222cf4a37707..6b30659f0e25 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -617,27 +617,6 @@ static const struct snd_soc_ops sdw_ops = { .shutdown = asoc_sdw_shutdown, }; -struct asoc_sdw_endpoint { - struct list_head list; - - u32 link_mask; - const char *codec_name; - const char *name_prefix; - bool include_sidecar; - - struct asoc_sdw_codec_info *codec_info; - const struct asoc_sdw_dai_info *dai_info; -}; - -struct asoc_sdw_dailink { - bool initialised; - - u8 group_id; - u32 link_mask[SNDRV_PCM_STREAM_LAST + 1]; - int num_devs[SNDRV_PCM_STREAM_LAST + 1]; - struct list_head endpoints; -}; - static const char * const type_strings[] = {"SimpleJack", "SmartAmp", "SmartMic"}; static int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends) From patchwork Fri Sep 13 09:06:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13803173 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2052.outbound.protection.outlook.com [40.107.212.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEE8E1D7E47; Fri, 13 Sep 2024 09:07:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726218442; cv=fail; b=dErQLY1dkNFtmSQKEQnrpGWUaVdJinf53Yg4X0U7zwl7a+vqDiQGb35dp5HszE66Akn33vZRrBLvl/gmwnxIBBpzyOdYlMnC+ODGHrIOtE68EVavlkfw39TOl7ViTZ0yis20SNMsT/a7xLwmSQfVygGFLhI1Htx9p6oo3oGKR14= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726218442; c=relaxed/simple; bh=Di1bxmwysb9WFJAKyqXgluM5cz8Fev/gtt65EeoHnt8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HwnpnERukLwGYg4FMUeOOYbrLpuTfu22s25yn/h94mz3GQlhHT3fh9YCqfNyCPk7VjHqzZX4f8UvHDnC3dBBlrAdTxYfOkdJ96y/fOHSryhDzdSgzn66rYTJp3Nc+LBLCcwzZ+PKavBOx2RGq24YR4fEn8inOP8mL0N29+549mo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=oy7lqV36; arc=fail smtp.client-ip=40.107.212.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="oy7lqV36" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GSWdKxCDbLbACAoSSdSXDzYrbdyp/qIpk9WagLM/V3mZdLXTcfGc/yf3bGcO1lxnyQpisAGFmxbfHbIMODlJOPQcJrx8xb/ejNiNGmauvcN5OUgsclRVpM12DPUn67UnzebzIZ4oVUllfn8DB5/UpEiqh7gZfngD1cZFv0g3u+K12Gu8gAMZ8nUKo0wxyv1STGJKD+Zbq9J/dyVRMNm4PinVldjGb4g4uFVD3kR/eTcIvrH0FV/ECQ0lNY3WbRus/2gyzn2yHAE7Tl16ijsgcZtFb14Td6y24MWGPkzMjJ8wTIWtNSYNYBmldRx+pk0TLlpd/KW0JF9S6MFLQDMp7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eM3RbXQpsn0B5ikrQSLkhLs6a25j5zbxsfe8PhyKsac=; b=IdaGthl58915j8ZNgUoglOl2zoM6PTUaKwcYp/K8uC8i4o/Xpttv1aP3+G++d5eEsLpNqrwPaEQCTobHnw4xxxf7nJ0Tw6wU6oHFabtIuFECGWHdmMQ1FfTVHhrc/qMoCfsqvql3YoNQBvkrBMeGWuA5kjXoo8tj0BtTMgyXYfHY70WqMsB5plsB8I8jAT5zhbx6sARDE5kE71+575+Fv91Ogk84rOQVbFvolgNMnWbWsiw76ErOKxHoSMytXr58xwon1aEvGYt1HqBdYYiyTAI5KGGl4zpZY6XJFAu4pwB38PzC+dwQ4IFynnwMUn54fvsiOKOrVRyAR6uT5P/inw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eM3RbXQpsn0B5ikrQSLkhLs6a25j5zbxsfe8PhyKsac=; b=oy7lqV36luqevGfU1P/RPRSv2srZrpM+S0pghr5lvalUIC0zm2IwqTUatF9mYqEo7TjxbZaC8u7bo+UEpWLUeY9cAqV2jluPcZZbwrJTHdxD46kyVXTMydb6I8m24hCMIcBibMwkDaja/PIm1MwYvPkfAv/toJ0LpmwaMvTyEdw= Received: from PH7P222CA0010.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:33a::9) by MW6PR12MB8897.namprd12.prod.outlook.com (2603:10b6:303:24a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.24; Fri, 13 Sep 2024 09:07:16 +0000 Received: from CY4PEPF0000EE34.namprd05.prod.outlook.com (2603:10b6:510:33a:cafe::a9) by PH7P222CA0010.outlook.office365.com (2603:10b6:510:33a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.27 via Frontend Transport; Fri, 13 Sep 2024 09:07:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE34.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 13 Sep 2024 09:07:15 +0000 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 13 Sep 2024 04:07:06 -0500 From: Vijendar Mukunda To: CC: , , , , , , , , , , , , , , Vijendar Mukunda Subject: [PATCH 4/5] ASoC: sdw_utils/intel: move soundwire endpoint parsing helper functions Date: Fri, 13 Sep 2024 14:36:30 +0530 Message-ID: <20240913090631.1834543-5-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913090631.1834543-1-Vijendar.Mukunda@amd.com> References: <20240913090631.1834543-1-Vijendar.Mukunda@amd.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE34:EE_|MW6PR12MB8897:EE_ X-MS-Office365-Filtering-Correlation-Id: 2718fa33-3033-44b7-8308-08dcd3d37692 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|7416014|36860700013; X-Microsoft-Antispam-Message-Info: F5hKH6ntRz+ishMrbKrrd2EwOROi8qmSbkUX4cFWBk4OkzcyK9eX5ejv93fQcTypnSx4zVQwPiERTBUUQJQs1x25U0UD3G+DUofJNWT2yfVj/etGssi/NQGk93Lw2q+KRDXXxavrjp1p9i33fVhmRm79aWdEKv8XFmFL9WgNk2BA2m5QSehw/Dv/A6V+cozePUdzoI9GpaitICTChAcYUVQLiDBW5FVpfq4ra9zFbiZkfSiK+6tUqON1UdkG+wkjkVIiXpPR5KQJY2MtiQ6uNm6IL/Qzp+TTwjJRY3doKNbpNsqvxLidwP74/IIHfJ4jEZwFiCXupRFQ6Cd0LeLWYTEPqm81vNjrqUEVzzgv24s+TvK+XA20DWgXNkU/QZYP0AXS1Yxp77/cCtyBjBYLvdekL7oj6x+tQ5bTXbQXZH1kBT0x9qtH3UmeMWW7OQixVIyK+v9RftVIDycnqqpHjGotjnURzcDo3sXgbB1wQ5+fEvE06lUhZInWeNONseV7PS+mBDlAnKPOjKZu7Ab80jxhVG2afmQlSxo3HPLF0MzYDRL+ZoQ6z4SCLMN2x9zar+iw0LCd2leeonBNwQqAeAvZtqBufKuqN99Xjk+UNX+IXse7Mx5Qy/5GrShNLMD+lJFdruPO5LUNNi3VwKKMkFYxN3Q742JcYfGwDKW9AM0iAW2pREuDA7n1W1th30b//6LEbnYiuPEGRVE+RH5brJUVGjt6+oPGhAlAaDWd5Wtu0AgB7ZuXLmaUcRqo5RgBEEvosRySFwzHHhu1HBi+O+9BiPzhMA/OKAn1ChyQ4tSeMra4/ZJuwNOmrSSUMR+8ON5TM94fwGeWW27CxrOeq5rqQad5euUdFEjVnx3yclzIdQy801MuZMZaghuOr7yolWEjgWAkBj+ymsKe5+nYZLMkBLC0+4hgcvBh2JY4Z7oVrLcMfU9NJNYBdxDwq28NLQv0pYHt1pX48fykkT2gaNDkBf2O7fFPDCDaIOjvAyO2z+7BH2UeDl3wtsxo4SfvOpjd8yMmKX5mPQvjsnVEJQZNZCje6Y4oDWpOUCu1xX3ZCY+gP6P/UGXpohIr2YTUM71BdriJgQL7JRpHaJ0tcNSep/oMy7v+Xqf8oeNPYTvGxN+8LTlIncTAJISHVtD3Z4Jhi9xhOohorJ91Th3DfGqDov8TeUvtY1oMFX2L99efsMsTyaxuCcTn9DwxicsQ7QE2ZZfq6JfktNs9JFVY0BZF/1ws6tDL7DA8P40AqS2D99f8LW4UJXhf0KUHPPH4hkQTUnWAiBAelL0xysRot/SuUrKRh+98d76y1XavwDKJ1qYriO5bEgW6i7dhZ8qLo+P9JMd5C9zhki+iZNqruGKrcOP406LfEfscHT5R/0h0u0ZsP220QnjYGsFEd7FLctJjYhORxC8tZpFywy5VCZ6pCdTa7xLalyRu7rqI57eejJR7JljgjvijD0GMMlYY X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 09:07:15.8766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2718fa33-3033-44b7-8308-08dcd3d37692 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE34.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8897 Move SoundWire endpoint parsing helper functions to common place holder. These functions will be used by other platform machine driver code. Signed-off-by: Vijendar Mukunda Reviewed-by: Bard Liao --- include/sound/soc_sdw_utils.h | 10 ++ sound/soc/intel/boards/sof_sdw.c | 158 --------------------------- sound/soc/sdw_utils/soc_sdw_utils.c | 161 ++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+), 158 deletions(-) diff --git a/include/sound/soc_sdw_utils.h b/include/sound/soc_sdw_utils.h index e3482720a3eb..f68c1f193b3b 100644 --- a/include/sound/soc_sdw_utils.h +++ b/include/sound/soc_sdw_utils.h @@ -161,6 +161,16 @@ int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *d int (*init)(struct snd_soc_pcm_runtime *rtd), const struct snd_soc_ops *ops); +int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends); + +struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks, + const struct snd_soc_acpi_endpoint *new); + +int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card, + struct asoc_sdw_dailink *soc_dais, + struct asoc_sdw_endpoint *soc_ends, + int *num_devs); + int asoc_sdw_rtd_init(struct snd_soc_pcm_runtime *rtd); /* DMIC support */ diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index 6b30659f0e25..5196d96f5c0e 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -619,164 +619,6 @@ static const struct snd_soc_ops sdw_ops = { static const char * const type_strings[] = {"SimpleJack", "SmartAmp", "SmartMic"}; -static int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends) -{ - struct device *dev = card->dev; - struct snd_soc_acpi_mach *mach = dev_get_platdata(dev); - struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params; - const struct snd_soc_acpi_link_adr *adr_link; - int i; - - for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) { - *num_devs += adr_link->num_adr; - - for (i = 0; i < adr_link->num_adr; i++) - *num_ends += adr_link->adr_d[i].num_endpoints; - } - - dev_dbg(dev, "Found %d devices with %d endpoints\n", *num_devs, *num_ends); - - return 0; -} - -static struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks, - const struct snd_soc_acpi_endpoint *new) -{ - while (dailinks->initialised) { - if (new->aggregated && dailinks->group_id == new->group_id) - return dailinks; - - dailinks++; - } - - INIT_LIST_HEAD(&dailinks->endpoints); - dailinks->group_id = new->group_id; - dailinks->initialised = true; - - return dailinks; -} - -static int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card, - struct asoc_sdw_dailink *sof_dais, - struct asoc_sdw_endpoint *sof_ends, - int *num_devs) -{ - struct device *dev = card->dev; - struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card); - struct snd_soc_acpi_mach *mach = dev_get_platdata(dev); - struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params; - const struct snd_soc_acpi_link_adr *adr_link; - struct asoc_sdw_endpoint *sof_end = sof_ends; - int num_dais = 0; - int i, j; - int ret; - - for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) { - int num_link_dailinks = 0; - - if (!is_power_of_2(adr_link->mask)) { - dev_err(dev, "link with multiple mask bits: 0x%x\n", - adr_link->mask); - return -EINVAL; - } - - for (i = 0; i < adr_link->num_adr; i++) { - const struct snd_soc_acpi_adr_device *adr_dev = &adr_link->adr_d[i]; - struct asoc_sdw_codec_info *codec_info; - const char *codec_name; - - if (!adr_dev->name_prefix) { - dev_err(dev, "codec 0x%llx does not have a name prefix\n", - adr_dev->adr); - return -EINVAL; - } - - codec_info = asoc_sdw_find_codec_info_part(adr_dev->adr); - if (!codec_info) - return -EINVAL; - - ctx->ignore_internal_dmic |= codec_info->ignore_internal_dmic; - - codec_name = asoc_sdw_get_codec_name(dev, codec_info, adr_link, i); - if (!codec_name) - return -ENOMEM; - - dev_dbg(dev, "Adding prefix %s for %s\n", - adr_dev->name_prefix, codec_name); - - sof_end->name_prefix = adr_dev->name_prefix; - - if (codec_info->count_sidecar && codec_info->add_sidecar) { - ret = codec_info->count_sidecar(card, &num_dais, num_devs); - if (ret) - return ret; - - sof_end->include_sidecar = true; - } - - for (j = 0; j < adr_dev->num_endpoints; j++) { - const struct snd_soc_acpi_endpoint *adr_end; - const struct asoc_sdw_dai_info *dai_info; - struct asoc_sdw_dailink *sof_dai; - int stream; - - adr_end = &adr_dev->endpoints[j]; - dai_info = &codec_info->dais[adr_end->num]; - sof_dai = asoc_sdw_find_dailink(sof_dais, adr_end); - - if (dai_info->quirk && !(dai_info->quirk & sof_sdw_quirk)) - continue; - - dev_dbg(dev, - "Add dev: %d, 0x%llx end: %d, %s, %c/%c to %s: %d\n", - ffs(adr_link->mask) - 1, adr_dev->adr, - adr_end->num, type_strings[dai_info->dai_type], - dai_info->direction[SNDRV_PCM_STREAM_PLAYBACK] ? 'P' : '-', - dai_info->direction[SNDRV_PCM_STREAM_CAPTURE] ? 'C' : '-', - adr_end->aggregated ? "group" : "solo", - adr_end->group_id); - - if (adr_end->num >= codec_info->dai_num) { - dev_err(dev, - "%d is too many endpoints for codec: 0x%x\n", - adr_end->num, codec_info->part_id); - return -EINVAL; - } - - for_each_pcm_streams(stream) { - if (dai_info->direction[stream] && - dai_info->dailink[stream] < 0) { - dev_err(dev, - "Invalid dailink id %d for codec: 0x%x\n", - dai_info->dailink[stream], - codec_info->part_id); - return -EINVAL; - } - - if (dai_info->direction[stream]) { - num_dais += !sof_dai->num_devs[stream]; - sof_dai->num_devs[stream]++; - sof_dai->link_mask[stream] |= adr_link->mask; - } - } - - num_link_dailinks += !!list_empty(&sof_dai->endpoints); - list_add_tail(&sof_end->list, &sof_dai->endpoints); - - sof_end->link_mask = adr_link->mask; - sof_end->codec_name = codec_name; - sof_end->codec_info = codec_info; - sof_end->dai_info = dai_info; - sof_end++; - } - } - - ctx->append_dai_type |= (num_link_dailinks > 1); - } - - return num_dais; -} - static int create_sdw_dailink(struct snd_soc_card *card, struct asoc_sdw_dailink *sof_dai, struct snd_soc_dai_link **dai_links, diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c index d59ccb56642c..a6070f822eb9 100644 --- a/sound/soc/sdw_utils/soc_sdw_utils.c +++ b/sound/soc/sdw_utils/soc_sdw_utils.c @@ -1005,5 +1005,166 @@ int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *d } EXPORT_SYMBOL_NS(asoc_sdw_init_simple_dai_link, SND_SOC_SDW_UTILS); +int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends) +{ + struct device *dev = card->dev; + struct snd_soc_acpi_mach *mach = dev_get_platdata(dev); + struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params; + const struct snd_soc_acpi_link_adr *adr_link; + int i; + + for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) { + *num_devs += adr_link->num_adr; + + for (i = 0; i < adr_link->num_adr; i++) + *num_ends += adr_link->adr_d[i].num_endpoints; + } + + dev_dbg(dev, "Found %d devices with %d endpoints\n", *num_devs, *num_ends); + + return 0; +} +EXPORT_SYMBOL_NS(asoc_sdw_count_sdw_endpoints, SND_SOC_SDW_UTILS); + +struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks, + const struct snd_soc_acpi_endpoint *new) +{ + while (dailinks->initialised) { + if (new->aggregated && dailinks->group_id == new->group_id) + return dailinks; + + dailinks++; + } + + INIT_LIST_HEAD(&dailinks->endpoints); + dailinks->group_id = new->group_id; + dailinks->initialised = true; + + return dailinks; +} +EXPORT_SYMBOL_NS(asoc_sdw_find_dailink, SND_SOC_SDW_UTILS); + +int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card, + struct asoc_sdw_dailink *soc_dais, + struct asoc_sdw_endpoint *soc_ends, + int *num_devs) +{ + struct device *dev = card->dev; + struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card); + struct snd_soc_acpi_mach *mach = dev_get_platdata(dev); + struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params; + const struct snd_soc_acpi_link_adr *adr_link; + struct asoc_sdw_endpoint *soc_end = soc_ends; + int num_dais = 0; + int i, j; + int ret; + + for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) { + int num_link_dailinks = 0; + + if (!is_power_of_2(adr_link->mask)) { + dev_err(dev, "link with multiple mask bits: 0x%x\n", + adr_link->mask); + return -EINVAL; + } + + for (i = 0; i < adr_link->num_adr; i++) { + const struct snd_soc_acpi_adr_device *adr_dev = &adr_link->adr_d[i]; + struct asoc_sdw_codec_info *codec_info; + const char *codec_name; + + if (!adr_dev->name_prefix) { + dev_err(dev, "codec 0x%llx does not have a name prefix\n", + adr_dev->adr); + return -EINVAL; + } + + codec_info = asoc_sdw_find_codec_info_part(adr_dev->adr); + if (!codec_info) + return -EINVAL; + + ctx->ignore_internal_dmic |= codec_info->ignore_internal_dmic; + + codec_name = asoc_sdw_get_codec_name(dev, codec_info, adr_link, i); + if (!codec_name) + return -ENOMEM; + + dev_dbg(dev, "Adding prefix %s for %s\n", + adr_dev->name_prefix, codec_name); + + soc_end->name_prefix = adr_dev->name_prefix; + + if (codec_info->count_sidecar && codec_info->add_sidecar) { + ret = codec_info->count_sidecar(card, &num_dais, num_devs); + if (ret) + return ret; + + soc_end->include_sidecar = true; + } + + for (j = 0; j < adr_dev->num_endpoints; j++) { + const struct snd_soc_acpi_endpoint *adr_end; + const struct asoc_sdw_dai_info *dai_info; + struct asoc_sdw_dailink *soc_dai; + int stream; + + adr_end = &adr_dev->endpoints[j]; + dai_info = &codec_info->dais[adr_end->num]; + soc_dai = asoc_sdw_find_dailink(soc_dais, adr_end); + + if (dai_info->quirk && !(dai_info->quirk & ctx->mc_quirk)) + continue; + + dev_dbg(dev, + "Add dev: %d, 0x%llx end: %d, dai: %d, %c/%c to %s: %d\n", + ffs(adr_link->mask) - 1, adr_dev->adr, + adr_end->num, dai_info->dai_type, + dai_info->direction[SNDRV_PCM_STREAM_PLAYBACK] ? 'P' : '-', + dai_info->direction[SNDRV_PCM_STREAM_CAPTURE] ? 'C' : '-', + adr_end->aggregated ? "group" : "solo", + adr_end->group_id); + + if (adr_end->num >= codec_info->dai_num) { + dev_err(dev, + "%d is too many endpoints for codec: 0x%x\n", + adr_end->num, codec_info->part_id); + return -EINVAL; + } + + for_each_pcm_streams(stream) { + if (dai_info->direction[stream] && + dai_info->dailink[stream] < 0) { + dev_err(dev, + "Invalid dailink id %d for codec: 0x%x\n", + dai_info->dailink[stream], + codec_info->part_id); + return -EINVAL; + } + + if (dai_info->direction[stream]) { + num_dais += !soc_dai->num_devs[stream]; + soc_dai->num_devs[stream]++; + soc_dai->link_mask[stream] |= adr_link->mask; + } + } + + num_link_dailinks += !!list_empty(&soc_dai->endpoints); + list_add_tail(&soc_end->list, &soc_dai->endpoints); + + soc_end->link_mask = adr_link->mask; + soc_end->codec_name = codec_name; + soc_end->codec_info = codec_info; + soc_end->dai_info = dai_info; + soc_end++; + } + } + + ctx->append_dai_type |= (num_link_dailinks > 1); + } + + return num_dais; +} +EXPORT_SYMBOL_NS(asoc_sdw_parse_sdw_endpoints, SND_SOC_SDW_UTILS); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("SoundWire ASoC helpers"); From patchwork Fri Sep 13 09:06:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijendar Mukunda X-Patchwork-Id: 13803174 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2074.outbound.protection.outlook.com [40.107.93.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39F451D7E4F; Fri, 13 Sep 2024 09:07:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726218448; cv=fail; b=HZuLHA8IKgK9bl21LP571jha5vAfNLVQQN5szQo3zmdlipWB4FnKKWqIp7DqEuixSwSnyR4S7Ntc7qLgalGJkdmPkbk7lZoYo+SRjI233BTmeOhTxm2BR0RKkRR+jMg3UYMGiZBg9Vpe04yTrNs8LOqg2oFTfOypDUs8qppRG/Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726218448; c=relaxed/simple; bh=8X0aIkHeooPN2xRbL9E65bAn/BprQbpEzSfFWpcwO6k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KK2XeacloQ7rEVA6552UU4sIVZwYJlkWH/ZIjeiMTDmpA1kuvdVT8BWcIHJCC5kYiABNtcyHe1KRt41ePfhvxSsSUU2mPIPZT70ZISOcoAekIshMR+fXiZwFuNIJS8pwO1Fnt9xtvItbHjknRmuHh9X8zkV3FVzP0Twbl4xxiz0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=UKtCONg5; arc=fail smtp.client-ip=40.107.93.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="UKtCONg5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uKmVwCTCOOaepSd5wEb7krGdOAzai3iKiJ6S1Tr4VwLovJ4kN1CPmeoSiaD9Qj57TZSzMBhyAgWV8Zzpix072QFDYTmqMB4pHsp7zNV6cIm0T6Ga/8bCOPlDOAAdiGvyrnplNwVfSJHLRSRUpnIMmd4OEcUPOrhVbMM51Drc/AFgvSPj7ADWtCgN4siJ8muIWCMPR4VT4e8EBLZzXlkwMIFqc7hblB6fuAH7mmHKp09bpJFFwaYrlzve80hAyYh01RlsjzQCa/rICtjRgbpG852BiqkFSNDHTcoQw+JQfYohqG+Fl233z96dE23K+dHQV6CLkhpU4YBk+Fxzm+P1vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eg9agBLp2CJDujLSJNf1qgNzRtrS1AFfrWUygIPzwPw=; b=uZDcqRAbCVqwkfGrPgVGRb3VpcqqEzHFcbrFBGoc4Hxt1ozbmEP43eBRKPQXVuJINDFnJ35A1qgfNaiCFDu9Imjez2cCIzFCOS8RIrxTDxTeRaNniYlGafelkXVqo6HW661oeIWZGotc2AZ8Ciq31lbVP5t0amPRfTqyqyZuTbK/XUAUyk4ga/tjaFZ/j9WHe4K9AWzl9r76Itz/znC2nXPdTpChma4muHpLN1ZpLB1WSkDthGHd9Aya4Aj+N3Od5aao6WCs6qPBYoQ3TkIrAEfXWIrpwlcolF1h6MRevJythrsazRNYmRm0N2CQgncHcOMS9FCeoeBhh0mvrajrdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eg9agBLp2CJDujLSJNf1qgNzRtrS1AFfrWUygIPzwPw=; b=UKtCONg5DqDvdEz4xAVFUs54Kugxyv6ljtb+5mpzlMhrBXYRkRD6gFdUx95Ql2sTRCLiRmw1wE2ifh6i6Er1YJDZZYWJDEBNiV9QWyVAHmTJyxZUL8Z4wFwAL34NYWMVMI3u7KObYE08UhnnjnkJYUtz36I5y9QwF8Bu0wEn5J0= Received: from DS7PR06CA0004.namprd06.prod.outlook.com (2603:10b6:8:2a::19) by MW4PR12MB5625.namprd12.prod.outlook.com (2603:10b6:303:168::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.27; Fri, 13 Sep 2024 09:07:19 +0000 Received: from CY4PEPF0000EE31.namprd05.prod.outlook.com (2603:10b6:8:2a:cafe::d3) by DS7PR06CA0004.outlook.office365.com (2603:10b6:8:2a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.26 via Frontend Transport; Fri, 13 Sep 2024 09:07:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE31.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 13 Sep 2024 09:07:18 +0000 Received: from vijendar-X570-GAMING-X.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 13 Sep 2024 04:07:11 -0500 From: Vijendar Mukunda To: CC: , , , , , , , , , , , , , , Vijendar Mukunda Subject: [PATCH 5/5] ASoC: amd: acp: refactor SoundWire machine driver code Date: Fri, 13 Sep 2024 14:36:31 +0530 Message-ID: <20240913090631.1834543-6-Vijendar.Mukunda@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913090631.1834543-1-Vijendar.Mukunda@amd.com> References: <20240913090631.1834543-1-Vijendar.Mukunda@amd.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE31:EE_|MW4PR12MB5625:EE_ X-MS-Office365-Filtering-Correlation-Id: aca866b1-3bb0-4d8a-d244-08dcd3d37842 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: r661I9huaQx3zWm49JWMNQdlQawbdcBAEb/++KASe1AQNkUPI6LbkX8RH7Aj04nKVkd+0SsomI8FLltmeDtnravopJEzPixhOtdbsgLfSjIatGfbgAlv+LgvBNMvW4PeyAUPzzN1pyRsKo124bogxqC+hKU34+NXLERJrz3XIThHG9uNBwQiXUJL4MuXm0L5zjKhJ+52JUZrwx2/Ln1iW6yhXRaF6S83qRYXhjnu/YUbbBynvj42aBirvLvA3UlviW2QD/pkyo/dThUuHkPS+LkQpPnqw38aCdH/PctV3grdadeIKFQDBzx1Cz7Y1IrX0BVoJPdx82AAPjZJhiSeVJDGuFbeAL6OGIN6ankwG1rXCTv5nf8u24oQkUuh/ECcfG7enGwHVwbxs96tnKAtjQy3OwXrPcf4P3aBpA6T7nsusbVrGO1XCxQvbLQJD2DzJMnn/6EeVk/l72GCLNiy44OZ6EPEAJm0bRphjFvC/b3oKxMJIx853FS2GLJE+5tCY+vCXXSidiVCtU6sUQkRXL/gAGNbA2XOXraWHmBoPwUKuCFcbGOBW5CBcCqTHg3Rrqzva3uQ+B7N9CKqQPWiuKCHIvzxBtJWP2zG0JeH5owBVjGPypi1yyzgnrepktoBocv9p+ZY2b0NTSov5xO0liZdr4HONRD2az0UU7gQkNso2y47nD0YBntO2781POYMBRqpVS/LPhl7ZCxGoW74NMWv/P3JPhVBPOP94PXXU/TAxkDwGtzWFnsveDAbCmaAVwBKJX9YAiuI5AMF4/wwhP36JnSqyysgmM2y/n6cdFyuUpuUJVYjkMr/1KC5q3anRrAhY3e73IbkpJT5+q3FwF0m7fn3TuTieUxtaXkGwj1ZVZKvxNHlMI9rUsuBS5VtOHXQwkWQ8BqAMLqnHezNscUZIfUNKKLP+NHqZq+Yj/pzd0tIl0REIPdiNByTxIAu3WSG0bHhjpj5Rsse9Q/Z8+uS19iby32+2SX8Eo3+7FGQzsDUSjcK26BJ0AdbwcvgJIll2FiFgwKmqjTbOxaUMx2DfPLWGh6CYcBtxLS1KoS1TdaNHknQIJ9mRwF/oYMHWruZf93UVXf9+rahc8G1HwkcgXDRlj7Jfpl8pmTiYKkC0V6ppHOUrFTT/7JLFYrUT+N5TbRgsG46ymrgAL4yXiKXPFxNdgmn2FefbLw1tGwfkV/4zMwlKURl3zET/VQHENGL4CCATPRlClJ+qqnvMktiJtmL+PsLFm44evONVJ4dEBii22inXRD9F3tY+FacuCo0fe43qy3ogbyq6/Vkobd8Ajxrs63IzvTs3ysFAwfIF+Sjdk2LhUMeNi9mr+qIAJ3TkQ1dWdtU5KpgSh4qCJgACvVf1arSE6+ttH+P6O2RbJC3MPWNOooEjHmtBVIRU0SsCjbvGkRKXXbMvS/ukNkj3qgQRaqTAzremGXZuBxJlV2E0ca1Tb5je2Q6k2hN X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(1800799024)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2024 09:07:18.7098 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aca866b1-3bb0-4d8a-d244-08dcd3d37842 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE31.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5625 Refactor Soundwire machine driver code by using common SoundWire endpoint parsing helper functions. Signed-off-by: Vijendar Mukunda Reviewed-by: Bard Liao --- sound/soc/amd/acp/acp-sdw-sof-mach.c | 540 ++++++++------------------- 1 file changed, 154 insertions(+), 386 deletions(-) diff --git a/sound/soc/amd/acp/acp-sdw-sof-mach.c b/sound/soc/amd/acp/acp-sdw-sof-mach.c index b1cd173f607d..6c50c8276538 100644 --- a/sound/soc/amd/acp/acp-sdw-sof-mach.c +++ b/sound/soc/amd/acp/acp-sdw-sof-mach.c @@ -64,197 +64,6 @@ static const struct snd_soc_ops sdw_ops = { .shutdown = asoc_sdw_shutdown, }; -/* - * get BE dailink number and CPU DAI number based on sdw link adr. - * Since some sdw slaves may be aggregated, the CPU DAI number - * may be larger than the number of BE dailinks. - */ -static int get_dailink_info(struct device *dev, - const struct snd_soc_acpi_link_adr *adr_link, - int *sdw_be_num, int *codecs_num) -{ - bool group_visited[AMD_SDW_MAX_GROUPS]; - int i; - int j; - - *sdw_be_num = 0; - - if (!adr_link) - return -EINVAL; - - for (i = 0; i < AMD_SDW_MAX_GROUPS; i++) - group_visited[i] = false; - - for (; adr_link->num_adr; adr_link++) { - const struct snd_soc_acpi_endpoint *endpoint; - struct asoc_sdw_codec_info *codec_info; - int stream; - u64 adr; - - /* make sure the link mask has a single bit set */ - if (!is_power_of_2(adr_link->mask)) - return -EINVAL; - - for (i = 0; i < adr_link->num_adr; i++) { - adr = adr_link->adr_d[i].adr; - codec_info = asoc_sdw_find_codec_info_part(adr); - if (!codec_info) - return -EINVAL; - - *codecs_num += codec_info->dai_num; - - if (!adr_link->adr_d[i].name_prefix) { - dev_err(dev, "codec 0x%llx does not have a name prefix\n", - adr_link->adr_d[i].adr); - return -EINVAL; - } - - endpoint = adr_link->adr_d[i].endpoints; - if (endpoint->aggregated && !endpoint->group_id) { - dev_err(dev, "invalid group id on link %x\n", - adr_link->mask); - return -EINVAL; - } - - for (j = 0; j < codec_info->dai_num; j++) { - /* count DAI number for playback and capture */ - for_each_pcm_streams(stream) { - if (!codec_info->dais[j].direction[stream]) - continue; - - /* count BE for each non-aggregated slave or group */ - if (!endpoint->aggregated || - !group_visited[endpoint->group_id]) - (*sdw_be_num)++; - } - } - - if (endpoint->aggregated) - group_visited[endpoint->group_id] = true; - } - } - return 0; -} - -static int fill_sdw_codec_dlc(struct device *dev, - const struct snd_soc_acpi_link_adr *adr_link, - struct snd_soc_dai_link_component *codec, - int adr_index, int dai_index) -{ - u64 adr = adr_link->adr_d[adr_index].adr; - struct asoc_sdw_codec_info *codec_info; - - codec_info = asoc_sdw_find_codec_info_part(adr); - if (!codec_info) - return -EINVAL; - - codec->name = asoc_sdw_get_codec_name(dev, codec_info, adr_link, adr_index); - if (!codec->name) - return -ENOMEM; - - codec->dai_name = codec_info->dais[dai_index].dai_name; - dev_err(dev, "codec->dai_name:%s\n", codec->dai_name); - return 0; -} - -static int set_codec_init_func(struct snd_soc_card *card, - const struct snd_soc_acpi_link_adr *adr_link, - struct snd_soc_dai_link *dai_links, - bool playback, int group_id, int adr_index, int dai_index) -{ - int i = adr_index; - - do { - /* - * Initialize the codec. If codec is part of an aggregated - * group (group_id>0), initialize all codecs belonging to - * same group. - * The first link should start with adr_link->adr_d[adr_index] - * because that is the device that we want to initialize and - * we should end immediately if it is not aggregated (group_id=0) - */ - for ( ; i < adr_link->num_adr; i++) { - struct asoc_sdw_codec_info *codec_info; - - codec_info = asoc_sdw_find_codec_info_part(adr_link->adr_d[i].adr); - if (!codec_info) - return -EINVAL; - - /* The group_id is > 0 iff the codec is aggregated */ - if (adr_link->adr_d[i].endpoints->group_id != group_id) - continue; - if (codec_info->dais[dai_index].init) - codec_info->dais[dai_index].init(card, - dai_links, - codec_info, - playback); - - if (!group_id) - return 0; - } - - i = 0; - adr_link++; - } while (adr_link->mask); - - return 0; -} - -/* - * check endpoint status in slaves and gather link ID for all slaves in - * the same group to generate different CPU DAI. Now only support - * one sdw link with all slaves set with only single group id. - * - * one slave on one sdw link with aggregated = 0 - * one sdw BE DAI <---> one-cpu DAI <---> one-codec DAI - * - * two or more slaves on one sdw link with aggregated = 1 - * one sdw BE DAI <---> one-cpu DAI <---> multi-codec DAIs - */ -static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link, - struct device *dev, int *cpu_dai_id, int *cpu_dai_num, - int *codec_num, unsigned int *group_id, - int adr_index) -{ - int i; - - if (!adr_link->adr_d[adr_index].endpoints->aggregated) { - cpu_dai_id[0] = ffs(adr_link->mask) - 1; - *cpu_dai_num = 1; - *codec_num = 1; - *group_id = 0; - return 0; - } - - *codec_num = 0; - *cpu_dai_num = 0; - *group_id = adr_link->adr_d[adr_index].endpoints->group_id; - - /* Count endpoints with the same group_id in the adr_link */ - for (; adr_link && adr_link->num_adr; adr_link++) { - unsigned int link_codecs = 0; - - for (i = 0; i < adr_link->num_adr; i++) { - if (adr_link->adr_d[i].endpoints->aggregated && - adr_link->adr_d[i].endpoints->group_id == *group_id) - link_codecs++; - } - - if (link_codecs) { - *codec_num += link_codecs; - - if (*cpu_dai_num >= ACP63_SDW_MAX_CPU_DAIS) { - dev_err(dev, "cpu_dai_id array overflowed\n"); - return -EINVAL; - } - - cpu_dai_id[(*cpu_dai_num)++] = ffs(adr_link->mask) - 1; - } - } - - return 0; -} - static int get_acp63_cpu_pin_id(u32 sdw_link_id, int be_id, int *cpu_pin_id, struct device *dev) { switch (sdw_link_id) { @@ -306,116 +115,64 @@ static int get_acp63_cpu_pin_id(u32 sdw_link_id, int be_id, int *cpu_pin_id, str static const char * const type_strings[] = {"SimpleJack", "SmartAmp", "SmartMic"}; static int create_sdw_dailink(struct snd_soc_card *card, + struct asoc_sdw_dailink *sof_dai, struct snd_soc_dai_link **dai_links, - const struct snd_soc_acpi_link_adr *adr_link, - struct snd_soc_codec_conf **codec_conf, - int *be_id, int adr_index, int dai_index) + int *be_id, struct snd_soc_codec_conf **codec_conf) { + struct device *dev = card->dev; struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card); struct amd_mc_ctx *amd_ctx = (struct amd_mc_ctx *)ctx->private; - struct device *dev = card->dev; - const struct snd_soc_acpi_link_adr *adr_link_next; - struct snd_soc_dai_link_ch_map *sdw_codec_ch_maps; - struct snd_soc_dai_link_component *codecs; - struct snd_soc_dai_link_component *cpus; - struct asoc_sdw_codec_info *codec_info; - int cpu_dai_id[ACP63_SDW_MAX_CPU_DAIS]; - int cpu_dai_num; - unsigned int group_id; - unsigned int sdw_link_id; - int codec_dlc_index = 0; - int codec_num; + struct asoc_sdw_endpoint *sof_end; + int cpu_pin_id; int stream; - int i = 0; - int j, k; int ret; - int cpu_pin_id; - - ret = get_slave_info(adr_link, dev, cpu_dai_id, &cpu_dai_num, &codec_num, - &group_id, adr_index); - if (ret) - return ret; - codecs = devm_kcalloc(dev, codec_num, sizeof(*codecs), GFP_KERNEL); - if (!codecs) - return -ENOMEM; - sdw_codec_ch_maps = devm_kcalloc(dev, codec_num, - sizeof(*sdw_codec_ch_maps), GFP_KERNEL); - if (!sdw_codec_ch_maps) - return -ENOMEM; - - /* generate codec name on different links in the same group */ - j = adr_index; - for (adr_link_next = adr_link; adr_link_next && adr_link_next->num_adr && - i < cpu_dai_num; adr_link_next++) { - /* skip the link excluded by this processed group */ - if (cpu_dai_id[i] != ffs(adr_link_next->mask) - 1) - continue; - - /* j reset after loop, adr_index only applies to first link */ - for (k = 0 ; (j < adr_link_next->num_adr) && (k < codec_num) ; j++, k++) { - const struct snd_soc_acpi_endpoint *endpoints; - - endpoints = adr_link_next->adr_d[j].endpoints; - if (group_id && (!endpoints->aggregated || - endpoints->group_id != group_id)) - continue; - - /* sanity check */ - if (*codec_conf >= card->codec_conf + card->num_configs) { - dev_err(dev, "codec_conf array overflowed\n"); - return -EINVAL; - } + list_for_each_entry(sof_end, &sof_dai->endpoints, list) { + if (sof_end->name_prefix) { + (*codec_conf)->dlc.name = sof_end->codec_name; + (*codec_conf)->name_prefix = sof_end->name_prefix; + (*codec_conf)++; + } - ret = fill_sdw_codec_dlc(dev, adr_link_next, - &codecs[codec_dlc_index], - j, dai_index); + if (sof_end->include_sidecar) { + ret = sof_end->codec_info->add_sidecar(card, dai_links, codec_conf); if (ret) return ret; - (*codec_conf)->dlc = codecs[codec_dlc_index]; - (*codec_conf)->name_prefix = adr_link_next->adr_d[j].name_prefix; - - sdw_codec_ch_maps[codec_dlc_index].cpu = i; - sdw_codec_ch_maps[codec_dlc_index].codec = codec_dlc_index; - - codec_dlc_index++; - (*codec_conf)++; } - j = 0; - - /* check next link to create codec dai in the processed group */ - i++; } - /* find codec info to create BE DAI */ - codec_info = asoc_sdw_find_codec_info_part(adr_link->adr_d[adr_index].adr); - if (!codec_info) - return -EINVAL; - - ctx->ignore_internal_dmic |= codec_info->ignore_internal_dmic; - - sdw_link_id = (adr_link->adr_d[adr_index].adr) >> 48; for_each_pcm_streams(stream) { - char *name, *cpu_name; - int playback, capture; static const char * const sdw_stream_name[] = { "SDW%d-PIN%d-PLAYBACK", "SDW%d-PIN%d-CAPTURE", "SDW%d-PIN%d-PLAYBACK-%s", "SDW%d-PIN%d-CAPTURE-%s", }; + struct snd_soc_dai_link_ch_map *codec_maps; + struct snd_soc_dai_link_component *codecs; + struct snd_soc_dai_link_component *cpus; + int num_cpus = hweight32(sof_dai->link_mask[stream]); + int num_codecs = sof_dai->num_devs[stream]; + int playback, capture; + int i = 0, j = 0; + char *name; - if (!codec_info->dais[dai_index].direction[stream]) + if (!sof_dai->num_devs[stream]) continue; - *be_id = codec_info->dais[dai_index].dailink[stream]; + sof_end = list_first_entry(&sof_dai->endpoints, + struct asoc_sdw_endpoint, list); + + *be_id = sof_end->dai_info->dailink[stream]; if (*be_id < 0) { dev_err(dev, "Invalid dailink id %d\n", *be_id); return -EINVAL; } + switch (amd_ctx->acp_rev) { case ACP63_PCI_REV: - ret = get_acp63_cpu_pin_id(sdw_link_id, *be_id, &cpu_pin_id, dev); + ret = get_acp63_cpu_pin_id(ffs(sof_end->link_mask - 1), + *be_id, &cpu_pin_id, dev); if (ret) return ret; break; @@ -425,55 +182,105 @@ static int create_sdw_dailink(struct snd_soc_card *card, /* create stream name according to first link id */ if (ctx->append_dai_type) { name = devm_kasprintf(dev, GFP_KERNEL, - sdw_stream_name[stream + 2], sdw_link_id, cpu_pin_id, - type_strings[codec_info->dais[dai_index].dai_type]); + sdw_stream_name[stream + 2], + ffs(sof_end->link_mask) - 1, + cpu_pin_id, + type_strings[sof_end->dai_info->dai_type]); } else { name = devm_kasprintf(dev, GFP_KERNEL, - sdw_stream_name[stream], sdw_link_id, cpu_pin_id); + sdw_stream_name[stream], + ffs(sof_end->link_mask) - 1, + cpu_pin_id); } if (!name) return -ENOMEM; - cpus = devm_kcalloc(dev, cpu_dai_num, sizeof(*cpus), GFP_KERNEL); + cpus = devm_kcalloc(dev, num_cpus, sizeof(*cpus), GFP_KERNEL); if (!cpus) return -ENOMEM; - /* - * generate CPU DAI name base on the sdw link ID and - * cpu pin id according to sdw dai driver. - */ - for (k = 0; k < cpu_dai_num; k++) { - cpu_name = devm_kasprintf(dev, GFP_KERNEL, - "SDW%d Pin%d", sdw_link_id, cpu_pin_id); - if (!cpu_name) + + codecs = devm_kcalloc(dev, num_codecs, sizeof(*codecs), GFP_KERNEL); + if (!codecs) + return -ENOMEM; + + codec_maps = devm_kcalloc(dev, num_codecs, sizeof(*codec_maps), GFP_KERNEL); + if (!codec_maps) + return -ENOMEM; + + list_for_each_entry(sof_end, &sof_dai->endpoints, list) { + if (!sof_end->dai_info->direction[stream]) + continue; + + int link_num = ffs(sof_end->link_mask) - 1; + + cpus[i].dai_name = devm_kasprintf(dev, GFP_KERNEL, + "SDW%d Pin%d", + link_num, cpu_pin_id); + dev_dbg(dev, "cpu[%d].dai_name:%s\n", i, cpus[i].dai_name); + if (!cpus[i].dai_name) return -ENOMEM; - cpus[k].dai_name = cpu_name; + codec_maps[j].cpu = i; + codec_maps[j].codec = j; + + codecs[j].name = sof_end->codec_name; + codecs[j].dai_name = sof_end->dai_info->dai_name; + j++; } + WARN_ON(j != num_codecs); + playback = (stream == SNDRV_PCM_STREAM_PLAYBACK); capture = (stream == SNDRV_PCM_STREAM_CAPTURE); - asoc_sdw_init_dai_link(dev, *dai_links, be_id, name, - playback, capture, - cpus, cpu_dai_num, - platform_component, ARRAY_SIZE(platform_component), - codecs, codec_num, + + asoc_sdw_init_dai_link(dev, *dai_links, be_id, name, playback, capture, + cpus, num_cpus, platform_component, + ARRAY_SIZE(platform_component), codecs, num_codecs, asoc_sdw_rtd_init, &sdw_ops); + /* * SoundWire DAILINKs use 'stream' functions and Bank Switch operations * based on wait_for_completion(), tag them as 'nonatomic'. */ (*dai_links)->nonatomic = true; - (*dai_links)->ch_maps = sdw_codec_ch_maps; + (*dai_links)->ch_maps = codec_maps; - ret = set_codec_init_func(card, adr_link, *dai_links, - playback, group_id, adr_index, dai_index); - if (ret < 0) { - dev_err(dev, "failed to init codec 0x%x\n", codec_info->part_id); - return ret; + list_for_each_entry(sof_end, &sof_dai->endpoints, list) { + if (sof_end->dai_info->init) + sof_end->dai_info->init(card, *dai_links, + sof_end->codec_info, + playback); } (*dai_links)++; } + + return 0; +} + +static int create_sdw_dailinks(struct snd_soc_card *card, + struct snd_soc_dai_link **dai_links, int *be_id, + struct asoc_sdw_dailink *sof_dais, + struct snd_soc_codec_conf **codec_conf) +{ + int ret; + + /* generate DAI links by each sdw link */ + while (sof_dais->initialised) { + int current_be_id; + + ret = create_sdw_dailink(card, sof_dais, dai_links, + ¤t_be_id, codec_conf); + if (ret) + return ret; + + /* Update the be_id to match the highest ID used for SDW link */ + if (*be_id < current_be_id) + *be_id = current_be_id; + + sof_dais++; + } + return 0; } @@ -504,132 +311,93 @@ static int sof_card_dai_links_create(struct snd_soc_card *card) int sdw_be_num = 0, dmic_num = 0; struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card); struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params; - const struct snd_soc_acpi_link_adr *adr_link = mach_params->links; struct snd_soc_codec_conf *codec_conf; - int codec_conf_num = 0; - bool group_generated[AMD_SDW_MAX_GROUPS] = { }; + struct asoc_sdw_endpoint *sof_ends; + struct asoc_sdw_dailink *sof_dais; struct snd_soc_dai_link *dai_links; - struct asoc_sdw_codec_info *codec_info; + int num_devs = 0; + int num_ends = 0; int num_links; - int i, j, be_id = 0; + int be_id = 0; int ret; - ret = get_dailink_info(dev, adr_link, &sdw_be_num, &codec_conf_num); + ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends); if (ret < 0) { - dev_err(dev, "failed to get sdw link info %d\n", ret); + dev_err(dev, "failed to count devices/endpoints: %d\n", ret); return ret; } + /* One per DAI link, worst case is a DAI link for every endpoint */ + sof_dais = kcalloc(num_ends, sizeof(*sof_dais), GFP_KERNEL); + if (!sof_dais) + return -ENOMEM; + + /* One per endpoint, ie. each DAI on each codec/amp */ + sof_ends = kcalloc(num_ends, sizeof(*sof_ends), GFP_KERNEL); + if (!sof_ends) { + ret = -ENOMEM; + goto err_dai; + } + + ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs); + if (ret < 0) + goto err_end; + + sdw_be_num = ret; + /* enable dmic */ if (sof_sdw_quirk & ASOC_SDW_ACP_DMIC || mach_params->dmic_num) dmic_num = 1; dev_dbg(dev, "sdw %d, dmic %d", sdw_be_num, dmic_num); + codec_conf = devm_kcalloc(dev, num_devs, sizeof(*codec_conf), GFP_KERNEL); + if (!codec_conf) { + ret = -ENOMEM; + goto err_end; + } + /* allocate BE dailinks */ num_links = sdw_be_num + dmic_num; dai_links = devm_kcalloc(dev, num_links, sizeof(*dai_links), GFP_KERNEL); - if (!dai_links) - return -ENOMEM; - - /* allocate codec conf, will be populated when dailinks are created */ - codec_conf = devm_kcalloc(dev, codec_conf_num, sizeof(*codec_conf), - GFP_KERNEL); - if (!codec_conf) - return -ENOMEM; + if (!dai_links) { + ret = -ENOMEM; + goto err_end; + } + card->codec_conf = codec_conf; + card->num_configs = num_devs; card->dai_link = dai_links; card->num_links = num_links; - card->codec_conf = codec_conf; - card->num_configs = codec_conf_num; /* SDW */ - if (!sdw_be_num) - goto DMIC; - - for (; adr_link->num_adr; adr_link++) { - /* - * If there are two or more different devices on the same sdw link, we have to - * append the codec type to the dai link name to prevent duplicated dai link name. - * The same type devices on the same sdw link will be in the same - * snd_soc_acpi_adr_device array. They won't be described in different adr_links. - */ - for (i = 0; i < adr_link->num_adr; i++) { - /* find codec info to get dai_num */ - codec_info = asoc_sdw_find_codec_info_part(adr_link->adr_d[i].adr); - if (!codec_info) - return -EINVAL; - if (codec_info->dai_num > 1) { - ctx->append_dai_type = true; - goto out; - } - for (j = 0; j < i; j++) { - if ((SDW_PART_ID(adr_link->adr_d[i].adr) != - SDW_PART_ID(adr_link->adr_d[j].adr)) || - (SDW_MFG_ID(adr_link->adr_d[i].adr) != - SDW_MFG_ID(adr_link->adr_d[j].adr))) { - ctx->append_dai_type = true; - goto out; - } - } - } - } -out: - - /* generate DAI links by each sdw link */ - for (adr_link = mach_params->links ; adr_link->num_adr; adr_link++) { - for (i = 0; i < adr_link->num_adr; i++) { - const struct snd_soc_acpi_endpoint *endpoint; - - endpoint = adr_link->adr_d[i].endpoints; - - /* this group has been generated */ - if (endpoint->aggregated && - group_generated[endpoint->group_id]) - continue; - - /* find codec info to get dai_num */ - codec_info = asoc_sdw_find_codec_info_part(adr_link->adr_d[i].adr); - if (!codec_info) - return -EINVAL; - - for (j = 0; j < codec_info->dai_num ; j++) { - int current_be_id; - - ret = create_sdw_dailink(card, &dai_links, adr_link, - &codec_conf, ¤t_be_id, - i, j); - if (ret < 0) { - dev_err(dev, - "failed to create dai link %d on 0x%x\n", - j, codec_info->part_id); - return ret; - } - /* Update the be_id to match the highest ID used for SDW link */ - if (be_id < current_be_id) - be_id = current_be_id; - } - - if (endpoint->aggregated) - group_generated[endpoint->group_id] = true; - } + if (sdw_be_num) { + ret = create_sdw_dailinks(card, &dai_links, &be_id, + sof_dais, &codec_conf); + if (ret) + goto err_end; } -DMIC: /* dmic */ if (dmic_num > 0) { if (ctx->ignore_internal_dmic) { dev_warn(dev, "Ignoring ACP DMIC\n"); } else { - be_id = SOC_SDW_DMIC_DAI_ID; ret = create_dmic_dailinks(card, &dai_links, &be_id); if (ret) - return ret; + goto err_end; } } + WARN_ON(codec_conf != card->codec_conf + card->num_configs); WARN_ON(dai_links != card->dai_link + card->num_links); - return 0; + +err_end: + kfree(sof_ends); +err_dai: + kfree(sof_dais); + + return ret; } /* SoC card */