From patchwork Thu Oct 19 17:34:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 735651 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 DF207CDB465 for ; Thu, 19 Oct 2023 17:36:31 +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 0AD6FAE8; Thu, 19 Oct 2023 19:35:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0AD6FAE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1697736990; bh=ci4ulWbiczJaL32FjYNIPNE48dvTPf7Qx2ed5oot2TM=; 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=meCs03sU9o6hwy5/C9jkVXEcjPrUQeRZf8DH4SEoJqvtljekYntriJEFr/Ztp8j/4 0CsitMxL0FnXaCtykYgHFZvDyzcC0htSVXo1EM4+FXW2FvNOZdIYTjDPyMshqWn3hN hI2xilF0s2Uh/Rdvt3BkFvaLDoza3UQKVhuWrzLM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 66880F80589; Thu, 19 Oct 2023 19:34:44 +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 9F6AEF8055B; Thu, 19 Oct 2023 19:34:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 26936F8055A; Thu, 19 Oct 2023 19:34:39 +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 F1FC6F8027B for ; Thu, 19 Oct 2023 19:34:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F1FC6F8027B 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=YqfuULpe DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697736872; x=1729272872; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ci4ulWbiczJaL32FjYNIPNE48dvTPf7Qx2ed5oot2TM=; b=YqfuULpeGpirItYZ6JiuAL433vqf6H8AQrfTk4NtdqMwEPw+lUO4pMKa Z0fo3Xw0CR2utuEPJacnUneVRM/3EnLVRM1nOD5qapjReZ8Ht0YOf2eTd b71oEPBQQBF6wniQfHryjXk5w3XDtjSvfuSgEq/8yO1/r23XdWiHuZmKE OvxzHN8SU7ZvUlDK0SPRi9VjNin4KwMxaYA1DCfcEzkGlHamMut3e2dLX qr0t/4g57UYSG57qSVU4d0Z+d2/ib+q/j/qHzbUNemCO3Ro/2LXp9ciKI 5dOVpRfc+aO4mlEHxgBED+2zkRS76MA2M27SWjqiCfgaUOeirfr81Q/sz w==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="7884326" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="7884326" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:34:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="792090634" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="792090634" Received: from jihao1-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.213.163.144]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:34:24 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, Charles Keepax , Bard Liao , Pierre-Louis Bossart Subject: [PATCH 03/10] ASoC: intel: sof_sdw_cs42l43: Create separate jacks for hp and mic Date: Thu, 19 Oct 2023 12:34:04 -0500 Message-Id: <20231019173411.166759-4-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019173411.166759-1-pierre-louis.bossart@linux.intel.com> References: <20231019173411.166759-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 7NTJ3CKCTWNWAAMRBE73NT45XTNAUEM4 X-Message-ID-Hash: 7NTJ3CKCTWNWAAMRBE73NT45XTNAUEM4 X-MailFrom: pierre-louis.bossart@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: From: Charles Keepax It makes sense to report the microphone separately from the headphones, that way ALSA UCM can differentiate between switching the playback and the capture. For example, still using the built-in microphone path when a 3-pole headset is inserted. Reviewed-by: Bard Liao Signed-off-by: Charles Keepax Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/sof_sdw_cs42l43.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw_cs42l43.c b/sound/soc/intel/boards/sof_sdw_cs42l43.c index 9b072c745f10..360f11b72aa2 100644 --- a/sound/soc/intel/boards/sof_sdw_cs42l43.c +++ b/sound/soc/intel/boards/sof_sdw_cs42l43.c @@ -39,6 +39,17 @@ static const struct snd_soc_dapm_route cs42l43_dmic_map[] = { { "cs42l43 PDM2_DIN", NULL, "DMIC" }, }; +static struct snd_soc_jack_pin sof_jack_pins[] = { + { + .pin = "Headphone", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, +}; + static int cs42l43_hs_rtd_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component; @@ -66,12 +77,13 @@ static int cs42l43_hs_rtd_init(struct snd_soc_pcm_runtime *rtd) return ret; } - ret = snd_soc_card_jack_new(card, "Headphone Jack", - SND_JACK_MECHANICAL | SND_JACK_AVOUT | - SND_JACK_HEADSET | SND_JACK_LINEOUT | - SND_JACK_BTN_0 | SND_JACK_BTN_1 | - SND_JACK_BTN_2 | SND_JACK_BTN_3, - jack); + ret = snd_soc_card_jack_new_pins(card, "Jack", + SND_JACK_MECHANICAL | SND_JACK_AVOUT | + SND_JACK_HEADSET | SND_JACK_LINEOUT | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3, + jack, sof_jack_pins, + ARRAY_SIZE(sof_jack_pins)); if (ret) { dev_err(card->dev, "Failed to create jack: %d\n", ret); return ret; From patchwork Thu Oct 19 17:34:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 735650 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 0772ECDB465 for ; Thu, 19 Oct 2023 17:37: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 D022D852; Thu, 19 Oct 2023 19:36:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D022D852 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1697737021; bh=RdD+F+x24vXfLV6mR5hwiNCO9FTu9ZbSLJaLVxMYXBI=; 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=vdCGxJ1rlGjQxgwQ13beeGcqA3L66EfjnIyz9KZqT/wStWF7tHfGvyIVizKSzrZZa +HQL7R9PcV0V37VBhX8VXMLOG9bRPW/rhQkOv96ZXY153pgHBmaGruerNh4cgUos6j 6jGp/j9dtbZp46EVfDCo6986lPMFm8+rGSMhuu18= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7483AF805B0; Thu, 19 Oct 2023 19:34:51 +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 E154EF80536; Thu, 19 Oct 2023 19:34:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9A2FAF8057D; Thu, 19 Oct 2023 19:34:42 +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 B2AA5F8032D for ; Thu, 19 Oct 2023 19:34:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B2AA5F8032D 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=ecAjkfeS DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697736873; x=1729272873; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RdD+F+x24vXfLV6mR5hwiNCO9FTu9ZbSLJaLVxMYXBI=; b=ecAjkfeSf3j8mNhRDcSeGPWjB+/dIny6f1+lNuhkL+EVHQ5NKD4ZwfFB zgrsxvmm//Z28wKJ724dOzz8o95D3dnD1n4PiqeVqPmlO7awmmxnOOEPX vObUsuju9f8SdtxgtgdR+9kzjqJnfQfV51Qxp4OKzov902wxDPT0+99Ny DvpXyAaqm2hH5qucrDKArgt9jyQzOpCNtsWG0QnbnhoLuNiCEqVDHofGJ rpDs4HTDyxyBaQ03pI8YLpz+9CkFSKr8OOKUOEnzi6g9QKG8oT51xfrYk YaC+VnGtUDzascpJ8Eysop/HQqMzMOPacq+yN9FyAG/+4kgFIUPgOYPnB w==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="7884336" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="7884336" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:34:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="792090646" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="792090646" Received: from jihao1-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.213.163.144]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:34:25 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, Charles Keepax , Bard Liao , Pierre-Louis Bossart Subject: [PATCH 04/10] ASoC: intel: sof_sdw: Move the builtin microphones to dataport 1 Date: Thu, 19 Oct 2023 12:34:05 -0500 Message-Id: <20231019173411.166759-5-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019173411.166759-1-pierre-louis.bossart@linux.intel.com> References: <20231019173411.166759-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: VJKLME332VR6ZGTXP7NZCHIXC44Q3NRA X-Message-ID-Hash: VJKLME332VR6ZGTXP7NZCHIXC44Q3NRA X-MailFrom: pierre-louis.bossart@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: From: Charles Keepax cs42l43 supports 4 hardwired microphones, but only supports up to 2 microphone headsets. Only dataport 1 can support 4 channel capture, but that is currently used for the headset microphone. Switch things around such that DP1 is used for the builtin mics and DP2 is used for the headset microphones. Reviewed-by: Bard Liao Signed-off-by: Charles Keepax Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/sof_sdw.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index ad1d01ebbcd9..3312ad8a563b 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -939,16 +939,16 @@ static struct sof_sdw_codec_info codec_info_list[] = { { .direction = {false, true}, .dai_name = "cs42l43-dp1", - .dai_type = SOF_SDW_DAI_TYPE_JACK, - .dailink = {SDW_UNUSED_DAI_ID, SDW_JACK_IN_DAI_ID}, - }, - { - .direction = {false, true}, - .dai_name = "cs42l43-dp2", .dai_type = SOF_SDW_DAI_TYPE_MIC, .dailink = {SDW_UNUSED_DAI_ID, SDW_DMIC_DAI_ID}, .init = sof_sdw_cs42l43_dmic_init, - } + }, + { + .direction = {false, true}, + .dai_name = "cs42l43-dp2", + .dai_type = SOF_SDW_DAI_TYPE_JACK, + .dailink = {SDW_UNUSED_DAI_ID, SDW_JACK_IN_DAI_ID}, + }, }, .dai_num = 3, }, From patchwork Thu Oct 19 17:34:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 735649 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 C01D0CDB465 for ; Thu, 19 Oct 2023 17:37:36 +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 02465A4D; Thu, 19 Oct 2023 19:36:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 02465A4D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1697737055; bh=1yf54dellcqsfaGDqZHU10FeruGNInLonMi8h0y1HMc=; 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=imAsGw8SndVFdyFz5TBGNogG9QmMnRKkACzpNbyyVssSUEbTHEB3M+aU7zciPAqiB WEeUkntwr0ORr644QVOsfBgTNwcBCNDc1sVmM4PgvRE/Wg+5GVsDge/5sMBELeuQt0 l6QQsLplCCYGGtSwqMpOgtSBPsZceFp8Jir2vdQQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6B227F805C6; Thu, 19 Oct 2023 19:34:56 +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 EA227F805C2; Thu, 19 Oct 2023 19:34:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1E0EDF805A9; Thu, 19 Oct 2023 19:34:48 +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 13B8BF80536 for ; Thu, 19 Oct 2023 19:34:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 13B8BF80536 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=JA/BgPZn DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697736875; x=1729272875; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1yf54dellcqsfaGDqZHU10FeruGNInLonMi8h0y1HMc=; b=JA/BgPZnO9gMnkzmVW1CVb9ucyTj7aOfCA7Y8MOhsodMnbla8ODPAQLV g9s/BeVni6sPQhzpi1voLOIaBOPDHCSA5lvGzBJS25AQYNThIL/xNym3w qeZ9oN5Inz06WzflV6SCEUP3UP0JyiVt5rxVkm+CKGpjWisix0Q6vltDr uPNE2QJMNo+paa5bYbohQaMUIEAcRT+e7D7/H/npZxYIMM33p+aSKbNN1 8KVICBdmCkV7DGS2YC38w0BybTatkmZFCAWEUi7i3XpEo1Q2OhcnsUkk6 n/8itKnoL5fddIq4AhmhopEAZ3ZjF4pEYrgwrW6R9WKj52tgTUOpoy/uQ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="7884349" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="7884349" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:34:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="792090676" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="792090676" Received: from jihao1-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.213.163.144]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:34:26 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, Brent Lu , Bard Liao , Pierre-Louis Bossart Subject: [PATCH 06/10] ASoC: Intel: board_helpers: support dmic link initialization Date: Thu, 19 Oct 2023 12:34:07 -0500 Message-Id: <20231019173411.166759-7-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019173411.166759-1-pierre-louis.bossart@linux.intel.com> References: <20231019173411.166759-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 4SFSZX6TXZ3DMTVBPBZRBCFFVZ2VVNQR X-Message-ID-Hash: 4SFSZX6TXZ3DMTVBPBZRBCFFVZ2VVNQR X-MailFrom: pierre-louis.bossart@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: From: Brent Lu Add functions for machine drivers to initialize dmic01 and dmic16k DAI links. Reviewed-by: Bard Liao Signed-off-by: Brent Lu Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/sof_board_helpers.c | 92 ++++++++++++++++++++++ sound/soc/intel/boards/sof_board_helpers.h | 10 +++ 2 files changed, 102 insertions(+) diff --git a/sound/soc/intel/boards/sof_board_helpers.c b/sound/soc/intel/boards/sof_board_helpers.c index 627742ce84bd..ce2967850c2d 100644 --- a/sound/soc/intel/boards/sof_board_helpers.c +++ b/sound/soc/intel/boards/sof_board_helpers.c @@ -36,9 +36,49 @@ int sof_intel_board_card_late_probe(struct snd_soc_card *card) } EXPORT_SYMBOL_NS(sof_intel_board_card_late_probe, SND_SOC_INTEL_SOF_BOARD_HELPERS); +/* + * DMIC DAI Link + */ +static const struct snd_soc_dapm_widget dmic_widgets[] = { + SND_SOC_DAPM_MIC("SoC DMIC", NULL), +}; + +static const struct snd_soc_dapm_route dmic_routes[] = { + {"DMic", NULL, "SoC DMIC"}, +}; + +static int dmic_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_card *card = rtd->card; + int ret; + + ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets, + ARRAY_SIZE(dmic_widgets)); + if (ret) { + dev_err(rtd->dev, "fail to add dmic widgets, ret %d\n", ret); + return ret; + } + + ret = snd_soc_dapm_add_routes(&card->dapm, dmic_routes, + ARRAY_SIZE(dmic_routes)); + if (ret) { + dev_err(rtd->dev, "fail to add dmic routes, ret %d\n", ret); + return ret; + } + + return 0; +} + /* * DAI Link Helpers */ +static struct snd_soc_dai_link_component dmic_component[] = { + { + .name = "dmic-codec", + .dai_name = "dmic-hifi", + } +}; + static struct snd_soc_dai_link_component platform_component[] = { { /* name might be overridden during probe */ @@ -46,6 +86,58 @@ static struct snd_soc_dai_link_component platform_component[] = { } }; +int sof_intel_board_set_dmic_link(struct device *dev, + struct snd_soc_dai_link *link, int be_id, + enum sof_dmic_be_type be_type) +{ + struct snd_soc_dai_link_component *cpus; + + /* cpus */ + cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component), + GFP_KERNEL); + if (!cpus) + return -ENOMEM; + + switch (be_type) { + case SOF_DMIC_01: + dev_dbg(dev, "link %d: dmic01\n", be_id); + + link->name = "dmic01"; + cpus->dai_name = "DMIC01 Pin"; + break; + case SOF_DMIC_16K: + dev_dbg(dev, "link %d: dmic16k\n", be_id); + + link->name = "dmic16k"; + cpus->dai_name = "DMIC16k Pin"; + break; + default: + dev_err(dev, "invalid be type %d\n", be_type); + return -EINVAL; + } + + link->cpus = cpus; + link->num_cpus = 1; + + /* codecs */ + link->codecs = dmic_component; + link->num_codecs = ARRAY_SIZE(dmic_component); + + /* platforms */ + link->platforms = platform_component; + link->num_platforms = ARRAY_SIZE(platform_component); + + link->id = be_id; + if (be_type == SOF_DMIC_01) + link->init = dmic_init; + link->ignore_suspend = 1; + link->no_pcm = 1; + link->dpcm_capture = 1; + + return 0; +} +EXPORT_SYMBOL_NS(sof_intel_board_set_dmic_link, SND_SOC_INTEL_SOF_BOARD_HELPERS); + int sof_intel_board_set_intel_hdmi_link(struct device *dev, struct snd_soc_dai_link *link, int be_id, int hdmi_id, bool idisp_codec) diff --git a/sound/soc/intel/boards/sof_board_helpers.h b/sound/soc/intel/boards/sof_board_helpers.h index 7a15ddaa3a2c..df99f576c1d8 100644 --- a/sound/soc/intel/boards/sof_board_helpers.h +++ b/sound/soc/intel/boards/sof_board_helpers.h @@ -28,6 +28,7 @@ struct sof_rt5682_private { * @hdmi: init data for hdmi dai link * @codec_type: type of headset codec * @amp_type: type of speaker amplifier + * @dmic_be_num: number of Intel PCH DMIC BE link * @hdmi_num: number of Intel HDMI BE link * @rt5682: private data for rt5682 machine driver */ @@ -38,6 +39,7 @@ struct sof_card_private { enum sof_ssp_codec codec_type; enum sof_ssp_codec amp_type; + int dmic_be_num; int hdmi_num; union { @@ -45,8 +47,16 @@ struct sof_card_private { }; }; +enum sof_dmic_be_type { + SOF_DMIC_01, + SOF_DMIC_16K, +}; + int sof_intel_board_card_late_probe(struct snd_soc_card *card); +int sof_intel_board_set_dmic_link(struct device *dev, + struct snd_soc_dai_link *link, int be_id, + enum sof_dmic_be_type be_type); int sof_intel_board_set_intel_hdmi_link(struct device *dev, struct snd_soc_dai_link *link, int be_id, int hdmi_id, bool idisp_codec); From patchwork Thu Oct 19 17:34:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 735648 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 69072CDB483 for ; Thu, 19 Oct 2023 17:38:05 +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 8C7E0DEB; Thu, 19 Oct 2023 19:37:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8C7E0DEB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1697737083; bh=JmyZr48xxaLo0YGzXMrRWp/iCPGdwmbM+DUGgC6M7xA=; 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=nXzJDCKRrguOlkuwp3+wlQftfRhtXhxIMkjuE8G76O0C4StNEdAqv330ugukkDT3R TpQ0M7wPZZM9MCPmzP756aAKAXxrrDHxFhCaM8xDY8iayUXci3lzzWEzz9vGDW9UNQ gk26KYH41qoBxZ4Fws0Ft1CWHCDhbOKympwclq8g= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 65D1EF8032D; Thu, 19 Oct 2023 19:37:11 +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 C5DADF8032D; Thu, 19 Oct 2023 19:37:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 312FDF8027B; Thu, 19 Oct 2023 19:37:08 +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 3A479F80552 for ; Thu, 19 Oct 2023 19:34:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3A479F80552 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=jhG79i8D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697736875; x=1729272875; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JmyZr48xxaLo0YGzXMrRWp/iCPGdwmbM+DUGgC6M7xA=; b=jhG79i8DaMZ3ca0ppHvDnCzvC4vnBFwCOLkISud4+wYd1AHufe/ns13S CFQarrgEDLaLVLRi+J9WfCo2UHXwfXZDQOONiL6kiXE30jSH9iHzfl0Ak lXpjk5xC8jQt/+RO/tJXAD5N8kf4m7EpW4EF+rFJEgPtPsfUinZs1kdKx oW5XFSoUSQLEiOSnMmrRxoojMCldhqXyrtpoYB8B3z46oLgfBcTpg/Clq ID1ZUmVH1+6G7CPbRS+Cd5PNhIzG5KU0NBUXox8YgCZHEWFCa3cwhAcHt mLI256qXuHexJ1OGniE0jZgPz6drGkIiMDlLgiwNx+/wTc4oXC8TMpIFZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="7884360" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="7884360" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:34:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="792090691" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="792090691" Received: from jihao1-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.213.163.144]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:34:27 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, Brent Lu , Bard Liao , Pierre-Louis Bossart Subject: [PATCH 07/10] ASoC: Intel: sof_cs42l42: use common module for DMIC links Date: Thu, 19 Oct 2023 12:34:08 -0500 Message-Id: <20231019173411.166759-8-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019173411.166759-1-pierre-louis.bossart@linux.intel.com> References: <20231019173411.166759-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: QKU6EMBOAECPSNL2SFKYUQOBFKZQDSKA X-Message-ID-Hash: QKU6EMBOAECPSNL2SFKYUQOBFKZQDSKA X-MailFrom: pierre-louis.bossart@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: From: Brent Lu Use intel_board module for dmic01 and dmic16k DAI link initialization. Reviewed-by: Bard Liao Signed-off-by: Brent Lu Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/sof_cs42l42.c | 121 +++++++-------------------- 1 file changed, 32 insertions(+), 89 deletions(-) diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/sof_cs42l42.c index 6c7d0c85f1a0..1f760fc4cab2 100644 --- a/sound/soc/intel/boards/sof_cs42l42.c +++ b/sound/soc/intel/boards/sof_cs42l42.c @@ -160,10 +160,6 @@ static const struct snd_soc_dapm_widget sof_widgets[] = { SND_SOC_DAPM_MIC("Headset Mic", NULL), }; -static const struct snd_soc_dapm_widget dmic_widgets[] = { - SND_SOC_DAPM_MIC("SoC DMIC", NULL), -}; - static const struct snd_soc_dapm_route sof_map[] = { /* HP jack connectors - unknown if we have jack detection */ {"Headphone Jack", NULL, "HP"}, @@ -172,33 +168,6 @@ static const struct snd_soc_dapm_route sof_map[] = { {"HS", NULL, "Headset Mic"}, }; -static const struct snd_soc_dapm_route dmic_map[] = { - /* digital mics */ - {"DMic", NULL, "SoC DMIC"}, -}; - -static int dmic_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_card *card = rtd->card; - int ret; - - ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets, - ARRAY_SIZE(dmic_widgets)); - if (ret) { - dev_err(card->dev, "DMic widget addition failed: %d\n", ret); - /* Don't need to add routes if widget addition failed */ - return ret; - } - - ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map, - ARRAY_SIZE(dmic_map)); - - if (ret) - dev_err(card->dev, "DMic map addition failed: %d\n", ret); - - return ret; -} - /* sof audio machine driver for cs42l42 codec */ static struct snd_soc_card sof_audio_card_cs42l42 = { .name = "cs42l42", /* the sof- prefix is added by the core */ @@ -220,13 +189,6 @@ static struct snd_soc_dai_link_component cs42l42_component[] = { } }; -static struct snd_soc_dai_link_component dmic_component[] = { - { - .name = "dmic-codec", - .dai_name = "dmic-hifi", - } -}; - static int create_spk_amp_dai_links(struct device *dev, struct snd_soc_dai_link *links, struct snd_soc_dai_link_component *cpus, @@ -322,47 +284,6 @@ static int create_hp_codec_dai_links(struct device *dev, return -ENOMEM; } -static int create_dmic_dai_links(struct device *dev, - struct snd_soc_dai_link *links, - struct snd_soc_dai_link_component *cpus, - int *id, int dmic_be_num) -{ - int i; - - /* dmic */ - if (dmic_be_num <= 0) - return 0; - - /* at least we have dmic01 */ - links[*id].name = "dmic01"; - links[*id].cpus = &cpus[*id]; - links[*id].cpus->dai_name = "DMIC01 Pin"; - links[*id].init = dmic_init; - if (dmic_be_num > 1) { - /* set up 2 BE links at most */ - links[*id + 1].name = "dmic16k"; - links[*id + 1].cpus = &cpus[*id + 1]; - links[*id + 1].cpus->dai_name = "DMIC16k Pin"; - dmic_be_num = 2; - } - - for (i = 0; i < dmic_be_num; i++) { - links[*id].id = *id; - links[*id].num_cpus = 1; - links[*id].codecs = dmic_component; - links[*id].num_codecs = ARRAY_SIZE(dmic_component); - links[*id].platforms = platform_component; - links[*id].num_platforms = ARRAY_SIZE(platform_component); - links[*id].ignore_suspend = 1; - links[*id].dpcm_capture = 1; - links[*id].no_pcm = 1; - - (*id)++; - } - - return 0; -} - static int create_bt_offload_dai_links(struct device *dev, struct snd_soc_dai_link *links, struct snd_soc_dai_link_component *cpus, @@ -446,11 +367,34 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, } break; case LINK_DMIC: - ret = create_dmic_dai_links(dev, links, cpus, &id, dmic_be_num); - if (ret < 0) { - dev_err(dev, "fail to create dmic dai links, ret %d\n", - ret); - goto devm_err; + if (dmic_be_num > 0) { + /* at least we have dmic01 */ + ret = sof_intel_board_set_dmic_link(dev, + &links[id], + id, + SOF_DMIC_01); + if (ret) { + dev_err(dev, "fail to create dmic01 link, ret %d\n", + ret); + goto devm_err; + } + + id++; + } + + if (dmic_be_num > 1) { + /* set up 2 BE links at most */ + ret = sof_intel_board_set_dmic_link(dev, + &links[id], + id, + SOF_DMIC_16K); + if (ret) { + dev_err(dev, "fail to create dmic16k link, ret %d\n", + ret); + goto devm_err; + } + + id++; } break; case LINK_HDMI: @@ -496,7 +440,6 @@ static int sof_audio_probe(struct platform_device *pdev) struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; struct snd_soc_dai_link *dai_links; struct sof_card_private *ctx; - int dmic_be_num; int ret, ssp_bt, ssp_amp, ssp_codec; ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); @@ -510,10 +453,10 @@ static int sof_audio_probe(struct platform_device *pdev) ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev); if (soc_intel_is_glk()) { - dmic_be_num = 1; + ctx->dmic_be_num = 1; ctx->hdmi_num = 3; } else { - dmic_be_num = 2; + ctx->dmic_be_num = 2; ctx->hdmi_num = (sof_cs42l42_quirk & SOF_CS42L42_NUM_HDMIDEV_MASK) >> SOF_CS42L42_NUM_HDMIDEV_SHIFT; /* default number of HDMI DAI's */ @@ -535,7 +478,7 @@ static int sof_audio_probe(struct platform_device *pdev) ssp_codec = sof_cs42l42_quirk & SOF_CS42L42_SSP_CODEC_MASK; /* compute number of dai links */ - sof_audio_card_cs42l42.num_links = 1 + dmic_be_num + ctx->hdmi_num; + sof_audio_card_cs42l42.num_links = 1 + ctx->dmic_be_num + ctx->hdmi_num; if (ctx->amp_type != CODEC_NONE) sof_audio_card_cs42l42.num_links++; @@ -544,7 +487,7 @@ static int sof_audio_probe(struct platform_device *pdev) dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type, ssp_codec, ssp_amp, ssp_bt, - dmic_be_num, ctx->hdmi_num, + ctx->dmic_be_num, ctx->hdmi_num, ctx->hdmi.idisp_codec); if (!dai_links) return -ENOMEM; From patchwork Thu Oct 19 17:34:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 735647 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 93BD3CDB465 for ; Thu, 19 Oct 2023 17:38:41 +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 C54C3BC0; Thu, 19 Oct 2023 19:37:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C54C3BC0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1697737119; bh=zGGP93Orvj8T3+JJztvqW239On7FSYEnBF7CPHLskpM=; 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=HFo8O3lFtUYjln2noYCmn9hCT/qY98tQ78Tg8uJLBSdGnkf1APjSCzlBZKjLqfiVK gVESgCm2TjDToH+rGKCYShXkk9OEzeuwu4FIYDuWpB8oEAy2taLDkkPVIN38Mrjyb8 kAtRDjAj0YToQqYVHH34jX/2iof6v8NAZfjwu7a4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2D26AF80589; Thu, 19 Oct 2023 19:37:17 +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 B26AAF8057C; Thu, 19 Oct 2023 19:37:16 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F1489F80564; Thu, 19 Oct 2023 19:37:11 +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 437A3F800C9 for ; Thu, 19 Oct 2023 19:34:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 437A3F800C9 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=QNMkzVjR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697736877; x=1729272877; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zGGP93Orvj8T3+JJztvqW239On7FSYEnBF7CPHLskpM=; b=QNMkzVjRgUFFNFb05pwVxCUeH1WQyOoQY56M8Go+k4sJAN9+wfftmW7e Ijw4qFiOUa1CrjTyBqmDzcMN9qNwyaQMcKGSWwcxI6aIAUB7kHugJ7qvH UGjniY5m0GSXHSSk3rocYGWBjnDc4rVyFZfuPX2C/xmV1xTxJevpb4AOD BeaDmbYHkjYdMTFkg0gnmgB2ObLiD713wIJ0OpV/P5ixTrthoQw36R1GW w9Hsq7+sOFQ+sNIrL3ronk1lFHqk2n/fVFhFmx8iWFWMIPGE/9LymLE/w wY8jv0rz6PPIEy91Np2NJz6kZDGNvsNk6pkv3L02C4dbhptHONSB6Vs4w Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="7884377" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="7884377" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:34:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="792090727" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="792090727" Received: from jihao1-mobl.amr.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.213.163.144]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 10:34:28 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, Brent Lu , Bard Liao , Pierre-Louis Bossart Subject: [PATCH 09/10] ASoC: Intel: sof_rt5682: use common module for DMIC links Date: Thu, 19 Oct 2023 12:34:10 -0500 Message-Id: <20231019173411.166759-10-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231019173411.166759-1-pierre-louis.bossart@linux.intel.com> References: <20231019173411.166759-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: P4SISW54MS7SG2JZL6NOOZQTHB23R4Z4 X-Message-ID-Hash: P4SISW54MS7SG2JZL6NOOZQTHB23R4Z4 X-MailFrom: pierre-louis.bossart@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: From: Brent Lu Use intel_board module for dmic01 and dmic16k DAI link initialization. Reviewed-by: Bard Liao Signed-off-by: Brent Lu Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/sof_rt5682.c | 81 ++++++----------------------- 1 file changed, 17 insertions(+), 64 deletions(-) diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index 1e90dff61b9b..06ad15af46de 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -503,10 +503,6 @@ static const struct snd_soc_dapm_widget sof_widgets[] = { SND_SOC_DAPM_SPK("Right Spk", NULL), }; -static const struct snd_soc_dapm_widget dmic_widgets[] = { - SND_SOC_DAPM_MIC("SoC DMIC", NULL), -}; - static const struct snd_soc_dapm_route sof_map[] = { /* HP jack connectors - unknown if we have jack detection */ { "Headphone Jack", NULL, "HPOL" }, @@ -522,11 +518,6 @@ static const struct snd_soc_dapm_route rt5650_spk_dapm_routes[] = { { "Right Spk", NULL, "SPOR" }, }; -static const struct snd_soc_dapm_route dmic_map[] = { - /* digital mics */ - {"DMic", NULL, "SoC DMIC"}, -}; - static int rt5650_spk_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_card *card = rtd->card; @@ -540,28 +531,6 @@ static int rt5650_spk_init(struct snd_soc_pcm_runtime *rtd) return ret; } -static int dmic_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_card *card = rtd->card; - int ret; - - ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets, - ARRAY_SIZE(dmic_widgets)); - if (ret) { - dev_err(card->dev, "DMic widget addition failed: %d\n", ret); - /* Don't need to add routes if widget addition failed */ - return ret; - } - - ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map, - ARRAY_SIZE(dmic_map)); - - if (ret) - dev_err(card->dev, "DMic map addition failed: %d\n", ret); - - return ret; -} - /* sof audio machine driver for rt5682 codec */ static struct snd_soc_card sof_audio_card_rt5682 = { .name = "rt5682", /* the sof- prefix is added by the core */ @@ -601,13 +570,6 @@ static struct snd_soc_dai_link_component rt5650_components[] = { } }; -static struct snd_soc_dai_link_component dmic_component[] = { - { - .name = "dmic-codec", - .dai_name = "dmic-hifi", - } -}; - static struct snd_soc_dai_link * sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type, enum sof_ssp_codec amp_type, int ssp_codec, @@ -692,29 +654,21 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type, /* dmic */ if (dmic_be_num > 0) { /* at least we have dmic01 */ - links[id].name = "dmic01"; - links[id].cpus = &cpus[id]; - links[id].cpus->dai_name = "DMIC01 Pin"; - links[id].init = dmic_init; - if (dmic_be_num > 1) { - /* set up 2 BE links at most */ - links[id + 1].name = "dmic16k"; - links[id + 1].cpus = &cpus[id + 1]; - links[id + 1].cpus->dai_name = "DMIC16k Pin"; - dmic_be_num = 2; - } + ret = sof_intel_board_set_dmic_link(dev, &links[id], id, + SOF_DMIC_01); + if (ret) + return NULL; + + id++; } - for (i = 0; i < dmic_be_num; i++) { - links[id].id = id; - links[id].num_cpus = 1; - links[id].codecs = dmic_component; - links[id].num_codecs = ARRAY_SIZE(dmic_component); - links[id].platforms = platform_component; - links[id].num_platforms = ARRAY_SIZE(platform_component); - links[id].ignore_suspend = 1; - links[id].dpcm_capture = 1; - links[id].no_pcm = 1; + if (dmic_be_num > 1) { + /* set up 2 BE links at most */ + ret = sof_intel_board_set_dmic_link(dev, &links[id], id, + SOF_DMIC_16K); + if (ret) + return NULL; + id++; } @@ -865,7 +819,6 @@ static int sof_audio_probe(struct platform_device *pdev) struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; struct snd_soc_dai_link *dai_links; struct sof_card_private *ctx; - int dmic_be_num; int ret, ssp_amp, ssp_codec; ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); @@ -891,7 +844,7 @@ static int sof_audio_probe(struct platform_device *pdev) if (soc_intel_is_byt() || soc_intel_is_cht()) { ctx->rt5682.is_legacy_cpu = true; - dmic_be_num = 0; + ctx->dmic_be_num = 0; /* HDMI is not supported by SOF on Baytrail/CherryTrail */ ctx->hdmi_num = 0; /* default quirk for legacy cpu */ @@ -899,7 +852,7 @@ static int sof_audio_probe(struct platform_device *pdev) SOF_RT5682_MCLK_BYTCHT_EN | SOF_RT5682_SSP_CODEC(2); } else { - dmic_be_num = 2; + ctx->dmic_be_num = 2; ctx->hdmi_num = (sof_rt5682_quirk & SOF_RT5682_NUM_HDMIDEV_MASK) >> SOF_RT5682_NUM_HDMIDEV_SHIFT; /* default number of HDMI DAI's */ @@ -938,7 +891,7 @@ static int sof_audio_probe(struct platform_device *pdev) ssp_codec = sof_rt5682_quirk & SOF_RT5682_SSP_CODEC_MASK; /* compute number of dai links */ - sof_audio_card_rt5682.num_links = 1 + dmic_be_num + ctx->hdmi_num; + sof_audio_card_rt5682.num_links = 1 + ctx->dmic_be_num + ctx->hdmi_num; if (ctx->amp_type != CODEC_NONE) sof_audio_card_rt5682.num_links++; @@ -953,7 +906,7 @@ static int sof_audio_probe(struct platform_device *pdev) dai_links = sof_card_dai_links_create(&pdev->dev, ctx->codec_type, ctx->amp_type, ssp_codec, ssp_amp, - dmic_be_num, ctx->hdmi_num, + ctx->dmic_be_num, ctx->hdmi_num, ctx->hdmi.idisp_codec, ctx->rt5682.is_legacy_cpu); if (!dai_links)