From patchwork Thu Oct 12 08:35:04 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: 732495 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 7897CCDB46E for ; Thu, 12 Oct 2023 08:44:04 +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 96A00E84; Thu, 12 Oct 2023 10:43:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 96A00E84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1697100242; bh=ABhfhXaTshg1nrN8Qq/s0E784tRgHAmyMuAgdWrlgDU=; 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=ediL57MjDEewzugzte48a/ThzgkVIwwbzv7uTr9qHfKicUjPEd/TNollXll3yVyq8 tTwX7c/K2x3E9ZEvR988Ca/IJ3x+RV1S2cyEd275xC7smZvZ48erAOXDgqYk6ztm4W WoBYNLcjyChuEJa/WdDc0azeSRfviXKKsVht54wU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id BF362F80620; Thu, 12 Oct 2023 10:39:13 +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 7C100F8061B; Thu, 12 Oct 2023 10:39:13 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D09EDF805F7; Thu, 12 Oct 2023 10:39:06 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 98372F80552 for ; Thu, 12 Oct 2023 10:35:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 98372F80552 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=QKMOg4mU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697099721; x=1728635721; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ABhfhXaTshg1nrN8Qq/s0E784tRgHAmyMuAgdWrlgDU=; b=QKMOg4mUk9aDKr5TyIjOHGUcu5YHIGIGGiH0Jl0eHXhurUgXfev6hLeq AcoX1RCdrYNNaF1tRKQDe7kDjy+++kzRqNKIubHPnXKeIbA4pDCHMK3RD dtqUDbcb930mKJkHqL/yS5eua+YSDwbqnqXk/q3lRBpojEQnMsWpq7m+a zXOQdGAi1ad0nzXpLQ/F0/6uxukXypguw00fOvO5hG0gldawZgTJO8gmH TG5mPI1P7+8IhIutDygBU/nOwT9MnXgqnGEeoSWX5jy3QECU5e/REbzWp fg62MqyGUXg2hYtc4GK46631Ey8KSfFiQfSOJ4eHoNfG0D+faa4lOPmYX w==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="6417264" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="6417264" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2023 01:35:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="824516616" X-IronPort-AV: E=Sophos;i="6.03,218,1694761200"; d="scan'208";a="824516616" Received: from dev2 (HELO DEV2.igk.intel.com) ([10.237.148.94]) by fmsmga004.fm.intel.com with ESMTP; 12 Oct 2023 01:35: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 v2 06/16] ASoC: Intel: avs: rt5682: Validate machine board configuration Date: Thu, 12 Oct 2023 10:35:04 +0200 Message-Id: <20231012083514.492626-7-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012083514.492626-1-amadeuszx.slawinski@linux.intel.com> References: <20231012083514.492626-1-amadeuszx.slawinski@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 4EDFPDIA4YZNCGOCDECBFD7GJMRCDBPY X-Message-ID-Hash: 4EDFPDIA4YZNCGOCDECBFD7GJMRCDBPY 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. Signed-off-by: Amadeusz Sławiński --- sound/soc/intel/avs/boards/rt5682.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/avs/boards/rt5682.c b/sound/soc/intel/avs/boards/rt5682.c index f1c46c6abd9d..84e850c0b085 100644 --- a/sound/soc/intel/avs/boards/rt5682.c +++ b/sound/soc/intel/avs/boards/rt5682.c @@ -21,6 +21,7 @@ #include #include "../../common/soc-intel-quirks.h" #include "../../../codecs/rt5682.h" +#include "../utils.h" #define AVS_RT5682_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0)) #define AVS_RT5682_SSP_CODEC_MASK (GENMASK(2, 0)) @@ -203,7 +204,7 @@ avs_rt5682_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pcm_hw_param } 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; @@ -215,13 +216,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), 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->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-10EC5682:00"); dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, AVS_RT5682_CODEC_DAI_NAME); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) @@ -270,7 +273,7 @@ static int avs_rt5682_probe(struct platform_device *pdev) struct snd_soc_jack *jack; struct device *dev = &pdev->dev; const char *pname; - int ssp_port, ret; + int ssp_port, tdm_slot, ret; if (pdev->id_entry && pdev->id_entry->driver_data) avs_rt5682_quirk = (unsigned long)pdev->id_entry->driver_data; @@ -280,9 +283,12 @@ static int avs_rt5682_probe(struct platform_device *pdev) 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;