imx-audmix.c (9f5f078aed9d4dc024c397507a97bbf07e3ac4f3) imx-audmix.c (1ce8f643ed875d754ff09bf2096dfac3b905ab80)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright 2017 NXP
4 *
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
8 *
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright 2017 NXP
4 *
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
8 *
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
9 * https://www.opensource.org/licenses/gpl-license.html
10 * https://www.gnu.org/copyleft/gpl.html
11 */
12
13#include <linux/module.h>
14#include <linux/of_platform.h>
15#include <linux/clk.h>
16#include <sound/soc.h>
17#include <sound/soc-dapm.h>
18#include <linux/pm_runtime.h>

--- 20 unchanged lines hidden (view full) ---

39
40static const struct snd_pcm_hw_constraint_list imx_audmix_rate_constraints = {
41 .count = ARRAY_SIZE(imx_audmix_rates),
42 .list = imx_audmix_rates,
43};
44
45static int imx_audmix_fe_startup(struct snd_pcm_substream *substream)
46{
11 */
12
13#include <linux/module.h>
14#include <linux/of_platform.h>
15#include <linux/clk.h>
16#include <sound/soc.h>
17#include <sound/soc-dapm.h>
18#include <linux/pm_runtime.h>

--- 20 unchanged lines hidden (view full) ---

39
40static const struct snd_pcm_hw_constraint_list imx_audmix_rate_constraints = {
41 .count = ARRAY_SIZE(imx_audmix_rates),
42 .list = imx_audmix_rates,
43};
44
45static int imx_audmix_fe_startup(struct snd_pcm_substream *substream)
46{
47 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
47 struct snd_soc_pcm_runtime *rtd = substream->private_data;
48 struct imx_audmix *priv = snd_soc_card_get_drvdata(rtd->card);
49 struct snd_pcm_runtime *runtime = substream->runtime;
50 struct device *dev = rtd->card->dev;
51 unsigned long clk_rate = clk_get_rate(priv->cpu_mclk);
52 int ret;
53
54 if (clk_rate % 24576000 == 0) {
55 ret = snd_pcm_hw_constraint_list(runtime, 0,

--- 12 unchanged lines hidden (view full) ---

68
69 return snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT,
70 FSL_AUDMIX_FORMATS);
71}
72
73static int imx_audmix_fe_hw_params(struct snd_pcm_substream *substream,
74 struct snd_pcm_hw_params *params)
75{
48 struct imx_audmix *priv = snd_soc_card_get_drvdata(rtd->card);
49 struct snd_pcm_runtime *runtime = substream->runtime;
50 struct device *dev = rtd->card->dev;
51 unsigned long clk_rate = clk_get_rate(priv->cpu_mclk);
52 int ret;
53
54 if (clk_rate % 24576000 == 0) {
55 ret = snd_pcm_hw_constraint_list(runtime, 0,

--- 12 unchanged lines hidden (view full) ---

68
69 return snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT,
70 FSL_AUDMIX_FORMATS);
71}
72
73static int imx_audmix_fe_hw_params(struct snd_pcm_substream *substream,
74 struct snd_pcm_hw_params *params)
75{
76 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
76 struct snd_soc_pcm_runtime *rtd = substream->private_data;
77 struct device *dev = rtd->card->dev;
78 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
79 unsigned int fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF;
80 u32 channels = params_channels(params);
81 int ret, dir;
82
83 /* For playback the AUDMIX is slave, and for record is master */
84 fmt |= tx ? SND_SOC_DAIFMT_CBS_CFS : SND_SOC_DAIFMT_CBM_CFM;

--- 22 unchanged lines hidden (view full) ---

107 dev_err(dev, "failed to set cpu dai tdm slot: %d\n", ret);
108
109 return ret;
110}
111
112static int imx_audmix_be_hw_params(struct snd_pcm_substream *substream,
113 struct snd_pcm_hw_params *params)
114{
77 struct device *dev = rtd->card->dev;
78 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
79 unsigned int fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF;
80 u32 channels = params_channels(params);
81 int ret, dir;
82
83 /* For playback the AUDMIX is slave, and for record is master */
84 fmt |= tx ? SND_SOC_DAIFMT_CBS_CFS : SND_SOC_DAIFMT_CBM_CFM;

--- 22 unchanged lines hidden (view full) ---

107 dev_err(dev, "failed to set cpu dai tdm slot: %d\n", ret);
108
109 return ret;
110}
111
112static int imx_audmix_be_hw_params(struct snd_pcm_substream *substream,
113 struct snd_pcm_hw_params *params)
114{
115 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
115 struct snd_soc_pcm_runtime *rtd = substream->private_data;
116 struct device *dev = rtd->card->dev;
117 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
118 unsigned int fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF;
119 int ret;
120
121 if (!tx)
122 return 0;
123

--- 233 unchanged lines hidden ---
116 struct device *dev = rtd->card->dev;
117 bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
118 unsigned int fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF;
119 int ret;
120
121 if (!tx)
122 return 0;
123

--- 233 unchanged lines hidden ---