From patchwork Wed Oct 11 12:16:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 13417294 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2995DCD6E61 for ; Wed, 11 Oct 2023 12:21:29 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 87947167F; Wed, 11 Oct 2023 14:20:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 87947167F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1697026887; bh=ahNt5IlFJob3SAq8b6d0eCyh9kkGDFCWrzmGzgYcIbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Xn0gr8tw8Dn/OfFKRt+RFntU4ORbvXaDjMQWfcTs1RPnw1wf5hAt+txPZ4zngHoqe qiVNB3Kgm0fhYyITOWNfwi7T1ad8whaBBrYHy5NPIBjlH5MbtZEDy++cbcMapnQ6ag ze0pDJzrwdEmINJad8Qxyggr81w+3X2RHxRVzseY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8F17AF80557; Wed, 11 Oct 2023 14:17:54 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 11E35F805F2; Wed, 11 Oct 2023 14:17:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F2579F805CB; Wed, 11 Oct 2023 14:17:43 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4EB97F8057C for ; Wed, 11 Oct 2023 14:17:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4EB97F8057C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=cx+IOeg0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697026658; x=1728562658; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ahNt5IlFJob3SAq8b6d0eCyh9kkGDFCWrzmGzgYcIbY=; b=cx+IOeg0hoU9ZYOGY3jQJcGKOsAclGHbItVCIvjYRc1X58kBGib7H9G8 FhEWUlb/0xRkikI6DeyM4+m1O4ZLaD2iqhgmkvR9u7eN7HD5DNd9tOLo9 PXoN5jCeLkhZo2bLuEtFR07go5DY7SpAZZR0dQ8xihznYPqNmAvN8TFSM aI8YpwwwMft4jxhDC5xxc/4CMCrb4h4PLJ83129Q3PSV3vjWbdXe5ksTL L2aUdEhSMuyakutGD6qg92OucZ7C6cGGGentXOjyv7crASkXcAA9kjEZS 1u5gbBeEY9CmMrJSDttUAc58GpATq1pACNqZPUhO7tqhM1tF0XfVPy6FM Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="374988566" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="374988566" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 05:17:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="747428428" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="747428428" Received: from dev2 (HELO DEV2.igk.intel.com) ([10.237.148.94]) by orsmga007.jf.intel.com with ESMTP; 11 Oct 2023 05:17:17 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Mark Brown Cc: Cezary Rojewski , Takashi Iwai , Jaroslav Kysela , alsa-devel@alsa-project.org, =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= Subject: [PATCH 11/16] ASoC: Intel: avs: max98373: Validate machine board configuration Date: Wed, 11 Oct 2023 14:16:58 +0200 Message-Id: <20231011121703.363652-12-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011121703.363652-1-amadeuszx.slawinski@linux.intel.com> References: <20231011121703.363652-1-amadeuszx.slawinski@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 7DUN6WYAHSLJBASV54RXDBFBDKWA6DBX X-Message-ID-Hash: 7DUN6WYAHSLJBASV54RXDBFBDKWA6DBX X-MailFrom: amadeuszx.slawinski@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Allow for board to be used with TDMs. Reviewed-by: Cezary Rojewski Signed-off-by: Amadeusz Sławiński --- sound/soc/intel/avs/boards/max98373.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/avs/boards/max98373.c b/sound/soc/intel/avs/boards/max98373.c index 7820435e3a53..cc7dfdf72083 100644 --- a/sound/soc/intel/avs/boards/max98373.c +++ b/sound/soc/intel/avs/boards/max98373.c @@ -12,6 +12,7 @@ #include #include #include +#include "../utils.h" #define MAX98373_DEV0_NAME "i2c-MX98373:00" #define MAX98373_DEV1_NAME "i2c-MX98373:01" @@ -95,7 +96,7 @@ static const struct snd_soc_ops avs_max98373_ops = { }; static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port, - struct snd_soc_dai_link **dai_link) + int tdm_slot, struct snd_soc_dai_link **dai_link) { struct snd_soc_dai_link_component *platform; struct snd_soc_dai_link *dl; @@ -107,13 +108,15 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in platform->name = platform_name; - dl->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_port); + dl->name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs) * 2, GFP_KERNEL); if (!dl->name || !dl->cpus || !dl->codecs) return -ENOMEM; - dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); + dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, + AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot)); dl->codecs[0].name = devm_kasprintf(dev, GFP_KERNEL, MAX98373_DEV0_NAME); dl->codecs[0].dai_name = devm_kasprintf(dev, GFP_KERNEL, MAX98373_CODEC_NAME); dl->codecs[1].name = devm_kasprintf(dev, GFP_KERNEL, MAX98373_DEV1_NAME); @@ -148,13 +151,16 @@ static int avs_max98373_probe(struct platform_device *pdev) struct snd_soc_card *card; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret; mach = dev_get_platdata(dev); pname = mach->mach_params.platform; - ssp_port = __ffs(mach->mach_params.i2s_link_mask); - ret = avs_create_dai_link(dev, pname, ssp_port, &dai_link); + ret = avs_mach_get_ssp_tdm(dev, mach, &ssp_port, &tdm_slot); + if (ret) + return ret; + + ret = avs_create_dai_link(dev, pname, ssp_port, tdm_slot, &dai_link); if (ret) { dev_err(dev, "Failed to create dai link: %d", ret); return ret;