From patchwork Fri May 25 17:36:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 136971 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3877845lji; Fri, 25 May 2018 10:37:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo4atBbO7u8xQxgP/I8qTqiqhmzWYH2pB5roWxR5toL1+YYuCQm/30OkEMTW9tDqaoNw3+N X-Received: by 2002:a1c:acc2:: with SMTP id v185-v6mr2412523wme.67.1527269823572; Fri, 25 May 2018 10:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527269823; cv=none; d=google.com; s=arc-20160816; b=Sgh/WhvEwTNmF4+TnOTymxyii6JANPI4yuhwDofo9bpuq3imOYOuUCn5yKVJtGpl3u M6UqEznK/rA8+G8lH1/h07wePZArGEq6KSmewt/U5pAzOrD4560zMTyoXzO9cUiMBp6g 0g9LO/MEFRlwzKobSFeF1GK1Uri6HFBc9KIYdOZW8M6+jq1BZZpU2tp4nU7RqIlvfiCc xc2FUE64ZjWsz/7ZvhwUk2FxXPLUxkRyaxk83sgUPdBz49YCilBlxPuJl5GLB7ZmLKYZ qmqbWNpscvYJ0RmBzFtmdNm8/8ciWrTJMLS9uRE4sHf0zvuOhJh34e2jGmC+Seo3l7oi A5GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=DLQx0gUiqyrpuIORLDw867NenNbQ1ePxvA8TqdnDP1A=; b=gfiPhR8nfidKDRmjli71i+/stgB/wsXAHX+ugWjK9xMV+ymNdEEIVc/RcqJzfyFYAh w6I4nhqtxc7B7DbFg4uuIuSaQiCDIZ3Z1nBxXPGl4iEPbhVhWvg1AQxj0+2CgEGDqTFO ri+jirTFM0GOMU9Uqbxe0WE9ryPj30VKbjAl2mE4DfnjxJpP+h4XjcXTwo202ulpxGIB wfTdB+8/QhgQTdywf+5ADHfPoGRigkoNC4vbGBkoOLvRs8Nc/gz7GgIiPW7NfxcxqNzv FcMi/dZJ+jE9FrY+zunz9tQw737FbT0U2x0tDIMlyBpu/xVDK0FTeyzO2GEQCWmugLYh EeqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=CSMk1256; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id v19-v6si2574843wrc.122.2018.05.25.10.37.03; Fri, 25 May 2018 10:37:03 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=CSMk1256; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B1D842676A3; Fri, 25 May 2018 19:36:55 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 39388267693; Fri, 25 May 2018 19:36:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id B207F26768E for ; Fri, 25 May 2018 19:36:46 +0200 (CEST) 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=6JlP9qZ9WR1VfNudB3X6V+4K5kmneC5x7C6FHFtrIeQ=; b=CSMk1256Z5U3 0IysK3rnwhycwr5LV9OWhWHYpRSruWDoySNwulSE5tKAX8ZY7BvKeRAHB79jfZ73qsUlCoxUTrSsd 43+/rW4/QUi3QjNl0fUgzVsloY0DmxyIlK6XJXf1Qi03lWnIypDhjxKFNVUHClbpBxyRCsDXgnobl p+4dY=; 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 1fMGds-0007m2-CW; Fri, 25 May 2018 17:36:40 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fMGdr-00082W-VF; Fri, 25 May 2018 18:36:39 +0100 From: Mark Brown To: KaiChieh Chuang In-Reply-To: <1527218274-27699-1-git-send-email-kaichieh.chuang@mediatek.com> Message-Id: Date: Fri, 25 May 2018 18:36:39 +0100 Cc: alsa-devel@alsa-project.org, wsd_upstream@mediatek.com, garlic.tseng@mediatek.com, broonie@kernel.org, linux-mediatek@lists.infradead.org, kaichieh.chuang@mediatek.com Subject: [alsa-devel] Applied "ASoC: mediatek: add sub dai to mtk_base_afe" to the asoc tree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: mediatek: add sub dai to mtk_base_afe has been applied to the asoc tree at https://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 13be427e5df4cea08c2d48017aabe112400e1b2f Mon Sep 17 00:00:00 2001 From: KaiChieh Chuang Date: Fri, 25 May 2018 11:48:16 +0800 Subject: [PATCH] ASoC: mediatek: add sub dai to mtk_base_afe In MediaTek SoC chip we have multiple DAI, such as I2S, ADDA, PCM, etc. Organize each DAI in to one sub dai, with its dai driver, controls, widgets, routes. add mtk_afe_combine_sub_dai() to combine dai driver from each DAI. add mtk_afe_add_sub_dai_control() to register the control, widget, routes to component. Signed-off-by: KaiChieh Chuang Signed-off-by: Mark Brown --- .../mediatek/common/mtk-afe-platform-driver.c | 78 +++++++++++++++++++ .../mediatek/common/mtk-afe-platform-driver.h | 5 ++ sound/soc/mediatek/common/mtk-base-afe.h | 18 +++++ 3 files changed, 101 insertions(+) -- 2.17.0 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c index 8966ee138387..c4491883090d 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c @@ -13,6 +13,84 @@ #include "mtk-afe-platform-driver.h" #include "mtk-base-afe.h" +int mtk_afe_combine_sub_dai(struct mtk_base_afe *afe) +{ + struct snd_soc_dai_driver *sub_dai_drivers; + size_t num_dai_drivers = 0, dai_idx = 0; + int i; + + if (!afe->sub_dais) { + dev_err(afe->dev, "%s(), sub_dais == NULL\n", __func__); + return -EINVAL; + } + + /* calcualte total dai driver size */ + for (i = 0; i < afe->num_sub_dais; i++) { + if (afe->sub_dais[i].dai_drivers && + afe->sub_dais[i].num_dai_drivers != 0) + num_dai_drivers += afe->sub_dais[i].num_dai_drivers; + } + + dev_info(afe->dev, "%s(), num of dai %zd\n", __func__, num_dai_drivers); + + /* combine sub_dais */ + afe->num_dai_drivers = num_dai_drivers; + afe->dai_drivers = devm_kcalloc(afe->dev, + num_dai_drivers, + sizeof(struct snd_soc_dai_driver), + GFP_KERNEL); + if (!afe->dai_drivers) + return -ENOMEM; + + for (i = 0; i < afe->num_sub_dais; i++) { + if (afe->sub_dais[i].dai_drivers && + afe->sub_dais[i].num_dai_drivers != 0) { + sub_dai_drivers = afe->sub_dais[i].dai_drivers; + /* dai driver */ + memcpy(&afe->dai_drivers[dai_idx], + sub_dai_drivers, + afe->sub_dais[i].num_dai_drivers * + sizeof(struct snd_soc_dai_driver)); + dai_idx += afe->sub_dais[i].num_dai_drivers; + } + } + + return 0; +} + +int mtk_afe_add_sub_dai_control(struct snd_soc_component *component) +{ + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); + int i; + + if (!afe->sub_dais) { + dev_err(afe->dev, "%s(), sub_dais == NULL\n", __func__); + return -EINVAL; + } + + for (i = 0; i < afe->num_sub_dais; i++) { + if (afe->sub_dais[i].controls) + snd_soc_add_component_controls(component, + afe->sub_dais[i].controls, + afe->sub_dais[i].num_controls); + + if (afe->sub_dais[i].dapm_widgets) + snd_soc_dapm_new_controls(&component->dapm, + afe->sub_dais[i].dapm_widgets, + afe->sub_dais[i].num_dapm_widgets); + + if (afe->sub_dais[i].dapm_routes) + snd_soc_dapm_add_routes(&component->dapm, + afe->sub_dais[i].dapm_routes, + afe->sub_dais[i].num_dapm_routes); + } + + snd_soc_dapm_new_widgets(component->dapm.card); + + return 0; + +} + static snd_pcm_uframes_t mtk_afe_pcm_pointer (struct snd_pcm_substream *substream) { diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.h b/sound/soc/mediatek/common/mtk-afe-platform-driver.h index 1c81d911cf2a..0c31fa4b6f8c 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.h +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.h @@ -12,5 +12,10 @@ #define AFE_PCM_NAME "mtk-afe-pcm" extern const struct snd_soc_component_driver mtk_afe_pcm_platform; +struct mtk_base_afe; +struct snd_soc_component; + +int mtk_afe_combine_sub_dai(struct mtk_base_afe *afe); +int mtk_afe_add_sub_dai_control(struct snd_soc_component *component); #endif diff --git a/sound/soc/mediatek/common/mtk-base-afe.h b/sound/soc/mediatek/common/mtk-base-afe.h index c2c5a6c5751d..bcf562f029b6 100644 --- a/sound/soc/mediatek/common/mtk-base-afe.h +++ b/sound/soc/mediatek/common/mtk-base-afe.h @@ -48,6 +48,7 @@ struct mtk_base_irq_data { struct device; struct mtk_base_afe_memif; struct mtk_base_afe_irq; +struct mtk_base_afe_dai; struct regmap; struct snd_pcm_substream; struct snd_soc_dai; @@ -71,6 +72,11 @@ struct mtk_base_afe { struct mtk_base_afe_irq *irqs; int irqs_size; + struct mtk_base_afe_dai *sub_dais; + int num_sub_dais; + struct snd_soc_dai_driver *dai_drivers; + unsigned int num_dai_drivers; + const struct snd_pcm_hardware *mtk_afe_hardware; int (*memif_fs)(struct snd_pcm_substream *substream, unsigned int rate); @@ -94,5 +100,17 @@ struct mtk_base_afe_irq { int irq_occupyed; }; +struct mtk_base_afe_dai { + struct snd_soc_dai_driver *dai_drivers; + unsigned int num_dai_drivers; + + const struct snd_kcontrol_new *controls; + unsigned int num_controls; + const struct snd_soc_dapm_widget *dapm_widgets; + unsigned int num_dapm_widgets; + const struct snd_soc_dapm_route *dapm_routes; + unsigned int num_dapm_routes; +}; + #endif