From patchwork Wed Oct 3 09:01:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 10624441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71EF4175A for ; Wed, 3 Oct 2018 09:01:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E2E52870B for ; Wed, 3 Oct 2018 09:01:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 516862870D; Wed, 3 Oct 2018 09:01:51 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82ACA2870B for ; Wed, 3 Oct 2018 09:01:50 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 579A1267889; Wed, 3 Oct 2018 11:01:49 +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 6C5972678F7; Wed, 3 Oct 2018 11:01:47 +0200 (CEST) Received: from relay1.mentorg.com (relay1.mentorg.com [192.94.38.131]) by alsa0.perex.cz (Postfix) with ESMTP id AB4E4267844 for ; Wed, 3 Oct 2018 11:01:45 +0200 (CEST) Received: from svr-orw-mbx-03.mgc.mentorg.com ([147.34.90.203]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1g7d2O-0002lr-Q0 from Jiada_Wang@mentor.com ; Wed, 03 Oct 2018 02:01:44 -0700 Received: from jiwang-OptiPlex-980.tokyo.mentorg.com (147.34.91.1) by svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 3 Oct 2018 02:01:41 -0700 From: To: , , , , Date: Wed, 3 Oct 2018 18:01:36 +0900 Message-ID: <20181003090136.4556-1-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 X-ClientProxiedBy: svr-orw-mbx-01.mgc.mentorg.com (147.34.90.201) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) Cc: jiada_wang@mentor.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH linux-next v2 9/9] ASoC: rsnd: add busif property to dai stream 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jiada Wang in GEN3 SSI may use different BUSIF for data transfer, this patch adds busif property to each dai stream, to indicate the BUSIF used by playback/capture stream. Also adds rsnd_ssi_select_busif() to automatically select BUSIF (currently only BUSIF0 is selected) Signed-off-by: Jiada Wang --- sound/soc/sh/rcar/core.c | 3 +++ sound/soc/sh/rcar/dma.c | 31 +++++++++++++++++++++++++++++++ sound/soc/sh/rcar/rsnd.h | 3 +++ sound/soc/sh/rcar/ssi.c | 30 +++++++++++++++++++++++++++++- 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 40d7dc4f7839..5e3e6e65bcdf 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1158,6 +1158,9 @@ static int rsnd_hw_params(struct snd_pcm_substream *substream, struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); int ret; + int chan = rsnd_runtime_channel_for_ssi_with_params(io, hw_params); + + rsnd_ssi_select_busif(io, chan); ret = rsnd_dai_call(hw_params, io, substream, hw_params); if (ret) diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c index 6d1947515dc8..bf87939f79bb 100644 --- a/sound/soc/sh/rcar/dma.c +++ b/sound/soc/sh/rcar/dma.c @@ -792,6 +792,37 @@ int rsnd_dma_attach(struct rsnd_dai_stream *io, struct rsnd_mod *mod, return rsnd_dai_connect(*dma_mod, io, (*dma_mod)->type); } +void rsnd_dma_addr_update(struct rsnd_dai_stream *io) +{ + struct rsnd_mod *ssi_mod = rsnd_io_to_mod_ssi(io); + struct rsnd_mod *mod_from = NULL; + struct rsnd_mod *mod_to = NULL; + struct rsnd_priv *priv = rsnd_io_to_priv(io); + struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv); + struct device *dev = rsnd_priv_to_dev(priv); + int is_play = rsnd_io_is_play(io); + struct rsnd_dma *dma = rsnd_mod_to_dma(io->dma); + + if (!dmac) + return; + + rsnd_dma_of_path(ssi_mod, io, is_play, &mod_from, &mod_to); + + dma->src_addr = rsnd_dma_addr(io, mod_from, is_play, 1); + dma->dst_addr = rsnd_dma_addr(io, mod_to, is_play, 0); + + if (mod_from && mod_to) { + struct rsnd_dmapp *dmapp = rsnd_dma_to_dmapp(dma); + + dmapp->chcr = rsnd_dmapp_get_chcr(io, mod_from, mod_to) | + PDMACHCR_DE; + } + + dev_dbg(dev, "%s[%d] %pad -> %pad\n", + rsnd_mod_name(ssi_mod), rsnd_mod_id(ssi_mod), + &dma->src_addr, &dma->dst_addr); +} + int rsnd_dma_probe(struct rsnd_priv *priv) { struct platform_device *pdev = rsnd_priv_to_pdev(priv); diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 4464d1d0a042..7ce10267c87b 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -227,12 +227,14 @@ void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg, u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io); u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io); u32 rsnd_get_busif_shift(struct rsnd_dai_stream *io, struct rsnd_mod *mod); +void rsnd_ssi_select_busif(struct rsnd_dai_stream *io, int chan); /* * R-Car DMA */ int rsnd_dma_attach(struct rsnd_dai_stream *io, struct rsnd_mod *mod, struct rsnd_mod **dma_mod); +void rsnd_dma_addr_update(struct rsnd_dai_stream *io); int rsnd_dma_probe(struct rsnd_priv *priv); struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, struct rsnd_mod *mod, char *name); @@ -457,6 +459,7 @@ struct rsnd_dai_stream { struct rsnd_dai *rdai; struct device *dmac_dev; /* for IPMMU */ u32 parent_ssi_status; + u32 busif; }; #define rsnd_io_to_mod(io, i) ((i) < RSND_MOD_MAX ? (io)->mod[(i)] : NULL) #define rsnd_io_to_mod_ssi(io) rsnd_io_to_mod((io), RSND_MOD_SSI) diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 992aeac09e76..d515ee192276 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -154,7 +154,35 @@ int rsnd_ssi_use_busif(struct rsnd_dai_stream *io) int rsnd_ssi_get_busif(struct rsnd_dai_stream *io) { - return 0; /* BUSIF0 only for now */ + struct rsnd_priv *priv = rsnd_io_to_priv(io); + + if (!rsnd_is_gen3(priv)) + return 0; + + if (!rsnd_ssi_use_busif(io)) + return 0; + + return io->busif; +} + +void rsnd_ssi_select_busif(struct rsnd_dai_stream *io, int chan) +{ + struct rsnd_priv *priv = rsnd_io_to_priv(io); + u32 busif = 0; /* BUSIF0 only for now */ + + if (!rsnd_is_gen3(priv)) + return; + + if (!rsnd_ssi_use_busif(io)) + return; + + /* FIXME: calcuate BUSIF based on SSI mode in future */ + if (io->busif == busif) + return; + + io->busif = busif; + + rsnd_dma_addr_update(io); } static void rsnd_ssi_status_clear(struct rsnd_mod *mod)