From 2f07906bd040fadbe993a58f4040fe3466f7c5e9 Mon Sep 17 00:00:00 2001 From: Mohan Kumar Date: Thu, 22 Oct 2015 03:36:02 -0700 Subject: [PATCH] ASoC: tegra-alt: Support adma iso client Support adma as a part iso client to calculate the adma bandwidth based on the usecase on both cpu and adsp side. This will help the iso manager to alter the emc frequency. Bug 1675078 Change-Id: I301aa710929665ea56f8183de8d22851913afa9c Signed-off-by: Mohan Kumar Reviewed-on: http://git-master/r/924061 Reviewed-by: Ayoosh Bansal Reviewed-by: Ravindra Lokhande --- sound/soc/tegra-alt/Makefile | 2 ++ sound/soc/tegra-alt/tegra210_admaif_alt.c | 28 +++++++++++++++++++++++ sound/soc/tegra-alt/tegra210_adsp_alt.c | 5 ++++ 3 files changed, 35 insertions(+) diff --git a/sound/soc/tegra-alt/Makefile b/sound/soc/tegra-alt/Makefile index 6b7b87d3..8726ce8f 100644 --- a/sound/soc/tegra-alt/Makefile +++ b/sound/soc/tegra-alt/Makefile @@ -7,6 +7,7 @@ snd-soc-tegra-alt-pcm-objs := tegra_pcm_alt.o snd-soc-tegra-alt-utils-objs := tegra_asoc_utils_alt.o snd-soc-tegra-alt-hwdep-objs := tegra_asoc_hwdep_alt.o snd-soc-tegra-alt-machine-objs := tegra_asoc_machine_alt.o +snd-soc-tegra-alt-isomgr-objs := tegra_isomgr_bw_alt.o snd-soc-tegra30-alt-apbif-objs := tegra30_apbif_alt.o snd-soc-tegra30-alt-xbar-objs := tegra30_xbar_alt.o snd-soc-tegra30-alt-i2s-objs := tegra30_i2s_alt.o @@ -36,6 +37,7 @@ snd-soc-tegra210-alt-fpga-clock-objs := ahub_unit_fpga_clock.o obj-$(CONFIG_SND_SOC_TEGRA_ALT) += snd-soc-tegra-alt-utils.o obj-$(CONFIG_SND_SOC_TEGRA_ALT) += snd-soc-tegra-alt-pcm.o obj-$(CONFIG_SND_SOC_TEGRA_ALT) += snd-soc-tegra210-alt-fpga-clock.o +obj-$(CONFIG_SND_SOC_TEGRA_ALT) += snd-soc-tegra-alt-isomgr.o obj-$(CONFIG_SND_SOC_TEGRA_ASOC_HWDEP_ALT) += snd-soc-tegra-alt-hwdep.o obj-$(CONFIG_SND_SOC_TEGRA_ASOC_MACHINE_ALT) += snd-soc-tegra-alt-machine.o obj-$(CONFIG_SND_SOC_TEGRA30_APBIF_ALT) += snd-soc-tegra30-alt-apbif.o diff --git a/sound/soc/tegra-alt/tegra210_admaif_alt.c b/sound/soc/tegra-alt/tegra210_admaif_alt.c index 39abf885..c6559991 100644 --- a/sound/soc/tegra-alt/tegra210_admaif_alt.c +++ b/sound/soc/tegra-alt/tegra210_admaif_alt.c @@ -32,6 +32,7 @@ #include "tegra_pcm_alt.h" #include "tegra210_xbar_alt.h" +#include "tegra_isomgr_bw_alt.h" #if defined(CONFIG_ARCH_TEGRA_18x_SOC) #include #endif @@ -287,6 +288,26 @@ static int tegra210_admaif_set_pack_mode(struct regmap *map, unsigned int reg, return 0; } +static int tegra210_admaif_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + tegra_isomgr_adma_setbw(substream, true); + + return 0; +} + +static int tegra210_admaif_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + return 0; +} + +static void tegra210_admaif_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + tegra_isomgr_adma_setbw(substream, false); +} + static int tegra210_admaif_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -463,6 +484,9 @@ static int tegra210_admaif_trigger(struct snd_pcm_substream *substream, int cmd, static struct snd_soc_dai_ops tegra210_admaif_dai_ops = { .hw_params = tegra210_admaif_hw_params, .trigger = tegra210_admaif_trigger, + .startup = tegra210_admaif_startup, + .shutdown = tegra210_admaif_shutdown, + .prepare = tegra210_admaif_prepare, }; static int tegra210_admaif_get_channels(struct snd_kcontrol *kcontrol, @@ -857,6 +881,8 @@ static int tegra210_admaif_probe(struct platform_device *pdev) goto err_pm_disable; } + tegra_isomgr_adma_register(); + for (i = 0; i < admaif->soc_data->num_ch; i++) { admaif->playback_dma_data[i].addr = res->start + TEGRA210_ADMAIF_XBAR_TX_FIFO_WRITE + @@ -940,6 +966,8 @@ err: static int tegra210_admaif_remove(struct platform_device *pdev) { + tegra_isomgr_adma_unregister(); + snd_soc_unregister_component(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); diff --git a/sound/soc/tegra-alt/tegra210_adsp_alt.c b/sound/soc/tegra-alt/tegra210_adsp_alt.c index ca07d8e9..4a1d8045 100644 --- a/sound/soc/tegra-alt/tegra210_adsp_alt.c +++ b/sound/soc/tegra-alt/tegra210_adsp_alt.c @@ -49,6 +49,7 @@ #include #include #include +#include "tegra_isomgr_bw_alt.h" #include "tegra210_adsp_alt.h" @@ -1308,6 +1309,8 @@ static int tegra210_adsp_pcm_open(struct snd_pcm_substream *substream) dev_vdbg(adsp->dev, "%s", __func__); + tegra_isomgr_adma_setbw(substream, true); + if (!adsp->pcm_path[fe_reg][substream->stream].fe_reg || !adsp->pcm_path[fe_reg][substream->stream].be_reg) { dev_err(adsp->dev, "Broken Path%d - FE not linked to BE", fe_reg); @@ -1377,6 +1380,8 @@ static int tegra210_adsp_pcm_close(struct snd_pcm_substream *substream) dev_vdbg(prtd->dev, "%s", __func__); + tegra_isomgr_adma_setbw(substream, false); + if (prtd) { tegra210_adsp_send_reset_msg(prtd->fe_apm, TEGRA210_ADSP_MSG_FLAG_SEND);