From patchwork Tue Sep 19 13:46:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 9959131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 085AB601E9 for ; Tue, 19 Sep 2017 13:54:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCD0428914 for ; Tue, 19 Sep 2017 13:54:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1438286AA; Tue, 19 Sep 2017 13:54:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D297328646 for ; Tue, 19 Sep 2017 13:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Message-Id: In-Reply-To:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: References:List-Owner; bh=zR35G7jpA02v3f9HdwRlc9gwftLSVGQUoAAtCi8DVWU=; b=QyZ HqG0fUbnAzVHsFvzNyHGYxXi2RV16p9L7Tn89vDWdBJhio23CbeUpgOTq7MmWfsO9p69YvgrB/xEM 2azk5siEWyAtk17d7hS17EmKn2j7fsw+g5T7l9KJJpZmxbCx9HKIMW5FmkYs6HX+hp9OlL3oU/Z6T 2r4CZR+AEdTNFJYSnIFYbFvHQ+X26wqCpzx5X+ZL3fNORxKFf+UU0Dfe2RxNFj+7xkHGAglNBX2gv yZ5z6AdTz9A2CeyrU184PCk1h1IlEQMhqqoV/haN4UgzkTQri9+mYRjjMYvFdVETn14+SUCAYRejQ 94Y0Vn20HDDSkpsFUuL7W8Oin1MTWXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1duIzA-00017o-AE; Tue, 19 Sep 2017 13:54:48 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1duIsR-0006Em-Nk; Tue, 19 Sep 2017 13:47:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Message-Id:In-Reply-To:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wWZV4pZrCJe0XS7gGgHZHgCl9DZt8AU+Zq77VoQTgNs=; b=qPJpHDqcLRkDFRVz0EVx+Ijs7n m0z2t8ThAp5sWdrAP3SsZkzo6yXznqgyqdP01+e5gCsHMADge4i+staoZBzkrNLQDL6hruXWUbCrD +CiACnSbccMjSLfHZB0I5J/KRYnYlnZF5R/cGczgArpHR5IbvjfaMsM/ASyd4A0yjnT7SzE45LmlS 4RKfP3SXYPvC4O/rDuDTKEnCpowWMFp8wWDnT09gsU10irqP4CRLM/hM+eLd73rBez3JWvA332XOR PEHGJah/YYsK/LC1zAwxGIpbQiI07ZVOqHGPk2njpRIG3fT9goIUbUOIBbEzZyurd7t3gKFm42R+N DI3ScVrQ==; Received: from heliosphere.sirena.org.uk ([2a01:7e01::f03c:91ff:fed4:a3b6]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1duIsI-0002Df-Jo; Tue, 19 Sep 2017 13:47:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=wWZV4pZrCJe0XS7gGgHZHgCl9DZt8AU+Zq77VoQTgNs=; b=KnhXke5nIUy2 Z9HAPkjtnQPmUyz7QJFHflht+OwHjpzMzIwq/dE4AbGA5GczBq7tHXn6BLSv24aVD2wW0j/FGdj2l VEVnuKBQnTtm8UfQ63x+7GiacIScF6xk3TbMOVt45zBNZ2TaOWYyXzFQnbzZMJSMsOMcZ12hRGw+1 x0pd8=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1duIqz-0001O5-4t; Tue, 19 Sep 2017 13:46:21 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1duIqy-0008DH-O0; Tue, 19 Sep 2017 14:46:20 +0100 From: Mark Brown To: Jeffy Chen Subject: Applied "ASoC: rockchip: Init dapm routes dynamically" to the asoc tree In-Reply-To: <20170918014441.17572-3-jeffy.chen@rock-chips.com> Message-Id: Date: Tue, 19 Sep 2017 14:46:20 +0100 X-Bad-Reply: In-Reply-To but no 'Re:' in Subject. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, dianders@chromium.org, Heiko Stuebner , briannorris@chromium.org, linux-kernel@vger.kernel.org, Liam Girdwood , linux-rockchip@lists.infradead.org, Mark Brown , Takashi Iwai , mka@chromium.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The patch ASoC: rockchip: Init dapm routes dynamically has been applied to the asoc tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From d9f9c167edae999fc0fcbc97188ab29278e24958 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Tue, 19 Sep 2017 20:57:58 +0800 Subject: [PATCH] ASoC: rockchip: Init dapm routes dynamically Currently we are using a fixed list of dapm routes. Init dapm routes dynamically when parsing dailinks, since we are supporting optional codecs. Signed-off-by: Jeffy Chen Reviewed-by: Matthias Kaehlcke Tested-by: Matthias Kaehlcke Signed-off-by: Mark Brown --- sound/soc/rockchip/rk3399_gru_sound.c | 88 ++++++++++++++++++++++++++++------- 1 file changed, 72 insertions(+), 16 deletions(-) diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index ad19e391c4a6..fab868850d3a 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -50,20 +50,6 @@ static const struct snd_soc_dapm_widget rockchip_dapm_widgets[] = { SND_SOC_DAPM_LINE("HDMI", NULL), }; -static const struct snd_soc_dapm_route rockchip_dapm_routes[] = { - /* Input Lines */ - {"MIC", NULL, "Headset Mic"}, - {"DMIC1L", NULL, "Int Mic"}, - {"DMIC1R", NULL, "Int Mic"}, - {"DMic", NULL, "Int Mic"}, - - /* Output Lines */ - {"Headphones", NULL, "HPL"}, - {"Headphones", NULL, "HPR"}, - {"Speakers", NULL, "Speaker"}, - {"HDMI", NULL, "TX"}, -}; - static const struct snd_kcontrol_new rockchip_controls[] = { SOC_DAPM_PIN_SWITCH("Headphones"), SOC_DAPM_PIN_SWITCH("Speakers"), @@ -318,8 +304,6 @@ static struct snd_soc_card rockchip_sound_card = { .owner = THIS_MODULE, .dapm_widgets = rockchip_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(rockchip_dapm_widgets), - .dapm_routes = rockchip_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rockchip_dapm_routes), .controls = rockchip_controls, .num_controls = ARRAY_SIZE(rockchip_controls), }; @@ -395,6 +379,65 @@ static const struct snd_soc_dai_link rockchip_dais[] = { }, }; +static const struct snd_soc_dapm_route rockchip_sound_cdndp_routes[] = { + /* Output */ + {"HDMI", NULL, "TX"}, +}; + +static const struct snd_soc_dapm_route rockchip_sound_da7219_routes[] = { + /* Output */ + {"Headphones", NULL, "HPL"}, + {"Headphones", NULL, "HPR"}, + + /* Input */ + {"MIC", NULL, "Headset Mic"}, +}; + +static const struct snd_soc_dapm_route rockchip_sound_dmic_routes[] = { + /* Input */ + {"DMic", NULL, "Int Mic"}, +}; + +static const struct snd_soc_dapm_route rockchip_sound_max98357a_routes[] = { + /* Output */ + {"Speakers", NULL, "Speaker"}, +}; + +static const struct snd_soc_dapm_route rockchip_sound_rt5514_routes[] = { + /* Input */ + {"DMIC1L", NULL, "Int Mic"}, + {"DMIC1R", NULL, "Int Mic"}, +}; + +struct rockchip_sound_route { + const struct snd_soc_dapm_route *routes; + int num_routes; +}; + +static const struct rockchip_sound_route rockchip_routes[] = { + [DAILINK_CDNDP] = { + .routes = rockchip_sound_cdndp_routes, + .num_routes = ARRAY_SIZE(rockchip_sound_cdndp_routes), + }, + [DAILINK_DA7219] = { + .routes = rockchip_sound_da7219_routes, + .num_routes = ARRAY_SIZE(rockchip_sound_da7219_routes), + }, + [DAILINK_DMIC] = { + .routes = rockchip_sound_dmic_routes, + .num_routes = ARRAY_SIZE(rockchip_sound_dmic_routes), + }, + [DAILINK_MAX98357A] = { + .routes = rockchip_sound_max98357a_routes, + .num_routes = ARRAY_SIZE(rockchip_sound_max98357a_routes), + }, + [DAILINK_RT5514] = { + .routes = rockchip_sound_rt5514_routes, + .num_routes = ARRAY_SIZE(rockchip_sound_rt5514_routes), + }, + [DAILINK_RT5514_DSP] = {}, +}; + static int rockchip_sound_codec_node_match(struct device_node *np_codec) { int i; @@ -412,6 +455,7 @@ static int rockchip_sound_of_parse_dais(struct device *dev, struct device_node *np_cpu, *np_cpu0, *np_cpu1; struct device_node *np_codec; struct snd_soc_dai_link *dai; + struct snd_soc_dapm_route *routes; int i, index; card->dai_link = devm_kzalloc(dev, sizeof(rockchip_dais), @@ -419,9 +463,16 @@ static int rockchip_sound_of_parse_dais(struct device *dev, if (!card->dai_link) return -ENOMEM; + routes = devm_kzalloc(dev, sizeof(rockchip_routes), + GFP_KERNEL); + if (!routes) + return -ENOMEM; + card->dapm_routes = routes; + np_cpu0 = of_parse_phandle(dev->of_node, "rockchip,cpu", 0); np_cpu1 = of_parse_phandle(dev->of_node, "rockchip,cpu", 1); + card->num_dapm_routes = 0; card->num_links = 0; for (i = 0; i < ARRAY_SIZE(rockchip_dais); i++) { np_codec = of_parse_phandle(dev->of_node, @@ -449,6 +500,11 @@ static int rockchip_sound_of_parse_dais(struct device *dev, dai->codec_of_node = np_codec; dai->platform_of_node = np_cpu; dai->cpu_of_node = np_cpu; + + memcpy(routes + card->num_dapm_routes, + rockchip_routes[index].routes, + rockchip_routes[index].num_routes * sizeof(*routes)); + card->num_dapm_routes += rockchip_routes[index].num_routes; } return 0;