mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-02-25 14:08:46 +07:00

Hi Mark Many ASoC drivers are getting rtd from substream by rtd = substream->private_data OTOH, we have snd_pcm_substream_chip() macro for it. #define snd_pcm_substream_chip(substream) ((substream)->private_data) But, both are not understandable for reader. This patch adds new asoc_substream_to_rtd() which is easy to understand. These are not important, but for readable code. Kuninori Morimoto (29): ASoC: soc-xxx: add asoc_substream_to_rtd() ASoC: ux500: use asoc_substream_to_rtd() ASoC: ti: use asoc_substream_to_rtd() ASoC: tegra: use asoc_substream_to_rtd() ASoC: sunxi: use asoc_substream_to_rtd() ASoC: stm: use asoc_substream_to_rtd() ASoC: sof: use asoc_substream_to_rtd() ASoC: sh: use asoc_substream_to_rtd() ASoC: samsung: use asoc_substream_to_rtd() ASoC: pxa: use asoc_substream_to_rtd() ASoC: cirrus: use asoc_substream_to_rtd() ASoC: rockchip: use asoc_substream_to_rtd() ASoC: amd: use asoc_substream_to_rtd() ASoC: fsl: use asoc_substream_to_rtd() ASoC: mediatek: use asoc_substream_to_rtd() ASoC: atmel: use asoc_substream_to_rtd() ASoC: qcom: use asoc_substream_to_rtd() ASoC: dwc: use asoc_substream_to_rtd() ASoC: intel: use asoc_substream_to_rtd() ASoC: meson: use asoc_substream_to_rtd() ASoC: au1x: use asoc_substream_to_rtd() ASoC: bcm: use asoc_substream_to_rtd() ASoC: codecs: use asoc_substream_to_rtd() ASoC: generic: use asoc_substream_to_rtd() ASoC: sprd: use asoc_substream_to_rtd() ASoC: kirkwood: use asoc_substream_to_rtd() ASoC: xtensa: use asoc_substream_to_rtd() ASoC: mxs: use asoc_substream_to_rtd() ASoC: uniphier: use asoc_substream_to_rtd() include/sound/soc.h | 2 + sound/soc/amd/acp-da7219-max98357a.c | 12 ++-- sound/soc/amd/acp-pcm-dma.c | 2 +- sound/soc/amd/acp-rt5645.c | 2 +- sound/soc/amd/acp3x-rt5682-max9836.c | 8 +-- sound/soc/amd/raven/acp3x-i2s.c | 2 +- sound/soc/amd/raven/acp3x-pcm-dma.c | 6 +- sound/soc/atmel/atmel-classd.c | 8 +-- sound/soc/atmel/atmel-pcm-dma.c | 4 +- sound/soc/atmel/atmel-pcm-pdc.c | 2 +- sound/soc/atmel/atmel-pdmic.c | 10 +-- sound/soc/atmel/atmel_wm8904.c | 2 +- sound/soc/au1x/db1200.c | 2 +- sound/soc/au1x/dbdma2.c | 2 +- sound/soc/au1x/dma.c | 2 +- sound/soc/bcm/bcm63xx-pcm-whistler.c | 12 ++-- sound/soc/bcm/cygnus-pcm.c | 16 ++--- sound/soc/cirrus/edb93xx.c | 2 +- sound/soc/cirrus/snappercl15.c | 2 +- sound/soc/codecs/rt5677-spi.c | 4 +- sound/soc/dwc/dwc-pcm.c | 2 +- sound/soc/fsl/eukrea-tlv320.c | 2 +- sound/soc/fsl/fsl-asoc-card.c | 2 +- sound/soc/fsl/fsl_asrc_dma.c | 4 +- sound/soc/fsl/fsl_dma.c | 2 +- sound/soc/fsl/fsl_spdif.c | 10 +-- sound/soc/fsl/fsl_ssi.c | 8 +-- sound/soc/fsl/imx-audmix.c | 6 +- sound/soc/fsl/imx-mc13783.c | 2 +- sound/soc/fsl/mpc5200_dma.c | 8 +-- sound/soc/fsl/mpc5200_psc_i2s.c | 2 +- sound/soc/fsl/mpc8610_hpcd.c | 2 +- sound/soc/fsl/mx27vis-aic32x4.c | 2 +- sound/soc/fsl/p1022_ds.c | 2 +- sound/soc/fsl/p1022_rdk.c | 2 +- sound/soc/fsl/wm1133-ev1.c | 2 +- sound/soc/generic/simple-card-utils.c | 6 +- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 6 +- sound/soc/intel/baytrail/sst-baytrail-pcm.c | 16 ++--- sound/soc/intel/boards/bdw-rt5650.c | 2 +- sound/soc/intel/boards/bdw-rt5677.c | 4 +- sound/soc/intel/boards/broadwell.c | 2 +- sound/soc/intel/boards/bxt_rt298.c | 2 +- sound/soc/intel/boards/byt-rt5640.c | 2 +- sound/soc/intel/boards/bytcht_da7213.c | 4 +- sound/soc/intel/boards/bytcr_rt5640.c | 2 +- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- sound/soc/intel/boards/cht_bsw_max98090_ti.c | 2 +- sound/soc/intel/boards/cht_bsw_nau8824.c | 2 +- sound/soc/intel/boards/cht_bsw_rt5645.c | 2 +- sound/soc/intel/boards/cht_bsw_rt5672.c | 2 +- sound/soc/intel/boards/cml_rt1011_rt5682.c | 4 +- sound/soc/intel/boards/ehl_rt5660.c | 2 +- sound/soc/intel/boards/glk_rt5682_max98357a.c | 2 +- sound/soc/intel/boards/haswell.c | 2 +- sound/soc/intel/boards/kbl_da7219_max98927.c | 8 +-- sound/soc/intel/boards/kbl_rt5660.c | 2 +- sound/soc/intel/boards/kbl_rt5663_max98927.c | 4 +- .../intel/boards/kbl_rt5663_rt5514_max98927.c | 4 +- .../soc/intel/boards/skl_nau88l25_max98357a.c | 2 +- sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 2 +- sound/soc/intel/boards/skl_rt286.c | 2 +- sound/soc/intel/boards/sof_da7219_max98373.c | 2 +- sound/soc/intel/boards/sof_maxim_common.c | 4 +- sound/soc/intel/boards/sof_pcm512x.c | 4 +- sound/soc/intel/boards/sof_rt5682.c | 4 +- sound/soc/intel/boards/sof_sdw_rt1308.c | 2 +- sound/soc/intel/boards/sof_wm8804.c | 2 +- sound/soc/intel/haswell/sst-haswell-pcm.c | 12 ++-- sound/soc/intel/keembay/kmb_platform.c | 2 +- sound/soc/intel/skylake/skl-pcm.c | 8 +-- sound/soc/kirkwood/armada-370-db.c | 2 +- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 12 ++-- .../mediatek/common/mtk-afe-platform-driver.c | 2 +- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 2 +- sound/soc/mediatek/mt2701/mt2701-cs42448.c | 2 +- sound/soc/mediatek/mt2701/mt2701-wm8960.c | 2 +- sound/soc/mediatek/mt6797/mt6797-afe-pcm.c | 4 +- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 2 +- sound/soc/mediatek/mt8173/mt8173-max98090.c | 2 +- .../mediatek/mt8173/mt8173-rt5650-rt5514.c | 2 +- .../mediatek/mt8173/mt8173-rt5650-rt5676.c | 2 +- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 2 +- sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 4 +- .../mediatek/mt8183/mt8183-da7219-max98357.c | 8 +-- .../mt8183/mt8183-mt6358-ts3a227-max98357.c | 12 ++-- sound/soc/meson/axg-card.c | 2 +- sound/soc/meson/gx-card.c | 2 +- sound/soc/meson/meson-card-utils.c | 2 +- sound/soc/meson/meson-codec-glue.c | 2 +- sound/soc/mxs/mxs-sgtl5000.c | 2 +- sound/soc/pxa/brownstone.c | 2 +- sound/soc/pxa/corgi.c | 4 +- sound/soc/pxa/hx4700.c | 2 +- sound/soc/pxa/imote2.c | 2 +- sound/soc/pxa/magician.c | 6 +- sound/soc/pxa/mmp-pcm.c | 2 +- sound/soc/pxa/poodle.c | 4 +- sound/soc/pxa/pxa2xx-i2s.c | 2 +- sound/soc/pxa/spitz.c | 4 +- sound/soc/pxa/tosa.c | 2 +- sound/soc/pxa/z2.c | 2 +- sound/soc/pxa/zylonite.c | 2 +- sound/soc/qcom/apq8096.c | 2 +- sound/soc/qcom/lpass-platform.c | 14 ++--- sound/soc/qcom/qdsp6/q6asm-dai.c | 6 +- sound/soc/qcom/qdsp6/q6routing.c | 2 +- sound/soc/qcom/sdm845.c | 14 ++--- sound/soc/qcom/storm.c | 2 +- sound/soc/rockchip/rk3288_hdmi_analog.c | 2 +- sound/soc/rockchip/rk3399_gru_sound.c | 8 +-- sound/soc/rockchip/rockchip_i2s.c | 2 +- sound/soc/rockchip/rockchip_max98090.c | 2 +- sound/soc/rockchip/rockchip_rt5645.c | 2 +- sound/soc/samsung/aries_wm8994.c | 4 +- sound/soc/samsung/arndale.c | 4 +- sound/soc/samsung/h1940_uda1380.c | 2 +- sound/soc/samsung/i2s.c | 2 +- sound/soc/samsung/jive_wm8750.c | 2 +- sound/soc/samsung/littlemill.c | 2 +- sound/soc/samsung/neo1973_wm8753.c | 8 +-- sound/soc/samsung/odroid.c | 6 +- sound/soc/samsung/pcm.c | 4 +- sound/soc/samsung/rx1950_uda1380.c | 2 +- sound/soc/samsung/s3c-i2s-v2.c | 2 +- sound/soc/samsung/s3c24xx_simtec.c | 2 +- sound/soc/samsung/s3c24xx_uda134x.c | 6 +- sound/soc/samsung/smartq_wm8987.c | 2 +- sound/soc/samsung/smdk_spdif.c | 2 +- sound/soc/samsung/smdk_wm8580.c | 2 +- sound/soc/samsung/smdk_wm8994.c | 2 +- sound/soc/samsung/smdk_wm8994pcm.c | 2 +- sound/soc/samsung/snow.c | 2 +- sound/soc/samsung/spdif.c | 6 +- sound/soc/samsung/tm2_wm5110.c | 8 +-- sound/soc/sh/dma-sh7760.c | 12 ++-- sound/soc/sh/fsi.c | 2 +- sound/soc/sh/migor.c | 4 +- sound/soc/sh/rcar/core.c | 4 +- sound/soc/soc-component.c | 20 +++--- sound/soc/soc-dai.c | 8 +-- sound/soc/soc-dapm.c | 6 +- sound/soc/soc-generic-dmaengine-pcm.c | 4 +- sound/soc/soc-link.c | 12 ++-- sound/soc/soc-pcm.c | 62 +++++++++---------- sound/soc/soc-utils.c | 2 +- sound/soc/sof/intel/hda-dai.c | 10 +-- sound/soc/sof/intel/hda-dsp.c | 2 +- sound/soc/sof/intel/hda-pcm.c | 2 +- sound/soc/sof/pcm.c | 18 +++--- sound/soc/sprd/sprd-pcm-dma.c | 2 +- sound/soc/stm/stm32_adfsdm.c | 12 ++-- sound/soc/stm/stm32_sai_sub.c | 2 +- sound/soc/sunxi/sun4i-codec.c | 12 ++-- sound/soc/sunxi/sun4i-spdif.c | 2 +- sound/soc/tegra/tegra_alc5632.c | 2 +- sound/soc/tegra/tegra_max98090.c | 2 +- sound/soc/tegra/tegra_rt5640.c | 2 +- sound/soc/tegra/tegra_rt5677.c | 2 +- sound/soc/tegra/tegra_sgtl5000.c | 2 +- sound/soc/tegra/tegra_wm8753.c | 2 +- sound/soc/tegra/tegra_wm8903.c | 2 +- sound/soc/tegra/trimslice.c | 2 +- sound/soc/ti/davinci-evm.c | 6 +- sound/soc/ti/davinci-vcif.c | 4 +- sound/soc/ti/j721e-evm.c | 6 +- sound/soc/ti/n810.c | 4 +- sound/soc/ti/omap-abe-twl6040.c | 4 +- sound/soc/ti/omap-mcbsp.c | 4 +- sound/soc/ti/omap-twl4030.c | 2 +- sound/soc/ti/omap3pandora.c | 2 +- sound/soc/ti/osk5912.c | 2 +- sound/soc/ti/rx51.c | 4 +- sound/soc/uniphier/aio-dma.c | 6 +- sound/soc/ux500/mop500_ab8500.c | 8 +-- sound/soc/ux500/ux500_pcm.c | 2 +- sound/soc/xtensa/xtfpga-i2s.c | 2 +- 177 files changed, 397 insertions(+), 395 deletions(-) -- 2.25.1
357 lines
10 KiB
C
357 lines
10 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright 2017 NXP
|
|
*
|
|
* The code contained herein is licensed under the GNU General Public
|
|
* License. You may obtain a copy of the GNU General Public License
|
|
* Version 2 or later at the following locations:
|
|
*
|
|
* https://www.opensource.org/licenses/gpl-license.html
|
|
* https://www.gnu.org/copyleft/gpl.html
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/of_platform.h>
|
|
#include <linux/clk.h>
|
|
#include <sound/soc.h>
|
|
#include <sound/soc-dapm.h>
|
|
#include <linux/pm_runtime.h>
|
|
#include "fsl_sai.h"
|
|
#include "fsl_audmix.h"
|
|
|
|
struct imx_audmix {
|
|
struct platform_device *pdev;
|
|
struct snd_soc_card card;
|
|
struct platform_device *audmix_pdev;
|
|
struct platform_device *out_pdev;
|
|
struct clk *cpu_mclk;
|
|
int num_dai;
|
|
struct snd_soc_dai_link *dai;
|
|
int num_dai_conf;
|
|
struct snd_soc_codec_conf *dai_conf;
|
|
int num_dapm_routes;
|
|
struct snd_soc_dapm_route *dapm_routes;
|
|
};
|
|
|
|
static const u32 imx_audmix_rates[] = {
|
|
8000, 12000, 16000, 24000, 32000, 48000, 64000, 96000,
|
|
};
|
|
|
|
static const struct snd_pcm_hw_constraint_list imx_audmix_rate_constraints = {
|
|
.count = ARRAY_SIZE(imx_audmix_rates),
|
|
.list = imx_audmix_rates,
|
|
};
|
|
|
|
static int imx_audmix_fe_startup(struct snd_pcm_substream *substream)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
|
struct imx_audmix *priv = snd_soc_card_get_drvdata(rtd->card);
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
struct device *dev = rtd->card->dev;
|
|
unsigned long clk_rate = clk_get_rate(priv->cpu_mclk);
|
|
int ret;
|
|
|
|
if (clk_rate % 24576000 == 0) {
|
|
ret = snd_pcm_hw_constraint_list(runtime, 0,
|
|
SNDRV_PCM_HW_PARAM_RATE,
|
|
&imx_audmix_rate_constraints);
|
|
if (ret < 0)
|
|
return ret;
|
|
} else {
|
|
dev_warn(dev, "mclk may be not supported %lu\n", clk_rate);
|
|
}
|
|
|
|
ret = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS,
|
|
1, 8);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
return snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT,
|
|
FSL_AUDMIX_FORMATS);
|
|
}
|
|
|
|
static int imx_audmix_fe_hw_params(struct snd_pcm_substream *substream,
|
|
struct snd_pcm_hw_params *params)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
|
struct device *dev = rtd->card->dev;
|
|
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
|
|
unsigned int fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF;
|
|
u32 channels = params_channels(params);
|
|
int ret, dir;
|
|
|
|
/* For playback the AUDMIX is slave, and for record is master */
|
|
fmt |= tx ? SND_SOC_DAIFMT_CBS_CFS : SND_SOC_DAIFMT_CBM_CFM;
|
|
dir = tx ? SND_SOC_CLOCK_OUT : SND_SOC_CLOCK_IN;
|
|
|
|
/* set DAI configuration */
|
|
ret = snd_soc_dai_set_fmt(asoc_rtd_to_cpu(rtd, 0), fmt);
|
|
if (ret) {
|
|
dev_err(dev, "failed to set cpu dai fmt: %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
ret = snd_soc_dai_set_sysclk(asoc_rtd_to_cpu(rtd, 0), FSL_SAI_CLK_MAST1, 0, dir);
|
|
if (ret) {
|
|
dev_err(dev, "failed to set cpu sysclk: %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Per datasheet, AUDMIX expects 8 slots and 32 bits
|
|
* for every slot in TDM mode.
|
|
*/
|
|
ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_cpu(rtd, 0), BIT(channels) - 1,
|
|
BIT(channels) - 1, 8, 32);
|
|
if (ret)
|
|
dev_err(dev, "failed to set cpu dai tdm slot: %d\n", ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int imx_audmix_be_hw_params(struct snd_pcm_substream *substream,
|
|
struct snd_pcm_hw_params *params)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
|
|
struct device *dev = rtd->card->dev;
|
|
bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
|
|
unsigned int fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF;
|
|
int ret;
|
|
|
|
if (!tx)
|
|
return 0;
|
|
|
|
/* For playback the AUDMIX is slave */
|
|
fmt |= SND_SOC_DAIFMT_CBM_CFM;
|
|
|
|
/* set AUDMIX DAI configuration */
|
|
ret = snd_soc_dai_set_fmt(asoc_rtd_to_cpu(rtd, 0), fmt);
|
|
if (ret)
|
|
dev_err(dev, "failed to set AUDMIX DAI fmt: %d\n", ret);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static struct snd_soc_ops imx_audmix_fe_ops = {
|
|
.startup = imx_audmix_fe_startup,
|
|
.hw_params = imx_audmix_fe_hw_params,
|
|
};
|
|
|
|
static struct snd_soc_ops imx_audmix_be_ops = {
|
|
.hw_params = imx_audmix_be_hw_params,
|
|
};
|
|
|
|
static int imx_audmix_probe(struct platform_device *pdev)
|
|
{
|
|
struct device_node *np = pdev->dev.of_node;
|
|
struct device_node *audmix_np = NULL, *out_cpu_np = NULL;
|
|
struct platform_device *audmix_pdev = NULL;
|
|
struct platform_device *cpu_pdev;
|
|
struct of_phandle_args args;
|
|
struct imx_audmix *priv;
|
|
int i, num_dai, ret;
|
|
const char *fe_name_pref = "HiFi-AUDMIX-FE-";
|
|
char *be_name, *be_pb, *be_cp, *dai_name, *capture_dai_name;
|
|
|
|
if (pdev->dev.parent) {
|
|
audmix_np = pdev->dev.parent->of_node;
|
|
} else {
|
|
dev_err(&pdev->dev, "Missing parent device.\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (!audmix_np) {
|
|
dev_err(&pdev->dev, "Missing DT node for parent device.\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
audmix_pdev = of_find_device_by_node(audmix_np);
|
|
if (!audmix_pdev) {
|
|
dev_err(&pdev->dev, "Missing AUDMIX platform device for %s\n",
|
|
np->full_name);
|
|
return -EINVAL;
|
|
}
|
|
put_device(&audmix_pdev->dev);
|
|
|
|
num_dai = of_count_phandle_with_args(audmix_np, "dais", NULL);
|
|
if (num_dai != FSL_AUDMIX_MAX_DAIS) {
|
|
dev_err(&pdev->dev, "Need 2 dais to be provided for %s\n",
|
|
audmix_np->full_name);
|
|
return -EINVAL;
|
|
}
|
|
|
|
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
|
if (!priv)
|
|
return -ENOMEM;
|
|
|
|
priv->num_dai = 2 * num_dai;
|
|
priv->dai = devm_kzalloc(&pdev->dev, priv->num_dai *
|
|
sizeof(struct snd_soc_dai_link), GFP_KERNEL);
|
|
if (!priv->dai)
|
|
return -ENOMEM;
|
|
|
|
priv->num_dai_conf = num_dai;
|
|
priv->dai_conf = devm_kzalloc(&pdev->dev, priv->num_dai_conf *
|
|
sizeof(struct snd_soc_codec_conf),
|
|
GFP_KERNEL);
|
|
if (!priv->dai_conf)
|
|
return -ENOMEM;
|
|
|
|
priv->num_dapm_routes = 3 * num_dai;
|
|
priv->dapm_routes = devm_kzalloc(&pdev->dev, priv->num_dapm_routes *
|
|
sizeof(struct snd_soc_dapm_route),
|
|
GFP_KERNEL);
|
|
if (!priv->dapm_routes)
|
|
return -ENOMEM;
|
|
|
|
for (i = 0; i < num_dai; i++) {
|
|
struct snd_soc_dai_link_component *dlc;
|
|
|
|
/* for CPU/Codec/Platform x 2 */
|
|
dlc = devm_kzalloc(&pdev->dev, 6 * sizeof(*dlc), GFP_KERNEL);
|
|
if (!dlc) {
|
|
dev_err(&pdev->dev, "failed to allocate dai_link\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
ret = of_parse_phandle_with_args(audmix_np, "dais", NULL, i,
|
|
&args);
|
|
if (ret < 0) {
|
|
dev_err(&pdev->dev, "of_parse_phandle_with_args failed\n");
|
|
return ret;
|
|
}
|
|
|
|
cpu_pdev = of_find_device_by_node(args.np);
|
|
if (!cpu_pdev) {
|
|
dev_err(&pdev->dev, "failed to find SAI platform device\n");
|
|
return -EINVAL;
|
|
}
|
|
put_device(&cpu_pdev->dev);
|
|
|
|
dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%s",
|
|
fe_name_pref, args.np->full_name + 1);
|
|
|
|
dev_info(pdev->dev.parent, "DAI FE name:%s\n", dai_name);
|
|
|
|
if (i == 0) {
|
|
out_cpu_np = args.np;
|
|
capture_dai_name =
|
|
devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",
|
|
dai_name, "CPU-Capture");
|
|
}
|
|
|
|
priv->dai[i].cpus = &dlc[0];
|
|
priv->dai[i].codecs = &dlc[1];
|
|
priv->dai[i].platforms = &dlc[2];
|
|
|
|
priv->dai[i].num_cpus = 1;
|
|
priv->dai[i].num_codecs = 1;
|
|
priv->dai[i].num_platforms = 1;
|
|
|
|
priv->dai[i].name = dai_name;
|
|
priv->dai[i].stream_name = "HiFi-AUDMIX-FE";
|
|
priv->dai[i].codecs->dai_name = "snd-soc-dummy-dai";
|
|
priv->dai[i].codecs->name = "snd-soc-dummy";
|
|
priv->dai[i].cpus->of_node = args.np;
|
|
priv->dai[i].cpus->dai_name = dev_name(&cpu_pdev->dev);
|
|
priv->dai[i].platforms->of_node = args.np;
|
|
priv->dai[i].dynamic = 1;
|
|
priv->dai[i].dpcm_playback = 1;
|
|
priv->dai[i].dpcm_capture = (i == 0 ? 1 : 0);
|
|
priv->dai[i].ignore_pmdown_time = 1;
|
|
priv->dai[i].ops = &imx_audmix_fe_ops;
|
|
|
|
/* Add AUDMIX Backend */
|
|
be_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
|
|
"audmix-%d", i);
|
|
be_pb = devm_kasprintf(&pdev->dev, GFP_KERNEL,
|
|
"AUDMIX-Playback-%d", i);
|
|
be_cp = devm_kasprintf(&pdev->dev, GFP_KERNEL,
|
|
"AUDMIX-Capture-%d", i);
|
|
|
|
priv->dai[num_dai + i].cpus = &dlc[3];
|
|
priv->dai[num_dai + i].codecs = &dlc[4];
|
|
priv->dai[num_dai + i].platforms = &dlc[5];
|
|
|
|
priv->dai[num_dai + i].num_cpus = 1;
|
|
priv->dai[num_dai + i].num_codecs = 1;
|
|
priv->dai[num_dai + i].num_platforms = 1;
|
|
|
|
priv->dai[num_dai + i].name = be_name;
|
|
priv->dai[num_dai + i].codecs->dai_name = "snd-soc-dummy-dai";
|
|
priv->dai[num_dai + i].codecs->name = "snd-soc-dummy";
|
|
priv->dai[num_dai + i].cpus->of_node = audmix_np;
|
|
priv->dai[num_dai + i].cpus->dai_name = be_name;
|
|
priv->dai[num_dai + i].platforms->name = "snd-soc-dummy";
|
|
priv->dai[num_dai + i].no_pcm = 1;
|
|
priv->dai[num_dai + i].dpcm_playback = 1;
|
|
priv->dai[num_dai + i].dpcm_capture = 1;
|
|
priv->dai[num_dai + i].ignore_pmdown_time = 1;
|
|
priv->dai[num_dai + i].ops = &imx_audmix_be_ops;
|
|
|
|
priv->dai_conf[i].dlc.of_node = args.np;
|
|
priv->dai_conf[i].name_prefix = dai_name;
|
|
|
|
priv->dapm_routes[i].source =
|
|
devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",
|
|
dai_name, "CPU-Playback");
|
|
priv->dapm_routes[i].sink = be_pb;
|
|
priv->dapm_routes[num_dai + i].source = be_pb;
|
|
priv->dapm_routes[num_dai + i].sink = be_cp;
|
|
priv->dapm_routes[2 * num_dai + i].source = be_cp;
|
|
priv->dapm_routes[2 * num_dai + i].sink = capture_dai_name;
|
|
}
|
|
|
|
cpu_pdev = of_find_device_by_node(out_cpu_np);
|
|
if (!cpu_pdev) {
|
|
dev_err(&pdev->dev, "failed to find SAI platform device\n");
|
|
return -EINVAL;
|
|
}
|
|
put_device(&cpu_pdev->dev);
|
|
|
|
priv->cpu_mclk = devm_clk_get(&cpu_pdev->dev, "mclk1");
|
|
if (IS_ERR(priv->cpu_mclk)) {
|
|
ret = PTR_ERR(priv->cpu_mclk);
|
|
dev_err(&cpu_pdev->dev, "failed to get DAI mclk1: %d\n", ret);
|
|
return -EINVAL;
|
|
}
|
|
|
|
priv->audmix_pdev = audmix_pdev;
|
|
priv->out_pdev = cpu_pdev;
|
|
|
|
priv->card.dai_link = priv->dai;
|
|
priv->card.num_links = priv->num_dai;
|
|
priv->card.codec_conf = priv->dai_conf;
|
|
priv->card.num_configs = priv->num_dai_conf;
|
|
priv->card.dapm_routes = priv->dapm_routes;
|
|
priv->card.num_dapm_routes = priv->num_dapm_routes;
|
|
priv->card.dev = &pdev->dev;
|
|
priv->card.owner = THIS_MODULE;
|
|
priv->card.name = "imx-audmix";
|
|
|
|
platform_set_drvdata(pdev, &priv->card);
|
|
snd_soc_card_set_drvdata(&priv->card, priv);
|
|
|
|
ret = devm_snd_soc_register_card(&pdev->dev, &priv->card);
|
|
if (ret) {
|
|
dev_err(&pdev->dev, "snd_soc_register_card failed\n");
|
|
return ret;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static struct platform_driver imx_audmix_driver = {
|
|
.probe = imx_audmix_probe,
|
|
.driver = {
|
|
.name = "imx-audmix",
|
|
.pm = &snd_soc_pm_ops,
|
|
},
|
|
};
|
|
module_platform_driver(imx_audmix_driver);
|
|
|
|
MODULE_DESCRIPTION("NXP AUDMIX ASoC machine driver");
|
|
MODULE_AUTHOR("Viorel Suman <viorel.suman@nxp.com>");
|
|
MODULE_ALIAS("platform:imx-audmix");
|
|
MODULE_LICENSE("GPL v2");
|