From patchwork Wed Jun 26 13:36:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 167804 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp961101ilk; Wed, 26 Jun 2019 06:36:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKa66+tTumb8TFgI7crZKL1keWR2p5oN4qNrC/NIPMwbBZ71y60W60JtvKVUDErMTqbFQZ X-Received: by 2002:a63:190d:: with SMTP id z13mr3044321pgl.191.1561556200528; Wed, 26 Jun 2019 06:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561556200; cv=none; d=google.com; s=arc-20160816; b=IsPkY0McIlmeDe331jh2bzPLacAUrATSPDpMwIT97ItiJbtQTpgSaRPbi8/C/58tmq b8WUh9JJ6QhPSkZJv38hiDQGbT162TJZZYo/TAM79tfAFNDIokNcL6eHF4PfcJuzLVa8 wtNodS+oXnnf7uysm02Wssb3xaB+okLWLDBD2agQlDZ39NPXNRmquOmGCM/dSYvYO3uV QinhKZN/kP3HPhaEHcPj3QIHOrsrjqv0R0VvFKp6IxhPkroZcb2q8CJYmWFzulVNuNSj GY7/k4Evs31yviKc6Wn0iAZBx4/9mWQA5iOHHOvm39qUm1Elk2ntE4p/qVrB5msgxqkv iS1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gnbXfzzoDtydJ87Q5fD6teACNHZuePi08QBtGx5OaUc=; b=bAwMhrtUgQqBZIGZVqcSw/Ht8cdTfXb5ApomhL0Bu4xLagXQS7zgbJ5nZLiAv6OLdm 4Afx8RWCYuYQlCVcBQJlOWxSvGIIuDGp04NUebWO2hVS7fcWRewy2tilwBqo+d3eIWnk mMeYbfoZFGnIfi1hnAUx2Vy2W4vMT7D+xS8dSMELbsaZzvo+VevUyLVlqCgpzrt76Xw/ WWTOHdodh8NvZM1wqDhAmalIyXeyWVpRdhDCk0kvpBSSoUBlsPfVotFLv9UB7YzEQWko CQr/2EoRjAPsTwAHQoZ9jk7+B9CI2KZBKF3fT9E4TFvpULNxbRDs8yCgAN769gPhNXb1 xQKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=blN2Wv4W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6si3292313pll.162.2019.06.26.06.36.40; Wed, 26 Jun 2019 06:36:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=blN2Wv4W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727731AbfFZNgj (ORCPT + 30 others); Wed, 26 Jun 2019 09:36:39 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42117 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727793AbfFZNgh (ORCPT ); Wed, 26 Jun 2019 09:36:37 -0400 Received: by mail-wr1-f68.google.com with SMTP id x17so2762932wrl.9 for ; Wed, 26 Jun 2019 06:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gnbXfzzoDtydJ87Q5fD6teACNHZuePi08QBtGx5OaUc=; b=blN2Wv4WVam0hiUqSylbBjtVDmRMsW53HOX2psNbZKAxgOV2/z/PkOMtPkvN/ugaMZ Sg4t47aCwoKzFiHw5nHazKAzbtIIT1w5Cg3nv+jk5gdLshoApig4CdNMpdMnYHjq9tnk CedAXDygrR2Ry2XQZjRO9kNtKX+IT1NbJk0z0dwj9Lpr0DgIjdw6g0Z9+faU+mkx7mrF CTbKNYE6FmB6gqFUzdzYfA74pNkEU/94kdqZgl9dh8fj7D+Yhwb2d2/+4XhXJeLiYfEa RHU/dazcHlX1nB+mtKcX232onWixjioT9LUKx+Rkgfh1Q3bg1P6IAwWw0fNvYbujtGBk gw+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gnbXfzzoDtydJ87Q5fD6teACNHZuePi08QBtGx5OaUc=; b=AVigiNn+o5mJEt+/FN5W8WguzmIFFeHl5Ig21zNPpKL5LDcJuQMLFjDy3Zv0DAYwpb LEXL28gKAQeyxzKdpSR7dB2x8JP+LloRlzScFSgTOYQ4gzFCuMNJAY+3DHORHDzdFK9V 4+C91EfAV1aUXdPTDkcXxSG+a2O0gmxRGDyBN5deGHPcLnh8o0l1tgxi9Cj+7DGwJiTx XnxgpALEGuNPhN1BaI/t13vJCkZnyyzIOrrIrtbq63SI3blB26IFhZFO1bZ43CbOydBS 2bHMWHUmFwWvGXrDP6/Prx+D841b9EY6pMLRS3GfekxpGvG1KT+Xyt2EOKFj0uh3qJA6 z/hQ== X-Gm-Message-State: APjAAAXAc67ZFG99l6hGAtTJW66QSiavXDyRuZ3kagGyrWJX29h8MoC/ NfhTlXeyfRySs6VMRs0Endu63RoqffSvBg== X-Received: by 2002:a5d:67cd:: with SMTP id n13mr2478127wrw.138.1561556195567; Wed, 26 Jun 2019 06:36:35 -0700 (PDT) Received: from starbuck.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id w185sm2877880wma.39.2019.06.26.06.36.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 06:36:35 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood , Kevin Hilman Cc: Jerome Brunet , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 1/2] ASoC: soc-core: defer card registration if codec component is missing Date: Wed, 26 Jun 2019 15:36:16 +0200 Message-Id: <20190626133617.25959-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190626133617.25959-1-jbrunet@baylibre.com> References: <20190626133617.25959-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Like cpus and platforms, defer sound card initialization if the codec component is missing when initializing the dai_link Signed-off-by: Jerome Brunet --- sound/soc/soc-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.21.0 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 358f1fbf9a30..002ddbf4e5a3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1064,12 +1064,20 @@ static int soc_init_dai_link(struct snd_soc_card *card, link->name); return -EINVAL; } + /* Codec DAI name must be specified */ if (!codec->dai_name) { dev_err(card->dev, "ASoC: codec_dai_name not set for %s\n", link->name); return -EINVAL; } + + /* + * Defer card registartion if codec component is not added to + * component list. + */ + if (!soc_find_component(codec)) + return -EPROBE_DEFER; } /* From patchwork Wed Jun 26 13:36:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 167805 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp961159ilk; Wed, 26 Jun 2019 06:36:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoMo+y86R+O0y2A6OPPHd8g0jFfmn3ElYVfnRuLced95s9H6oEaicSb6MrQ0EG3DhXSt+Q X-Received: by 2002:a17:90a:bb94:: with SMTP id v20mr4913135pjr.88.1561556203246; Wed, 26 Jun 2019 06:36:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561556203; cv=none; d=google.com; s=arc-20160816; b=GCz46XvT+iSZgxm+mmX8xjrgLkmNX0nCe4vXdMr/A+jhl3dngNt2HaXw6NQCqlcPWg fczHP3za5AFutY2rfrpjQ1AHs+ZNLVtz8+tZrl3jc5iNlpbCnCBfMjO/xu2Gk1bghCdW 0OsmObDlIrDBo3dPzBsMDGpk5R4R+jW/9xJn4JioFoDZVgueKvFysGB7cuZ7OgcCFjH+ FRjFtz1Tr/CYcNDjljwZ2G+wycOQ/4q4f8oGtvg4bHQGyAW9xvcUGyg/s19rotYsJAWn pUKxgrLa1ZK5HNsAPwC0UYL5s3yMT6K+fZWa/i4/U+Za2Ve8KpB79VJQDms9Y4RcygHD mP0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=T7ZRClmFeqyZ4D18CQN6W27UJDdTkTXzm4pfq532FJg=; b=dxorGa8sVdhNORxl8RRPN1DyckOIX6U+MZUxwhxZs/ZRsciFTjTukaF9rrw0d9M34h yZvuR5xrH9Q2Hyq0f9Qpvb1zMu3nTW2x3ob5B+OAjlvWF3qcjn8xGUZ/wppFtRtxdvvW vyDdkn5BJzIcJQ/Rtqyp+ZQ0MJiyd+HJKY9i29PMNllI0GrDtSqWyoJrYxj4vgw4KBpe f6KnR5E8HuQGPChE2OCe/cbBmVSHDyuAp7e12BLrnios6GfMWO+HwccnHbbXpcB8cQDT LARqxCFRSYBbF4QntD+GjeLPOdsR4RmVMm7Ccfx7XXSLylh/MsaWDkGxYUJtJiC0vVAq yw7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=TWguFFAX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y4si17325993pgi.556.2019.06.26.06.36.42; Wed, 26 Jun 2019 06:36:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=TWguFFAX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727836AbfFZNgl (ORCPT + 30 others); Wed, 26 Jun 2019 09:36:41 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:45626 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbfFZNgi (ORCPT ); Wed, 26 Jun 2019 09:36:38 -0400 Received: by mail-wr1-f66.google.com with SMTP id f9so2748161wre.12 for ; Wed, 26 Jun 2019 06:36:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T7ZRClmFeqyZ4D18CQN6W27UJDdTkTXzm4pfq532FJg=; b=TWguFFAXrPN64W+X4eBYlZPZH2QrZ3RtaEk2RtjrznN+tIo2MHrKBmJuHOYO0Uxo82 CFP2HHb8vbibDiKipegaJwcQALrm2NrxCXayWfVXmKAcXmPvc89FzlJn27GwnE9dp9Jn TOmD7Y531MOUW4bMYKxXAlil3CTluuV2QY2Ocwu8EhCb9Ddn60MQ4rZjV5KStJJJZEny g1ynMXpyyM6tb5symDm+PSC0EgIq5hVwtlbTPNM1Yc333p5mIi/fL9jVfe4gbsAqYZDn xi7Sho9UEBe6Y+B41ZD6Fh4xckuLJjEvfvy8pec2lLenRMJaJVqr9uOUMwAgWUFtQMv5 uFxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T7ZRClmFeqyZ4D18CQN6W27UJDdTkTXzm4pfq532FJg=; b=mYsxp0gRAp9VRGqzPuGf9o7cphw5Ol40WY9oJJsGqAgLO181BYhwui2+EVVuoOkALD lvu6zSiTIWSa05o6ZtFelOfkS89meA2AKOYbSdFI3j2IckA8iTFaHXzzi8kmWw9dbCDi wiI0z//IIXqlQxnih0WBaKtBMoVT3xeIntvYDJ9B+RZPFeMwWo71x0MTVI4ci8/xl2V+ a72kRVa+eW68Irq2+QamBq6iWM75Gea99vnirb6nF7xhpQp/WJKtjvTWB8uolqBC7CBd 1j/s+GqTuLHVO+HdMW820qV16I8dBF7PHHKC71PLcJcKQxidVgBfDtvicoUwDT8irmxj 5U4g== X-Gm-Message-State: APjAAAU/Loag1GtlSFmVS+OLuZ1I2iXyJWucV3kiENE0Tgb4W7RxHe4h NvifZPZolw2uyI2be81JaLDWNQ== X-Received: by 2002:a5d:4949:: with SMTP id r9mr3595411wrs.289.1561556196920; Wed, 26 Jun 2019 06:36:36 -0700 (PDT) Received: from starbuck.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id w185sm2877880wma.39.2019.06.26.06.36.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 06:36:36 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood , Kevin Hilman Cc: Jerome Brunet , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, Kuninori Morimoto Subject: [PATCH 2/2] ASoC: soc-core: support dai_link with platforms_num != 1 Date: Wed, 26 Jun 2019 15:36:17 +0200 Message-Id: <20190626133617.25959-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190626133617.25959-1-jbrunet@baylibre.com> References: <20190626133617.25959-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support platforms_num != 1 in dai_link. Initially, the main purpose of this change was to make the platform optional in the dai_link, instead of inserting the dummy platform driver. This particular case had just been solved by Kuninori Morimoto with commit 1d7689892878 ("ASoC: soc-core: allow no Platform on dai_link"). However, this change may still be useful for those who need multiple platform components on a single dai_link (it solves one of the FIXME note in soc-core) Cc: Kuninori Morimoto Signed-off-by: Jerome Brunet --- include/sound/soc.h | 6 ++++ sound/soc/soc-core.c | 66 +++++++++++++++++++------------------------- 2 files changed, 34 insertions(+), 38 deletions(-) -- 2.21.0 diff --git a/include/sound/soc.h b/include/sound/soc.h index 64405cdab8bb..4e8071269639 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -997,6 +997,12 @@ struct snd_soc_dai_link { ((i) < link->num_codecs) && ((codec) = &link->codecs[i]); \ (i)++) +#define for_each_link_platforms(link, i, platform) \ + for ((i) = 0; \ + ((i) < link->num_platforms) && \ + ((platform) = &link->platforms[i]); \ + (i)++) + /* * Sample 1 : Single CPU/Codec/Platform * diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 002ddbf4e5a3..3053a4a461b3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -887,7 +887,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) { struct snd_soc_pcm_runtime *rtd; - struct snd_soc_dai_link_component *codecs; + struct snd_soc_dai_link_component *dlc; struct snd_soc_component *component; int i; @@ -917,13 +917,14 @@ static int soc_bind_dai_link(struct snd_soc_card *card, /* Find CODEC from registered CODECs */ rtd->num_codecs = dai_link->num_codecs; - for_each_link_codecs(dai_link, i, codecs) { - rtd->codec_dais[i] = snd_soc_find_dai(codecs); + for_each_link_codecs(dai_link, i, dlc) { + rtd->codec_dais[i] = snd_soc_find_dai(dlc); if (!rtd->codec_dais[i]) { dev_info(card->dev, "ASoC: CODEC DAI %s not registered\n", - codecs->dai_name); + dlc->dai_name); goto _err_defer; } + snd_soc_rtdcom_add(rtd, rtd->codec_dais[i]->component); } @@ -931,12 +932,13 @@ static int soc_bind_dai_link(struct snd_soc_card *card, rtd->codec_dai = rtd->codec_dais[0]; /* Find PLATFORM from registered PLATFORMs */ - for_each_component(component) { - if (!snd_soc_is_matching_component(dai_link->platforms, - component)) - continue; + for_each_link_platforms(dai_link, i, dlc) { + for_each_component(component) { + if (!snd_soc_is_matching_component(dlc, component)) + continue; - snd_soc_rtdcom_add(rtd, component); + snd_soc_rtdcom_add(rtd, component); + } } soc_add_pcm_runtime(card, rtd); @@ -1051,22 +1053,22 @@ static int soc_init_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link) { int i; - struct snd_soc_dai_link_component *codec; + struct snd_soc_dai_link_component *dlc; - for_each_link_codecs(link, i, codec) { + for_each_link_codecs(link, i, dlc) { /* * Codec must be specified by 1 of name or OF node, * not both or neither. */ - if (!!codec->name == - !!codec->of_node) { + if (!!dlc->name == + !!dlc->of_node) { dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n", link->name); return -EINVAL; } /* Codec DAI name must be specified */ - if (!codec->dai_name) { + if (!dlc->dai_name) { dev_err(card->dev, "ASoC: codec_dai_name not set for %s\n", link->name); return -EINVAL; @@ -1076,40 +1078,28 @@ static int soc_init_dai_link(struct snd_soc_card *card, * Defer card registartion if codec component is not added to * component list. */ - if (!soc_find_component(codec)) + if (!soc_find_component(dlc)) return -EPROBE_DEFER; } - /* - * Platform may be specified by either name or OF node, - * or no Platform. - * - * FIXME - * - * We need multi-platform support - */ - if (link->num_platforms > 0) { - - if (link->num_platforms > 1) { - dev_err(card->dev, - "ASoC: multi platform is not yet supported %s\n", - link->name); - return -EINVAL; - } - - if (link->platforms->name && link->platforms->of_node) { + for_each_link_platforms(link, i, dlc) { + /* + * Platform may be specified by either name or OF node, but it + * can be left unspecified, then no components will be inserted + * in the rtdcom list + */ + if (!!dlc->name == !!dlc->of_node) { dev_err(card->dev, - "ASoC: Both platform name/of_node are set for %s\n", + "ASoC: Neither/both platform name/of_node are set for %s\n", link->name); return -EINVAL; } /* - * Defer card registartion if platform dai component is not - * added to component list. + * Defer card registartion if platform component is not added to + * component list. */ - if ((link->platforms->of_node || link->platforms->name) && - !soc_find_component(link->platforms)) + if (!soc_find_component(dlc)) return -EPROBE_DEFER; }